Bläddra i källkod

题卡规则新增变量填充字段

zhangjie 1 år sedan
förälder
incheckning
52d5770d6b

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

@@ -60,7 +60,7 @@
           </el-select>
         </el-form-item>
         <el-form-item
-          v-if="modalForm.examNumberStyle === 'FILL'"
+          v-if="isFillModel"
           prop="examNumberDigit"
           label="学号位数:"
           class="inline-block"
@@ -99,7 +99,7 @@
           >
           <el-checkbox
             v-model="modalForm.writeSign"
-            :disabled="modalForm.examNumberStyle === 'FILL' || !editable"
+            :disabled="isFillModel || !editable"
             >启用“手写签名”</el-checkbox
           >
           <el-checkbox v-model="modalForm.undertakingEnable"
@@ -130,9 +130,24 @@
               :key="column.code"
               v-model="column.enable"
               :disabled="!editable"
+              @change="updateFillFields"
               >{{ column.name }}</el-checkbox
             >
           </el-form-item>
+          <el-form-item
+            v-if="isFillModel"
+            label="变量填充字段:"
+            label-width="115px"
+          >
+            <el-checkbox-group v-model="modalForm.fillFields">
+              <el-checkbox
+                v-for="column in selectedFields"
+                :key="column.code"
+                :label="column.code"
+                >{{ column.name }}</el-checkbox
+              >
+            </el-checkbox-group>
+          </el-form-item>
         </div>
         <el-form-item prop="titleRule" label="题卡标题规则:">
           <card-title-rule-edit
@@ -223,6 +238,7 @@ const initModalForm = {
   undertakingBody: UNDERTAKING_BODY,
   requiredFields: [],
   extendFields: [],
+  fillFields: [],
   titleRule: "",
   firstLevelSubheading: "",
   secondLevelSubheading: "",
@@ -259,12 +275,15 @@ export default {
     editable() {
       return this.editType !== "PREVIEW";
     },
-    // fieldSourses() {
-    //   return [
-    //     ...this.modalForm.requiredFields,
-    //     ...this.modalForm.extendFields
-    //   ].filter(item => item.enable);
-    // }
+    isFillModel() {
+      return this.modalForm.examNumberStyle === "FILL";
+    },
+    selectedFields() {
+      return [
+        ...this.modalForm.requiredFields,
+        ...this.modalForm.extendFields,
+      ].filter((item) => item.enable);
+    },
   },
   data() {
     return {
@@ -393,6 +412,9 @@ export default {
       if (val.id) {
         this.modalForm.requiredFields = JSON.parse(val.requiredFields);
         this.modalForm.extendFields = JSON.parse(val.extendFields);
+        this.modalForm.fillFields = val.fillFields
+          ? val.fillFields.split(",")
+          : [];
       }
     },
     visibleChange() {
@@ -412,22 +434,31 @@ export default {
       this.modalForm.writeSign = this.modalForm.examNumberStyle !== "FILL";
       if (this.modalForm.examNumberStyle !== "FILL") {
         this.modalForm.examNumberDigit = 10;
+        this.modalForm.fillFields = [];
       }
     },
     toEditUndertaking() {
       this.$refs.ModifyCardRuleUndertaking.open();
     },
+    updateFillFields() {
+      const fields = this.selectedFields.map((item) => item.code);
+      this.modalForm.fillFields = this.modalForm.fillFields.filter((item) =>
+        fields.includes(item)
+      );
+    },
     async submit() {
       const valid = await this.$refs.modalFormComp.validate().catch(() => {});
       if (!valid) return;
 
       if (this.isSubmit) return;
       this.isSubmit = true;
-      let modals = {
+      this.updateFillFields();
+      const modals = {
         ...this.modalForm,
       };
       modals.requiredFields = JSON.stringify(modals.requiredFields);
       modals.extendFields = JSON.stringify(modals.extendFields);
+      modals.fillFields = modals.fillFields.join();
       const data = await saveCardRule(modals).catch(() => {});
       this.isSubmit = false;
       if (!data) return;

+ 8 - 14
src/modules/base/components/ModifyExamStudent.vue

@@ -193,9 +193,8 @@ export default {
       rules: {},
       curExam: {},
       // date-picker
-      curCreateTime: [],
-      createDate: "",
-      createTime: [],
+      createDate: null,
+      createTime: [null, null],
     };
   },
   methods: {
@@ -214,15 +213,16 @@ export default {
       } else {
         this.modalForm = { ...initModalForm };
         this.getInitCreateTime();
-        this.initExamTime();
       }
       this.updateRules();
     },
     getInitCreateTime() {
-      const curDate = getTimeDatestamp(Date.now());
-      const hour = 60 * 60 * 1000;
-      this.createTime = [curDate + 8 * hour, curDate + 10 * hour];
-      this.createDate = null;
+      // const curDate = getTimeDatestamp(Date.now());
+      // const hour = 60 * 60 * 1000;
+      // this.createTime = [curDate + 8 * hour, curDate + 10 * hour];
+      // this.createDate = null;
+      this.createTime = [null, null];
+      this.createTime = null;
     },
     visibleChange() {
       this.initData(this.instance);
@@ -394,12 +394,6 @@ export default {
     updateClazz() {
       this.modalForm.clazzId = "";
     },
-    initExamTime() {
-      const curDate = getTimeDatestamp(Date.now());
-      const hour = 60 * 60 * 1000;
-      this.curCreateTime = [curDate + 8 * hour, curDate + 10 * hour];
-      this.createTime = [...this.curCreateTime];
-    },
     timeChange() {
       if (!this.createDate || !this.createTime) {
         this.modalForm.examStartTime = null;

+ 1 - 1
src/modules/exam/views/PdfBuildManage.vue

@@ -48,7 +48,7 @@
           </el-form-item>
           <el-form-item label="考场:">
             <el-input
-              v-model.trim="filter.examPlace"
+              v-model.trim="filter.examRoom"
               placeholder="考场"
               clearable
             >