|
|
|
@ -91,14 +91,14 @@ |
|
|
|
@click="searchSupplierPartList" |
|
|
|
>查询</el-button> |
|
|
|
<el-button class="customer-bun-min" @click="resetSearch">重置</el-button> |
|
|
|
<!-- 批量开始审核:勾选多行后一次性发起(仅“未发起”状态可选)- rqrq --> |
|
|
|
<!-- 批量开始/重新审核:勾选多行后一次性发起(“未发起”开始审核,“不通过”重新审核)- rqrq --> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
class="customer-bun-min" |
|
|
|
:disabled="mainSelection.length === 0" |
|
|
|
:loading="batchStarting" |
|
|
|
@click="handleBatchStartAudit" |
|
|
|
>批量开始审核</el-button> |
|
|
|
>批量审核</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
@ -115,7 +115,7 @@ |
|
|
|
@row-click="handleMainRowClick" |
|
|
|
@selection-change="handleMainSelectionChange" |
|
|
|
> |
|
|
|
<el-table-column type="selection" width="45" fixed="left" header-align="center" align="center" :selectable="canRowStartAudit" /> |
|
|
|
<el-table-column type="selection" width="45" fixed="left" header-align="center" align="center" :selectable="canRowBatchAudit" /> |
|
|
|
<el-table-column fixed="right" label="操作" width="80" header-align="center" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-link |
|
|
|
@ -843,6 +843,11 @@ export default { |
|
|
|
const status = (row && row.latestAuditStatus) ? String(row.latestAuditStatus).toUpperCase() : 'NONE' |
|
|
|
return status === 'NONE' |
|
|
|
}, |
|
|
|
canRowBatchAudit (row) { |
|
|
|
// 批量操作支持「未发起」开始审核 与「不通过」重新审核 - rqrq |
|
|
|
const status = (row && row.latestAuditStatus) ? String(row.latestAuditStatus).toUpperCase() : 'NONE' |
|
|
|
return status === 'NONE' || status === 'REJECTED' |
|
|
|
}, |
|
|
|
canRowRestartAudit (row) { |
|
|
|
const status = (row && row.latestAuditStatus) ? String(row.latestAuditStatus).toUpperCase() : '' |
|
|
|
return status === 'REJECTED' |
|
|
|
@ -879,13 +884,23 @@ export default { |
|
|
|
this.mainSelection = val || [] |
|
|
|
}, |
|
|
|
handleBatchStartAudit () { |
|
|
|
// 仅对“未发起”状态行执行开始审核(与单选 canRowStartAudit 口径一致)- rqrq |
|
|
|
const rows = (this.mainSelection || []).filter(r => this.canRowStartAudit(r)) |
|
|
|
// 对「未发起」行执行开始审核,对「不通过」行执行重新审核 - rqrq |
|
|
|
const rows = (this.mainSelection || []).filter(r => this.canRowBatchAudit(r)) |
|
|
|
if (rows.length === 0) { |
|
|
|
this.$message.warning('请勾选需要开始审核的物料(仅“未发起”状态可开始)') |
|
|
|
this.$message.warning('请勾选需要操作的物料(仅"未发起"或"不通过"状态可批量操作)') |
|
|
|
return |
|
|
|
} |
|
|
|
this.$confirm(`确认对选中的 ${rows.length} 条物料批量开始审核?`, '批量开始审核', { |
|
|
|
const startCount = rows.filter(r => this.canRowStartAudit(r)).length |
|
|
|
const restartCount = rows.length - startCount |
|
|
|
let confirmMsg = '' |
|
|
|
if (startCount > 0 && restartCount > 0) { |
|
|
|
confirmMsg = `确认对选中的 ${rows.length} 条物料批量操作?(开始审核 ${startCount} 条,重新审核 ${restartCount} 条)` |
|
|
|
} else if (restartCount > 0) { |
|
|
|
confirmMsg = `确认对选中的 ${rows.length} 条物料批量重新审核?` |
|
|
|
} else { |
|
|
|
confirmMsg = `确认对选中的 ${rows.length} 条物料批量开始审核?` |
|
|
|
} |
|
|
|
this.$confirm(confirmMsg, '批量操作', { |
|
|
|
confirmButtonText: '确定', |
|
|
|
cancelButtonText: '取消', |
|
|
|
type: 'warning' |
|
|
|
@ -903,7 +918,7 @@ export default { |
|
|
|
this.mainSelection = [] |
|
|
|
this.searchSupplierPartList() |
|
|
|
if (failDetails.length === 0) { |
|
|
|
this.$message.success(`批量开始审核完成,成功 ${successCount} 条`) |
|
|
|
this.$message.success(`批量操作完成,成功 ${successCount} 条`) |
|
|
|
} else { |
|
|
|
const detailMsg = failDetails.slice(0, 5).map(d => `${d.partNo}:${d.reason}`).join(';') |
|
|
|
this.$message({ |
|
|
|
@ -914,18 +929,19 @@ export default { |
|
|
|
return |
|
|
|
} |
|
|
|
const row = rows[idx] |
|
|
|
startNewProductAudit({ |
|
|
|
site: row.site, |
|
|
|
supplierCode: row.supplierCode, |
|
|
|
partNo: row.partNo |
|
|
|
}).then(({ data }) => { |
|
|
|
const isRestart = !this.canRowStartAudit(row) |
|
|
|
const apiCall = isRestart |
|
|
|
? restartNewProductAudit({ site: row.site, supplierCode: row.supplierCode, partNo: row.partNo }) |
|
|
|
: startNewProductAudit({ site: row.site, supplierCode: row.supplierCode, partNo: row.partNo }) |
|
|
|
const failMsg = isRestart ? '重新审核失败' : '开始审核失败' |
|
|
|
apiCall.then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
successCount++ |
|
|
|
} else { |
|
|
|
failDetails.push({ partNo: row.partNo, reason: (data && data.msg) || '开始审核失败' }) |
|
|
|
failDetails.push({ partNo: row.partNo, reason: (data && data.msg) || failMsg }) |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
failDetails.push({ partNo: row.partNo, reason: '开始审核失败' }) |
|
|
|
failDetails.push({ partNo: row.partNo, reason: failMsg }) |
|
|
|
}).finally(() => { |
|
|
|
runNext(idx + 1) |
|
|
|
}) |
|
|
|
|