feat(miniprogram): add withdraw button on reimburse and advance lists
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f8c93d2bd6
commit
31d3a044cf
3 files changed
+92
No files matched your search
@@ -117,6 +117,14 @@
|
|||||||
</view>
|
</view>
|
||||||
<view v-else class="op-actions">
|
<view v-else class="op-actions">
|
||||||
<button class="btn btn-sm btn-primary" @click="goDetail(item.id)">查看</button>
|
<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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -140,8 +148,21 @@ import {
|
|||||||
formatApplyDate
|
formatApplyDate
|
||||||
} from '@/utils/bxFormat'
|
} from '@/utils/bxFormat'
|
||||||
import { getSafeAreaStyle } from '@/utils/safeArea'
|
import { getSafeAreaStyle } from '@/utils/safeArea'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
const safeAreaStyle = getSafeAreaStyle()
|
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 = [
|
const tabs = [
|
||||||
{ label: '全部', value: '' },
|
{ label: '全部', value: '' },
|
||||||
@@ -286,6 +307,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 advanceApi.withdraw(item.id)
|
||||||
|
uni.showToast({ title: '已撤回', icon: 'success' })
|
||||||
|
} catch (e) {
|
||||||
|
// toasted by bxRequest
|
||||||
|
} finally {
|
||||||
|
withdrawingId.value = ''
|
||||||
|
onRefresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
computeListHeight()
|
computeListHeight()
|
||||||
onRefresh()
|
onRefresh()
|
||||||
|
|||||||
@@ -132,6 +132,14 @@
|
|||||||
</view>
|
</view>
|
||||||
<view v-else class="op-actions">
|
<view v-else class="op-actions">
|
||||||
<button class="btn btn-sm btn-primary" @click="goDetail(item.id)">查看</button>
|
<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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -158,8 +166,21 @@ import {
|
|||||||
resolveExpenseDisplay
|
resolveExpenseDisplay
|
||||||
} from '@/utils/bxFormat'
|
} from '@/utils/bxFormat'
|
||||||
import { getSafeAreaStyle } from '@/utils/safeArea'
|
import { getSafeAreaStyle } from '@/utils/safeArea'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
const safeAreaStyle = getSafeAreaStyle()
|
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 = [
|
const tabs = [
|
||||||
{ label: '全部', value: '' },
|
{ 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(() => {
|
onShow(() => {
|
||||||
computeListHeight()
|
computeListHeight()
|
||||||
loadExpenseFlat()
|
loadExpenseFlat()
|
||||||
|
|||||||
@@ -455,6 +455,12 @@
|
|||||||
border-color: var(--text-sec);
|
border-color: var(--text-sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bx-page .btn-ghost {
|
||||||
|
background: #fff !important;
|
||||||
|
color: var(--text) !important;
|
||||||
|
border-color: var(--border, #e2e8f0);
|
||||||
|
}
|
||||||
|
|
||||||
.bx-page .btn-block {
|
.bx-page .btn-block {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user