daiqisheng 3 years ago
parent
commit
0d78c0287f

+ 12 - 10
src/pages/main/demandDevelop/index.vue

@@ -86,7 +86,7 @@
           :model="infolist"
           ref="infolist"
           :rules="rules"
-          style="height: calc(100vh - 180px); overflow-y: scroll"
+          style="height: calc(100vh - 180px)"
         >
           <div class="info-line">
             <el-form-item prop="demandName">
@@ -394,20 +394,20 @@
               :defaultList="defaultList"
               :type="depttype"
               :closeList="closeList"
+              :reset-list="treeList"
             ></deptTreeOnly>
             <div class="tree treeUser">
-              <p>
-                {{ treeListonly.leaderAuditName }}
+              <p v-for="(item, index) in treeList" :key="index">
+                {{ item.label }}
                 <i
-                  v-if="treeListonly.leaderAuditName"
-                  @click="deletes()"
+                  v-if="item.label"
+                  @click="deletes(item)"
                   class="el-icon-error"
                 ></i>
               </p>
             </div>
           </el-form-item>
         </el-form>
-
         <div slot="footer" style="text-align: right; padding-bottom: 20px">
           <el-button type="primary" @click="dialogCliadd" v-if="!visionchonly"
             >确 定</el-button
@@ -543,6 +543,7 @@ export default {
       demandTypeopt: [],
       carryChannelopt: [],
       checkexa: false,
+      treeList: [],
       treeListonly: {},
       defaultList: [],
       closeList: false,
@@ -602,13 +603,14 @@ export default {
         //console.log(res)
       });
     },
-    deletes() {
-      this.treeListonly = {};
+    deletes(v) {
+      // this.treeListonly = {};
+      this.treeList = this.treeList.filter((el) => el.loginNoStr !== v.loginNoStr);
       this.closeList = !this.closeList;
     },
     treeCheckonly(v) {
-      console.log(v, "123123212v");
-      this.treeListonly = v;
+      this.treeList = v;
+      // this.treeListonly = v;
     },
     choline(v, n) {
       if (v == 1) {

+ 50 - 28
src/pages/main/performance/components/deptTreeOnly.vue

@@ -33,7 +33,7 @@
 
 <script>
 export default {
-  props: ["defaultList", "type", "closeList"],
+  props: ["defaultList", "type", "closeList", "resetList"],
   data() {
     return {
       treeList: [],
@@ -48,17 +48,29 @@ export default {
   },
   methods: {
     getTree() {
-      const info = JSON.parse(sessionStorage.userInfo);
-      console.log(info, "JSON.parse(sessionStorage.userInfo)");
-      this.treeList = [
-        {
-          children: [],
-          o: info.groupId,
-          label: `${info.groupName}`,
-          haveUserFlag: "Y",
-          ou: `${info.groupName}`,
+      this.loading = true;
+      this.$http({
+        url: "/sysmgr/csysdept/queryAllList",
+        method: "post",
+        headers: {
+          "Content-Type": "application/json",
         },
-      ];
+        data: {},
+      }).then((res) => {
+        this.treeList = res.data;
+        this.loading = false;
+      });
+      // const info = JSON.parse(sessionStorage.userInfo);
+      // console.log(info, "JSON.parse(sessionStorage.userInfo)");
+      // this.treeList = [
+      //   {
+      //     children: [],
+      //     o: info.groupId,
+      //     label: `${info.groupName}`,
+      //     haveUserFlag: "Y",
+      //     ou: `${info.groupName}`,
+      //   },
+      // ];
     },
     handleNodeClick(v) {
       let s = false;
@@ -106,22 +118,24 @@ export default {
         }
       }
     },
-    handleCheckChange(v) {
-      let opt = {
-        loginNameStr: v.data.loginNoStr,
-        leaderAuditName: v.data.label,
-        displayname: v.data.displayname,
-        groupId: v.data.o,
-      };
-      this.$emit("treeCheck", opt);
-      for (let i = 0; i < this.$refs.tree.store._getAllNodes().length; i++) {
-        if (v.data.o == this.$refs.tree.store._getAllNodes()[i].data.o) {
-          this.$refs.tree.store._getAllNodes()[i].checked = true;
-        } else {
-          this.$refs.tree.store._getAllNodes()[i].checked = false;
-        }
-      }
-      this.$forceUpdate();
+    handleCheckChange() {
+      const nodeList = this.$refs.tree.store.getCheckedNodes();
+      // let opt = {
+      //   loginNameStr: v.data.loginNoStr,
+      //   leaderAuditName: v.data.label,
+      //   displayname: v.data.displayname,
+      //   groupId: v.data.o,
+      // };
+      this.$emit("treeCheck", nodeList);
+      // for (let i = 0; i < this.$refs.tree.store._getAllNodes().length; i++) {
+      //   if (v.data.o == this.$refs.tree.store._getAllNodes()[i].data.o) {
+      //     this.$refs.tree.store._getAllNodes()[i].checked = !this.$refs.tree.store._getAllNodes()[i].checked;
+      //   }
+      //   //  else {
+      //   //   this.$refs.tree.store._getAllNodes()[i].checked = false;
+      //   // }
+      // }
+      // this.$forceUpdate();
     },
   },
   created() {
@@ -130,6 +144,7 @@ export default {
   },
   watch: {
     type() {
+      console.log("aaa");
       this.defaultListc = this.defaultList;
       this.$forceUpdate();
     },
@@ -137,7 +152,14 @@ export default {
       this.$forceUpdate();
     },
     closeList() {
-      this.$refs.tree.setCheckedNodes([]);
+       this.$refs.tree.setCheckedKeys([]);
+      if ([...this.resetList] && [...this.resetList].length > 0) {
+        [...this.resetList].forEach((el) => {
+          this.$nextTick(() => {
+            this.$refs.tree.setChecked(el, true);
+          });
+        });
+      }
     },
   },
 };