|
|
@@ -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)
|