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()