From d2a13bdf8726c5b612f5a248b9d77621c9baba28 Mon Sep 17 00:00:00 2001 From: wuzilong <704541015@qq.com> Date: Mon, 14 Sep 2026 10:04:22 +0800 Subject: [PATCH] feat(miniprogram): add advance detail withdraw Co-authored-by: Cursor --- miniprogram/pages/bx/advance/detail.vue | 49 ++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/miniprogram/pages/bx/advance/detail.vue b/miniprogram/pages/bx/advance/detail.vue index 3dd2aab6b..3290cd056 100644 --- a/miniprogram/pages/bx/advance/detail.vue +++ b/miniprogram/pages/bx/advance/detail.vue @@ -185,6 +185,16 @@ + @@ -202,15 +212,28 @@ import { formatApplyDateTime } from '@/utils/bxFormat' import { getSafeAreaStyle } from '@/utils/safeArea' +import { useUserStore } from '@/stores/user' const safeAreaStyle = getSafeAreaStyle() +const userStore = useUserStore() const detailId = ref('') const detail = ref(null) const detailTab = ref(0) const approvals = ref([]) const attachments = ref([]) -const actionLoading = reactive({ submit: false, delete: false }) +const actionLoading = reactive({ submit: false, delete: false, withdraw: false }) + +function currentUserId() { + const u = userStore.userInfo || {} + return String(u.id || u.userId || '') +} + +const canWithdraw = computed(() => { + const d = detail.value + if (!d) return false + return d.status === 'pending' && String(d.applicantId || '') === currentUserId() +}) const isAdvanceIssued = computed(() => { const d = detail.value @@ -220,7 +243,7 @@ const isAdvanceIssued = computed(() => { const showActions = computed(() => { if (!detail.value) return false const status = detail.value.status - return status === 'draft' || status === 'rejected' + return status === 'draft' || status === 'rejected' || canWithdraw.value }) function goBack() { @@ -336,6 +359,28 @@ function handleResubmit() { }) } +function handleWithdraw() { + if (!detail.value) return + uni.showModal({ + title: '确认撤回', + content: '确定撤回该备用金申请?撤回后可修改再提交。', + confirmText: '确定撤回', + success: async (res) => { + if (!res.confirm) return + actionLoading.withdraw = true + try { + await advanceApi.withdraw(detail.value.id) + uni.showToast({ title: '已撤回', icon: 'success' }) + await loadDetail() + } catch (e) { + // toasted + } finally { + actionLoading.withdraw = false + } + } + }) +} + onLoad((query) => { detailId.value = query?.id ? String(query.id) : '' loadDetail()