Bladeren bron

学校设置

zhangjie 2 jaren geleden
bovenliggende
commit
143032ee46

+ 18 - 47
src/modules/admin/components/school/SchoolSetCheck.vue

@@ -1,16 +1,13 @@
 <template>
   <div class="school-set-check">
-    <el-form
-      ref="modalFormComp"
-      :model="modalForm"
-      :rules="rules"
-      label-width="240px"
-    >
+    <el-form ref="modalFormComp" label-width="240px">
       <el-form-item
-        prop="accountSmsVerify"
-        label="用户/密码模式是否开启短信验证:"
+        v-for="field in fields"
+        :key="field.code"
+        :prop="field.code"
+        :label="field.name + ':'"
       >
-        <el-radio-group v-model="modalForm.accountSmsVerify">
+        <el-radio-group v-if="field.isBoolean" v-model="field.value">
           <el-radio
             v-for="item in OPEN_STATUS"
             :key="item.value"
@@ -18,14 +15,10 @@
             >{{ item.label }}</el-radio
           >
         </el-radio-group>
-      </el-form-item>
-      <el-form-item
-        prop="teachcloudExchangeHostUrl"
-        label="第三方统一身份认证地址:"
-      >
         <el-input
-          v-model="modalForm.teachcloudExchangeHostUrl"
-          placeholder="请输入调用地址"
+          v-else
+          v-model="field.value"
+          :placeholder="`请输入${fidld.name}`"
           clearable
         >
         </el-input>
