feat(web-admin): add withdraw on advance apply page
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1917661266
commit
904630d695
1 file changed
+84
-1
@@ -37,6 +37,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>
|
||||
@@ -445,6 +453,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">
|
||||
@@ -542,9 +559,11 @@ import {
|
||||
Delete,
|
||||
FolderChecked,
|
||||
Promotion,
|
||||
Filter
|
||||
Filter,
|
||||
RefreshLeft
|
||||
} from '@element-plus/icons-vue'
|
||||
import { advanceApi, paymentApi } from '@/api/bx'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
import { canDeleteByCreator, allRowsDeletableByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
|
||||
import {
|
||||
@@ -582,6 +601,11 @@ const { rows, total, currentPage, pageSize, rangeText, loading, refresh, search,
|
||||
})
|
||||
|
||||
const quickSearchKeyword = ref('')
|
||||
const userStore = useUserStore()
|
||||
|
||||
function currentUserId() {
|
||||
return String(userStore.info?.userId || userStore.info?.id || '')
|
||||
}
|
||||
|
||||
const {
|
||||
filters,
|
||||
@@ -787,6 +811,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 advanceApi.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 advanceApi.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 === 0) {
|
||||
ElMessage.warning('请先勾选要编辑的申请')
|
||||
|
||||
Reference in new issue
Block a user