Browse Source

2026-07-22

Lab Test优化
master
fengyuan_yang 1 week ago
parent
commit
f06b9de1f1
  1. 153
      src/views/modules/lab/labRecord.vue

153
src/views/modules/lab/labRecord.vue

@ -92,7 +92,11 @@
<span>{{ displayYesNo(scope.row.returnSample) }}</span>
</template>
</el-table-column>
<el-table-column prop="testLab" header-align="center" align="center" label="测试实验室" width="140"></el-table-column>
<el-table-column prop="testLabName" header-align="center" align="center" label="测试实验室" width="140">
<template slot-scope="scope">
<span>{{ scope.row.testLabName || scope.row.testLab || '' }}</span>
</template>
</el-table-column>
<el-table-column prop="testStartDate" header-align="center" align="center" label="测试开始时间" width="120">
<template slot-scope="scope">
<span>{{ normalizeDateOnly(scope.row.testStartDate) }}</span>
@ -716,7 +720,7 @@
<el-input :value="currentDetail.applicationSurface || ''" disabled style="width: 533px"></el-input>
</el-form-item>
<el-form-item label="Test Lab">
<el-input :value="currentDetail.testLab || ''" disabled style="width: 225px"></el-input>
<el-input :value="currentDetail.testLabName || currentDetail.testLab || ''" disabled style="width: 225px"></el-input>
</el-form-item>
</el-form>
@ -858,6 +862,7 @@ import { verifyData } from '@/api/chooselist/chooselist.js'
import { searchProjectInfoList } from '@/api/quotation/quotationInformation.js'
import { queryCustomer } from '@/api/customer/customerInformation'
import { queryProjectByCustomer } from '@/api/project/project'
import { selectDictDataList } from '@/api/dict'
import ChooseList from '@/views/modules/common/Chooselist'
import DictDataSelect from '../sys/dict-data-select.vue'
import ApprovalInformation from '../changeManagement/approvalInformation.vue'
@ -1016,6 +1021,9 @@ export default {
operatorId: '',
operatorName: ''
},
labTestLabDictRows: [],
labTestLabValueLabelMap: {},
labTestLabLabelValueMap: {},
labApproverOptionList: [],
labApproverDisplayList: [],
labApproverSelectionCache: [],
@ -1031,6 +1039,7 @@ export default {
this.getButtonAuthData()
this.checkSuperAdmin()
this.loadSiteOptions()
this.loadLabTestLabDictOptions()
},
mounted () {
this.fetchNodeOptions()
@ -1154,6 +1163,7 @@ export default {
returnSample: '',
applicationSurface: '',
testLab: '',
testLabLabel: '',
labApprover: '',
labApproverName: '',
labApproverCodeList: [],
@ -1209,6 +1219,114 @@ export default {
this.nodeOptions = []
})
},
getLabTestLabDictSite () {
// Keep consistent with current Test Lab dict source configuration.
return '41'
},
buildLabTestLabDictMaps (rows) {
const valueLabelMap = {}
const labelValueMap = {}
;(rows || []).forEach(item => {
const value = String((item && item.dictValue) || '').trim()
const label = String((item && item.dictLabel) || '').trim()
const status = String((item && item.status) || '').trim().toUpperCase()
if (!value || !label || status === 'N') {
return
}
valueLabelMap[value] = label
if (!labelValueMap[label]) {
labelValueMap[label] = value
}
})
this.labTestLabValueLabelMap = valueLabelMap
this.labTestLabLabelValueMap = labelValueMap
},
loadLabTestLabDictOptions (forceRefresh = false) {
if (!forceRefresh && this.labTestLabDictRows && this.labTestLabDictRows.length > 0) {
return Promise.resolve(this.labTestLabDictRows)
}
const params = {
site: this.getLabTestLabDictSite(),
dictType: 'lab_test_lab'
}
return selectDictDataList(params).then(({ data }) => {
if (data && data.code === 0 && Array.isArray(data.rows)) {
this.labTestLabDictRows = data.rows
this.buildLabTestLabDictMaps(data.rows)
} else {
this.labTestLabDictRows = []
this.labTestLabValueLabelMap = {}
this.labTestLabLabelValueMap = {}
}
return this.labTestLabDictRows
}).catch(() => {
this.labTestLabDictRows = []
this.labTestLabValueLabelMap = {}
this.labTestLabLabelValueMap = {}
return []
})
},
resolveLabTestLabPair (rawValue) {
const rawText = String(rawValue || '').trim()
if (!rawText) {
return {
key: '',
label: ''
}
}
const labelByValue = this.labTestLabValueLabelMap[rawText]
if (labelByValue) {
return {
key: rawText,
label: labelByValue
}
}
const valueByLabel = this.labTestLabLabelValueMap[rawText]
if (valueByLabel) {
return {
key: valueByLabel,
label: rawText
}
}
return {
key: rawText,
label: rawText
}
},
applyLabTestLabPairToModalData (rawValue) {
if (!this.modalData) {
return
}
const pair = this.resolveLabTestLabPair(rawValue)
this.$set(this.modalData, 'testLab', pair.key)
this.$set(this.modalData, 'testLabLabel', pair.label)
},
getTesterRoleNoByTestLab () {
if (!this.modalData) {
return ''
}
const sourceValue = String(this.modalData.testLab || this.modalData.testLabLabel || '').trim()
const pair = this.resolveLabTestLabPair(sourceValue)
if (pair.key !== this.modalData.testLab) {
this.$set(this.modalData, 'testLab', pair.key)
}
if (pair.label !== this.modalData.testLabLabel) {
this.$set(this.modalData, 'testLabLabel', pair.label)
}
return String(pair.key || '').trim()
},
resolveLabTestLabLabelForSubmit (source) {
const labelText = String((source && source.testLabLabel) || '').trim()
if (labelText) {
return labelText
}
const sourceValue = String((source && source.testLab) || '').trim()
const pair = this.resolveLabTestLabPair(sourceValue)
if (pair.label) {
return pair.label
}
return sourceValue
},
handleModalSiteChange (site) {
if (!site || this.isEditMode) {
return
@ -1229,6 +1347,8 @@ export default {
this.modalData.projectId = ''
this.modalData.projectName = ''
this.modalData.projectIdFlag = true
this.$set(this.modalData, 'testLab', '')
this.$set(this.modalData, 'testLabLabel', '')
this.$set(this.modalData, 'testerCodeList', [])
this.$set(this.modalData, 'testerList', [])
this.$set(this.modalData, 'tester', '')
@ -1260,7 +1380,9 @@ export default {
if (!this.modalData || this.showModalFlag || this.isLabFieldDisabled('testLab')) {
return
}
this.$set(this.modalData, 'testLab', value || '')
const pair = this.resolveLabTestLabPair(value || '')
this.$set(this.modalData, 'testLab', pair.key)
this.$set(this.modalData, 'testLabLabel', pair.label)
this.testerFlag = false
this.testerOptionList = []
this.testerDisplayList = []
@ -1822,15 +1944,16 @@ export default {
})
},
loadTesterOptions () {
if (!this.modalData || !this.modalData.site || !String(this.modalData.testLab || '').trim()) {
const roleNo = this.getTesterRoleNoByTestLab()
if (!this.modalData || !this.modalData.site || !roleNo) {
this.testerOptionList = []
this.testerDisplayList = []
this.testerSelectionCache = []
return Promise.resolve()
}
const params = {
site: this.modalData.site,
roleNo: String(this.modalData.testLab || '').trim(),
site: '41',
roleNo: roleNo,
active: 'Y'
}
return searchUserListForRole(params).then(({data}) => {
@ -1867,7 +1990,7 @@ export default {
this.$message.warning('请先选择工厂')
return
}
if (!String(this.modalData.testLab || '').trim()) {
if (!this.getTesterRoleNoByTestLab()) {
this.$message.warning('请先选择Test Lab')
return
}
@ -1937,13 +2060,14 @@ export default {
})
},
loadLabApproverOptions () {
if (!this.modalData || !this.modalData.site || !this.modalData.testLab) {
const roleNo = this.getTesterRoleNoByTestLab()
if (!this.modalData || !this.modalData.site || !roleNo) {
this.resetLabApproverOptionState()
return Promise.resolve()
}
const params = {
site: this.modalData.site,
roleNo: this.modalData.testLab,
roleNo: roleNo,
active: 'Y'
}
return searchUserListForRole(params).then(({data}) => {
@ -1976,7 +2100,7 @@ export default {
this.$message.warning('请先选择工厂')
return
}
if (!this.modalData.testLab) {
if (!this.getTesterRoleNoByTestLab()) {
this.$message.warning('请先选择Test Lab')
return
}
@ -2469,7 +2593,13 @@ export default {
this.$set(this.modalData, 'csProcessControl', 'N')
this.$set(this.modalData, 'testerName', this.modalData.testerName || this.modalData.tester || '')
this.$set(this.modalData, 'labApproverName', this.modalData.labApproverName || this.modalData.labApprover || '')
this.loadLabTestLabDictOptions().then(() => {
this.applyLabTestLabPairToModalData(this.modalData.testLab)
this.loadTesterOptions()
}).catch(() => {
this.applyLabTestLabPairToModalData(this.modalData.testLab)
this.loadTesterOptions()
})
this.loadModalButtonCondition()
this.loadNodeAuthority(this.modalData.site || row.site, this.modalData.stepId !== null && this.modalData.stepId !== undefined ? this.modalData.stepId : 10)
this.refreshJudgeCriteriaFileList()
@ -2506,6 +2636,8 @@ export default {
this.$set(this.modalData, 'testerCodeList', [])
this.$set(this.modalData, 'testerList', [])
this.$set(this.modalData, 'testerName', '')
this.$set(this.modalData, 'testLab', '')
this.$set(this.modalData, 'testLabLabel', '')
this.$set(this.modalData, 'labApproverCodeList', [])
this.$set(this.modalData, 'labApproverList', [])
this.$set(this.modalData, 'labApproverName', '')
@ -2557,6 +2689,7 @@ export default {
fields.forEach(field => {
payload[field] = source[field]
})
payload.testLab = this.resolveLabTestLabLabelForSubmit(source)
return payload
},
dataFormSubmit () {

Loading…
Cancel
Save