|
|
@@ -132,6 +132,14 @@
|
|
|
</view>
|
|
|
<view v-else class="op-actions">
|
|
|
<button class="btn btn-sm btn-primary" @click="goDetail(item.id)">查看</button>
|
|
|
+ <button
|
|
|
+ v-if="canWithdraw(item)"
|
|
|
+ class="btn btn-sm btn-ghost"
|
|
|
+ :disabled="withdrawingId === item.id"
|
|
|
+ @click="handleWithdraw(item)"
|
|
|
+ >
|
|
|
+ 撤回
|
|
|
+ </button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -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()
|