diff --git a/miniprogram/pages/bx/reimburse/detail.vue b/miniprogram/pages/bx/reimburse/detail.vue index 319dc9a59..e65913922 100644 --- a/miniprogram/pages/bx/reimburse/detail.vue +++ b/miniprogram/pages/bx/reimburse/detail.vue @@ -208,6 +208,16 @@ 重新提交 + @@ -228,8 +238,10 @@ import { resolveExpenseDisplay } 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) @@ -237,12 +249,23 @@ const detailTab = ref(0) const approvals = ref([]) const attachments = ref([]) const flatList = 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 showActions = computed(() => { if (!detail.value) return false const status = detail.value.status - return status === 'draft' || status === 'rejected' + return status === 'draft' || status === 'rejected' || canWithdraw.value }) const totalAmount = computed(() => { @@ -380,6 +403,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 reimburseApi.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) : '' loadExpenseFlat()