feat(miniprogram): add reimburse detail withdraw

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-09-14 10:04:20 +08:00
1 parent 904630d695
commit c1a999e490
1 file changed
+47 -2
+47 -2
View File
@@ -208,6 +208,16 @@
重新提交
</button>
</template>
<template v-if="canWithdraw">
<button
class="btn btn-ghost"
style="flex: 1"
:disabled="actionLoading.withdraw"
@click="handleWithdraw"
>
撤回
</button>
</template>
</view>
</view>
</template>
@@ -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()