diff --git a/src/views/modules/plugins/power/poweraxis-add-or-update.vue b/src/views/modules/plugins/power/poweraxis-add-or-update.vue index 6419a28d..1803dc28 100644 --- a/src/views/modules/plugins/power/poweraxis-add-or-update.vue +++ b/src/views/modules/plugins/power/poweraxis-add-or-update.vue @@ -20,35 +20,23 @@ - + + :props="{ expandTrigger: 'hover', emitPath: false, label: 'orgName', value: 'orgId', children: 'subOrgList' }" + :show-all-levels="false" + clearable /> - - - - - - - - - - - - - + + @@ -120,7 +108,6 @@ export default { name:'', agencyId:'', agencyName:'', - orgId: '', agencyType:'', pid:'', categoryCode:'', @@ -132,11 +119,8 @@ export default { structCategoryArr: [], // 查询动力主轴标签类别 leaderCategoryArr: [], // 查询动力主轴负责人标签类别 agencytree: [], // 绑定组织列表 - GridPartyBranchList:[], // 上级网格党支部列表 - PartyCommList:[], // 党委列表 - orgListSwitch:false, // 组织列表开关 - GridPartyBranchSwitch:false, // 上级网格党支部列表 - partyCommSwitch:false, // 党委下拉框列表开关 + parentStructTree: [], // 上级节点列表 + orgListSwitch: false, // 组织列表开关 } }, computed: { @@ -148,7 +132,7 @@ export default { name:[ { required: true, message: "名称不能为空", trigger: "blur" } ], - orgId:[ + agencyId:[ { required: true, message: "所属组织不能为空", trigger: "blur" } ], pid:[ @@ -243,6 +227,18 @@ export default { }) return orgArray; }, + removeEmptyStructTree (structArray) { + structArray.forEach((structInfo) => { + if (structInfo && structInfo.children) { + if (structInfo.children.length === 0) { + structInfo.children = undefined + } else { + this.removeEmptyStructTree(structInfo.children) + } + } + }) + return structArray; + }, // 获取信息 getInfo () { this.$http.post(`/pli/power/axisStruct/queryModifyById/${this.dataForm.id}`).then(({ data: res }) => { @@ -253,48 +249,27 @@ export default { ...this.dataForm, ...res.data } - if(this.dataForm.categoryCode === 'community_party') { - this.orgListSwitch = true - this.GridPartyBranchSwitch = false - this.partyCommSwitch = false - } - if(this.dataForm.categoryCode === 'grid_party') { - this.orgListSwitch = false - this.GridPartyBranchSwitch = false - this.partyCommSwitch = true - this.getPartyCommList() - } - if(this.dataForm.categoryCode === 'group_party') { - this.GridPartyBranchSwitch = true - this.partyCommSwitch = false - this.getGridPartyBranchList() - } - }).catch(() => {}) - }, - // 获取上级网格党支部 - async getGridPartyBranchList(){ - const url = '/pli/power/axisStruct/GridPartyBranchList' - - let params = {} - - const { data, code, msg } = await requestPost(url,params) - - if (code === 0) { - this.GridPartyBranchList = data + let selectedLevel + this.structCategoryArr.forEach((item) => { + if(item.categoryCode === this.dataForm.categoryCode){ + selectedLevel = item.structLevel + } + }) + if(selectedLevel === 0) { + this.orgListSwitch = true } else { - this.$message.error(msg) + this.orgListSwitch = false + this.getParentStructTree(selectedLevel) } + }).catch(() => {}) }, - // 获取上级组织党委 - async getPartyCommList(){ - const url = '/pli/power/axisStruct/getPartyCommList' - + // 获取上级动力主轴节点 + async getParentStructTree(structLevel){ + const url = `/pli/power/axisStruct/bylevel/${structLevel}/parenttree` let params = {} - const { data, code, msg } = await requestPost(url,params) - if (code === 0) { - this.PartyCommList = data + this.parentStructTree = this.removeEmptyStructTree(data) } else { this.$message.error(msg) } @@ -309,23 +284,12 @@ export default { } }) if (selectedLevel === 0) { - this.orgListSwitch = true - this.GridPartyBranchSwitch = false - this.partyCommSwitch = false - this.dataForm.pid = '0' - } - if(selectedLevel === 1) { - this.orgListSwitch = false - this.GridPartyBranchSwitch = false - this.partyCommSwitch = true - this.dataForm.pid = '' - this.getPartyCommList() - } - if(selectedLevel === 2) { - this.GridPartyBranchSwitch = true - this.partyCommSwitch = false - this.dataForm.pid = '' - this.getGridPartyBranchList() + this.orgListSwitch = true + this.dataForm.pid = '0' + } else { + this.orgListSwitch = false + this.dataForm.pid = '' + this.getParentStructTree(selectedLevel) } }, // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 @@ -457,7 +421,6 @@ export default { }, 1000, { 'leading': true, 'trailing': false }), // 修改 async submitModifyOrg(){ - this.dataForm.agencyId = this.dataForm.orgId[this.dataForm.orgId.length - 1] const url = '/pli/power/axisStruct/update' const { data, code, msg } = await requestPost(url,this.dataForm) if (code === 0) { @@ -477,7 +440,6 @@ export default { // 新增 async submitAddNewOrg(){ const url = '/pli/power/axisStruct/save' - this.dataForm.agencyId = this.dataForm.orgId[this.dataForm.orgId.length - 1] const { data, code, msg } = await requestPost(url,this.dataForm) if (code === 0) { this.$message({ diff --git a/src/views/modules/plugins/power/poweraxis.vue b/src/views/modules/plugins/power/poweraxis.vue index f42975d8..798b524f 100644 --- a/src/views/modules/plugins/power/poweraxis.vue +++ b/src/views/modules/plugins/power/poweraxis.vue @@ -22,7 +22,7 @@
-
+