|
@@ -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;
|