diff --git a/src/views/modules/lab/labRecord.vue b/src/views/modules/lab/labRecord.vue index c0ce5aa..e5beef2 100644 --- a/src/views/modules/lab/labRecord.vue +++ b/src/views/modules/lab/labRecord.vue @@ -137,9 +137,9 @@ :close-on-click-modal="false" :showClose="false"> - + -
+
申请人 @@ -230,7 +230,25 @@ - + + + + + + + 实验室审批人 + 实验室审批人 + + + + + @@ -562,6 +580,43 @@ + + + + + + + + + + 查询 + + + + + + + + + + 确定 + 关闭 + + + @@ -667,6 +722,12 @@ + + + + + +
@@ -956,6 +1017,14 @@ export default { testerSearchData: { operatorId: '', operatorName: '' + }, + labApproverOptionList: [], + labApproverDisplayList: [], + labApproverSelectionCache: [], + labApproverFlag: false, + labApproverSearchData: { + operatorId: '', + operatorName: '' } } }, @@ -1039,6 +1108,10 @@ export default { returnSample: '', applicationSurface: '', testLab: '', + labApprover: '', + labApproverName: '', + labApproverCodeList: [], + labApproverList: [], attention: '', testStartDate: '', completedDate: '', @@ -1104,6 +1177,7 @@ export default { operatorId: '', operatorName: '' } + this.resetLabApproverOptionState() this.modalData.customerId = '' this.modalData.customerName = '' this.modalData.projectId = '' @@ -1113,11 +1187,36 @@ export default { this.$set(this.modalData, 'testerList', []) this.$set(this.modalData, 'tester', '') this.$set(this.modalData, 'testerName', '') + this.clearLabApproverFieldData() this.$set(this.modalData, 'propertyItemList', []) this.judgeCriteriaFileList = [] this.testReportFileList = [] this.searchProjectData.site = site }, + resetLabApproverOptionState () { + this.labApproverFlag = false + this.labApproverOptionList = [] + this.labApproverDisplayList = [] + this.labApproverSelectionCache = [] + this.labApproverSearchData = { + operatorId: '', + operatorName: '' + } + }, + clearLabApproverFieldData () { + this.$set(this.modalData, 'labApproverCodeList', []) + this.$set(this.modalData, 'labApproverList', []) + this.$set(this.modalData, 'labApprover', '') + this.$set(this.modalData, 'labApproverName', '') + }, + handleTestLabChange (value) { + if (!this.modalData || this.showModalFlag || this.isLabFieldDisabled('testLab')) { + return + } + this.$set(this.modalData, 'testLab', value || '') + this.resetLabApproverOptionState() + this.clearLabApproverFieldData() + }, loadNodeAuthority (site, stepId) { if (!site || stepId === null || stepId === undefined || !this.menuId) { this.plmLabAuthorityArr = [] @@ -1541,6 +1640,9 @@ export default { if (fieldId === 'tester') { return this.modalData.testerCodeList } + if (fieldId === 'labApprover') { + return this.modalData.labApproverCodeList + } return this.modalData[fieldId] }, isSubmitFieldEmpty (value) { @@ -1615,6 +1717,21 @@ export default { this.$set(this.modalData, 'tester', testerList.join(';')) this.$set(this.modalData, 'testerName', testerList.map(item => this.resolveTesterNameById(item)).join(';')) }, + resolveLabApproverNameById (operatorId) { + const normalizedId = String(operatorId || '').trim() + if (!normalizedId) { + return '' + } + const target = (this.labApproverOptionList || []).find(item => String(item.operatorId || '').trim() === normalizedId) + return target ? String(target.operatorName || '').trim() : normalizedId + }, + syncLabApproverField () { + const labApproverList = this.normalizeTesterList(this.modalData.labApproverCodeList || this.modalData.labApproverList || this.modalData.labApprover) + this.$set(this.modalData, 'labApproverCodeList', labApproverList) + this.$set(this.modalData, 'labApproverList', labApproverList) + this.$set(this.modalData, 'labApprover', labApproverList.join(';')) + this.$set(this.modalData, 'labApproverName', labApproverList.map(item => this.resolveLabApproverNameById(item)).join(';')) + }, filterTesterOptions () { const operatorIdKeyword = String(this.testerSearchData.operatorId || '').trim().toUpperCase() const operatorNameKeyword = String(this.testerSearchData.operatorName || '').trim().toUpperCase() @@ -1726,6 +1843,110 @@ export default { this.$set(this.modalData, 'testerCodeList', []) this.syncTesterField() }, + filterLabApproverOptions () { + const operatorIdKeyword = String(this.labApproverSearchData.operatorId || '').trim().toUpperCase() + const operatorNameKeyword = String(this.labApproverSearchData.operatorName || '').trim().toUpperCase() + this.labApproverDisplayList = (this.labApproverOptionList || []).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 + }) + }, + loadLabApproverOptions () { + if (!this.modalData || !this.modalData.site || !this.modalData.testLab) { + this.resetLabApproverOptionState() + return Promise.resolve() + } + const params = { + site: this.modalData.site, + roleNo: this.modalData.testLab, + active: 'Y' + } + return searchUserListForRole(params).then(({data}) => { + if (data && data.code === 0) { + const roleUserSet = new Set( + (Array.isArray(data.searchUserListForRole) ? data.searchUserListForRole : []) + .map(item => String(item || '').trim()) + .filter(item => !!item) + ) + const userList = (Array.isArray(data.userList) ? data.userList : []).filter(item => { + const username = String(item.username || item.userName || '').trim() + return !!username && roleUserSet.has(username) + }) + this.labApproverOptionList = this.normalizeTesterOptionList(userList) + this.filterLabApproverOptions() + this.labApproverSelectionCache = [] + this.syncLabApproverField() + } else { + this.resetLabApproverOptionState() + } + }).catch(() => { + this.resetLabApproverOptionState() + }) + }, + openLabApproverChooseModal () { + if (this.isLabFieldDisabled('labApprover')) { + return + } + if (!this.modalData || !String(this.modalData.site || '').trim()) { + this.$message.warning('请先选择工厂') + return + } + if (!this.modalData.testLab) { + this.$message.warning('请先选择Test Lab') + return + } + this.loadLabApproverOptions().then(() => { + if (!this.labApproverOptionList || this.labApproverOptionList.length === 0) { + this.$message.warning('未查询到可选实验室审批人') + return + } + this.labApproverFlag = true + }) + }, + openLabApproverDialog () { + this.labApproverSearchData = { + operatorId: '', + operatorName: '' + } + this.filterLabApproverOptions() + const selectedOperatorSet = new Set( + (this.modalData.labApproverCodeList || []) + .map(item => String(item || '').trim()) + .filter(item => !!item) + ) + const selectedRows = (this.labApproverOptionList || []).filter(item => selectedOperatorSet.has(String(item.operatorId || '').trim())) + this.labApproverSelectionCache = JSON.parse(JSON.stringify(selectedRows)) + this.$nextTick(() => { + if (!this.$refs.labApproverTable) { + return + } + this.$refs.labApproverTable.clearSelection() + selectedRows.forEach(item => { + this.$refs.labApproverTable.toggleRowSelection(item, true) + }) + }) + }, + closeLabApproverDialog () { + this.labApproverSelectionCache = [] + }, + handleLabApproverSelectionChange (rows) { + this.labApproverSelectionCache = rows || [] + }, + saveLabApproverChooseModal () { + const selectedCodes = (this.labApproverSelectionCache || []) + .map(item => String(item.operatorId || '').trim()) + .filter(item => !!item) + this.$set(this.modalData, 'labApproverCodeList', selectedCodes) + this.syncLabApproverField() + this.labApproverFlag = false + }, + clearLabApproverSelection () { + this.$set(this.modalData, 'labApproverCodeList', []) + this.syncLabApproverField() + }, isCurrentApprover () { return this.superAdmin || (this.modalData.createBy2 && this.modalData.createBy2.split(';').includes(this.createBy2)) }, @@ -1823,6 +2044,7 @@ export default { this.fillDisplayFields(mergedDetail, row || {}) this.$set(mergedDetail, 'propertyItemList', (detail.propertyItemList || []).map(item => this.normalizePropertyItem(item))) this.$set(mergedDetail, 'testerList', this.normalizeTesterList(mergedDetail.tester)) + this.$set(mergedDetail, 'labApproverList', this.normalizeTesterList(mergedDetail.labApprover)) this.currentDetail = mergedDetail } else { const fallbackDetail = { @@ -2058,6 +2280,7 @@ export default { operatorId: '', operatorName: '' } + this.resetLabApproverOptionState() this.plmLabAuthorityArr = [] this.nodeAuthorityLoaded = !row this.isEditMode = !!row @@ -2077,6 +2300,8 @@ export default { this.$set(this.modalData, 'propertyItemList', (detail.propertyItemList || []).map(item => this.normalizePropertyItem(item))) this.$set(this.modalData, 'testerCodeList', this.normalizeTesterList(this.modalData.tester)) this.$set(this.modalData, 'testerList', this.modalData.testerCodeList || []) + this.$set(this.modalData, 'labApproverCodeList', this.normalizeTesterList(this.modalData.labApprover)) + this.$set(this.modalData, 'labApproverList', this.modalData.labApproverCodeList || []) this.$set(this.modalData, 'customerIdFlag', true) this.$set(this.modalData, 'projectIdFlag', true) this.$set(this.modalData, 'createBy2', '') @@ -2084,7 +2309,9 @@ export default { this.$set(this.modalData, 'tpProcessControl', 'N') 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.loadTesterOptions() + this.loadLabApproverOptions() this.loadModalButtonCondition() this.loadNodeAuthority(this.modalData.site || row.site, this.modalData.stepId !== null && this.modalData.stepId !== undefined ? this.modalData.stepId : 10) this.refreshJudgeCriteriaFileList() @@ -2119,6 +2346,9 @@ export default { this.$set(this.modalData, 'testerCodeList', []) this.$set(this.modalData, 'testerList', []) this.$set(this.modalData, 'testerName', '') + this.$set(this.modalData, 'labApproverCodeList', []) + this.$set(this.modalData, 'labApproverList', []) + this.$set(this.modalData, 'labApproverName', '') this.judgeCriteriaFileList = [] this.testReportFileList = [] this.searchProjectData.site = defaultSite @@ -2153,6 +2383,7 @@ export default { this.testSpecDialogVisible = false this.testReportDialogVisible = false this.testerFlag = false + this.labApproverFlag = false this.modalFlag = false }, buildLabPayload (source) { @@ -2160,7 +2391,7 @@ export default { 'site', 'referenceNo', 'applicant', 'applicationDate', 'applyDepartment', 'requestedDate', 'projectId', 'customerId', 'sampleName', 'sampleModel', 'sampleQty', 'testPurpose', 'productStage', 'testType', 'reportDocument', 'returnSample', 'applicationSurface', 'testLab', - 'attention', 'testStartDate', 'completedDate', 'unnormalSymptomAndDescription', 'testNumber', + 'labApprover', 'attention', 'testStartDate', 'completedDate', 'unnormalSymptomAndDescription', 'testNumber', 'testerComments', 'departmentManagerComments', 'labComments', 'tester', 'propertyItemList', 'status', 'stepId', 'rejectFlag', 'rejectStepId', 'createDate', 'createBy', 'updateDate', 'updateBy' ] @@ -2176,6 +2407,7 @@ export default { return } this.syncTesterField() + this.syncLabApproverField() this.syncPropertyItemList() const payload = this.buildLabPayload(this.modalData) const submitMethod = this.modalTitle === 'Lab 新增' ? api.saveLab : api.updateLab @@ -2231,6 +2463,7 @@ export default { return } this.syncTesterField() + this.syncLabApproverField() this.syncPropertyItemList() if (!this.nodeAuthorityLoaded) { this.$message.warning('节点权限加载中,请稍后重试') @@ -2365,7 +2598,7 @@ export default { if (val === 102) { if (type === 1) { strVal = this.modalData.customerId - conSql = " order by Customer_no " + conSql = ' order by Customer_no ' } } if (val === 103) {