From 96bf3121bb1f9c957eb541989a491368d026d2cb Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Tue, 6 Jan 2026 14:28:16 +0800 Subject: [PATCH] =?UTF-8?q?2026-01-06=20=E7=89=A9=E6=96=99=E6=A1=A3?= =?UTF-8?q?=E6=A1=88=E7=AE=A1=E7=90=86->=E8=B4=A8=E9=87=8F=E6=A3=80?= =?UTF-8?q?=E9=AA=8C=E6=A8=A1=E6=9D=BF=E6=96=B0=E5=A2=9E=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/qc/qcPartAttribute.vue | 169 ++++++++++++++++------- 1 file changed, 120 insertions(+), 49 deletions(-) diff --git a/src/views/modules/qc/qcPartAttribute.vue b/src/views/modules/qc/qcPartAttribute.vue index 70e4e55..93e81d1 100644 --- a/src/views/modules/qc/qcPartAttribute.vue +++ b/src/views/modules/qc/qcPartAttribute.vue @@ -700,6 +700,7 @@
- 添加 - 删除 + 添加 + 删除
@@ -832,6 +833,7 @@ { - this.itemList1 = data.row1 - this.itemList2 = data.row2 - }) + // 刷新模板列表 + this.refreshTemplateLists() + + // 根据检验类型调整布局 if (this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '107') { this.span1 = 12 this.span2 = 6 @@ -2312,9 +2318,23 @@ }, checkInspectionType2 () { + this.refreshTemplateLists() + }, + + // 刷新可选模板列表和已有模板列表(统一方法,带loading) + refreshTemplateLists () { + this.itemList1Loading = true + this.itemList2Loading = true getPartTemplateLists(this.detailData).then(({data}) => { - this.itemList1 = data.row1 - this.itemList2 = data.row2 + if (data) { + this.itemList1 = data.row1 || [] + this.itemList2 = data.row2 || [] + } + }).catch(err => { + console.error('加载模板列表失败:', err) + }).finally(() => { + this.itemList1Loading = false + this.itemList2Loading = false }) }, @@ -2347,25 +2367,60 @@ // 快速新增 addFastModal () { - this.itemSelections1 = null - this.itemSelections2 = null - getPartTemplateLists(this.detailData).then(({data}) => { - this.itemList1 = data.row1 - this.itemList2 = data.row2 - }) + // 检查是否已选择物料 + if (!this.detailData.partNo || !this.detailData.site) { + this.$message.warning('请先选择要设置模板的物料!') + return + } + + // 检查检验类型是否已加载 + if (!this.options || this.options.length === 0) { + this.$message.warning('检验类型数据加载中,请稍后再试') + return + } + + // 初始化选择状态 + this.itemSelections1 = [] + this.itemSelections2 = [] + + // 设置默认检验类型为第一个 this.detailData.inspectionTypeNo = this.options[0].inspectionTypeNo - this.checkInspectionType() + + // 根据检验类型调整布局 + if (this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '107') { + this.span1 = 12 + this.span2 = 6 + this.span3 = 6 + } else if (this.detailData.inspectionTypeNo === '105' || this.detailData.inspectionTypeNo === '109') { + this.span1 = 12 + this.span2 = 12 + } else { + this.span1 = 24 + } + + // 清空工序和机台选择 + this.operationSelections = [] + this.resourceSelections = [] this.dataListOperationSelections = [] this.operationData.operationDesc = '' this.resourceData.resourceId = '' this.resourceData.resourceDesc = '' + + // 清空供应商和客户选择 this.selectionManufacturer = [] this.selectionManufacturer2 = [] this.dataListManufacturerSelections = [] this.selectionCustomer = [] this.selectionCustomer2 = [] this.dataListCustomerSelections = [] + + // 打开对话框 this.fastAddFlag = true + + // 对话框打开后再加载模板列表(使用$nextTick确保对话框已渲染) + this.$nextTick(() => { + this.refreshTemplateLists() + }) }, // 可选项目 @@ -2392,37 +2447,42 @@ this.$message.warning('请选择可选模板!') return } - if ((this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107') && (this.operationSelections.length === 0)) { - this.$message.warning('请选择工序!') - return - } - if ((this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107') && (this.resourceSelections.length === 0)) { - this.$message.warning('请选择机台!') - return - } - if ((this.detailData.inspectionTypeNo === '105') && (this.selectionManufacturer == null || this.selectionManufacturer.length === 0)) { - this.$message.warning('请选择供应商!') - return + // IPQC/FQC类型:如果想选择机台,必须要选择工序 + if ((this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107')) { + if (this.resourceSelections.length > 0 && this.operationSelections.length === 0) { + this.$message.warning('如果选择机台,必须要选择工序!') + return + } } + + // 开始loading + this.addItemLoading = true + + // 构建请求参数 let inData = { site: this.detailData.site, buNo: this.detailData.buNo, attributeNo: this.detailData.partNo, itemList: this.itemSelections1, - operation: this.operationSelections.length === 0 ? '' : this.operationSelections[0].operationDesc, - resourceID: this.resourceSelections.length === 0 ? '' : this.resourceSelections[0].resourceId, - manufacturerList: this.selectionManufacturer, - customerList: this.selectionCustomer, + // IPQC/FQC类型:传递工序列表和机台列表(多选) + operationList: this.operationSelections.map(item => item.operationDesc), + resourceIDList: this.resourceSelections.map(item => item.resourceId), + // IQC类型:传递供应商列表(可为空) + manufacturerList: this.selectionManufacturer || [], + // OQC类型:传递客户列表(可为空) + customerList: this.selectionCustomer || [], attributeType: this.detailData.attributeType, inspectionTypeNo: this.detailData.inspectionTypeNo } savePartAttributeDetails(inData).then(({data}) => { if (data && data.code === 0) { - getPartTemplateLists(this.detailData).then(({data}) => { - this.itemList1 = data.row1 - this.itemList2 = data.row2 - }) + this.$message.success('添加成功!') + // 刷新可选模板列表和已有模板列表 + this.refreshTemplateLists() + // 清空选中状态 this.itemSelections1 = [] + this.operationSelections = [] + this.resourceSelections = [] this.selectionManufacturer = [] this.selectionManufacturer2 = [] this.selectionCustomer = [] @@ -2430,6 +2490,10 @@ } else { this.$message.error(data.msg) } + }).catch(err => { + this.$message.error('添加失败:' + (err.message || '未知错误')) + }).finally(() => { + this.addItemLoading = false }) }, @@ -2439,8 +2503,12 @@ this.$message.warning('请选择已有模板!') return } + + // 开始loading + this.deleteItemLoading = true + let inData = { - attributeNo:this.detailData.partNo, + attributeNo: this.detailData.partNo, itemList: this.itemSelections2, attributeType: this.detailData.attributeType, site: this.detailData.site, @@ -2448,14 +2516,17 @@ } deletePartAttributeDetails(inData).then(({data}) => { if (data && data.code === 0) { - getPartTemplateLists(this.detailData).then(({data}) => { - this.itemList1 = data.row1 - this.itemList2 = data.row2 - }) + this.$message.success('删除成功!') + // 刷新可选模板列表和已有模板列表 + this.refreshTemplateLists() this.itemSelections2 = [] } else { this.$message.error(data.msg) } + }).catch(err => { + this.$message.error('删除失败:' + (err.message || '未知错误')) + }).finally(() => { + this.deleteItemLoading = false }) }, @@ -2702,11 +2773,11 @@ this.$message.warning('请选择标签类型!') return } - + // 检查是否设置为默认,且已存在其他默认标签 if (this.labelTemplateData.defaultFlag === '1') { // 查找已存在的默认标签(排除当前编辑的记录) - const existingDefault = this.labelTemplateList.find(item => + const existingDefault = this.labelTemplateList.find(item => item.defaultFlag === '1' && item.labelTypeTb !== this.labelTemplateData.labelTypeTb ) if (existingDefault) { @@ -2738,10 +2809,10 @@ return } } - + this.doSaveLabelTemplate() }, - + // 执行保存标签模版 doSaveLabelTemplate () { this.saveLoading = true @@ -3069,9 +3140,9 @@ this.operationSelections = val }, + // 工序选择改为多选,移除单选限制 operationSelect (selection, row) { - this.$refs.operationTable.clearSelection() - this.$refs.operationTable.toggleRowSelection(row, true) + // 多选:不再清空其他选中项 }, getRowKeys (row) { @@ -3083,9 +3154,9 @@ this.resourceSelections = val }, + // 机台选择改为多选,移除单选限制 resourceSelect (selection, row) { - this.$refs.resourceTable.clearSelection() - this.$refs.resourceTable.toggleRowSelection(row, true) + // 多选:不再清空其他选中项 }, getRowKeys2 (row) {