feat: 采购申请完结功能移到批次主行,与出库审批一致
- 移除展开行内的单条完结按钮(需点开),改为主行'完结本批'直接可见 - 后端 batch-approve 支持 action=close(批次内已通过→已完结) - 超管/库管在主行操作列即可看到并完结
This commit is contained in:
@ -58,9 +58,6 @@
|
||||
<el-button type="success" link size="small" @click="handleApprove(it)">通过</el-button>
|
||||
<el-button type="danger" link size="small" @click="openRejectDialog(it)">驳回</el-button>
|
||||
</template>
|
||||
<template v-else-if="it.status === 1 && canClose">
|
||||
<el-button type="danger" plain link size="small" @click="handleCloseRequest(it)">完结</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -119,6 +116,10 @@
|
||||
<el-button type="success" link size="small" :loading="batchLoading" @click="handleApproveBatch(row.batchKey)">审批本批</el-button>
|
||||
<el-button type="danger" link size="small" :loading="batchLoading" @click="openRejectBatchDialog(row.batchKey)">驳回本批</el-button>
|
||||
</template>
|
||||
<!-- ★ 完结本批:批次内已通过的单,库管可直接完结(仿出库审批,主行可见) -->
|
||||
<template v-if="batchHasClosable(row) && canClose">
|
||||
<el-button type="danger" plain link size="small" :loading="batchLoading" @click="handleCloseBatch(row.batchKey)">完结本批</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -485,6 +486,34 @@ const handleApproveBatch = async (batchKey: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
// ★ 批次内是否存在「已通过」的单(可完结)
|
||||
const batchHasClosable = (row: any) => (row.items || []).some((it: any) => it.status === 1)
|
||||
|
||||
// ★ 完结本批:一键完结批次内所有「已通过」记录(仿出库审批)
|
||||
const handleCloseBatch = async (batchKey: string) => {
|
||||
const batch = list.value.find(b => b.batchKey === batchKey)
|
||||
const closable = batch ? (batch.items || []).filter((it: any) => it.status === 1) : []
|
||||
if (!closable.length) return ElMessage.warning('本批没有已通过记录可完结')
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定强制完结批次【${batchKey}】中 ${closable.length} 条已通过的记录吗?\n\n此操作不可恢复。`,
|
||||
'⚠️ 完结本批确认',
|
||||
{ confirmButtonText: '确认完结', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
} catch { return }
|
||||
|
||||
batchLoading.value = true
|
||||
try {
|
||||
const res: any = await batchApprovePurchase({ batch_key: batchKey, action: 'close' })
|
||||
ElMessage.success(res?.msg || '本批已完结')
|
||||
await fetchData()
|
||||
} catch (err: any) {
|
||||
ElMessage.error(err?.msg || err?.message || '完结失败')
|
||||
} finally {
|
||||
batchLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ★ 驳回本批:批次内所有待审批记录统一驳回
|
||||
const rejectBatchKey = ref('')
|
||||
const rejectBatchDialogVisible = ref(false)
|
||||
|
||||
Reference in New Issue
Block a user