Răsfoiți Sursa

适用范围修改

zhangjie 3 ani în urmă
părinte
comite
51d14a0904

+ 2 - 0
src/modules/base/components/ModifyCardRule.vue

@@ -326,6 +326,8 @@ export default {
         this.modalForm.requiredFields = JSON.parse(val.requiredFields);
         this.modalForm.extendFields = JSON.parse(val.extendFields);
         this.modalForm.orgIds = val.orgs.map(item => item.id);
+      } else {
+        this.modalForm.orgIds = [];
       }
     },
     visibleChange() {

+ 1 - 0
src/modules/base/components/ModifyTemplate.vue

@@ -209,6 +209,7 @@ export default {
         this.modalForm.orgIds = val.orgs.map(item => item.id);
         this.getAttachment();
       } else {
+        this.modalForm.orgIds = [];
         this.$nextTick(() => {
           this.$refs.UploadFileView.setAttachmentName("");
         });

+ 30 - 3
src/modules/base/components/SelectOrgs.vue

@@ -52,6 +52,7 @@ export default {
       selectedOrgs: [],
       // orgs: [],
       orgs: [],
+      leafOrgIds: [],
       defaultProps: {
         label: "name"
       }
@@ -67,7 +68,9 @@ export default {
   },
   methods: {
     async getList() {
-      this.orgs = await organizationList();
+      const orgs = await organizationList();
+      this.orgs = orgs || [];
+
       if (this.orgs.length) {
         this.orgs[0].children.sort((a, b) => {
           if (a.type === "PRINTING_HOUSE") return 1;
@@ -77,11 +80,31 @@ export default {
         });
       }
 
+      let leafOrgIds = [];
+      const getLeafOrg = orgs => {
+        orgs.forEach(org => {
+          if (org["children"] && org["children"].length) {
+            getLeafOrg(org.children);
+          } else {
+            leafOrgIds.push(org.id);
+          }
+        });
+      };
+      getLeafOrg(this.orgs);
+      this.leafOrgIds = leafOrgIds;
+
       this.$nextTick(() => {
         this.setCheckedNode(this.value);
       });
     },
     setCheckedNode(selectedIds) {
+      if (this.multiple) {
+        const leafSelectedIds = selectedIds.filter(id =>
+          this.leafOrgIds.includes(id)
+        );
+        this.$refs.MenuTree.setCheckedKeys(leafSelectedIds);
+        return;
+      }
       const selectedOrgs = this.$refs.MenuTree.getCheckedKeys();
       if (selectedOrgs.join() === selectedIds.join()) return;
 
@@ -89,8 +112,12 @@ export default {
     },
     checkChange() {
       if (!this.multiple) return;
-      const selectedOrgs = this.$refs.MenuTree.getCheckedKeys();
-      this.emitChange(selectedOrgs);
+
+      const halfCheckedIds = this.$refs.MenuTree.getHalfCheckedKeys();
+      const checkedIds = this.$refs.MenuTree.getCheckedKeys();
+      const checkedOrgs = [...halfCheckedIds, ...checkedIds];
+
+      this.emitChange(checkedOrgs);
     },
     checkClick(data) {
       if (this.multiple) return;