diff --git a/src/api/eam/eam.js b/src/api/eam/eam.js index cb35794..7b3401a 100644 --- a/src/api/eam/eam.js +++ b/src/api/eam/eam.js @@ -208,6 +208,7 @@ export const getDetail= data => createAPI(`/pms/eam/getDetail`,'post',data) export const AddTreeselect= data => createAPI(`/pms/eam/AddTreeselect`,'post',data) export const EditTreeselect= data => createAPI(`/pms/eam/EditTreeselect`,'post',data) export const getSiteAndBuByUserName= data => createAPI(`/pms/eam/getSiteAndBuByUserName`,'post',data) +export const getProjectCategoryByBu= data => createAPI(`/pms/eam/getProjectCategoryByBu`,'post',data) export const eamCheckRecordSearch= data => createAPI(`/pms/eam/eamCheckRecordSearch`,'post',data) export const eamCheckRecordSearch2= data => createAPI(`/pms/eam/eamCheckRecordSearch2`,'post',data) diff --git a/src/views/modules/eam/eamBuDocumentListDefinition.vue b/src/views/modules/eam/eamBuDocumentListDefinition.vue index 64a4f2b..a4586da 100644 --- a/src/views/modules/eam/eamBuDocumentListDefinition.vue +++ b/src/views/modules/eam/eamBuDocumentListDefinition.vue @@ -8,7 +8,7 @@ - + @@ -111,7 +111,7 @@ - + { if (data.code === 0) { this.userBuList = data.rows + const defaultBuNo = this.userBuList.length > 0 ? this.getBuNoByJoinedValue(this.userBuList[0].buNo) : '' + this.loadSearchProjectCategory('') + this.loadModalProjectCategory(defaultBuNo) + } else { + this.userBuList = [] + this.searchProjectCategoryList = [] + this.projectCategoryList = [] + } + }) + }, + // 从 site_bu 中截取 bu_no + getBuNoByJoinedValue (buValue) { + if (!buValue) { + return '' + } + let buParts = buValue.split('_') + if (buParts.length >= 2) { + return buParts[1] + } + return buValue + }, + // 根据 BU 描述获取 bu_no + getBuNoByBuDesc (buDesc) { + if (!buDesc) { + return '' + } + let matchBu = this.userBuList.find(item => item.buDesc === buDesc) + if (!matchBu) { + return '' + } + return this.getBuNoByJoinedValue(matchBu.buNo) + }, + // 加载查询区项目分类 + loadSearchProjectCategory (buNo) { + let inData = { + site: this.$store.state.user.site, + buNo: buNo || '' + } + getProjectCategoryByBu(inData).then(({data}) => { + if (data && data.code === 0) { + this.searchProjectCategoryList = data.rows || [] + } else { + this.searchProjectCategoryList = [] + } + }).catch(() => { + this.searchProjectCategoryList = [] + }) + }, + // 加载弹窗项目分类 + loadModalProjectCategory (buNo, currentProjectCategory) { + let inData = { + site: this.$store.state.user.site, + buNo: buNo || '' + } + getProjectCategoryByBu(inData).then(({data}) => { + if (data && data.code === 0) { + let categoryList = (data.rows || []).slice() + if (currentProjectCategory && !categoryList.some(item => item.projectCategory === currentProjectCategory)) { + categoryList.push({ + projectCategory: currentProjectCategory + }) + } + this.projectCategoryList = categoryList + } else { + this.projectCategoryList = [] } + }).catch(() => { + this.projectCategoryList = [] }) }, + // 查询区 BU 变化后刷新项目分类 + searchBuChangeHandle (buDesc) { + this.searchData.projectCategory = '' + let buNo = this.getBuNoByBuDesc(buDesc) + this.loadSearchProjectCategory(buNo) + }, + // 弹窗 BU 变化后刷新项目分类 + modalBuChangeHandle (buValue) { + this.modalData.projectCategory = '' + let buNo = this.getBuNoByJoinedValue(buValue) + this.loadModalProjectCategory(buNo) + }, // 获取基础数据列表S getBaseList (val,type) { @@ -795,6 +866,8 @@ createBy: this.$store.state.user.name, updateBy: this.$store.state.user.name, } + let defaultBuNo = this.getBuNoByJoinedValue(this.modalData.bu) + this.loadModalProjectCategory(defaultBuNo) this.modalDisableFlag = false this.modalFlag = true }, @@ -830,6 +903,8 @@ createBy: this.modalData.createBy, updateBy: this.modalData.updateBy, } + let editBuNo = this.getBuNoByJoinedValue(this.modalData.bu) + this.loadModalProjectCategory(editBuNo, this.modalData.projectCategory) this.disableButton = true this.modalDisableFlag = true this.modalFlag = true diff --git a/src/views/modules/eam/eamProjectInfo.vue b/src/views/modules/eam/eamProjectInfo.vue index 61bc7b2..3b31f0f 100644 --- a/src/views/modules/eam/eamProjectInfo.vue +++ b/src/views/modules/eam/eamProjectInfo.vue @@ -8,7 +8,7 @@ - + @@ -182,7 +182,7 @@ - +