feat(web-admin): add withdraw action on vehicle recharge apply

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-09-29 12:16:35 +08:00
1 parent 7a4ecc34e0
commit 94e4ef6f8e
2 files changed
+68

No files matched your search

+2
View File
@@ -1820,6 +1820,8 @@ export const vehicleRechargeApplyApi = {
request.post<VehicleRechargeApply>(`/transport/vehicle-recharge-apply/${id}/submit`),
cancel: (id: string) =>
request.post<VehicleRechargeApply>(`/transport/vehicle-recharge-apply/${id}/cancel`),
withdraw: (id: string) =>
request.post<VehicleRechargeApply>(`/transport/vehicle-recharge-apply/${id}/withdraw`),
delete: (ids: string) => request.delete(`/transport/vehicle-recharge-apply/${ids}`),
pendingOptions: () =>
request.get<VehicleRechargeApplyOption[]>('/transport/vehicle-recharge-apply/pending-options')
@@ -48,6 +48,14 @@
>
<el-icon><CircleClose /></el-icon>作废
</el-button>
<el-button
class="btn-ghost"
:disabled="selectedRows.length !== 1 || !canWithdraw(selectedRows[0])"
:loading="selectedRows.length === 1 && !!withdrawLoadingMap[selectedRows[0].id]"
@click="handleToolbarWithdraw"
>
<el-icon><RefreshLeft /></el-icon>撤回
</el-button>
<ListExportDropdown
:export-fn="vehicleRechargeApplyApi.export"
@@ -420,6 +428,15 @@
<el-icon><CircleClose /></el-icon>作废
</el-button>
</template>
<template v-else-if="canWithdraw(viewingRecord)" #hero-actions>
<el-button
class="btn-ghost"
:loading="!!withdrawLoadingMap[viewingRecord!.id]"
@click="handleWithdraw(viewingRecord!)"
>
<el-icon><RefreshLeft /></el-icon>撤回
</el-button>
</template>
<template #approval-flow>
<BxApprovalFlowTabs
section-title="审批记录"
@@ -456,6 +473,7 @@ import {
Edit,
Filter,
Plus,
RefreshLeft,
Upload
} from '@element-plus/icons-vue'
import {
@@ -595,10 +613,19 @@ const loading = ref(false)
const submitLoading = ref(false)
const saveAndSubmitLoading = ref(false)
const cancelLoadingMap = reactive<Record<string, boolean>>({})
const withdrawLoadingMap = reactive<Record<string, boolean>>({})
const workflowSubmitLoadingMap = reactive<Record<string, boolean>>({})
const tableData = ref<VehicleRechargeApply[]>([])
const selectedRows = ref<VehicleRechargeApply[]>([])
function canWithdraw(row?: VehicleRechargeApply | null) {
if (!row) return false
return (
row.status === 'in_approval' &&
String(row.applicantId || '') === String(currentUserId.value || '')
)
}
function buildListQueryParams(): Record<string, any> {
const params: Record<string, any> = { ...toQueryParams(), ...toSortQueryParams() }
const keyword = quickSearchKeyword.value.trim()
@@ -948,6 +975,45 @@ function handleToolbarCancel() {
handleCancel(selectedRows.value[0])
}
function handleToolbarWithdraw() {
if (selectedRows.value.length !== 1) {
ElMessage.warning('请先勾选一条申请')
return
}
handleWithdraw(selectedRows.value[0])
}
async function handleWithdraw(row: VehicleRechargeApply) {
if (!canWithdraw(row)) {
ElMessage.warning('仅本人申请且审批中的单据可撤回')
return
}
try {
await ElMessageBox.confirm(
'确定撤回该充值申请?撤回后变为草稿,可修改后再提交。',
'撤回确认',
{
confirmButtonText: '确定撤回',
cancelButtonText: '取消',
type: 'warning'
}
)
} catch {
return
}
withdrawLoadingMap[row.id] = true
try {
await vehicleRechargeApplyApi.withdraw(row.id)
ElMessage.success('已撤回')
await fetchData()
await refreshViewIfOpen(row.id)
} catch (e: any) {
ElMessage.error(e?.message || '撤回失败')
} finally {
withdrawLoadingMap[row.id] = false
}
}
async function handleViewCancel() {
if (!viewingRecord.value) return
await handleCancel(viewingRecord.value)