|
|
@ -17,7 +17,7 @@ |
|
|
<el-table |
|
|
<el-table |
|
|
:data="dataList" |
|
|
:data="dataList" |
|
|
border :height="height" |
|
|
border :height="height" |
|
|
v-loading="dataListLoading" |
|
|
|
|
|
|
|
|
v-loading="dataListLoading || cancelLoading" |
|
|
@selection-change="selectionChangeHandle" |
|
|
@selection-change="selectionChangeHandle" |
|
|
style="width: 100%; margin-bottom: 20px;"> |
|
|
style="width: 100%; margin-bottom: 20px;"> |
|
|
<el-table-column |
|
|
<el-table-column |
|
|
@ -180,7 +180,9 @@ export default { |
|
|
{ required: true, message: this.$t('purchase.cancelReceipt.cancelReasonRequired'), trigger: 'blur' } |
|
|
{ required: true, message: this.$t('purchase.cancelReceipt.cancelReasonRequired'), trigger: 'blur' } |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
currentCancelRecords: [] |
|
|
|
|
|
|
|
|
currentCancelRecords: [], |
|
|
|
|
|
// 行级 loading:记录当前正在取消的收货记录key(contract + receiptSequence) |
|
|
|
|
|
cancelingRecordKeys: [] |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
@ -241,8 +243,17 @@ export default { |
|
|
selectionChangeHandle (val) { |
|
|
selectionChangeHandle (val) { |
|
|
this.dataListSelections = val |
|
|
this.dataListSelections = val |
|
|
}, |
|
|
}, |
|
|
|
|
|
getCancelRecordKey (record) { |
|
|
|
|
|
return `${record.contract || ''}__${record.receiptSequence || ''}` |
|
|
|
|
|
}, |
|
|
|
|
|
isRecordCanceling (record) { |
|
|
|
|
|
return this.cancelingRecordKeys.includes(this.getCancelRecordKey(record)) |
|
|
|
|
|
}, |
|
|
// 取消单个接收记录 |
|
|
// 取消单个接收记录 |
|
|
cancelSingleReceipt (row) { |
|
|
cancelSingleReceipt (row) { |
|
|
|
|
|
if (this.cancelLoading) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
const receiptNo = row.receiptNo || row.sourceRef1 || '' |
|
|
const receiptNo = row.receiptNo || row.sourceRef1 || '' |
|
|
// 显示确认提示 |
|
|
// 显示确认提示 |
|
|
this.$confirm(this.$t('purchase.cancelReceipt.confirmSingle', { receiptNo }), this.$t('purchase.cancelReceipt.confirmTitle'), { |
|
|
this.$confirm(this.$t('purchase.cancelReceipt.confirmSingle', { receiptNo }), this.$t('purchase.cancelReceipt.confirmTitle'), { |
|
|
@ -260,6 +271,9 @@ export default { |
|
|
}, |
|
|
}, |
|
|
// 批量取消接收记录 |
|
|
// 批量取消接收记录 |
|
|
cancelSelectedReceipts () { |
|
|
cancelSelectedReceipts () { |
|
|
|
|
|
if (this.cancelLoading) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
if (this.dataListSelections.length === 0) { |
|
|
if (this.dataListSelections.length === 0) { |
|
|
this.$message.warning(this.$t('purchase.cancelReceipt.selectRecordsFirst')) |
|
|
this.$message.warning(this.$t('purchase.cancelReceipt.selectRecordsFirst')) |
|
|
return |
|
|
return |
|
|
@ -282,7 +296,9 @@ export default { |
|
|
// 确认取消 |
|
|
// 确认取消 |
|
|
confirmCancel () { |
|
|
confirmCancel () { |
|
|
this.cancelLoading = true |
|
|
this.cancelLoading = true |
|
|
const promises = this.currentCancelRecords.map(record => { |
|
|
|
|
|
|
|
|
const cancelRecords = [...this.currentCancelRecords] |
|
|
|
|
|
this.cancelingRecordKeys = cancelRecords.map(record => this.getCancelRecordKey(record)) |
|
|
|
|
|
const promises = cancelRecords.map(record => { |
|
|
return cancelReceipt({ |
|
|
return cancelReceipt({ |
|
|
receiptSequence: record.receiptSequence, |
|
|
receiptSequence: record.receiptSequence, |
|
|
site: record.contract, |
|
|
site: record.contract, |
|
|
@ -298,7 +314,7 @@ export default { |
|
|
if (result.data && result.data.code === 0) { |
|
|
if (result.data && result.data.code === 0) { |
|
|
successCount++ |
|
|
successCount++ |
|
|
} else { |
|
|
} else { |
|
|
const record = this.currentCancelRecords[index] |
|
|
|
|
|
|
|
|
const record = cancelRecords[index] |
|
|
errorMessages.push(this.$t('purchase.cancelReceipt.cancelItemFailed', { |
|
|
errorMessages.push(this.$t('purchase.cancelReceipt.cancelItemFailed', { |
|
|
receiptNo: record.receiptNo || record.sourceRef1 || '', |
|
|
receiptNo: record.receiptNo || record.sourceRef1 || '', |
|
|
reason: result.data.msg || this.$t('purchase.cancelReceipt.cancelFailed') |
|
|
reason: result.data.msg || this.$t('purchase.cancelReceipt.cancelFailed') |
|
|
@ -316,10 +332,11 @@ export default { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.cancelDialogVisible = false |
|
|
this.cancelDialogVisible = false |
|
|
this.cancelLoading = false |
|
|
|
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
this.$message.error(this.$t('purchase.cancelReceipt.cancelOperationFailed')) |
|
|
this.$message.error(this.$t('purchase.cancelReceipt.cancelOperationFailed')) |
|
|
|
|
|
}).finally(() => { |
|
|
this.cancelLoading = false |
|
|
this.cancelLoading = false |
|
|
|
|
|
this.cancelingRecordKeys = [] |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 重置查询 |
|
|
// 重置查询 |
|
|
|