diff --git a/src/views/modules/part/partInformation.vue b/src/views/modules/part/partInformation.vue index 4178f8f..979c7c8 100644 --- a/src/views/modules/part/partInformation.vue +++ b/src/views/modules/part/partInformation.vue @@ -153,7 +153,7 @@ - + @@ -683,7 +683,7 @@ 同步 保存 - 关闭 + 关闭 diff --git a/src/views/modules/project/projectInfo/com_project_info_part.vue b/src/views/modules/project/projectInfo/com_project_info_part.vue index 89bbfc8..513eefc 100644 --- a/src/views/modules/project/projectInfo/com_project_info_part.vue +++ b/src/views/modules/project/projectInfo/com_project_info_part.vue @@ -72,7 +72,7 @@ - + @@ -529,7 +529,7 @@ 保存 - 关闭 + 关闭 @@ -1726,7 +1726,14 @@ import { fixed: '', }, ], - itemSelections: [] + itemSelections: [], + watchers: [], + unwatchTable: null, // 用于保存监听器的取消函数 + mainInfoFlag: false, // 主信息标识 + costsInfoFlag: false, // costs标识 + manufacturingInfoFlag: false, // Manufacturing标识 + planningInfoFlag: false, // planning标识 + partItemInfoFlag: false, // 属性信息标识 } }, @@ -1735,6 +1742,75 @@ import { }, methods: { + // 重置标识 + resetFlags () { + this.mainInfoFlag = false + this.costsInfoFlag = false + this.manufacturingInfoFlag = false + this.planningInfoFlag = false + this.partItemInfoFlag = false + }, + + // 设置监听 + setupWatchers() { + this.teardownWatchers() + const groups = { + mainInfoFlag: ['partType', 'hazardCode', 'productGroupId4', 'productGroupId3', + 'umId', 'groupId', 'productGroupId1', 'familyId', 'productGroupId2', 'typeDesignation', + 'assetClass', 'dimQuality', 'partStatus', 'weightNet', 'uomForWeightNet', 'frequencyClass', + 'abcClass', 'volumeNet', 'uomForVolumeNet', 'lifecycleStage', 'manufacturingLeadTime', + 'countryOfOrigin', 'expectedLeadTime', 'durabilityDay', 'regionOfOrigin', 'intrastatConvFactor', + 'customsStatNo', 'remark', 'inventoryValuationMethod', 'partCostGroupId', 'inventoryPartCostLevel', + 'invoiceConsideration', 'zeroCostFlag'], + costsInfoFlag: ['estimatedMaterialCost'], + manufacturingInfoFlag: ['cumLeadTime', 'backFlushPart', 'byProdAsSupplyInMrpDb', 'unprotectedLeadTime', + 'issueType', 'mrpControlFlagDb', 'fixedLeadTimeDay', 'overReporting', 'useTheoreticalDensityDb', + 'variableLeadTimeDay', 'overReportTolerance', 'fixedLeadTimeHour', 'density', 'variableLeadTimeHour'], + planningInfoFlag: ['planningMethod', 'safetyStock', 'minOrderQty', 'maxOrderQty', 'mulOrderQty', + 'safetyLeadTime', 'shrinkageFac', 'stdOrderQty'], + } + Object.entries(groups).forEach(([flagName, keys]) => { + keys.forEach(key => { + const unwatch = this.$watch( + () => this.modalData[key], + (newVal, oldVal) => { + if (oldVal === undefined) return; // 忽略初始化赋值 + if (newVal !== oldVal && !this[flagName]) { + this[flagName] = true + } + } + ) + this.watchers.push(unwatch) + }) + }) + + let isFirstChange = true + this.unwatchTable = this.$watch( + () => JSON.stringify(this.partItemList), + (newVal, oldVal) => { + if (isFirstChange) { + isFirstChange = false + return // 第一次不处理 + } + if (newVal !== oldVal) { + this.partItemInfoFlag = true + } + } + ) + }, + + // 清除监听 + teardownWatchers () { + // 清除其他信息监听 + this.watchers.forEach(unwatch => unwatch()) + this.watchers = [] + // 清除属性监听 + if (this.unwatchTable) { + this.unwatchTable() + this.unwatchTable = null + } + }, + // 子明细每页数 sizeChangeHandle (val) { this.pageSize = val @@ -2038,6 +2114,11 @@ import { ifsPartNo: '', showInQueryFlag: 'Y', temporaryPartFlag: 'Y', + mainInfoFlag: false, // 主信息标识 + costsInfoFlag: false, // costs标识 + manufacturingInfoFlag: false, // Manufacturing标识 + planningInfoFlag: false, // planning标识 + partItemInfoFlag: false // 属性信息标识 } this.partItemList = [] this.modalFlag = true @@ -2161,7 +2242,14 @@ import { ifsPartNo: data.rows.ifsPartNo, showInQueryFlag: data.rows.showInQueryFlag, temporaryPartFlag: data.rows.temporaryPartFlag, + mainInfoFlag: false, // 主信息标识 + costsInfoFlag: false, // costs标识 + manufacturingInfoFlag: false, // Manufacturing标识 + planningInfoFlag: false, // planning标识 + partItemInfoFlag: false // 属性信息标识 } + this.resetFlags() // 重置标识 + this.setupWatchers() // 设置监听 this.getPartCharacteristicList(row.testPartNo) this.modalFlag = true this.modalDisableFlag = true @@ -2284,6 +2372,11 @@ import { ifsPartNo: data.rows.ifsPartNo, showInQueryFlag: 'Y', temporaryPartFlag: 'Y', + mainInfoFlag: false, // 主信息标识 + costsInfoFlag: false, // costs标识 + manufacturingInfoFlag: false, // Manufacturing标识 + planningInfoFlag: false, // planning标识 + partItemInfoFlag: false // 属性信息标识 } this.getPartCharacteristicList(row.testPartNo) this.modalFlag = true @@ -2295,6 +2388,18 @@ import { }) }, + // 关闭模态框 + closeModal () { + this.modalFlag = false + }, + + // 模态框关闭事件 + handleDialogClose () { + if (this.modalData.flag === '2') { + this.teardownWatchers() // 清除监听 + } + }, + // 物料信息新增 / 编辑 saveData () { if (this.modalData.partNo === '' || this.modalData.partNo == null) { @@ -2380,6 +2485,11 @@ import { } }) } else { + this.modalData.mainInfoFlag = this.mainInfoFlag + this.modalData.costsInfoFlag = this.costsInfoFlag + this.modalData.manufacturingInfoFlag = this.manufacturingInfoFlag + this.modalData.planningInfoFlag = this.planningInfoFlag + this.modalData.partItemInfoFlag = this.partItemInfoFlag partInformationEdit2(this.modalData).then(({data}) => { if (data && data.code === 0) { this.searchTable()