diff --git a/miniprogram/pages/bx/advance/list.vue b/miniprogram/pages/bx/advance/list.vue index 6d0db8581..c8790de95 100644 --- a/miniprogram/pages/bx/advance/list.vue +++ b/miniprogram/pages/bx/advance/list.vue @@ -117,6 +117,14 @@ + @@ -140,8 +148,21 @@ import { formatApplyDate } from '@/utils/bxFormat' import { getSafeAreaStyle } from '@/utils/safeArea' +import { useUserStore } from '@/stores/user' const safeAreaStyle = getSafeAreaStyle() +const userStore = useUserStore() +const withdrawingId = ref('') + +function currentUserId() { + const u = userStore.userInfo || {} + return String(u.id || u.userId || '') +} + +function canWithdraw(item) { + if (!item) return false + return item.status === 'pending' && String(item.applicantId || '') === currentUserId() +} const tabs = [ { label: '全部', value: '' }, @@ -286,6 +307,28 @@ function handleDelete(item) { }) } +function handleWithdraw(item) { + if (!item?.id || !canWithdraw(item)) return + uni.showModal({ + title: '确认撤回', + content: '确定撤回该备用金申请?撤回后可修改再提交。', + confirmText: '确定撤回', + success: async (res) => { + if (!res.confirm) return + withdrawingId.value = String(item.id) + try { + await advanceApi.withdraw(item.id) + uni.showToast({ title: '已撤回', icon: 'success' }) + } catch (e) { + // toasted by bxRequest + } finally { + withdrawingId.value = '' + onRefresh() + } + } + }) +} + onShow(() => { computeListHeight() onRefresh() diff --git a/miniprogram/pages/bx/reimburse/list.vue b/miniprogram/pages/bx/reimburse/list.vue index 7f32d82d0..53446bf28 100644 --- a/miniprogram/pages/bx/reimburse/list.vue +++ b/miniprogram/pages/bx/reimburse/list.vue @@ -132,6 +132,14 @@ + @@ -158,8 +166,21 @@ import { resolveExpenseDisplay } from '@/utils/bxFormat' import { getSafeAreaStyle } from '@/utils/safeArea' +import { useUserStore } from '@/stores/user' const safeAreaStyle = getSafeAreaStyle() +const userStore = useUserStore() +const withdrawingId = ref('') + +function currentUserId() { + const u = userStore.userInfo || {} + return String(u.id || u.userId || '') +} + +function canWithdraw(item) { + if (!item) return false + return item.status === 'pending' && String(item.applicantId || '') === currentUserId() +} const tabs = [ { label: '全部', value: '' }, @@ -315,6 +336,28 @@ function handleDelete(item) { }) } +function handleWithdraw(item) { + if (!item?.id || !canWithdraw(item)) return + uni.showModal({ + title: '确认撤回', + content: '确定撤回该报销单?撤回后将退回发票额度。', + confirmText: '确定撤回', + success: async (res) => { + if (!res.confirm) return + withdrawingId.value = String(item.id) + try { + await reimburseApi.withdraw(item.id) + uni.showToast({ title: '已撤回', icon: 'success' }) + } catch (e) { + // toasted by bxRequest + } finally { + withdrawingId.value = '' + onRefresh() + } + } + }) +} + onShow(() => { computeListHeight() loadExpenseFlat() diff --git a/miniprogram/styles/bx-theme.scss b/miniprogram/styles/bx-theme.scss index f66d66c9b..a154d076e 100644 --- a/miniprogram/styles/bx-theme.scss +++ b/miniprogram/styles/bx-theme.scss @@ -455,6 +455,12 @@ border-color: var(--text-sec); } +.bx-page .btn-ghost { + background: #fff !important; + color: var(--text) !important; + border-color: var(--border, #e2e8f0); +} + .bx-page .btn-block { width: 100%; }