zhangjie 2 роки тому
батько
коміт
00a4ab28a2

+ 8 - 1
src/modules/base/components/ModifyExamConfigDetail.vue

@@ -450,6 +450,7 @@ export default {
       // org select
       orgDataReady: false,
       orgs: [],
+      orgIds: [],
       leafOrgIds: [],
       defaultProps: {
         label: "name"
@@ -467,7 +468,7 @@ export default {
         id: this.instance.id
       });
       this.usedOrgIds = data || [];
-      this.setDisabledOrgs(this.usedOrgIds);
+      this.setDisabledOrgs(this.orgIds);
       this.orgDataReady = true;
 
       this.$nextTick(() => {
@@ -547,6 +548,9 @@ export default {
           item => this.templateSources[item.type]
         );
         this.modalForm = modalForm;
+        if (!this.usedOrgIds.length) {
+          this.modalForm.orgIds = [...this.leafOrgIds];
+        }
       }
 
       this.setCheckedNode(this.modalForm.orgIds);
@@ -699,9 +703,11 @@ export default {
       }
 
       let leafOrgIds = [];
+      let orgIds = [];
       const getLeafOrg = orgs => {
         orgs.forEach(org => {
           org.disabled = false;
+          orgIds.push(org.id);
           if (org["children"] && org["children"].length) {
             getLeafOrg(org.children);
           } else {
@@ -711,6 +717,7 @@ export default {
       };
       getLeafOrg(this.orgs);
       this.leafOrgIds = leafOrgIds;
+      this.orgIds = orgIds;
     },
     setDisabledOrgs(disabledOrgIds) {
       const updateInfo = orgs => {

+ 73 - 15
src/modules/print/components/ModifyPrintPlan.vue

@@ -54,6 +54,7 @@
             v-model="modalForm.examId"
             :semester-id="modalForm.semesterId"
             class="width-full"
+            @change="examChange"
           ></exam-select>
         </el-form-item>
       </div>
@@ -64,14 +65,14 @@
           <el-checkbox
             v-model="allSelected"
             label="全选"
-            :disabled="!editable"
+            disabled
             @change="selectAll"
           ></el-checkbox>
         </h4>
         <el-form-item prop="printContent" label="试卷、题卡:">
           <el-checkbox-group
             v-model="modalForm.printContent"
-            :disabled="!editable"
+            disabled
             @change="() => checkSelectAll()"
           >
             <el-checkbox
@@ -92,7 +93,7 @@
             class="mr-2"
             size="small"
             placeholder="请选择"
-            :disabled="!editable"
+            disabled
           >
             <el-option
               v-for="(val, key) in PAPER_BACKUP_TYPE"
@@ -110,7 +111,7 @@
             :step="1"
             step-strictly
             :controls="false"
-            :disabled="!editable"
+            disabled
             style="width: 60px"
           ></el-input-number>
           <span>份</span>
@@ -120,7 +121,7 @@
           prop="drawRule"
           label="抽卷规则:"
         >
-          <el-radio-group v-model="modalForm.drawRule" :disabled="!editable">
+          <el-radio-group v-model="modalForm.drawRule" disabled>
             <el-radio
               v-for="(val, key) in DRAW_RULE_TYPE"
               :label="key"
@@ -138,7 +139,7 @@
       </div>
 
       <div class="part-box">
-        <h4 class="part-box-tips">变量印品:</h4>
+        <h4 class="part-box-tips">其他印品:</h4>
         <el-form-item
           v-for="(item, index) in modalForm.variableContent"
           :key="item.type"
@@ -153,7 +154,7 @@
         >
           <el-checkbox-group
             v-model="item.templateId"
-            :disabled="!editable"
+            disabled
             @change="vals => tempChange(vals, `variableContent.${index}`)"
           >
             <el-checkbox
@@ -169,7 +170,7 @@
               class="mr-2"
               size="small"
               placeholder="请选择"
-              :disabled="!editable"
+              disabled
             >
               <el-option
                 v-for="(val, key) in PRINT_BACKUP_TYPE"
@@ -187,7 +188,7 @@
               :step="1"
               step-strictly
               :controls="false"
-              :disabled="!editable"
+              disabled
               style="width: 60px"
             ></el-input-number>
             <span>份</span>
@@ -196,7 +197,7 @@
       </div>
 
       <div class="part-box">
-        <h4 class="part-box-tips">普通印品:</h4>
+        <!-- <h4 class="part-box-tips">普通印品:</h4> -->
         <el-form-item
           v-for="(item, index) in modalForm.ordinaryContent"
           :key="item.type"
@@ -212,7 +213,7 @@
         >
           <el-checkbox-group
             v-model="item.templateId"
-            :disabled="!editable"
+            disabled
             @change="vals => tempChange(vals, `ordinaryContent.${index}`)"
           >
             <el-checkbox
@@ -228,7 +229,7 @@
               class="mr-2"
               size="small"
               placeholder="请选择"
-              :disabled="!editable"
+              disabled
             >
               <el-option
                 v-for="(val, key) in PRINT_BACKUP_TYPE"
@@ -246,7 +247,7 @@
               :step="1"
               step-strictly
               :controls="false"
-              :disabled="!editable"
+              disabled
               style="width: 60px"
             ></el-input-number>
             <span>份</span>
@@ -280,6 +281,7 @@ import {
 } from "@/constants/enumerate";
 import { deepCopy } from "@/plugins/utils";
 import { updatePrintPlan, printPlanTemplateList } from "../api";
+import { examConfigQuery } from "../../base/api";
 
 const initModalForm = {
   id: null,
@@ -566,7 +568,7 @@ export default {
           };
         };
         const initModalFormContent = deepCopy(initModalForm);
-        const variableContent = JSON.parse(val.variableContent);
+        const variableContent = val.variableContent;
         const variableContentTypes = variableContent.map(item => item.type);
         this.modalForm.variableContent = [];
         initModalFormContent.variableContent.forEach(item => {
@@ -581,7 +583,7 @@ export default {
           }
         });
 
-        const ordinaryContent = JSON.parse(val.ordinaryContent);
+        const ordinaryContent = val.ordinaryContent;
         const ordinaryContentTypes = ordinaryContent.map(item => item.type);
         this.modalForm.ordinaryContent = [];
         initModalFormContent.ordinaryContent.forEach(item => {
@@ -626,6 +628,62 @@ export default {
     open() {
       this.modalIsShow = true;
     },
+    async examChange() {
+      if (!this.modalForm.examId) return;
+      const data = await examConfigQuery({
+        examId: this.modalForm.examId,
+        pageNumber: 1,
+        pageSize: 10
+      });
+      this.initExamConfig(data.records[0]);
+    },
+    initExamConfig(val) {
+      // console.log(val);
+      if (!val) return;
+      const transformInfo = item => {
+        const templateIds = item.templateId ? [item.templateId] : [];
+        return {
+          type: item.type,
+          templateId: templateIds,
+          oldTemplateId: templateIds,
+          backupMethod: item.backupMethod,
+          backupCount: item.backupCount
+        };
+      };
+      const initModalFormContent = deepCopy(initModalForm);
+      const variableContent = JSON.parse(val.variableContent);
+      const variableContentTypes = variableContent.map(item => item.type);
+      this.modalForm.variableContent = [];
+      initModalFormContent.variableContent.forEach(item => {
+        if (variableContentTypes.includes(item.type)) {
+          const vitem = variableContent.find(cont => cont.type === item.type);
+          this.modalForm.variableContent.push(transformInfo(vitem));
+          return;
+        }
+        if (this.templateSources[item.type]) {
+          this.modalForm.variableContent.push(item);
+          return;
+        }
+      });
+
+      const ordinaryContent = JSON.parse(val.ordinaryContent);
+      const ordinaryContentTypes = ordinaryContent.map(item => item.type);
+      this.modalForm.ordinaryContent = [];
+      initModalFormContent.ordinaryContent.forEach(item => {
+        if (ordinaryContentTypes.includes(item.type)) {
+          const vitem = ordinaryContent.find(cont => cont.type === item.type);
+          this.modalForm.ordinaryContent.push(transformInfo(vitem));
+          return;
+        }
+        if (this.templateSources[item.type]) {
+          this.modalForm.ordinaryContent.push(item);
+          return;
+        }
+      });
+
+      this.modalForm.printContent = JSON.parse(val.printContent);
+      this.checkSelectAll();
+    },
     dateChange() {
       if (this.createTime) {
         this.modalForm.examStartTime = this.createTime[0];