@@ -56,42 +49,20 @@ export default {
   data() {
     return {
       loading: false,
-      modalForm: {
-        accountSmsVerify: false, //用户/密码模式是否开启短信验证,true为开启,false为关闭
-        teachcloudExchangeHostUrl: "" //第三方统一身份认证地址
-      },
-      OPEN_STATUS,
-      rules: {
-        accountSmsVerify: [
-          {
-            required: true,
-            validator: (rule, value, callback) => {
-              if (!value && value !== false) {
-                return callback(new Error(`请选择是否开启短信验证`));
-              }
-
-              callback();
-            },
-            trigger: "change"
-          }
-        ],
-        teachcloudExchangeHostUrl: [
-          {
-            required: true,
-            message: "请输入第三方统一身份认证地址",
-            trigger: "change"
-          }
-        ]
-      }
+      fields: [],
+      OPEN_STATUS
     };
   },
   mounted() {
-    this.getSchoolCheckInfo();
+    this.initData();
   },
   methods: {
-    async getSchoolCheckInfo() {
+    async initData() {
       const data = await schoolSetCheckInfo(this.school.id);
-      this.modalForm = this.$objAssign(this.modalForm, data);
+      this.fields = data.result || [];
+      this.fields.forEach(field => {
+        field.isBoolean = typeof field.valid === "boolean";
+      });
     },
     async confirm() {
       const valid = await this.$refs.modalFormComp.validate();
@@ -99,7 +70,7 @@ export default {
 
       if (this.loading) return;
       this.loading = true;
-      const datas = { ...this.modalForm, schoolId: this.school.id };
+      const datas = { param: this.fields, schoolId: this.school.id };
       const res = await schoolSetCheckUpdate(datas).catch(() => {});
       this.loading = false;
       if (!res) return;

+ 10 - 1
src/modules/admin/components/school/SchoolSetData.vue

@@ -29,7 +29,16 @@ export default {
   },
   methods: {
     async confirm() {
-      const confirm = await this.$confirm(
+      let confirm = await this.$confirm(
+        `确定要清除当前学校的基础数据集吗?`,
+        "提示",
+        {
+          type: "warning"
+        }
+      ).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      confirm = await this.$confirm(
         `确定要清除当前学校的基础数据集吗?`,
         "提示",
         {

+ 6 - 3
src/modules/admin/components/school/SchoolSetPaper.vue

@@ -46,6 +46,7 @@ export default {
         pdfSize: []
       },
       sysPdfSize: [],
+      paperInfo: [],
       rules: {
         pdfSize: [
           {
@@ -69,9 +70,10 @@ export default {
   methods: {
     async initData() {
       const paperData = await sysPaperSizeList();
-      this.sysPdfSize = paperData.sysPdfSize;
+      this.sysPdfSize = paperData.result[0].value;
       const data = await schoolSetPaperInfo(this.school.id);
-      this.modalForm.pdfSize = data.pdfSize;
+      this.paperInfo = data.result;
+      this.modalForm.pdfSize = data.result[0].value;
     },
     async confirm() {
       const valid = await this.$refs.modalFormComp.validate();
@@ -80,7 +82,8 @@ export default {
       if (this.loading) return;
       this.loading = true;
 
-      let datas = { pdfSize: this.modalForm.pdfSize, schoolId: this.school.id };
+      this.paperInfo[0].value = this.modalForm.pdfSize;
+      let datas = { param: this.paperInfo, schoolId: this.school.id };
       const res = await schoolSetPaperUpdate(datas).catch(() => {});
       this.loading = false;
 

+ 14 - 38
src/modules/admin/components/school/SchoolSetSync.vue

@@ -8,11 +8,11 @@
     >
       <el-form-item
         v-for="field in fields"
-        :key="field"
-        :prop="field"
-        :label="names[field] + ':'"
+        :key="field.code"
+        :prop="field.code"
+        :label="field.name + ':'"
       >
-        <el-radio-group v-model="checkSet[field]" @change="resetVal(field)">
+        <el-radio-group v-model="field.enable" @change="resetVal(field)">
           <el-radio
             v-for="item in OPEN_STATUS"
             :key="item.value"
@@ -21,11 +21,7 @@
           >
         </el-radio-group>
         <br />
-        <el-input
-          v-model="modalForm[field]"
-          placeholder="请输入调用地址"
-          clearable
-        >
+        <el-input v-model="field.value" placeholder="请输入调用地址" clearable>
         </el-input>
       </el-form-item>
       <el-form-item>
@@ -54,17 +50,7 @@ export default {
     return {
       loading: false,
       modalForm: {},
-      fields: [
-        "question.host.url",
-        "cloudmark.host.url",
-        "teachcloud.report.host.url"
-      ],
-      names: {
-        "question.host.url": "题库",
-        "cloudmark.host.url": "云阅卷",
-        "teachcloud.report.host.url": "教研分析"
-      },
-      checkSet: {},
+      fields: [],
       rules: {}
     };
   },
@@ -73,22 +59,16 @@ export default {
   },
   methods: {
     async initData() {
-      const res = await schoolSetSyncInfo(this.school.id);
-      const syncServicePaths = res.syncServicePaths
-        ? JSON.parse(res.syncServicePaths)
-        : {};
+      const data = await schoolSetSyncInfo(this.school.id);
+      this.fields = data.result || [];
       this.fields.forEach(field => {
-        this.$set(this.modalForm, field, syncServicePaths[field]);
-        this.$set(this.checkSet, field, !!syncServicePaths[field]);
+        this.$set(this.modalForm, field.code, fidld.value);
 
-        this.rules[field] = [
+        this.rules[field.code] = [
           {
-            required: true,
             validator: (rule, value, callback) => {
-              if (!value && this.checkSet[field]) {
-                return callback(
-                  new Error(`请输入${this.names[field]}请求地址`)
-                );
+              if (!field.value && field.enable) {
+                return callback(new Error(`请输入${field.name}请求地址`));
               }
 
               callback();
@@ -97,13 +77,9 @@ export default {
           }
         ];
       });
-      Object.entries(syncServicePaths).forEach(([k, v]) => {
-        this.modalForm[k] = v;
-        this.checkSet[k] = !!v;
-      });
     },
     resetVal(field) {
-      if (!this.checkSet[field]) this.modalForm[field] = "";
+      if (!field.enable) field.value = "";
     },
     async confirm() {
       const valid = await this.$refs.modalFormComp.validate();
@@ -111,7 +87,7 @@ export default {
 
       if (this.loading) return;
       this.loading = true;
-      const datas = { ...this.modalForm, schoolId: this.school.id };
+      const datas = { param: this.field, schoolId: this.school.id };
       const res = await schoolSetSyncUpdate(datas).catch(() => {});
       this.loading = false;
       if (!res) return;

+ 9 - 9
src/modules/base/components/ModifyCardRule.vue

@@ -60,20 +60,20 @@
       </el-form-item>
       <el-form-item
         v-if="modalForm.examNumberStyle === 'FILL'"
-        prop="fillNumber"
+        prop="examNumberDigit"
         label="考号位数:"
         class="inline-block"
       >
-        <!-- <el-input-number
-          v-model="modalForm.fillNumber"
+        <el-input-number
+          v-model="modalForm.examNumberDigit"
           :min="5"
           :max="15"
           :step="1"
           step-strictly
           :controls="false"
           style="width: 100px;"
-        ></el-input-number> -->
-        {{ modalForm.fillNumber }}
+        ></el-input-number>
+        <!-- {{ modalForm.examNumberDigit }} -->
       </el-form-item>
       <el-form-item prop="paperType" label="AB卷版式:" class="inline-block">
         <el-select
@@ -185,7 +185,7 @@ const initModalForm = {
   name: "",
   remark: "",
   examNumberStyle: "",
-  fillNumber: 8,
+  examNumberDigit: 8,
   paperType: "PRINT",
   examAbsent: true,
   discipline: true,
@@ -257,7 +257,7 @@ export default {
             trigger: "change"
           }
         ],
-        fillNumber: [
+        examNumberDigit: [
           {
             required: true,
             message: "请输入考号位数",
@@ -338,8 +338,8 @@ export default {
   methods: {
     initData(val) {
       this.modalForm = this.$objAssign(initModalForm, val);
-      this.modalForm.fillNumber =
-        this.modalForm.fillNumber || initModalForm.fillNumber;
+      this.modalForm.examNumberDigit =
+        this.modalForm.examNumberDigit || initModalForm.examNumberDigit;
 
       if (val.id) {
         this.modalForm.requiredFields = JSON.parse(val.requiredFields);

+ 1 - 24
src/modules/base/components/RuleExam.vue

@@ -41,18 +41,6 @@
           </div>
         </div>
       </el-form-item>
-      <el-form-item prop="examNumberDigit" label="考号位数:" required>
-        <el-input-number
-          v-model="modalForm.examNumberDigit"
-          :min="5"
-          :max="15"
-          :step="1"
-          step-strictly
-          :controls="false"
-          style="width: 100px;"
-          @change="checkRuleChange"
-        ></el-input-number>
-      </el-form-item>
       <el-form-item>
         <el-button
           type="primary"
@@ -76,7 +64,6 @@ import { examRuleDetail, saveExamRule } from "../api";
 
 const initModalForm = {
   id: null,
-  examNumberDigit: 8,
   requiredFields: "[]",
   extendFields: "[]"
 };
@@ -91,15 +78,7 @@ export default {
       examRule: {},
       ruleChanged: false,
       prevModalFrom: "",
-      rules: {
-        examNumberDigit: [
-          {
-            required: true,
-            message: "请输入考号位数",
-            trigger: "change"
-          }
-        ]
-      }
+      rules: {}
     };
   },
   mounted() {
@@ -108,8 +87,6 @@ export default {
   methods: {
     async init() {
       this.examRule = await examRuleDetail();
-      this.modalForm.examNumberDigit =
-        this.examRule.examNumberDigit || initModalForm.examNumberDigit;
       this.modalForm.requiredFields = JSON.parse(this.examRule.requiredFields);
       if (this.modalForm.extendFields)
         this.modalForm.extendFields = JSON.parse(this.examRule.extendFields);

+ 537 - 25
src/modules/print/components/ModifyPrintPlan.vue

@@ -3,7 +3,7 @@
     class="modify-print-plan"
     :visible.sync="modalIsShow"
     :title="title"
-    top="10vh"
+    top="10px"
     width="600px"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
@@ -12,29 +12,257 @@
   >
     <el-form
       ref="modalFormComp"
+      label-width="120px"
       :rules="rules"
       :model="modalForm"
-      label-width="120px"
+      label-position="left"
     >
-      <el-form-item prop="name" label="印刷计划名称:">
-        <el-input
-          v-model.trim="modalForm.name"
-          clearable
-          placeholder="请输入名称"
-        ></el-input>
-      </el-form-item>
-      <el-form-item prop="planEndTime" label="考试时间:">
-        <el-date-picker
-          v-model="modalForm.planEndTime"
-          type="datetime"
-          value-format="timestamp"
+      <div class="part-box">
+        <h4 class="part-box-tips">基本信息:</h4>
+        <el-form-item prop="name" label="印刷计划名称:">
+          <el-input
+            v-model.trim="modalForm.name"
+            clearable
+            placeholder="请输入"
+            :disabled="!editable"
+          ></el-input>
+        </el-form-item>
+        <el-form-item prop="examStartTime" label="考试时间:">
+          <el-date-picker
+            v-model="createTime"
+            type="datetimerange"
+            range-separator="至"
+            start-placeholder="开始时间"
+            end-placeholder="结束时间"
+            value-format="timestamp"
+            align="right"
+            unlink-panels
+            :disabled="!editable"
+            @change="dateChange"
+          >
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item prop="semesterId" label="使用学期:">
+          <semester-select
+            v-model="modalForm.semesterId"
+            class="width-full"
+            :disabled="!editable"
+          ></semester-select>
+        </el-form-item>
+        <el-form-item prop="examId" label="考试:">
+          <exam-select
+            v-model="modalForm.examId"
+            :semester-id="modalForm.semesterId"
+            class="width-full"
+          ></exam-select>
+        </el-form-item>
+      </div>
+
+      <div class="part-box">
+        <h4 class="part-box-tips">
+          试卷&题卡印品:
+          <el-checkbox
+            v-model="allSelected"
+            label="全选"
+            :disabled="!editable"
+            @change="selectAll"
+          ></el-checkbox>
+        </h4>
+        <el-form-item prop="printContent" label="试卷、题卡:">
+          <el-checkbox-group
+            v-model="modalForm.printContent"
+            :disabled="!editable"
+            @change="() => checkSelectAll()"
+          >
+            <el-checkbox
+              v-for="(val, key) in PRINT_CONTENT_TYPE"
+              :key="key"
+              :label="key"
+              >{{ val }}</el-checkbox
+            >
+          </el-checkbox-group>
+        </el-form-item>
+        <el-form-item
+          v-if="modalForm.printContent.length"
+          prop="backupMethod"
+          label="备用数量:"
+        >
+          <el-select
+            v-model="modalForm.backupMethod"
+            class="mr-2"
+            size="small"
+            placeholder="请选择"
+            :disabled="!editable"
+          >
+            <el-option
+              v-for="(val, key) in PAPER_BACKUP_TYPE"
+              :key="key"
+              :value="key"
+              :label="val"
+            ></el-option>
+          </el-select>
+          <el-input-number
+            class="mr-1"
+            v-model="modalForm.backupCount"
+            size="small"
+            :min="1"
+            :max="200"
+            :step="1"
+            step-strictly
+            :controls="false"
+            :disabled="!editable"
+            style="width: 60px"
+          ></el-input-number>
+          <span>份</span>
+        </el-form-item>
+        <el-form-item
+          v-if="contentIncludesPaper"
+          prop="drawRule"
+          label="抽卷规则:"
+        >
+          <el-radio-group v-model="modalForm.drawRule" :disabled="!editable">
+            <el-radio
+              v-for="(val, key) in DRAW_RULE_TYPE"
+              :label="key"
+              :key="key"
+              >{{ val }}</el-radio
+            >
+          </el-radio-group>
+          <p class="tips-info">
+            1.只抽取一次:不同印刷计划下,同一试卷编号下的卷型只能被抽取一次;
+          </p>
+          <p class="tips-info">
+            2.可反复抽取:不同印刷计划下,同一试卷编号下的卷型可重复抽取,系统默认优先抽取未曝光卷型。
+          </p>
+        </el-form-item>
+      </div>
+
+      <div class="part-box">
+        <h4 class="part-box-tips">变量印品:</h4>
+        <el-form-item
+          v-for="(item, index) in modalForm.variableContent"
+          :key="item.type"
+          :label="`${TEMPLATE_CLASSIFY[item.type]}:`"
+          :prop="`variableContent.${index}.templateId`"
+          :rules="{
+            required: false,
+            validator: templateValidator,
+            trigger: 'change'
+          }"
+          :required="!!item.templateId.length"
+        >
+          <el-checkbox-group
+            v-model="item.templateId"
+            :disabled="!editable"
+            @change="vals => tempChange(vals, `variableContent.${index}`)"
+          >
+            <el-checkbox
+              v-for="temp in templateSources[item.type]"
+              :label="temp.id"
+              :key="temp.id"
+              >{{ temp.name }}</el-checkbox
+            >
+          </el-checkbox-group>
+          <div v-if="item.templateId.length">
+            <el-select
+              v-model="item.backupMethod"
+              class="mr-2"
+              size="small"
+              placeholder="请选择"
+              :disabled="!editable"
+            >
+              <el-option
+                v-for="(val, key) in PRINT_BACKUP_TYPE"
+                :key="key"
+                :value="key"
+                :label="val"
+              ></el-option>
+            </el-select>
+            <el-input-number
+              v-model="item.backupCount"
+              class="mr-1"
+              size="small"
+              :min="1"
+              :max="200"
+              :step="1"
+              step-strictly
+              :controls="false"
+              :disabled="!editable"
+              style="width: 60px"
+            ></el-input-number>
+            <span>份</span>
+          </div>
+        </el-form-item>
+      </div>
+
+      <div class="part-box">
+        <h4 class="part-box-tips">普通印品:</h4>
+        <el-form-item
+          v-for="(item, index) in modalForm.ordinaryContent"
+          :key="item.type"
+          :label="`${TEMPLATE_CLASSIFY[item.type]}:`"
+          label-width="130px"
+          :prop="`ordinaryContent.${index}.templateId`"
+          :rules="{
+            required: false,
+            validator: templateValidator,
+            trigger: 'change'
+          }"
+          :required="!!item.templateId.length"
         >
-        </el-date-picker>
-      </el-form-item>
+          <el-checkbox-group
+            v-model="item.templateId"
+            :disabled="!editable"
+            @change="vals => tempChange(vals, `ordinaryContent.${index}`)"
+          >
+            <el-checkbox
+              v-for="temp in templateSources[item.type]"
+              :label="temp.id"
+              :key="temp.id"
+              >{{ temp.name }}</el-checkbox
+            >
+          </el-checkbox-group>
+          <div v-if="item.templateId.length">
+            <el-select
+              v-model="item.backupMethod"
+              class="mr-2"
+              size="small"
+              placeholder="请选择"
+              :disabled="!editable"
+            >
+              <el-option
+                v-for="(val, key) in PRINT_BACKUP_TYPE"
+                :key="key"
+                :value="key"
+                :label="val"
+              ></el-option>
+            </el-select>
+            <el-input-number
+              v-model="item.backupCount"
+              class="mr-1"
+              size="small"
+              :min="1"
+              :max="200"
+              :step="1"
+              step-strictly
+              :controls="false"
+              :disabled="!editable"
+              style="width: 60px"
+            ></el-input-number>
+            <span>份</span>
+          </div>
+        </el-form-item>
+      </div>
+
+      <el-form-item prop="selectedPrint"></el-form-item>
     </el-form>
 
     <div slot="footer">
-      <el-button type="primary" :disabled="isSubmit" @click="submit"
+      <el-button
+        v-if="editable"
+        type="primary"
+        :disabled="isSubmit"
+        @click="submit"
         >确认</el-button
       >
       <el-button @click="cancel">取消</el-button>
@@ -43,12 +271,52 @@
 </template>
 
 <script>
-import { updatePrintPlan } from "../api";
+import {
+  PRINT_CONTENT_TYPE,
+  DRAW_RULE_TYPE,
+  PRINT_BACKUP_TYPE,
+  PAPER_BACKUP_TYPE,
+  TEMPLATE_CLASSIFY
+} from "@/constants/enumerate";
+import { deepCopy } from "@/plugins/utils";
+import { updatePrintPlan, printPlanTemplateList } from "../api";
 
 const initModalForm = {
   id: null,
   name: "",
-  planEndTime: ""
+  examStartTime: "",
+  examEndTime: "",
+  semesterId: "",
+  examId: "",
+  printContent: [],
+  backupMethod: "ROOM",
+  backupCount: 1,
+  drawRule: "ONE",
+  variableContent: [
+    {
+      type: "SIGN",
+      templateId: [],
+      oldTemplateId: [],
+      backupMethod: "ROOM",
+      backupCount: 1
+    },
+    {
+      type: "PACKAGE",
+      templateId: [],
+      oldTemplateId: [],
+      backupMethod: "ROOM",
+      backupCount: 1
+    }
+  ],
+  ordinaryContent: [
+    {
+      type: "CHECK_IN",
+      templateId: [],
+      oldTemplateId: [],
+      backupMethod: "ROOM",
+      backupCount: 1
+    }
+  ]
 };
 
 export default {
@@ -59,6 +327,11 @@ export default {
       default() {
         return {};
       }
+    },
+    editType: {
+      type: String,
+      default: "ADD",
+      validator: val => ["ADD", "PREVIEW", "EDIT"].includes(val)
     }
   },
   computed: {
@@ -66,14 +339,69 @@ export default {
       return !!this.instance.id;
     },
     title() {
-      return (this.isEdit ? "编辑" : "新增") + "印刷计划";
+      const names = {
+        ADD: "新增印刷计划",
+        PREVIEW: "印刷计划详情",
+        EDIT: "编辑印刷计划"
+      };
+      return names[this.editType];
+    },
+    editable() {
+      return this.editType !== "PREVIEW";
+    },
+    contentIncludesPaper() {
+      return this.modalForm.printContent.includes("PAPER");
     }
   },
   data() {
+    // const printContentValidator = (rule, value, callback) => {
+    //   if (value.includes("PAPER") && !value.includes("CARD")) {
+    //     callback(new Error("选择了试卷,同时必须选择题卡"));
+    //   } else {
+    //     callback();
+    //   }
+    // };
+    const backupMethodValidator = (rule, value, callback) => {
+      if (!this.modalForm.printContent.length) {
+        return callback();
+      }
+      if (!value) {
+        return callback(new Error("请选择备份方式"));
+      }
+      if (!this.modalForm.backupCount) {
+        return callback(new Error("请输入备份数量"));
+      }
+
+      callback();
+    };
+    const selectedPrintValidator = (rule, value, callback) => {
+      const printInfo = [
+        ...this.modalForm.variableContent,
+        ...this.modalForm.ordinaryContent
+      ];
+      const hasPrintInfo = printInfo.some(item => item.templateId.length);
+
+      if (hasPrintInfo || this.modalForm.printContent.length) {
+        callback();
+      } else {
+        callback(new Error("必须选择一项印品"));
+      }
+    };
     return {
       modalIsShow: false,
       isSubmit: false,
-      modalForm: { ...initModalForm },
+      modalForm: deepCopy(initModalForm),
+      createTime: [],
+      PRINT_CONTENT_TYPE,
+      DRAW_RULE_TYPE,
+      PRINT_BACKUP_TYPE,
+      PAPER_BACKUP_TYPE,
+      TEMPLATE_CLASSIFY,
+      variableContent: [],
+      ordinaryContent: [],
+      templateSources: {},
+      oldPrintContent: [],
+      allSelected: false,
       rules: {
         name: [
           {
@@ -83,22 +411,177 @@ export default {
             trigger: "change"
           }
         ],
-        planEndTime: [
+        examStartTime: [
+          {
+            required: true,
+            message: "请设置考试时间",
+            trigger: "change"
+          }
+        ],
+        semesterId: [
+          {
+            required: true,
+            message: "请选择使用学期",
+            trigger: "change"
+          }
+        ],
+        examId: [
+          {
+            required: true,
+            message: "请选择使用考试",
+            trigger: "change"
+          }
+        ],
+        printContent: [
+          {
+            required: false,
+            // validator: printContentValidator,
+            trigger: "change"
+          }
+        ],
+        backupMethod: [
           {
             required: true,
-            message: "请设置印刷计划结束时间",
+            validator: backupMethodValidator,
+            trigger: "change"
+          }
+        ],
+        drawRule: [
+          {
+            required: true,
+            message: "请选择抽卷规则",
+            trigger: "change"
+          }
+        ],
+        selectedPrint: [
+          {
+            required: false,
+            validator: selectedPrintValidator,
             trigger: "change"
           }
         ]
       }
     };
   },
+  mounted() {
+    this.getTemplates();
+  },
   methods: {
+    async getTemplates() {
+      const data = await printPlanTemplateList();
+      const templateSources = {};
+      const templates = [...data.variable, ...data.ordinary];
+      templates.forEach(item => {
+        templateSources[item.type] = item.template;
+      });
+      this.templateSources = templateSources;
+    },
+    selectAll(selected) {
+      if (selected) {
+        this.modalForm.printContent = ["PAPER", "CARD"];
+        this.modalForm.variableContent.forEach(item => {
+          if (item.templateId && item.templateId.length) return;
+
+          const source = this.templateSources[item.type][0];
+          item.templateId = source && [source.id];
+          item.oldTemplateId = source && [source.id];
+        });
+        this.modalForm.ordinaryContent.forEach(item => {
+          if (item.templateId && item.templateId.length) return;
+
+          const source = this.templateSources[item.type][0];
+          item.templateId = source && [source.id];
+          item.oldTemplateId = source && [source.id];
+        });
+      } else {
+        this.modalForm.printContent = [];
+        this.modalForm.variableContent.forEach(item => {
+          item.templateId = [];
+          item.oldTemplateId = [];
+        });
+        this.modalForm.ordinaryContent.forEach(item => {
+          item.templateId = [];
+          item.oldTemplateId = [];
+        });
+      }
+    },
+    checkSelectAll() {
+      const vNotSelected = this.modalForm.variableContent.some(
+        item => !item.templateId.length
+      );
+      const oNotSelected = this.modalForm.ordinaryContent.some(
+        item => !item.templateId.length
+      );
+      const pNotSelected = this.modalForm.printContent.length < 2;
+
+      const selecteds = [vNotSelected, oNotSelected, pNotSelected];
+
+      this.allSelected = !selecteds.some(item => item);
+    },
+    templateValidator(rule, value, callback) {
+      const [field, index] = rule.field.split(".");
+      const val = this.modalForm[field][index];
+      if (val.templateId.length) {
+        if (!val.backupMethod) {
+          return callback(new Error("请选择备份方式"));
+        }
+        if (!val.backupCount) {
+          return callback(new Error("请输入备份数量"));
+        }
+        callback();
+      } else {
+        callback();
+      }
+    },
+    tempChange(vals, name) {
+      const [field, index] = name.split(".");
+      const info = this.modalForm[field][index];
+      const newVals = vals.filter(item => !info.oldTemplateId.includes(item));
+      info.templateId = newVals;
+      info.oldTemplateId = newVals;
+
+      this.checkSelectAll();
+      this.$refs.modalFormComp.validateField("selectedPrint");
+    },
+    printContentChange(val) {
+      const isSelectPaper =
+        !this.oldPrintContent.includes("PAPER") && val.includes("PAPER");
+      if (isSelectPaper && !val.includes("CARD")) {
+        val.push("CARD");
+      }
+      this.oldPrintContent = val;
+    },
     initData(val) {
       if (val.id) {
-        this.modalForm = this.$objAssign(initModalForm, val);
+        this.createTime = [val.examStartTime, val.examEndTime];
+        this.modalForm = this.$objAssign(deepCopy(initModalForm), val);
+        const transformInfo = item => {
+          const templateIds = item.templateId ? [item.templateId] : [];
+          return {
+            type: item.type,
+            templateId: templateIds,
+            oldTemplateId: templateIds,
+            backupMethod: item.backupMethod,
+            backupCount: item.backupCount
+          };
+        };
+        this.modalForm.variableContent = val.variableContent.map(transformInfo);
+        this.modalForm.ordinaryContent = val.ordinaryContent.map(transformInfo);
+        this.modalForm.printContent = val.printContent
+          ? val.printContent.split(",")
+          : [];
+        this.checkSelectAll();
       } else {
-        this.modalForm = { ...initModalForm };
+        this.allSelected = false;
+        let modalForm = deepCopy(initModalForm);
+        modalForm.variableContent = modalForm.variableContent.filter(
+          item => this.templateSources[item.type]
+        );
+        modalForm.ordinaryContent = modalForm.ordinaryContent.filter(
+          item => this.templateSources[item.type]
+        );
+        this.modalForm = modalForm;
+        this.createTime = [];
       }
     },
     visibleChange() {
@@ -114,6 +597,15 @@ export default {
     open() {
       this.modalIsShow = true;
     },
+    dateChange() {
+      if (this.createTime) {
+        this.modalForm.examStartTime = this.createTime[0];
+        this.modalForm.examEndTime = this.createTime[1];
+      } else {
+        this.modalForm.examStartTime = "";
+        this.modalForm.examEndTime = "";
+      }
+    },
     async submit() {
       const valid = await this.$refs.modalFormComp.validate().catch(() => {});
       if (!valid) return;
@@ -121,6 +613,26 @@ export default {
       if (this.isSubmit) return;
       this.isSubmit = true;
       const datas = { ...this.modalForm };
+      const transformInfo = item => {
+        const templateId = item.templateId.join();
+        const template = this.templateSources[item.type].find(
+          temp => temp.id === templateId
+        );
+        return {
+          type: item.type,
+          templateId,
+          attachmentId: template && template.attachmentId,
+          backupMethod: item.backupMethod,
+          backupCount: item.backupCount
+        };
+      };
+      datas.variableContent = JSON.stringify(
+        this.modalForm.variableContent.map(transformInfo)
+      );
+      datas.ordinaryContent = JSON.stringify(
+        this.modalForm.ordinaryContent.map(transformInfo)
+      );
+
       const data = await updatePrintPlan(datas).catch(() => {});
       this.isSubmit = false;
       if (!data) return;