浏览代码

Merge branch 'bug-fix-4435' into custom

cxmo 1 年之前
父节点
当前提交
f732f06dd9
共有 1 个文件被更改,包括 22 次插入33 次删除
  1. 22 33
      src/views/supply_manage/components/varietySetDia.vue

+ 22 - 33
src/views/supply_manage/components/varietySetDia.vue

@@ -33,8 +33,8 @@
             :show-all-levels="false"
             filterable
             :props="{
-              value:'ItemId',
-              label:'ItemName',
+              value:'NodeId',
+              label:'NodeName',
               children:'Children',
               emitPath: false,
               multiple: true
@@ -43,6 +43,7 @@
             clearable
             collapse-tags
             :placeholder="$t('SupplyAnalysis.StockPlant.placeholder03')"
+            @change="chooseUsers = getUserName()"
             @remove-tag="removeResearchersChange"
             style="width:80%"
           />
@@ -66,7 +67,7 @@
 
 <script>
 // import {roadshowInterence} from '@/api/modules/roadshowApi.js';
-import { dataAuthInterface } from '@/api/api.js';
+import { dataAuthInterface,departInterence } from '@/api/api.js';
 import * as supplyApi from '@/api/modules/supplyApi.js';
 export default {
   props: {
@@ -89,13 +90,6 @@ export default {
         }
       }
     },
-
-    'formData.users': {
-      handler(nval) {
-        // this.chooseUsers = this.researcherList.length && nval.map(_ => this.getUserName(_)).filter(_ => _);
-        this.chooseUsers = this.researcherList.length && this.getUserName()
-      }
-    }
   },
   data() {
     return {
@@ -142,7 +136,7 @@ export default {
     },
 
     getUserName(id) {
-      let checkedNodes=this.$refs.cascader.getCheckedNodes() || []
+      let checkedNodes=this.$refs.cascader.getCheckedNodes(true) || []
       return checkedNodes.map(item =>{
         return item.label
       })
@@ -168,40 +162,35 @@ export default {
 
     /* 获取研究员列表 */
     async getResearcherList() {
-      // const res = await roadshowInterence.getResearcherList();
       // 换成全部系统用户
-      const res = await dataAuthInterface.userSearch();
+      const res =  await departInterence.getSystemUser({KeyWord: ''})
       if (res.Ret !== 200) return
       
-      // this.researcherList = this.formatResearcherList(res.Data);
       this.researcherList = res.Data || []
+      //去掉Children为空的属性,非用户的叶子节点禁止选中
+      this.formatTreeData({Children:this.researcherList})
 
-      // if(this.form.VarietyId) this.chooseUsers = this.researcherList.length && this.formData.users.map(_ => this.getUserName(_)).filter(_ => _);
       if(this.form.VarietyId){
         this.$nextTick(()=>{
           this.chooseUsers = this.researcherList.length && this.getUserName()
         })
       }
     },
-
-    // 对获取到的研究员列表做处理
-    formatResearcherList(list) {
-      list.forEach((group) => {
-        // 对组做处理
-        group.label = group.GroupName;
-        // 如果有列表
-        if (group.ResearcherList) {
-          group.ResearcherList.forEach((item) => {
-            // 对研究员做处理
-            item.label = item.RealName;
-            item.value = item.AdminId;
-          });
-        } else {
-          // 没有列表
-          group.value = group.GroupId;
+    //遍历树形结构,处理children
+    formatTreeData(tree){
+        function dfs(node) {
+            if (Array.isArray(node.Children)) {
+                for (let child of node.Children) {
+                    dfs(child); // 递归调用 DFS 函数处理子节点
+                }
+                if(node.Children.length===0) delete node.Children
+            }
+            //若为叶子节点,且不为用户,禁止选中
+            if(!node.Children||!Array.isArray(node.Children)){
+                if(node.NodeType!==3) node.disabled = true
+            }
         }
-      });
-      return list;
+        dfs(tree); 
     },
   }
 }