feat(web-admin): add withdraw on reimburse apply page

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-09-14 10:03:11 +08:00
1 parent d058518e57
commit 1917661266
1 file changed
+78 -1
@@ -43,6 +43,14 @@
<el-button class="btn-ghost" :loading="loadingMap.submit" @click="handleToolbarSubmit">
<el-icon><Upload /></el-icon>提交审批
</el-button>
<el-button
class="btn-ghost"
:disabled="selectedRows.length !== 1 || !canWithdraw(selectedRows[0])"
:loading="loadingMap.withdraw"
@click="handleToolbarWithdraw"
>
<el-icon><RefreshLeft /></el-icon>撤回
</el-button>
<el-button class="btn-ghost" @click="openFlowDialog()">
<el-icon><View /></el-icon>查看审批流
</el-button>
@@ -672,6 +680,15 @@
<el-icon><Delete /></el-icon>删除
</el-button>
</div>
<div v-else-if="canWithdraw(viewData)" class="dlg-view-hero-actions">
<el-button
class="btn-ghost"
:loading="loadingMap[`withdraw_${viewData.id}`]"
@click="handleViewWithdraw"
>
<el-icon><RefreshLeft /></el-icon>撤回
</el-button>
</div>
</div>
<div class="dlg-view-section">
@@ -796,7 +813,8 @@ import {
FolderAdd,
UploadFilled,
Check,
Filter
Filter,
RefreshLeft
} from '@element-plus/icons-vue'
import type { UploadFile } from 'element-plus'
import { reimburseApi, invoiceWalletApi, attachmentApi } from '@/api/bx'
@@ -1348,6 +1366,65 @@ function isDraftEditable(row?: any) {
return row.status === 'draft' || row.status === 'rejected'
}
function canWithdraw(row?: any) {
if (!row) return false
return (
row.status === 'pending' &&
String(row.applicantId || '') === currentUserId()
)
}
async function handleToolbarWithdraw() {
if (selectedRows.value.length !== 1) {
ElMessage.warning('请先勾选一条报销单')
return
}
const row = selectedRows.value[0]
if (!canWithdraw(row)) {
ElMessage.warning('仅本人申请且审批中的报销单可撤回')
return
}
await handleWithdraw(row)
}
async function handleViewWithdraw() {
if (!viewData.value?.id) return
await handleWithdraw(viewData.value)
try {
const res = await reimburseApi.getById(viewData.value.id)
viewData.value = res.data || res
} catch {
dialogs.view = false
}
}
async function handleWithdraw(row: any) {
try {
await ElMessageBox.confirm(
'确定撤回该报销单?撤回后将退回发票额度,单据变为待提交,可修改后再提交。',
'撤回确认',
{
confirmButtonText: '确定撤回',
cancelButtonText: '取消',
type: 'warning'
}
)
loadingMap.withdraw = true
loadingMap[`withdraw_${row.id}`] = true
await reimburseApi.withdraw(row.id)
ElMessage.success('已撤回')
await refreshList()
} catch (e: any) {
if (e !== 'cancel') {
ElMessage.error(e?.message || '撤回失败')
await refreshList()
}
} finally {
loadingMap.withdraw = false
loadingMap[`withdraw_${row.id}`] = false
}
}
function handleToolbarEdit() {
if (selectedRows.value.length !== 1) {
ElMessage.warning('请先勾选一条报销单')