diff --git a/src/views/modules/erf/expIssueList.vue b/src/views/modules/erf/expIssueList.vue index 572f218..cbadbe9 100644 --- a/src/views/modules/erf/expIssueList.vue +++ b/src/views/modules/erf/expIssueList.vue @@ -90,11 +90,14 @@ + style="width: 100%" + @selection-change="handleMaterialSelectionChange"> + @@ -135,8 +138,12 @@ @@ -173,6 +180,8 @@ export default { tableHeight: (window.innerHeight - 260), materialDialogVisible: false, materialList: [], + // 弹窗内勾选的原材料,创建时只提交这部分 + selectedMaterialRows: [], issueNeedDate: '', createLoading: false } @@ -291,8 +300,15 @@ export default { return } this.materialList = availableList + this.selectedMaterialRows = [] this.issueNeedDate = availableList[0].needDate this.materialDialogVisible = true + // 每次打开都不带上次勾选,避免误提交 + this.$nextTick(() => { + if (this.$refs.materialTable && this.$refs.materialTable.clearSelection) { + this.$refs.materialTable.clearSelection() + } + }) } else { this.$message.error(data.msg || '加载领料明细失败') } @@ -302,21 +318,28 @@ export default { }, /** - * 创建领料单 + * 弹窗表格勾选变化 + */ + handleMaterialSelectionChange(selection) { + this.selectedMaterialRows = selection || [] + }, + + /** + * 创建领料单,只提交弹窗内勾选的原材料 */ submitCreateIssue() { - if (!this.materialList || this.materialList.length === 0) { - this.$message.warning('领料明细不能为空') + if (!this.selectedMaterialRows || this.selectedMaterialRows.length === 0) { + this.$message.warning('请先勾选需要领料的原材料') return } - const invalidItem = this.materialList.find(item => this.toNumber(item.issueQty) <= 0) + const invalidItem = this.selectedMaterialRows.find(item => this.toNumber(item.issueQty) <= 0) if (invalidItem) { this.$message.warning(`试验单${invalidItem.applyNo}存在本次领料数量小于等于0的记录`) return } - const overItem = this.materialList.find(item => this.toNumber(item.issueQty) > this.toNumber(item.availableQty)) + const overItem = this.selectedMaterialRows.find(item => this.toNumber(item.issueQty) > this.toNumber(item.availableQty)) if (overItem) { this.$message.warning(`试验单${overItem.applyNo}的本次领料数量不能超过可申请数量`) return @@ -327,7 +350,7 @@ export default { return } - const materialList = this.materialList.map(item => ({ + const materialList = this.selectedMaterialRows.map(item => ({ rawMaterialId: item.rawMaterialId, applyNo: item.applyNo, issueQty: this.toNumber(item.issueQty), @@ -342,6 +365,7 @@ export default { this.$message.success(`创建成功,领料单号:${data.issueNo}`) this.materialDialogVisible = false this.materialList = [] + this.selectedMaterialRows = [] this.issueNeedDate = '' this.getDataList() } else {