diff --git a/src/views/modules/rohs/rohsRecord.vue b/src/views/modules/rohs/rohsRecord.vue
index 3cb99ca..85c4db8 100644
--- a/src/views/modules/rohs/rohsRecord.vue
+++ b/src/views/modules/rohs/rohsRecord.vue
@@ -340,6 +340,9 @@
style="width: 420px"
placeholder="请选择人员"
@focus="openHsfApproverChooseModal">
+
+
+
@@ -560,21 +563,41 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+ 查询
+
+
+ handleHsfApproverTableClick(row,column,event,'hsfApproverTable')"
+ ref="hsfApproverTable"
+ border row-key="operatorId"
+ style="width: 100%;">
+
+
+
+
+
+
+ 确定
+ 关闭
+
@@ -1075,11 +1098,12 @@ export default {
nodeOptions: [],
projectList: [],
hsfApproverOptionList: [],
- hsfApproverTransferList: [],
+ hsfApproverDisplayList: [],
+ hsfApproverSelectionCache: [],
hsfApproverFlag: false,
- hsfApproverOperatorProp: {
- key: 'operatorId',
- label: 'operatorName'
+ hsfApproverSearchData: {
+ operatorId: '',
+ operatorName: ''
},
fileList: [],
approvalList: [],
@@ -1326,42 +1350,53 @@ export default {
}
},
syncHsfApproverFields () {
- const list = Array.isArray(this.modalData.hsfApproverList)
- ? this.modalData.hsfApproverList.filter(item => item && item.trim())
+ const sourceList = Array.isArray(this.modalData.hsfApproverList)
+ ? this.modalData.hsfApproverList
: []
- this.$set(this.modalData, 'hsfApproverList', list)
- this.$set(this.modalData, 'hsfApprover', list.join(';'))
- if (!list.includes(this.modalData.relatedPeople)) {
- this.$set(this.modalData, 'relatedPeople', '')
- }
- },
- mapHsfApproverNamesToIds (nameList, optionList = this.hsfApproverOptionList) {
- if (!Array.isArray(nameList) || !Array.isArray(optionList) || optionList.length === 0) {
- return []
- }
- const nameMap = new Map()
- optionList.forEach(item => {
- if (item && item.operatorName && item.operatorId && !nameMap.has(item.operatorName)) {
- nameMap.set(item.operatorName, item.operatorId)
+ const uniqueList = []
+ const seen = new Set()
+ sourceList.forEach(item => {
+ const value = String(item || '').trim()
+ if (!value || seen.has(value)) {
+ return
}
+ seen.add(value)
+ uniqueList.push(value)
})
- return nameList
- .map(name => nameMap.get(name))
- .filter(id => !!id)
+ this.$set(this.modalData, 'hsfApproverList', uniqueList)
+ this.$set(this.modalData, 'hsfApprover', uniqueList.join(';'))
+ if (!uniqueList.includes(this.modalData.relatedPeople)) {
+ this.$set(this.modalData, 'relatedPeople', '')
+ }
},
- mapHsfApproverIdsToNames (idList, optionList = this.hsfApproverOptionList) {
- if (!Array.isArray(idList) || !Array.isArray(optionList) || optionList.length === 0) {
+ normalizeHsfApproverOptionList (rows) {
+ if (!Array.isArray(rows)) {
return []
}
- const idMap = new Map()
- optionList.forEach(item => {
- if (item && item.operatorId && item.operatorName) {
- idMap.set(item.operatorId, item.operatorName)
- }
+ return rows
+ .map(item => {
+ const operatorId = String(item.operatorId || item.operator_id || item.username || item.userName || '').trim()
+ const operatorName = String(item.operatorName || item.operator_name || item.userDisplay || item.user_display || '').trim()
+ if (!operatorId || !operatorName) {
+ return null
+ }
+ return {
+ operatorId,
+ operatorName
+ }
+ })
+ .filter(item => !!item)
+ },
+ filterHsfApproverOptions () {
+ const operatorIdKeyword = String(this.hsfApproverSearchData.operatorId || '').trim().toUpperCase()
+ const operatorNameKeyword = String(this.hsfApproverSearchData.operatorName || '').trim().toUpperCase()
+ this.hsfApproverDisplayList = (this.hsfApproverOptionList || []).filter(item => {
+ const operatorId = String(item.operatorId || '').toUpperCase()
+ const operatorName = String(item.operatorName || '').toUpperCase()
+ const matchOperatorId = !operatorIdKeyword || operatorId.includes(operatorIdKeyword)
+ const matchOperatorName = !operatorNameKeyword || operatorName.includes(operatorNameKeyword)
+ return matchOperatorId && matchOperatorName
})
- return idList
- .map(id => idMap.get(id))
- .filter(name => !!name)
},
openHsfApproverChooseModal () {
if (this.isRohsFieldDisabled('hsfApprover')) {
@@ -1372,7 +1407,6 @@ export default {
return
}
this.loadHsfApproverByCurrentProject(false).then(() => {
- this.hsfApproverTransferList = this.mapHsfApproverNamesToIds(this.modalData.hsfApproverList)
if (!this.hsfApproverOptionList || this.hsfApproverOptionList.length === 0) {
this.$message.warning('未查询到可选HSF审批人')
return
@@ -1380,18 +1414,63 @@ export default {
this.hsfApproverFlag = true
})
},
+ openHsfApproverDialog () {
+ this.hsfApproverSearchData = {
+ operatorId: '',
+ operatorName: ''
+ }
+ this.filterHsfApproverOptions()
+ const selectedNameSet = new Set(
+ (this.modalData.hsfApproverList || [])
+ .map(item => String(item || '').trim())
+ .filter(item => !!item)
+ )
+ const selectedRows = (this.hsfApproverOptionList || []).filter(item => selectedNameSet.has(item.operatorName))
+ this.hsfApproverSelectionCache = JSON.parse(JSON.stringify(selectedRows))
+ this.$nextTick(() => {
+ if (!this.$refs.hsfApproverTable) {
+ return
+ }
+ this.$refs.hsfApproverTable.clearSelection()
+ selectedRows.forEach(item => {
+ this.$refs.hsfApproverTable.toggleRowSelection(item, true)
+ })
+ })
+ },
+ closeHsfApproverDialog () {
+ this.hsfApproverSelectionCache = []
+ },
+ handleHsfApproverSelectionChange (rows) {
+ this.hsfApproverSelectionCache = rows || []
+ },
+ handleHsfApproverTableClick (row, column, event, tableRef) {
+ if (this.$refs[tableRef]) {
+ this.$refs[tableRef].toggleRowSelection(row)
+ }
+ },
saveHsfApproverChooseModal () {
- const selectedNames = this.mapHsfApproverIdsToNames(this.hsfApproverTransferList)
+ const selectedNames = (this.hsfApproverSelectionCache || [])
+ .map(item => String(item.operatorName || '').trim())
+ .filter(item => !!item)
this.$set(this.modalData, 'hsfApproverList', selectedNames)
this.syncHsfApproverFields()
this.hsfApproverFlag = false
},
+ clearHsfApproverSelection () {
+ this.$set(this.modalData, 'hsfApproverList', [])
+ this.syncHsfApproverFields()
+ },
clearHsfApproverFields (clearBuNo = false) {
if (clearBuNo) {
this.$set(this.modalData, 'buNo', '')
}
this.hsfApproverOptionList = []
- this.hsfApproverTransferList = []
+ this.hsfApproverDisplayList = []
+ this.hsfApproverSelectionCache = []
+ this.hsfApproverSearchData = {
+ operatorId: '',
+ operatorName: ''
+ }
this.$set(this.modalData, 'hsfApproverList', [])
this.$set(this.modalData, 'hsfApprover', '')
this.$set(this.modalData, 'relatedPeople', '')
@@ -1402,7 +1481,8 @@ export default {
this.$message.warning('请先选择项目编码')
}
this.hsfApproverOptionList = []
- this.hsfApproverTransferList = []
+ this.hsfApproverDisplayList = []
+ this.hsfApproverSelectionCache = []
if (forceSelectAll) {
this.clearHsfApproverFields(false)
}
@@ -1414,7 +1494,8 @@ export default {
this.$message.warning('当前项目未维护BU,无法查询HSF审批人')
}
this.hsfApproverOptionList = []
- this.hsfApproverTransferList = []
+ this.hsfApproverDisplayList = []
+ this.hsfApproverSelectionCache = []
if (forceSelectAll) {
this.clearHsfApproverFields(false)
}
@@ -1427,25 +1508,26 @@ export default {
}
return api.searchBmUser(params).then(({data}) => {
if (data && data.code === 0 && Array.isArray(data.rows)) {
- this.hsfApproverOptionList = data.rows
+ this.hsfApproverOptionList = this.normalizeHsfApproverOptionList(data.rows)
+ this.filterHsfApproverOptions()
+ this.hsfApproverSelectionCache = []
if (forceSelectAll) {
- const defaultSelectedIds = data.rows.map(item => item.operatorId).filter(item => item)
- this.hsfApproverTransferList = defaultSelectedIds
- this.$set(this.modalData, 'hsfApproverList', this.mapHsfApproverIdsToNames(defaultSelectedIds, data.rows))
- } else {
- this.hsfApproverTransferList = this.mapHsfApproverNamesToIds(this.modalData.hsfApproverList, data.rows)
+ const defaultSelectedNames = this.hsfApproverOptionList.map(item => item.operatorName).filter(item => item)
+ this.$set(this.modalData, 'hsfApproverList', defaultSelectedNames)
}
this.syncHsfApproverFields()
} else {
this.hsfApproverOptionList = []
- this.hsfApproverTransferList = []
+ this.hsfApproverDisplayList = []
+ this.hsfApproverSelectionCache = []
if (forceSelectAll) {
this.clearHsfApproverFields(false)
}
}
}).catch(() => {
this.hsfApproverOptionList = []
- this.hsfApproverTransferList = []
+ this.hsfApproverDisplayList = []
+ this.hsfApproverSelectionCache = []
if (forceSelectAll) {
this.clearHsfApproverFields(false)
}
@@ -1791,7 +1873,12 @@ export default {
this.projectMaterialSelections = []
this.materialSelections = []
this.hsfApproverOptionList = []
- this.hsfApproverTransferList = []
+ this.hsfApproverDisplayList = []
+ this.hsfApproverSelectionCache = []
+ this.hsfApproverSearchData = {
+ operatorId: '',
+ operatorName: ''
+ }
this.hsfApproverFlag = false
this.plmRohsAuthorityArr = []
this.nodeAuthorityLoaded = !row