Ver Fonte

教育培训计划机构树与机构类型联动

jingyuanchao há 2 anos atrás
pai
commit
11106e499f

+ 99 - 84
src/components/orgTreeSelect/index.vue

@@ -34,7 +34,7 @@
             v-for="dict in dict.type.sys_org_type"
             :key="dict.value"
             :label="dict.label"
-            :value="`${dict.value}`"
+            :value="parseInt(dict.value)"
           ></el-option>
         </el-select>
       </el-col>
@@ -63,7 +63,7 @@
 </template>
 
 <script>
-import { deptTreeSelect } from "@/api/system/public";
+import {deptTreeSelect} from "@/api/system/public";
 
 export default {
   dicts: ["sys_org_type"],
@@ -77,6 +77,11 @@ export default {
       default: false,
       required: false,
     },
+    queryData: {
+      type: Number,
+      default: null,
+      required: false,
+    },
   },
   data() {
     return {
@@ -128,97 +133,107 @@ export default {
         }
       },
     },
-    // queryForm: {
-    //   deep: true,
-    //   handler(n, o) {
+    queryData: {
+      handler(n) {
+        if (n) {
+          this.queryForm.type = parseInt(n);
+          this.serchTreeHandler();
+        }
+      },
+      // queryForm: {
+      //   deep: true,
+      //   handler(n, o) {
 
-    //     if(!n.value&&!n.type){
-    //       this.$refs.tree.filter({});
-    //     }else{
+      //     if(!n.value&&!n.type){
+      //       this.$refs.tree.filter({});
+      //     }else{
 
-    //       this.$refs.tree.filter(n);
-    //     }
-    //   },
-    // },
-  },
-  // computed: {
-  //   defaultNode:
-  //   //pv: sync("value"),
-  // },
-  model: {
-    prop: "defaultNode",
-    event: "change",
-  },
-  methods: {
-    clear() {
-      this.sNodeList = [];
-      this.$refs.tree.setCheckedKeys([]);
-      this.$refs.tree.setCurrentKey(null);
-      this.$emit("selectNode", JSON.stringify(this.sNodeList));
-    },
-    //筛选条件变化
-    serchTreeHandler() {
-      this.$refs.tree.filter(this.queryForm);
+      //       this.$refs.tree.filter(n);
+      //     }
+      //   },
+      // },
     },
-    /** 查询机构树 */
-    getDeptTree() {
-      deptTreeSelect().then((response) => {
-        this.orgTree = response.data;
-      });
-    },
-    filterNode(value, data, node) {
-      if (this.queryForm.value && this.queryForm.type) {
-        return (
-          data.name.indexOf(this.queryForm.value) !== -1 &&
-          data.type == this.queryForm.type
-        );
-      }
-      if (this.queryForm.value) {
-        return data.name.indexOf(this.queryForm.value) !== -1;
-      }
-      if (this.queryForm.type) {
-        return data.type == this.queryForm.type;
-      }
-      return true;
+    // computed: {
+    //   defaultNode:
+    //   //pv: sync("value"),
+    // },
+    model: {
+      prop: "defaultNode",
+      event: "change",
     },
+  },
+    methods: {
+      clear() {
+        this.sNodeList = [];
+        this.$refs.tree.setCheckedKeys([]);
+        this.$refs.tree.setCurrentKey(null);
+        this.$emit("selectNode", JSON.stringify(this.sNodeList));
+      },
+      //筛选条件变化
+      serchTreeHandler() {
+        this.$refs.tree.filter(this.queryForm);
+      },
+      /** 查询机构树 */
+      getDeptTree() {
+        deptTreeSelect().then((response) => {
+          this.orgTree = response.data;
+        });
+      },
+      filterNode(value, data, node) {
+        if (this.queryForm.value && this.queryForm.type) {
+          return (
+            data.name.indexOf(this.queryForm.value) !== -1 &&
+            data.type == this.queryForm.type
+          );
+        }
+        if (this.queryForm.value) {
+          return data.name.indexOf(this.queryForm.value) !== -1;
+        }
+        if (this.queryForm.type) {
+          return data.type == this.queryForm.type;
+        }
+        return true;
+      },
 
-    handleNodeClick() {},
-    onCheck(data, checked, tree) {
-      if (this.checked) {
-        //当前按过滤机构类型勾选
-
-        //递归查询
-        this.recursionTreeHandler(this.queryForm.type, [data]);
-      }
-      // debugger;
-      this.sNodeList = this.$refs.tree.getCheckedNodes();
-      this.$emit("selectNode", JSON.stringify(this.sNodeList));
-    },
-    recursionTreeHandler(type, tree) {
-      tree.forEach((item) => {
-        if (type == item.type) {
-          this.$refs.tree.setCheckedKeys([item.id])
+      handleNodeClick() {
+      },
+      onCheck(data, checked, tree) {
+        if (this.checked) {
+          //当前按过滤机构类型勾选
 
+          //递归查询
+          this.recursionTreeHandler(this.queryForm.type, [data]);
         }
-      });
-      if (tree.children && tree.children.length > 0) {
-        this.recursionTreeHandler(type,tree.children)
-      } else {
-        return;
-      }
-    },
-    getSubOrgIdsByOrgType(topOrg, orgType, orgIdList) {
-      if (!topOrg) return;
-      if (topOrg.type == orgType) {
-        orgIdList.push(topOrg);
-      }
-      if (topOrg.children && topOrg.children.length > 0) {
-        topOrg.children.forEach((item) => {
-          this.getSubOrgIdsByOrgType(item, orgType, orgIdList);
+        // debugger;
+        this.sNodeList = this.$refs.tree.getCheckedNodes();
+        this.$emit("selectNode", JSON.stringify(this.sNodeList));
+      },
+      recursionTreeHandler(type, tree) {
+        tree.forEach((item) => {
+          if (type == item.type) {
+            this.$refs.tree.setCheckedKeys([item.id])
+
+          }
         });
-      }
+        if (tree.children && tree.children.length > 0) {
+          this.recursionTreeHandler(type, tree.children)
+        } else {
+          return;
+        }
+      },
+      getSubOrgIdsByOrgType(topOrg, orgType, orgIdList) {
+        if (!topOrg) return;
+        if (topOrg.type == orgType) {
+          orgIdList.push(topOrg);
+        }
+        if (topOrg.children && topOrg.children.length > 0) {
+          topOrg.children.forEach((item) => {
+            this.getSubOrgIdsByOrgType(item, orgType, orgIdList);
+          });
+        }
+      },
     },
-  },
+
 };
 </script>
 

+ 2 - 3
src/views/core/edu/plan/index.vue

@@ -219,7 +219,7 @@
                                        placeholder="请选择培训机构"/>
                         </el-form-item>-->
             <el-form-item label="培训机构" prop="planExecOrgIdList">
-              <org-tree-select ref="orgTreeSelect" @selectNode="queryNode"
+              <org-tree-select :queryData="form.execOrgType" ref="orgTreeSelect" @selectNode="queryNode"
                                placeholder="请选择培训机构"></org-tree-select>
             </el-form-item>
           </el-col>
@@ -306,6 +306,7 @@ export default {
       isUnfold: false,
       defaultSelect: [],
       orgId: null,
+      type:null,
       // 查询参数
       queryParams: {
         execOrgType: null,
@@ -511,7 +512,6 @@ export default {
     /** 新增按钮操作 */
     handleAdd() {
       this.initRoleList();
-      this.getDeptTree()
       this.reset();
       this.open = true;
       this.title = "添加教育培训计划";
@@ -519,7 +519,6 @@ export default {
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.initRoleList();
-      this.getDeptTree()
       this.reset();
       const id = row.id || this.ids
       getPlan(id).then(response => {

+ 2 - 2
src/views/core/edu/task/index.vue

@@ -11,7 +11,7 @@
       <el-form-item label="培训主题" prop="title">
         <el-input
           v-model="queryParams.title"
-          placeholder="请输入培训岗位"
+          placeholder="请输入培训主题"
           clearable
           @keyup.enter.native="handleQuery"
         />
@@ -25,7 +25,7 @@
         </el-date-picker>
       </el-form-item>
       <el-form-item label="培训类型" prop="type">
-        <el-select v-model="queryParams.type" placeholder="请选择执行机构类型" clearable>
+        <el-select v-model="queryParams.type" placeholder="请选择培训类型" clearable>
             <el-option
               v-for="dict in dict.type.edu_type"
               :key="dict.value"

+ 1 - 1
src/views/core/materials/index.vue

@@ -20,7 +20,7 @@
 
 
           <el-form-item label="公开状态" prop="isOpen">
-            <el-select v-model="queryParams.isOpen" placeholder="请选择资料类型" clearable>
+            <el-select v-model="queryParams.isOpen" placeholder="请选择公开状态" clearable>
               <el-option v-for="item in openOption" :key="item.value" :label="item.label"
                          :value="item.value"></el-option>
             </el-select>