浏览代码

配置管理新增禁选机构

zhangjie 3 年之前
父节点
当前提交
a40584daa2

+ 6 - 0
src/modules/base/api.js

@@ -370,6 +370,12 @@ export const examConfigByExamIdOrgId = datas => {
     datas
   );
 };
+export const listOrgsByExamId = ({ id, examId }) => {
+  return $postParam("/api/admin/basic/print_config/list_org_id_by_exam_id", {
+    id,
+    examId
+  });
+};
 // common
 export const uploadFile = datas => {
   return $post("/api/admin/common/file/upload", datas);

+ 12 - 10
src/modules/base/components/ModifyExamConfig.vue

@@ -98,12 +98,12 @@
                 @click="toEnable(scope.row)"
                 >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
               >
-              <!-- <el-button
-              class="btn-danger"
-              type="text"
-              @click="toDelete(scope.row)"
-              >删除</el-button
-            > -->
+              <el-button
+                class="btn-danger"
+                type="text"
+                @click="toDelete(scope.row)"
+                >删除</el-button
+              >
             </template>
           </el-table-column>
         </el-table>
@@ -125,7 +125,7 @@
     <modify-exam-config-detail
       ref="ModifyExamConfigDetail"
       :instance="curExamConfig"
-      @modified="getList"
+      @modified="examConfigDetailModified"
     ></modify-exam-config-detail>
   </div>
 </template>
@@ -162,6 +162,7 @@ export default {
       total: 0,
       examConfigList: [],
       curExamConfig: {},
+      usedOrgIds: [],
       // date-picker
       createTime: [],
       pickerOptions
@@ -183,9 +184,10 @@ export default {
     open() {
       this.modalIsShow = true;
     },
+    examConfigDetailModified() {
+      this.getList();
+    },
     async getList() {
-      // if (!this.checkPrivilege("list", "list")) return;
-
       const datas = {
         ...this.filter,
         pageNumber: this.current,
@@ -216,7 +218,7 @@ export default {
       this.$refs.ModifyExamConfigDetail.open();
     },
     toEdit(row) {
-      this.curExamConfig = row;
+      this.curExamConfig = { ...row, examId: this.filter.examId };
       this.$refs.ModifyExamConfigDetail.open();
     },
     toDelete(row) {

+ 14 - 4
src/modules/base/components/ModifyExamConfigDetail.vue

@@ -249,7 +249,7 @@ import {
   TEMPLATE_CLASSIFY
 } from "@/constants/enumerate";
 import { deepCopy } from "@/plugins/utils";
-import { updateExamConfig } from "../api";
+import { updateExamConfig, listOrgsByExamId } from "../api";
 import { printPlanTemplateList } from "../../print/api";
 import SelectOrgs from "./SelectOrgs";
 
@@ -359,6 +359,7 @@ export default {
       ordinaryContent: [],
       templateSources: {},
       oldPrintContent: [],
+      usedOrgIds: [],
       allSelected: false,
       infoShow: true,
       rules: {
@@ -417,8 +418,17 @@ export default {
     this.getTemplates();
   },
   methods: {
-    visibleChange() {
-      this.initData(this.instance);
+    async visibleChange() {
+      const data = await listOrgsByExamId({
+        examId: this.instance.examId,
+        id: this.instance.id
+      });
+      this.usedOrgIds = data || [];
+      this.$refs.SelectOrgs.setDisabledOrgs(this.usedOrgIds);
+
+      this.$nextTick(() => {
+        this.initData(this.instance);
+      });
     },
     cancel() {
       this.modalIsShow = false;
@@ -435,7 +445,7 @@ export default {
       });
       this.templateSources = templateSources;
     },
-    async initData(val) {
+    initData(val) {
       if (val.id) {
         this.modalForm = this.$objAssign(deepCopy(initModalForm), val);
         const transformInfo = item => {

+ 12 - 0
src/modules/base/components/SelectOrgs.vue

@@ -83,6 +83,7 @@ export default {
       let leafOrgIds = [];
       const getLeafOrg = orgs => {
         orgs.forEach(org => {
+          org.disabled = false;
           if (org["children"] && org["children"].length) {
             getLeafOrg(org.children);
           } else {
@@ -97,6 +98,17 @@ export default {
         this.setCheckedNode(this.value);
       });
     },
+    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) {
       if (this.multiple) {
         const leafSelectedIds = selectedIds.filter(id =>