|
@@ -8,7 +8,8 @@
|
|
|
:close-on-click-modal="false"
|
|
|
:close-on-press-escape="false"
|
|
|
append-to-body
|
|
|
- @open="visibleChange"
|
|
|
+ @opened="dialogOpened"
|
|
|
+ @close="dialogClose"
|
|
|
>
|
|
|
<el-form
|
|
|
ref="modalFormComp"
|
|
@@ -227,7 +228,24 @@
|
|
|
<el-form-item prop="selectedPrint"></el-form-item>
|
|
|
|
|
|
<el-form-item prop="orgIds" label="适用范围:">
|
|
|
- <select-orgs v-model="modalForm.orgIds" ref="SelectOrgs"></select-orgs>
|
|
|
+ <!-- <select-orgs v-model="modalForm.orgIds" ref="SelectOrgs"></select-orgs> -->
|
|
|
+ <div
|
|
|
+ v-if="orgDataReady"
|
|
|
+ class="select-orgs part-box part-box-pad part-box-border"
|
|
|
+ >
|
|
|
+ <el-tree
|
|
|
+ :data="orgs"
|
|
|
+ show-checkbox
|
|
|
+ default-expand-all
|
|
|
+ node-key="id"
|
|
|
+ ref="MenuTree"
|
|
|
+ :props="defaultProps"
|
|
|
+ check-on-click-node
|
|
|
+ :expand-on-click-node="false"
|
|
|
+ @check-change="checkChange"
|
|
|
+ >
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
@@ -249,9 +267,8 @@ import {
|
|
|
TEMPLATE_CLASSIFY
|
|
|
} from "@/constants/enumerate";
|
|
|
import { deepCopy } from "@/plugins/utils";
|
|
|
-import { updateExamConfig, listOrgsByExamId } from "../api";
|
|
|
+import { updateExamConfig, listOrgsByExamId, organizationList } from "../api";
|
|
|
import { printPlanTemplateList } from "../../print/api";
|
|
|
-import SelectOrgs from "./SelectOrgs";
|
|
|
|
|
|
const initModalForm = {
|
|
|
id: null,
|
|
@@ -291,7 +308,6 @@ const initModalForm = {
|
|
|
|
|
|
export default {
|
|
|
name: "modify-exam-config-detail",
|
|
|
- components: { SelectOrgs },
|
|
|
props: {
|
|
|
instance: {
|
|
|
type: Object,
|
|
@@ -411,25 +427,37 @@ export default {
|
|
|
trigger: "change"
|
|
|
}
|
|
|
]
|
|
|
+ },
|
|
|
+ // org select
|
|
|
+ orgDataReady: false,
|
|
|
+ orgs: [],
|
|
|
+ leafOrgIds: [],
|
|
|
+ defaultProps: {
|
|
|
+ label: "name"
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
this.getTemplates();
|
|
|
+ this.getOrgs();
|
|
|
},
|
|
|
methods: {
|
|
|
- async visibleChange() {
|
|
|
+ async dialogOpened() {
|
|
|
const data = await listOrgsByExamId({
|
|
|
examId: this.instance.examId,
|
|
|
id: this.instance.id
|
|
|
});
|
|
|
this.usedOrgIds = data || [];
|
|
|
- this.$refs.SelectOrgs.setDisabledOrgs(this.usedOrgIds);
|
|
|
+ this.setDisabledOrgs(this.usedOrgIds);
|
|
|
+ this.orgDataReady = true;
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
this.initData(this.instance);
|
|
|
});
|
|
|
},
|
|
|
+ dialogClose() {
|
|
|
+ this.orgDataReady = false;
|
|
|
+ },
|
|
|
cancel() {
|
|
|
this.modalIsShow = false;
|
|
|
},
|
|
@@ -477,6 +505,8 @@ export default {
|
|
|
this.modalForm = modalForm;
|
|
|
}
|
|
|
|
|
|
+ this.setCheckedNode(this.modalForm.orgIds);
|
|
|
+
|
|
|
if (!this.checkHasSelect()) {
|
|
|
this.allSelected = true;
|
|
|
this.selectAll(this.allSelected);
|
|
@@ -506,7 +536,6 @@ export default {
|
|
|
data.ordinaryContent = JSON.stringify(
|
|
|
this.modalForm.ordinaryContent.map(transformInfo)
|
|
|
);
|
|
|
- data.orgIds = this.$refs.SelectOrgs.getCheckedNode();
|
|
|
|
|
|
return data;
|
|
|
},
|
|
@@ -609,6 +638,55 @@ export default {
|
|
|
this.$message.success(this.title + "成功!");
|
|
|
this.$emit("modified");
|
|
|
this.cancel();
|
|
|
+ },
|
|
|
+ // org select
|
|
|
+ async getOrgs() {
|
|
|
+ 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;
|
|
|
+ if (b.type === "PRINTING_HOUSE") return -1;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ let leafOrgIds = [];
|
|
|
+ const getLeafOrg = orgs => {
|
|
|
+ orgs.forEach(org => {
|
|
|
+ org.disabled = false;
|
|
|
+ if (org["children"] && org["children"].length) {
|
|
|
+ getLeafOrg(org.children);
|
|
|
+ } else {
|
|
|
+ leafOrgIds.push(org.id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ getLeafOrg(this.orgs);
|
|
|
+ this.leafOrgIds = leafOrgIds;
|
|
|
+ },
|
|
|
+ setDisabledOrgs(disabledOrgIds) {
|
|
|
+ const updateInfo = orgs => {
|
|
|
+ orgs.forEach(org => {
|
|
|
+ org.disabled = disabledOrgIds.includes(org.id);
|
|
|
+ if (org["children"] && org["children"].length) {
|
|
|
+ updateInfo(org.children);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ updateInfo(this.orgs);
|
|
|
+ },
|
|
|
+ setCheckedNode(selectedIds) {
|
|
|
+ const leafSelectedIds = selectedIds.filter(id =>
|
|
|
+ this.leafOrgIds.includes(id)
|
|
|
+ );
|
|
|
+ this.$refs.MenuTree.setCheckedKeys(leafSelectedIds);
|
|
|
+ },
|
|
|
+ checkChange() {
|
|
|
+ this.modalForm.orgIds = this.$refs.MenuTree.getCheckedKeys();
|
|
|
+ this.$refs.modalFormComp.validateField("orgIds");
|
|
|
}
|
|
|
}
|
|
|
};
|