From c91e107f2bd5e32e279e0ee9275a7d381562377e Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Fri, 10 Jul 2026 13:27:41 +0800 Subject: [PATCH] =?UTF-8?q?2026-07-10=20RoHS=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/rohs/rohsRecord.vue | 113 +++++++++++++++++++++----- 1 file changed, 91 insertions(+), 22 deletions(-) diff --git a/src/views/modules/rohs/rohsRecord.vue b/src/views/modules/rohs/rohsRecord.vue index 4a2e723..3fdd234 100644 --- a/src/views/modules/rohs/rohsRecord.vue +++ b/src/views/modules/rohs/rohsRecord.vue @@ -1591,6 +1591,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 { queryBuList } from "@/api/base/bu" import { createOfficialPartForRohs, getNextPartNo as getPartNextPartNo, getItemListByCodeNo as getPartItemListByCodeNo, getItemExclusionAlreadyExists as getPartItemExclusionAlreadyExists } from "@/api/part/partInformation.js" import uploadFileList from '../common/uploadFileList' import ossComponents from '../oss/ossComponents.vue' @@ -2101,6 +2102,8 @@ export default { operatorId: '', operatorName: '' }, + userBuPermissionList: [], + userFirstBuNo: '', filterVisible: false, isFilterSearch: false, filterSearchData: {}, @@ -2362,15 +2365,6 @@ export default { handleProcessChange (value) { const processValue = String(value || '').trim() this.$set(this.modalData, 'process', processValue) - this.$set(this.modalData, 'buNo', processValue) - if (this.isEditMode) { - return - } - this.clearHsfApproverFields(false) - if (!processValue) { - return - } - this.loadHsfApproverByCurrentProcess(true) }, isRohsFieldDisabledWithFallback (primaryFieldId, fallbackFieldId) { if (this.showModalFlag) { @@ -2649,6 +2643,65 @@ export default { } this.applyHsfStandardDefaultByCustomer(formData) }, + resolveFirstBuNoFromPermissionList (rows) { + if (!Array.isArray(rows)) { + return '' + } + const firstRow = rows.find(item => item && String(item.buNo || item.bu_no || '').trim()) + return firstRow ? String(firstRow.buNo || firstRow.bu_no || '').trim() : '' + }, + loadCurrentUserBuPermissionList (forceRefresh = false) { + if (!forceRefresh && Array.isArray(this.userBuPermissionList) && this.userBuPermissionList.length > 0) { + return Promise.resolve(this.userBuPermissionList) + } + const site = this.modalData.site || this.$store.state.user.site + const username = this.$store.state.user.name + if (!site || !username) { + this.userBuPermissionList = [] + this.userFirstBuNo = '' + return Promise.resolve([]) + } + return queryBuList({ + site: site, + username: username + }).then(({data}) => { + if (data && data.code === 0 && Array.isArray(data.rows)) { + this.userBuPermissionList = data.rows + this.userFirstBuNo = this.resolveFirstBuNoFromPermissionList(data.rows) + } else { + this.userBuPermissionList = [] + this.userFirstBuNo = '' + } + return this.userBuPermissionList + }).catch(() => { + this.userBuPermissionList = [] + this.userFirstBuNo = '' + return [] + }) + }, + ensureModalBuNo (showWarning = false, allowUserFirstBuFallback = true) { + const currentBuNo = String((this.modalData && this.modalData.buNo) || '').trim() + if (currentBuNo) { + return Promise.resolve(currentBuNo) + } + if (!allowUserFirstBuFallback) { + if (showWarning) { + this.$message.warning('当前单据bu_no为空,无法查询HSF审批人') + } + return Promise.resolve('') + } + return this.loadCurrentUserBuPermissionList(false).then((rows) => { + const firstBuNo = this.resolveFirstBuNoFromPermissionList(rows) + if (firstBuNo) { + this.$set(this.modalData, 'buNo', firstBuNo) + return firstBuNo + } + if (showWarning) { + this.$message.warning('当前用户未配置BU权限,无法查询HSF审批人') + } + return '' + }) + }, resolveOperatorNameById (operatorId) { const normalizedId = String(operatorId || '').trim() if (!normalizedId) { @@ -2777,16 +2830,17 @@ export default { if (this.isRohsFieldDisabled('hsfApprover')) { return } - if (!this.modalData || !String(this.modalData.process || '').trim()) { - this.$message.warning('请先选择工艺') - return - } - this.loadHsfApproverByCurrentProcess(false).then(() => { - if (!this.hsfApproverOptionList || this.hsfApproverOptionList.length === 0) { - this.$message.warning('未查询到可选HSF审批人') + this.ensureModalBuNo(true, !this.isEditMode).then((buNo) => { + if (!buNo) { return } - this.hsfApproverFlag = true + this.loadHsfApproverByCurrentBuNo(false).then(() => { + if (!this.hsfApproverOptionList || this.hsfApproverOptionList.length === 0) { + this.$message.warning('未查询到可选HSF审批人') + return + } + this.hsfApproverFlag = true + }) }) }, openHsfApproverDialog () { @@ -2918,7 +2972,16 @@ export default { this.$set(this.modalData, 'relatedPeople', '') this.$set(this.modalData, 'relatedPeopleName', '') }, - loadHsfApproverByCurrentProcess (forceSelectAll = false) { + initHsfApproverForNewRecord () { + this.clearHsfApproverFields(false) + this.ensureModalBuNo(false, true).then((buNo) => { + if (!buNo) { + return + } + this.loadHsfApproverByCurrentBuNo(true) + }) + }, + loadHsfApproverByCurrentBuNo (forceSelectAll = false) { if (!this.modalData || !this.modalData.site) { this.hsfApproverOptionList = [] this.hsfApproverDisplayList = [] @@ -2928,10 +2991,10 @@ export default { } return Promise.resolve() } - const buNo = String(this.modalData.process || '').trim() + const buNo = String(this.modalData.buNo || '').trim() if (!buNo) { if (forceSelectAll) { - this.$message.warning('请先选择工艺') + this.$message.warning('当前单据未维护BU,无法加载HSF审批人') this.clearHsfApproverFields(false) } this.hsfApproverOptionList = [] @@ -3672,7 +3735,7 @@ export default { this.$set(this.modalData, 'materialClassifyList', this.modalData.materialClassify ? this.modalData.materialClassify.split(';').filter(item => item) : []) this.$set(this.modalData, 'materialList', Array.isArray(this.modalData.materialList) ? this.modalData.materialList : []) this.$set(this.modalData, 'hsfApproverCodeList', this.modalData.hsfApprover ? this.modalData.hsfApprover.split(';').filter(item => item) : []) - this.$set(this.modalData, 'buNo', this.modalData.process || '') + this.$set(this.modalData, 'buNo', String(this.modalData.buNo || '').trim()) this.$set(this.modalData, 'isAhGrade', this.normalizeCheckboxFlag(this.modalData.isAhGrade)) this.$set(this.modalData, 'validUntilValue', this.normalizeValidUntilValue(this.modalData.validUntilValue)) this.syncHsfApproverFields() @@ -3686,7 +3749,12 @@ export default { this.$set(this.modalData, 'tpProcessControl', 'N') this.$set(this.modalData, 'csProcessControl', 'N') this.loadModalButtonCondition() - this.loadHsfApproverByCurrentProcess(false) + this.ensureModalBuNo(true, false).then((buNo) => { + if (!buNo) { + return + } + this.loadHsfApproverByCurrentBuNo(false) + }) this.loadNodeAuthority(this.modalData.site || row.site, this.modalData.stepId !== null && this.modalData.stepId !== undefined ? this.modalData.stepId : (row.stepId !== null && row.stepId !== undefined ? row.stepId : 10)) } }).catch(() => { @@ -3775,6 +3843,7 @@ export default { tpProcessControl: 'N', csProcessControl: 'N' } + this.initHsfApproverForNewRecord() this.nodeAuthorityLoaded = true } },