Browse Source

显示label

master
han\hanst 1 week ago
parent
commit
46e2b4bb3c
  1. 94
      src/views/modules/sampleTracking/projectProofTracking.vue

94
src/views/modules/sampleTracking/projectProofTracking.vue

@ -1049,6 +1049,27 @@ function cloneDefaultProcessColumns () {
return DEFAULT_PROCESS_COLUMNS.map(item => Object.assign({}, item))
}
function buildProcessCodeLabelMapByRows (rows) {
const nextMap = {}
if (!Array.isArray(rows)) {
return nextMap
}
rows.forEach(item => {
if (!item) {
return
}
const code = item.code == null ? '' : String(item.code).trim()
const label = item.label == null ? '' : String(item.label).trim()
if (!code || !label) {
return
}
//
nextMap[code] = label
nextMap[code.toLowerCase()] = label
})
return nextMap
}
const ONE_KEY_ROLE_FIELDS = [
'projectManager',
'projectOwner',
@ -1279,6 +1300,7 @@ export default {
},
trackingColumnList: cloneDefaultTrackingColumns(),
processColumns: cloneDefaultProcessColumns(),
processCodeLabelMap: buildProcessCodeLabelMapByRows(cloneDefaultProcessColumns()),
buProcessConfigDialogVisible: false,
buProcessConfigRows: [],
buProcessConfigMap: {},
@ -1746,6 +1768,7 @@ export default {
if (!(data && data.code === 0)) {
this.$message.error((data && data.msg) || '加载工序列配置失败,已使用默认配置')
this.processColumns = cloneDefaultProcessColumns()
this.mergeProcessCodeLabelMapByRows(this.processColumns)
this.ensureBuProcessConfigRows()
this.refreshTrackingTableLayout()
return this.processColumns
@ -1793,6 +1816,7 @@ export default {
})
// 使
this.processColumns = nextColumns.length > 0 ? nextColumns : cloneDefaultProcessColumns()
this.mergeProcessCodeLabelMapByRows(this.processColumns)
this.syncDataListProcessValues()
this.ensureBuProcessConfigRows()
this.refreshTrackingTableLayout()
@ -1800,6 +1824,7 @@ export default {
}).catch(() => {
this.$message.error('加载工序列配置异常,已使用默认配置')
this.processColumns = cloneDefaultProcessColumns()
this.mergeProcessCodeLabelMapByRows(this.processColumns)
this.syncDataListProcessValues()
this.ensureBuProcessConfigRows()
this.refreshTrackingTableLayout()
@ -1862,16 +1887,67 @@ export default {
getAllProcessCodes () {
return this.processColumns.map(item => item.code)
},
mergeProcessCodeLabelMapByRows (rows) {
if (!Array.isArray(rows) || rows.length === 0) {
return
}
const nextMap = Object.assign({}, this.processCodeLabelMap || {})
const rowLabelMap = buildProcessCodeLabelMapByRows(rows)
Object.keys(rowLabelMap).forEach(code => {
nextMap[code] = rowLabelMap[code]
})
this.processCodeLabelMap = nextMap
},
mergeProcessCodeLabelMapByObject (labelMap) {
if (!labelMap || typeof labelMap !== 'object') {
return
}
const nextMap = Object.assign({}, this.processCodeLabelMap || {})
Object.keys(labelMap).forEach(rawCode => {
const code = rawCode == null ? '' : String(rawCode).trim()
const label = labelMap[rawCode] == null ? '' : String(labelMap[rawCode]).trim()
if (!code || !label) {
return
}
//
nextMap[code] = label
nextMap[code.toLowerCase()] = label
})
this.processCodeLabelMap = nextMap
},
getProcessLabelByCode (processCode) {
if (!processCode) {
return ''
}
const matched = this.processColumns.find(item => item && item.code === processCode)
const normalizedCode = String(processCode).trim()
const lowerCode = normalizedCode.toLowerCase()
const matched = this.processColumns.find(item => item && item.code === normalizedCode)
if (matched && matched.label) {
return matched.label
}
const defaultMatched = DEFAULT_PROCESS_COLUMNS.find(item => item && item.code === processCode)
return defaultMatched && defaultMatched.label ? defaultMatched.label : processCode
const caseInsensitiveMatched = this.processColumns.find(item => {
if (!item || !item.code) {
return false
}
return String(item.code).trim().toLowerCase() === lowerCode
})
if (caseInsensitiveMatched && caseInsensitiveMatched.label) {
return caseInsensitiveMatched.label
}
const codeLabelMap = this.processCodeLabelMap || {}
if (codeLabelMap[normalizedCode]) {
return codeLabelMap[normalizedCode]
}
if (codeLabelMap[lowerCode]) {
return codeLabelMap[lowerCode]
}
const defaultMatched = DEFAULT_PROCESS_COLUMNS.find(item => {
if (!item || !item.code) {
return false
}
return item.code.toLowerCase() === lowerCode
})
return defaultMatched && defaultMatched.label ? defaultMatched.label : normalizedCode
},
getValidProcessOrderCodes (codes) {
// BU
@ -2001,7 +2077,18 @@ export default {
}
const rows = data.rows || []
const nextMap = {}
const processLabelMap = {}
rows.forEach(item => {
if (item && item.processLabelMap && typeof item.processLabelMap === 'object') {
Object.keys(item.processLabelMap).forEach(rawCode => {
const code = rawCode == null ? '' : String(rawCode).trim()
const label = item.processLabelMap[rawCode] == null ? '' : String(item.processLabelMap[rawCode]).trim()
if (!code || !label) {
return
}
processLabelMap[code] = label
})
}
const buNo = this.normalizeBuNo(item && item.buNo ? item.buNo : '', this.$store.state.user.site)
if (!buNo) {
return
@ -2021,6 +2108,7 @@ export default {
processCodes: showAll ? processOrderCodes.slice() : processOrderCodes.filter(code => selectedCodeMap[code])
}
})
this.mergeProcessCodeLabelMapByObject(processLabelMap)
this.buProcessConfigMap = nextMap
this.ensureBuProcessConfigRows()
this.refreshTrackingTableLayout()

Loading…
Cancel
Save