|
|
@@ -185,6 +185,16 @@
|
|
|
<template v-if="detail?.status === 'rejected'">
|
|
|
<button class="btn btn-primary" style="flex: 1" @click="handleResubmit">重新提交</button>
|
|
|
</template>
|
|
|
+ <template v-if="canWithdraw">
|
|
|
+ <button
|
|
|
+ class="btn btn-ghost"
|
|
|
+ style="flex: 1"
|
|
|
+ :disabled="actionLoading.withdraw"
|
|
|
+ @click="handleWithdraw"
|
|
|
+ >
|
|
|
+ 撤回
|
|
|
+ </button>
|
|
|
+ </template>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
@@ -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()
|