molilang 3 years ago
parent
commit
cf92e72aa1

+ 4 - 3
src/pages/main/demandDevelop/index.vue

@@ -411,7 +411,7 @@
               :type="depttype"
               :closeList="closeList"
               :reset-list="treeList"
-              :only="selectOnly"
+              :only="only"
             ></deptTreeOnly>
             <div class="tree treeUser">
               <p v-for="(item, index) in treeList" :key="index">
@@ -490,7 +490,6 @@ export default {
       checkLaeder: false,
       checkexa: false,
       // 审核人组件只可选一人
-      selectOnly: false,
       leader: "",
       leaderList: [
         {
@@ -510,6 +509,8 @@ export default {
           value: "yuyang01",
         },
       ],
+      // 用来控制多选里的单选
+      only:true,
       // 信息回显
       infolist: {},
       // 用户信息
@@ -695,7 +696,7 @@ export default {
           type,
         };
       } else {
-        this.selectOnly = true
+        this.only = false
         reqdata = {
           countersignedId: "",
           receiveId: receiveId.join(","),

+ 20 - 19
src/pages/main/performance/components/deptTreeOnly.vue

@@ -33,7 +33,7 @@
 
 <script>
 export default {
-  props: ["defaultList", "type", "closeList", "resetList"],
+  props: ["defaultList", "type", "closeList", "resetList", "only"],
   data() {
     return {
       treeList: [],
@@ -119,23 +119,25 @@ export default {
       }
     },
     handleCheckChange() {
+      console.log(this.only, "only");
       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();
+      if (this.only) {
+        if (nodeList.length === 1) {
+          this.$emit("treeCheck", nodeList);
+        } else if (nodeList.length === 0) {
+          this.$refs.tree.setCheckedKeys([]);
+          this.$emit("treeCheck", nodeList);
+        } else {
+          let obj = { ...nodeList[0] };
+          this.$refs.tree.setCheckedKeys([]);
+          this.$nextTick(() => {
+            this.$refs.tree.setChecked(obj, true);
+          });
+          this.$message.error("这里只能选择一个审批人");
+        }
+      } else if (!this.only) {
+        this.$emit("treeCheck", nodeList);
+      }
     },
   },
   created() {
@@ -144,7 +146,6 @@ export default {
   },
   watch: {
     type() {
-      console.log("aaa");
       this.defaultListc = this.defaultList;
       this.$forceUpdate();
     },
@@ -152,7 +153,7 @@ export default {
       this.$forceUpdate();
     },
     closeList() {
-       this.$refs.tree.setCheckedKeys([]);
+      this.$refs.tree.setCheckedKeys([]);
       if ([...this.resetList] && [...this.resetList].length > 0) {
         [...this.resetList].forEach((el) => {
           this.$nextTick(() => {