Browse Source

2026-05-21

RoHs优化
master
fengyuan_yang 3 weeks ago
parent
commit
21edbddc12
  1. 211
      src/views/modules/rohs/rohsRecord.vue

211
src/views/modules/rohs/rohsRecord.vue

@ -340,6 +340,9 @@
style="width: 420px" style="width: 420px"
placeholder="请选择人员" placeholder="请选择人员"
@focus="openHsfApproverChooseModal"> @focus="openHsfApproverChooseModal">
<span slot="suffix" v-show="modalData.hsfApprover && !isRohsFieldDisabled('hsfApprover')" @click.stop="clearHsfApproverSelection">
<i class="el-icon-circle-close" style="margin-left: 5px;cursor: pointer;"></i>
</span>
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -560,21 +563,41 @@
</el-footer> </el-footer>
</el-dialog> </el-dialog>
<el-dialog width="530px" title="HSF审批人" :close-on-click-modal="false" :visible.sync="hsfApproverFlag">
<el-transfer
v-model="hsfApproverTransferList"
class="rq"
filterable
:props="hsfApproverOperatorProp"
:data="hsfApproverOptionList"
:titles="['未选择', '已选择']">
</el-transfer>
<span slot="footer" class="dialog-footer">
<div style="margin-top: 5px">
<el-button type="primary" @click="saveHsfApproverChooseModal">确定</el-button>
<el-button type="primary" @click="hsfApproverFlag = false">取消</el-button>
</div>
</span>
<el-dialog title="人员选择" @open="openHsfApproverDialog" @close="closeHsfApproverDialog" v-drag
:visible.sync="hsfApproverFlag" width="40vw" :close-on-click-modal="false">
<el-form :inline="true" label-position="top" :model="hsfApproverSearchData">
<el-form-item label="编码">
<el-input v-model="hsfApproverSearchData.operatorId" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item label="名称">
<el-input v-model="hsfApproverSearchData.operatorName" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item label=" ">
<el-button type="primary" @click="filterHsfApproverOptions">查询</el-button>
</el-form-item>
</el-form>
<el-table v-if="hsfApproverFlag"
:height="300"
:data="hsfApproverDisplayList"
@selection-change="handleHsfApproverSelectionChange"
@row-click="(row,column,event) => handleHsfApproverTableClick(row,column,event,'hsfApproverTable')"
ref="hsfApproverTable"
border row-key="operatorId"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
:reserve-selection="true"
width="50">
</el-table-column>
<el-table-column label="编码" property="operatorId" align="left" header-align="center"/>
<el-table-column label="名称" property="operatorName" align="left" header-align="center"/>
</el-table>
<el-footer style="height:40px;margin-top: 20px;text-align:center">
<el-button type="primary" @click="saveHsfApproverChooseModal">确定</el-button>
<el-button type="primary" @click="hsfApproverFlag = false">关闭</el-button>
</el-footer>
</el-dialog> </el-dialog>
<el-dialog title="驳回" top="30vh" :close-on-click-modal="false" v-drag :visible.sync="submitModalFlag" width="500px"> <el-dialog title="驳回" top="30vh" :close-on-click-modal="false" v-drag :visible.sync="submitModalFlag" width="500px">
@ -1075,11 +1098,12 @@ export default {
nodeOptions: [], nodeOptions: [],
projectList: [], projectList: [],
hsfApproverOptionList: [], hsfApproverOptionList: [],
hsfApproverTransferList: [],
hsfApproverDisplayList: [],
hsfApproverSelectionCache: [],
hsfApproverFlag: false, hsfApproverFlag: false,
hsfApproverOperatorProp: {
key: 'operatorId',
label: 'operatorName'
hsfApproverSearchData: {
operatorId: '',
operatorName: ''
}, },
fileList: [], fileList: [],
approvalList: [], approvalList: [],
@ -1326,42 +1350,53 @@ export default {
} }
}, },
syncHsfApproverFields () { 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 [] 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 () { openHsfApproverChooseModal () {
if (this.isRohsFieldDisabled('hsfApprover')) { if (this.isRohsFieldDisabled('hsfApprover')) {
@ -1372,7 +1407,6 @@ export default {
return return
} }
this.loadHsfApproverByCurrentProject(false).then(() => { this.loadHsfApproverByCurrentProject(false).then(() => {
this.hsfApproverTransferList = this.mapHsfApproverNamesToIds(this.modalData.hsfApproverList)
if (!this.hsfApproverOptionList || this.hsfApproverOptionList.length === 0) { if (!this.hsfApproverOptionList || this.hsfApproverOptionList.length === 0) {
this.$message.warning('未查询到可选HSF审批人') this.$message.warning('未查询到可选HSF审批人')
return return
@ -1380,18 +1414,63 @@ export default {
this.hsfApproverFlag = true 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 () { 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.$set(this.modalData, 'hsfApproverList', selectedNames)
this.syncHsfApproverFields() this.syncHsfApproverFields()
this.hsfApproverFlag = false this.hsfApproverFlag = false
}, },
clearHsfApproverSelection () {
this.$set(this.modalData, 'hsfApproverList', [])
this.syncHsfApproverFields()
},
clearHsfApproverFields (clearBuNo = false) { clearHsfApproverFields (clearBuNo = false) {
if (clearBuNo) { if (clearBuNo) {
this.$set(this.modalData, 'buNo', '') this.$set(this.modalData, 'buNo', '')
} }
this.hsfApproverOptionList = [] this.hsfApproverOptionList = []
this.hsfApproverTransferList = []
this.hsfApproverDisplayList = []
this.hsfApproverSelectionCache = []
this.hsfApproverSearchData = {
operatorId: '',
operatorName: ''
}
this.$set(this.modalData, 'hsfApproverList', []) this.$set(this.modalData, 'hsfApproverList', [])
this.$set(this.modalData, 'hsfApprover', '') this.$set(this.modalData, 'hsfApprover', '')
this.$set(this.modalData, 'relatedPeople', '') this.$set(this.modalData, 'relatedPeople', '')
@ -1402,7 +1481,8 @@ export default {
this.$message.warning('请先选择项目编码') this.$message.warning('请先选择项目编码')
} }
this.hsfApproverOptionList = [] this.hsfApproverOptionList = []
this.hsfApproverTransferList = []
this.hsfApproverDisplayList = []
this.hsfApproverSelectionCache = []
if (forceSelectAll) { if (forceSelectAll) {
this.clearHsfApproverFields(false) this.clearHsfApproverFields(false)
} }
@ -1414,7 +1494,8 @@ export default {
this.$message.warning('当前项目未维护BU,无法查询HSF审批人') this.$message.warning('当前项目未维护BU,无法查询HSF审批人')
} }
this.hsfApproverOptionList = [] this.hsfApproverOptionList = []
this.hsfApproverTransferList = []
this.hsfApproverDisplayList = []
this.hsfApproverSelectionCache = []
if (forceSelectAll) { if (forceSelectAll) {
this.clearHsfApproverFields(false) this.clearHsfApproverFields(false)
} }
@ -1427,25 +1508,26 @@ export default {
} }
return api.searchBmUser(params).then(({data}) => { return api.searchBmUser(params).then(({data}) => {
if (data && data.code === 0 && Array.isArray(data.rows)) { 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) { 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() this.syncHsfApproverFields()
} else { } else {
this.hsfApproverOptionList = [] this.hsfApproverOptionList = []
this.hsfApproverTransferList = []
this.hsfApproverDisplayList = []
this.hsfApproverSelectionCache = []
if (forceSelectAll) { if (forceSelectAll) {
this.clearHsfApproverFields(false) this.clearHsfApproverFields(false)
} }
} }
}).catch(() => { }).catch(() => {
this.hsfApproverOptionList = [] this.hsfApproverOptionList = []
this.hsfApproverTransferList = []
this.hsfApproverDisplayList = []
this.hsfApproverSelectionCache = []
if (forceSelectAll) { if (forceSelectAll) {
this.clearHsfApproverFields(false) this.clearHsfApproverFields(false)
} }
@ -1791,7 +1873,12 @@ export default {
this.projectMaterialSelections = [] this.projectMaterialSelections = []
this.materialSelections = [] this.materialSelections = []
this.hsfApproverOptionList = [] this.hsfApproverOptionList = []
this.hsfApproverTransferList = []
this.hsfApproverDisplayList = []
this.hsfApproverSelectionCache = []
this.hsfApproverSearchData = {
operatorId: '',
operatorName: ''
}
this.hsfApproverFlag = false this.hsfApproverFlag = false
this.plmRohsAuthorityArr = [] this.plmRohsAuthorityArr = []
this.nodeAuthorityLoaded = !row this.nodeAuthorityLoaded = !row

Loading…
Cancel
Save