diff --git a/src/views/modules/rohs/rohsRecord.vue b/src/views/modules/rohs/rohsRecord.vue index 7f7e03b..46d6488 100644 --- a/src/views/modules/rohs/rohsRecord.vue +++ b/src/views/modules/rohs/rohsRecord.vue @@ -115,8 +115,16 @@ - - + + + + + + @@ -442,13 +450,13 @@ HSF审批人/HSF Approver HSF审批人/HSF Approver - + @@ -457,13 +465,13 @@ Inform Related people Inform Related people - + @@ -975,8 +983,8 @@ - - + + @@ -1326,8 +1334,10 @@ export default { fiberInformation: '', hsfStandard: '', hsfApprover: '', - hsfApproverList: [], + hsfApproverName: '', + hsfApproverCodeList: [], relatedPeople: '', + relatedPeopleName: '', buNo: '', validUntilValue: 0, validUntil: '', @@ -1642,7 +1652,7 @@ export default { materialClassify: 'materialClassifyList', qualificationDocumentsNeeded: 'qualificationDocumentsNeededList', testReportIncludingItems: 'testReportIncludingItemsList', - hsfApprover: 'hsfApproverList' + hsfApprover: 'hsfApproverCodeList' } const mappedField = fieldMapping[fieldId] if (mappedField) { @@ -1757,55 +1767,88 @@ export default { } this.applyHsfStandardDefaultByCustomer(formData) }, + resolveOperatorNameById (operatorId) { + const normalizedId = String(operatorId || '').trim() + if (!normalizedId) { + return '' + } + const option = (this.hsfApproverOptionList || []).find(item => String(item.operatorId || '').trim() === normalizedId) || + (this.relatedPeopleOptionList || []).find(item => String(item.operatorId || '').trim() === normalizedId) + return option ? String(option.operatorName || '').trim() : normalizedId + }, + resolveOperatorIdByCodeOrName (operatorValue) { + const normalizedValue = String(operatorValue || '').trim() + if (!normalizedValue) { + return '' + } + const option = (this.hsfApproverOptionList || []).find(item => String(item.operatorId || '').trim() === normalizedValue) || + (this.hsfApproverOptionList || []).find(item => String(item.operatorName || '').trim() === normalizedValue) || + (this.relatedPeopleOptionList || []).find(item => String(item.operatorId || '').trim() === normalizedValue) || + (this.relatedPeopleOptionList || []).find(item => String(item.operatorName || '').trim() === normalizedValue) + return option ? String(option.operatorId || '').trim() : normalizedValue + }, syncHsfApproverFields () { - const sourceList = Array.isArray(this.modalData.hsfApproverList) - ? this.modalData.hsfApproverList + const sourceList = Array.isArray(this.modalData.hsfApproverCodeList) + ? this.modalData.hsfApproverCodeList : [] - const uniqueList = [] + const uniqueCodeList = [] const seen = new Set() sourceList.forEach(item => { - const value = String(item || '').trim() + const value = this.resolveOperatorIdByCodeOrName(item) if (!value || seen.has(value)) { return } seen.add(value) - uniqueList.push(value) + uniqueCodeList.push(value) }) - this.$set(this.modalData, 'hsfApproverList', uniqueList) - this.$set(this.modalData, 'hsfApprover', uniqueList.join(';')) - this.buildRelatedPeopleOptions(uniqueList) - const relatedPeople = String(this.modalData.relatedPeople || '').trim() - if (relatedPeople && !uniqueList.includes(relatedPeople)) { + this.$set(this.modalData, 'hsfApproverCodeList', uniqueCodeList) + this.$set(this.modalData, 'hsfApprover', uniqueCodeList.join(';')) + this.$set(this.modalData, 'hsfApproverName', uniqueCodeList.map(item => this.resolveOperatorNameById(item)).join(';')) + this.buildRelatedPeopleOptions(uniqueCodeList) + + const relatedPeopleCode = this.resolveOperatorIdByCodeOrName(this.modalData.relatedPeople) + if (relatedPeopleCode && !uniqueCodeList.includes(relatedPeopleCode)) { this.$set(this.modalData, 'relatedPeople', '') + this.$set(this.modalData, 'relatedPeopleName', '') + return + } + if (relatedPeopleCode) { + this.$set(this.modalData, 'relatedPeople', relatedPeopleCode) + this.$set(this.modalData, 'relatedPeopleName', this.resolveOperatorNameById(relatedPeopleCode)) } }, - buildRelatedPeopleOptions (selectedNames) { - const normalizedNames = (Array.isArray(selectedNames) ? selectedNames : (this.modalData.hsfApproverList || [])) - .map(item => String(item || '').trim()) + buildRelatedPeopleOptions (selectedOperatorIds) { + const normalizedIds = (Array.isArray(selectedOperatorIds) ? selectedOperatorIds : (this.modalData.hsfApproverCodeList || [])) + .map(item => this.resolveOperatorIdByCodeOrName(item)) .filter(item => !!item) - const selectedSet = new Set(normalizedNames) + const selectedSet = new Set(normalizedIds) let optionList = (this.hsfApproverOptionList || []) - .filter(item => selectedSet.has(String(item.operatorName || '').trim())) + .filter(item => selectedSet.has(String(item.operatorId || '').trim())) .map(item => ({ operatorId: item.operatorId, operatorName: item.operatorName })) - const existingNameSet = new Set(optionList.map(item => String(item.operatorName || '').trim())) - normalizedNames.forEach(name => { - if (existingNameSet.has(name)) { + const existingIdSet = new Set(optionList.map(item => String(item.operatorId || '').trim())) + normalizedIds.forEach(operatorId => { + if (existingIdSet.has(operatorId)) { return } optionList.push({ - operatorId: name, - operatorName: name + operatorId: operatorId, + operatorName: this.resolveOperatorNameById(operatorId) }) - existingNameSet.add(name) + existingIdSet.add(operatorId) }) this.relatedPeopleOptionList = optionList this.filterRelatedPeopleOptions() - const selectedRelatedPeople = String(this.modalData.relatedPeople || '').trim() - if (selectedRelatedPeople && !optionList.some(item => String(item.operatorName || '').trim() === selectedRelatedPeople)) { + const selectedRelatedPeopleCode = this.resolveOperatorIdByCodeOrName(this.modalData.relatedPeople) + const selectedRelatedPeopleRow = optionList.find(item => String(item.operatorId || '').trim() === selectedRelatedPeopleCode) + if (!selectedRelatedPeopleRow) { this.$set(this.modalData, 'relatedPeople', '') + this.$set(this.modalData, 'relatedPeopleName', '') + } else { + this.$set(this.modalData, 'relatedPeople', selectedRelatedPeopleCode) + this.$set(this.modalData, 'relatedPeopleName', String(selectedRelatedPeopleRow.operatorName || '').trim()) } }, normalizeHsfApproverOptionList (rows) { @@ -1870,12 +1913,12 @@ export default { operatorName: '' } this.filterHsfApproverOptions() - const selectedNameSet = new Set( - (this.modalData.hsfApproverList || []) + const selectedOperatorSet = new Set( + (this.modalData.hsfApproverCodeList || []) .map(item => String(item || '').trim()) .filter(item => !!item) ) - const selectedRows = (this.hsfApproverOptionList || []).filter(item => selectedNameSet.has(item.operatorName)) + const selectedRows = (this.hsfApproverOptionList || []).filter(item => selectedOperatorSet.has(String(item.operatorId || '').trim())) this.hsfApproverSelectionCache = JSON.parse(JSON.stringify(selectedRows)) this.$nextTick(() => { if (!this.$refs.hsfApproverTable) { @@ -1899,26 +1942,26 @@ export default { } }, saveHsfApproverChooseModal () { - const selectedNames = (this.hsfApproverSelectionCache || []) - .map(item => String(item.operatorName || '').trim()) + const selectedCodes = (this.hsfApproverSelectionCache || []) + .map(item => String(item.operatorId || '').trim()) .filter(item => !!item) - this.$set(this.modalData, 'hsfApproverList', selectedNames) + this.$set(this.modalData, 'hsfApproverCodeList', selectedCodes) this.syncHsfApproverFields() this.hsfApproverFlag = false }, clearHsfApproverSelection () { - this.$set(this.modalData, 'hsfApproverList', []) + this.$set(this.modalData, 'hsfApproverCodeList', []) this.syncHsfApproverFields() }, openRelatedPeopleChooseModal () { if (this.isRohsFieldDisabled('relatedPeople')) { return } - if (!this.modalData || !Array.isArray(this.modalData.hsfApproverList) || this.modalData.hsfApproverList.length === 0) { + if (!this.modalData || !Array.isArray(this.modalData.hsfApproverCodeList) || this.modalData.hsfApproverCodeList.length === 0) { this.$message.warning('请先选择HSF审批人') return } - this.buildRelatedPeopleOptions(this.modalData.hsfApproverList) + this.buildRelatedPeopleOptions(this.modalData.hsfApproverCodeList) if (!this.relatedPeopleOptionList || this.relatedPeopleOptionList.length === 0) { this.$message.warning('未查询到可选Inform Related people') return @@ -1931,8 +1974,8 @@ export default { operatorName: '' } this.filterRelatedPeopleOptions() - const relatedPeople = String(this.modalData.relatedPeople || '').trim() - const selectedRow = (this.relatedPeopleOptionList || []).find(item => String(item.operatorName || '').trim() === relatedPeople) || null + const relatedPeopleCode = String(this.modalData.relatedPeople || '').trim() + const selectedRow = (this.relatedPeopleOptionList || []).find(item => String(item.operatorId || '').trim() === relatedPeopleCode) || null this.relatedPeopleSelection = selectedRow this.$nextTick(() => { if (!this.$refs.relatedPeopleTable) { @@ -1954,12 +1997,15 @@ export default { } }, saveRelatedPeopleChooseModal () { + const selectedCode = this.relatedPeopleSelection ? String(this.relatedPeopleSelection.operatorId || '').trim() : '' const selectedName = this.relatedPeopleSelection ? String(this.relatedPeopleSelection.operatorName || '').trim() : '' - this.$set(this.modalData, 'relatedPeople', selectedName) + this.$set(this.modalData, 'relatedPeople', selectedCode) + this.$set(this.modalData, 'relatedPeopleName', selectedName) this.relatedPeopleFlag = false }, clearRelatedPeopleSelection () { this.$set(this.modalData, 'relatedPeople', '') + this.$set(this.modalData, 'relatedPeopleName', '') this.relatedPeopleSelection = null if (this.$refs.relatedPeopleTable) { this.$refs.relatedPeopleTable.setCurrentRow(null) @@ -1984,9 +2030,11 @@ export default { operatorId: '', operatorName: '' } - this.$set(this.modalData, 'hsfApproverList', []) + this.$set(this.modalData, 'hsfApproverCodeList', []) this.$set(this.modalData, 'hsfApprover', '') + this.$set(this.modalData, 'hsfApproverName', '') this.$set(this.modalData, 'relatedPeople', '') + this.$set(this.modalData, 'relatedPeopleName', '') }, loadHsfApproverByCurrentProcess (forceSelectAll = false) { if (!this.modalData || !this.modalData.site) { @@ -2020,8 +2068,8 @@ export default { this.filterHsfApproverOptions() this.hsfApproverSelectionCache = [] if (forceSelectAll) { - const defaultSelectedNames = this.hsfApproverOptionList.map(item => item.operatorName).filter(item => item) - this.$set(this.modalData, 'hsfApproverList', defaultSelectedNames) + const defaultSelectedCodes = this.hsfApproverOptionList.map(item => item.operatorId).filter(item => item) + this.$set(this.modalData, 'hsfApproverCodeList', defaultSelectedCodes) } this.syncHsfApproverFields() } else { @@ -2257,7 +2305,7 @@ export default { if (!target) { return } - const fields = ['nodeId', 'nodeName', 'currentApprover', 'applicantName', 'pmName', 'npdEngineerName', 'technicalPlanName', 'buyerName', 'endCustomerName', 'projectName', 'commGroup1Desc', 'commGroup2Desc', 'commGroup3Desc'] + const fields = ['nodeId', 'nodeName', 'currentApprover', 'applicantName', 'pmName', 'npdEngineerName', 'technicalPlanName', 'buyerName', 'endCustomerName', 'projectName', 'commGroup1Desc', 'commGroup2Desc', 'commGroup3Desc', 'hsfApproverName', 'relatedPeopleName'] fields.forEach(field => { const value = target[field] || fallbackData[field] || '' this.$set(target, field, value) @@ -2349,6 +2397,8 @@ export default { commGroup1Desc: '', commGroup2Desc: '', commGroup3Desc: '', + hsfApproverName: '', + relatedPeopleName: '', ...item } }) @@ -2422,6 +2472,8 @@ export default { row.expiredDate = this.normalizeDateOnly(row.expiredDate) row.expiryDate = this.normalizeDateOnly(row.expiryDate) row.validUntilDisplay = this.getValidUntilDisplay(row.validUntilValue, row.validUntil) + row.hsfApproverName = row.hsfApproverName || row.hsfApprover || '' + row.relatedPeopleName = row.relatedPeopleName || row.relatedPeople || '' return row }) } else { @@ -2528,7 +2580,7 @@ export default { this.$set(this.modalData, 'testReportIncludingItemsList', this.modalData.testReportIncludingItems ? this.modalData.testReportIncludingItems.split(';').filter(item => item) : []) this.$set(this.modalData, 'materialClassifyList', this.modalData.materialClassify ? this.modalData.materialClassify.split(';').filter(item => item) : []) this.$set(this.modalData, 'materialList', Array.isArray(this.modalData.materialList) ? this.modalData.materialList : []) - this.$set(this.modalData, 'hsfApproverList', this.modalData.hsfApprover ? this.modalData.hsfApprover.split(';').filter(item => item) : []) + this.$set(this.modalData, 'hsfApproverCodeList', this.modalData.hsfApprover ? this.modalData.hsfApprover.split(';').filter(item => item) : []) this.$set(this.modalData, 'buNo', this.modalData.process || '') this.$set(this.modalData, 'isAhGrade', this.normalizeCheckboxFlag(this.modalData.isAhGrade)) this.$set(this.modalData, 'validUntilValue', this.normalizeValidUntilValue(this.modalData.validUntilValue)) @@ -2609,8 +2661,10 @@ export default { fiberInformation: '', hsfStandard: '', hsfApprover: '', - hsfApproverList: [], + hsfApproverName: '', + hsfApproverCodeList: [], relatedPeople: '', + relatedPeopleName: '', buNo: '', validUntilValue: 0, validUntil: '',