Pārlūkot izejas kodu

卷库发布印刷任务调试

zhangjie 3 gadi atpakaļ
vecāks
revīzija
6c06c3b81a

+ 2 - 2
src/components/base/PrintRoomSelect.vue

@@ -1,7 +1,7 @@
 <template>
   <el-select
     v-model="selected"
-    class="campus-select"
+    class="print-room-select"
     placeholder="请选择"
     :style="styles"
     filterable
@@ -23,7 +23,7 @@
 import { organizationFindByTypeList } from "../../modules/base/api";
 
 export default {
-  name: "campus-select",
+  name: "print-room-select",
   props: {
     disabled: { type: Boolean, default: false },
     value: { type: [Number, String], default: "" },

+ 10 - 4
src/modules/exam/api.js

@@ -122,21 +122,27 @@ export const paperAndCardBatchExport = datas => {
 };
 // publish-print-task
 export const listTaskPrint = datas => {
-  return $post("/api/admin/exam/task/list_task_print", datas);
+  return $postParam("/api/admin/exam/task/list_task_print", datas);
 };
 export const createTaskPrint = datas => {
-  return $post("/api/admin/exam/task/create_task_print", datas);
+  return $post("/api/admin/exam/task/save_task_print", datas);
 };
 export const removeTaskPrint = examTaskPrintId => {
-  return $post("/api/admin/exam/task/remove_task_print", { examTaskPrintId });
+  return $postParam("/api/admin/exam/task/remove_task_print", {
+    examTaskPrintId
+  });
 };
 export const listTaskPrintStudent = datas => {
-  return $post("/api/admin/exam/task/list_task_print_student", datas);
+  return $postParam("/api/admin/exam/task/list_task_print_student", datas);
 };
 // 班级查询
 export const listTaskPrintClass = datas => {
   return $postParam("/api/admin/exam/task/list_task_print_class", datas);
 };
+// 印刷室查询
+export const listTaskPrintHouse = datas => {
+  return $postParam("/api/admin/exam/task/list_task_print_house", datas);
+};
 
 // card
 export const cardForSelectList = datas => {

+ 81 - 41
src/modules/exam/components/CreatePrintTask.vue

@@ -3,10 +3,11 @@
     class="create-print-task"
     :visible.sync="modalIsShow"
     :title="title"
+    top="10px"
+    width="700px"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
     append-to-body
-    fullscreen
     @opened="visibleChange"
   >
     <div class="part-box part-box-pad part-box-border">
@@ -17,9 +18,12 @@
         :model="modalForm"
       >
         <el-form-item label="印刷计划:">
-          <span>{{ printPlanName }}</span>
+          <span>{{ instance.printPlanName }}</span>
+        </el-form-item>
+        <el-form-item label="考试时间:"
+          >{{ instance.examStartTime | timestampFilter }} 至
+          {{ instance.examEndTime | timestampFilter }}
         </el-form-item>
-        <el-form-item label="考试时间:">{{ createTime }} </el-form-item>
         <el-form-item label="考场:">
           <el-input
             v-model="modalForm.examRoom"
@@ -35,31 +39,22 @@
           ></el-input>
         </el-form-item>
         <el-form-item label="监考老师:">
-          <el-select
+          <el-input
             v-model="modalForm.invigilatorTeacher"
-            style="width: 142px;"
-            placeholder="请选择"
+            placeholder="请填写监考老师"
             clearable
-          >
-            <el-option
-              v-for="teacher in teachers"
-              :key="teacher.id"
-              :value="teacher.id"
-              :label="teacher.name"
-            ></el-option>
-          </el-select>
+          ></el-input>
         </el-form-item>
         <el-form-item prop="classId" label="考试对象:">
           <el-select
             v-model="classIds"
-            style="width: 142px;"
             placeholder="请选择"
             multiple
             clearable
             @change="classChange"
           >
             <el-option
-              v-for="clazz in clazzs"
+              v-for="clazz in classList"
               :key="clazz.classId"
               :value="clazz.classId"
               :label="clazz.className"
@@ -69,7 +64,7 @@
         <el-form-item prop="studentCount" label="人数:">
           <el-input-number
             v-model="modalForm.studentCount"
-            :min="1"
+            :min="0"
             :max="10000"
             :step="1"
             step-strictly
@@ -80,26 +75,32 @@
         <el-form-item prop="printHouseId" label="印刷室:">
           <el-select
             v-model="modalForm.printHouseId"
-            style="width: 142px;"
             placeholder="请选择"
-            clearable
+            @change="printHouseChange"
           >
             <el-option
               v-for="room in printRooms"
-              :key="room.id"
-              :value="room.id"
-              :label="room.name"
+              :key="room.houseId"
+              :value="room.houseId"
+              :label="room.houseName"
             ></el-option>
           </el-select>
         </el-form-item>
+      </el-form>
+      <el-form
+        ref="extendFieldFormComp"
+        label-width="100px"
+        :rules="extendFieldRules"
+        :model="extendFieldModal"
+      >
         <el-form-item
           v-for="item in extendFields"
           :key="item.code"
-          :label="item.name"
+          :label="`${item.name}:`"
           :prop="item.code"
         >
           <el-input
-            v-model="modalForm[item.code]"
+            v-model="extendFieldModal[item.code]"
             :placeholder="`请填写${item.name}`"
             clearable
           ></el-input>
@@ -118,7 +119,11 @@
 
 <script>
 import { calcSum } from "@/plugins/utils";
-import { createTaskPrint } from "../api";
+import {
+  createTaskPrint,
+  listTaskPrintHouse,
+  listTaskPrintClass
+} from "../api";
 
 export default {
   name: "create-print-task",
@@ -129,12 +134,6 @@ export default {
         return {};
       }
     },
-    clazzs: {
-      type: Array,
-      default() {
-        return [];
-      }
-    },
     extendFields: {
       type: Array,
       default() {
@@ -158,8 +157,7 @@ export default {
       tableData: [],
       printRooms: [],
       teachers: [],
-      printPlanName: "",
-      createTime: "",
+      classList: [],
       classIds: [],
       rules: {
         examRoom: [
@@ -204,12 +202,16 @@ export default {
             trigger: "change"
           }
         ]
-      }
+      },
+      // extend field
+      extendFieldModal: {},
+      extendFieldRules: {}
     };
   },
   created() {
+    this.getPrintHouses();
     this.extendFields.forEach(field => {
-      this.rules[field.code] = [
+      this.extendFieldRules[field.code] = [
         {
           required: true,
           message: `请输入${field.name}`,
@@ -219,9 +221,34 @@ export default {
     });
   },
   methods: {
+    async getPrintHouses() {
+      this.printRooms = await listTaskPrintHouse();
+    },
+    async getClazzs() {
+      const data = await listTaskPrintClass({
+        printPlanId: this.instance.printPlanId,
+        courseCode: this.instance.courseCode,
+        paperNumber: this.instance.paperNumber,
+        examTaskPrintId: this.instance.id
+      });
+      this.classList = data || [];
+    },
     visibleChange() {
+      this.getClazzs();
       this.modalForm = { ...this.instance };
-      this.classIds = this.modalForm.classId.split(",");
+      this.classIds = this.modalForm.classId
+        ? this.modalForm.classId.split(",")
+        : [];
+      const extendVals = this.instance.extends;
+      let extendFieldModal = {};
+      this.extendFields.forEach(field => {
+        extendFieldModal[field.code] = extendVals ? extendVals[field.code] : "";
+      });
+      this.extendFieldModal = extendFieldModal;
+      this.$nextTick(() => {
+        this.$refs.modalFormComp.clearValidate();
+        this.$refs.extendFieldFormComp.clearValidate();
+      });
     },
     cancel() {
       this.modalIsShow = false;
@@ -230,27 +257,40 @@ export default {
       this.modalIsShow = true;
     },
     classChange(vals) {
-      console.log(vals);
-      this.modalForm.className = vals.map(item => item.className);
+      const classes = this.classList.filter(item =>
+        vals.includes(item.classId)
+      );
+      this.modalForm.className = classes.map(item => item.className).join(",");
       this.modalForm.classId = this.classIds.join(",");
       this.modalForm.studentCount = calcSum(
-        vals.map(item => item.studentCount)
+        classes.map(item => item.studentCount)
       );
     },
+    printHouseChange(val) {
+      const curHouse = this.printRooms.find(item => item.houseId === val);
+      if (curHouse) {
+        this.modalForm.printHouseName = curHouse.houseName;
+      }
+    },
     async submit() {
       const valid = await this.$refs.modalFormComp.validate().catch(() => {});
       if (!valid) return;
 
+      const extendValid = await this.$refs.extendFieldFormComp
+        .validate()
+        .catch(() => {});
+      if (!extendValid) return;
+
       if (this.isSubmit) return;
       this.isSubmit = true;
 
       let datas = { ...this.modalForm };
       const extendFields = this.extendFields.map(field => {
         let info = { ...field };
-        info.value = datas[field.code];
+        info.value = this.extendFieldModal[field.code];
         return info;
       });
-      datas.extendFields = extendFields;
+      datas.extendFields = JSON.stringify(extendFields);
 
       const data = await createTaskPrint(datas).catch(() => {});
       this.isSubmit = false;

+ 0 - 13
src/modules/exam/components/PrintTaskStudents.vue

@@ -10,19 +10,6 @@
     append-to-body
     @open="visibleChange"
   >
-    <div class="part-box part-box-pad part-box-border">
-      <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
-        <el-form-item>
-          <el-input v-model="params" placeholder="请输入" clearable></el-input>
-        </el-form-item>
-        <el-form-item label-width="0px">
-          <el-button type="primary" icon="el-icon-search" @click="toPage(1)"
-            >查询</el-button
-          >
-        </el-form-item>
-      </el-form>
-    </div>
-
     <div class="part-box">
       <el-table ref="TableList" :data="dataList" border stripe>
         <el-table-column

+ 53 - 46
src/modules/exam/components/PublishPrintTask.vue

@@ -31,13 +31,16 @@
             value-format="timestamp"
             align="right"
             unlink-panels
+            @change="timeChange"
           >
           </el-date-picker>
         </el-form-item>
       </el-form>
     </div>
-    <div class="part-box">
-      <el-button type="primary" @click="toAdd">增加考试对象</el-button>
+    <div class="part-box part-box-pad part-box-border">
+      <el-button class="mb-2" type="primary" @click="toAdd"
+        >增加考试对象</el-button
+      >
       <el-table ref="TableList" :data="tableData" border stripe>
         <el-table-column
           type="index"
@@ -49,7 +52,7 @@
         <el-table-column prop="examPlace" label="考点"> </el-table-column>
         <el-table-column prop="invigilatorTeacher" label="监考老师">
         </el-table-column>
-        <el-table-column prop="clazzName" label="考试对象"> </el-table-column>
+        <el-table-column prop="className" label="考试对象"> </el-table-column>
         <el-table-column prop="studentCount" label="人数"> </el-table-column>
         <el-table-column prop="printHouseName" label="印刷室">
         </el-table-column>
@@ -59,7 +62,7 @@
           :label="item.name"
         >
           <div slot-scope="scope">
-            {{ scope.row[item.code] }}
+            {{ scope.row.extends[item.code] }}
           </div>
         </el-table-column>
         <el-table-column label="操作">
@@ -74,14 +77,14 @@
             <el-button
               class="btn-table-icon"
               type="text"
-              icon="icon icon-circle-right"
+              icon="icon icon-edit"
               @click="toEdit(scope.row)"
               title="编辑"
             ></el-button>
             <el-button
               class="btn-table-icon"
               type="text"
-              icon="icon icon-circle-right"
+              icon="icon icon-delete"
               @click="toDelete(scope.row)"
               title="删除"
             ></el-button>
@@ -107,7 +110,7 @@
     <create-print-task
       ref="CreatePrintTask"
       :instance="curRow"
-      :clazz="validClazzes"
+      :clazzs="clazzs"
       :extend-fields="extendFields"
       @modified="getList"
     ></create-print-task>
@@ -120,7 +123,7 @@
 </template>
 
 <script>
-import { listTaskPrint, removeTaskPrint, listTaskPrintClass } from "../api";
+import { listTaskPrint, removeTaskPrint } from "../api";
 import { examRuleDetail } from "../../base/api";
 import pickerOptions from "@/constants/datePickerOptions";
 import CreatePrintTask from "./CreatePrintTask";
@@ -142,6 +145,7 @@ export default {
       modalIsShow: false,
       isSubmit: false,
       filter: {
+        printPlanName: "",
         printPlanId: "",
         examStartTime: "",
         examEndTime: "",
@@ -159,7 +163,6 @@ export default {
       teachers: [],
       clazzs: [],
       curClassId: "",
-      validClazzes: [],
       extendFields: [],
       // date-picker
       createTime: [],
@@ -172,18 +175,12 @@ export default {
   methods: {
     visibleChange() {
       this.filter = this.$objAssign(this.filter, this.instance);
-      this.getClazzs();
     },
     async getExtendFields() {
       const examRule = await examRuleDetail();
-      this.extendFields = JSON.parse(examRule.extendFields);
-    },
-    async getClazzs() {
-      this.clazzs = await listTaskPrintClass({
-        printPlanId: this.filter.printPlanId,
-        courseCode: this.instance.courseCode,
-        paperNumber: this.instance.paperNumber
-      });
+      this.extendFields = examRule.extendFields
+        ? JSON.parse(examRule.extendFields)
+        : [];
     },
     async getList() {
       const datas = {
@@ -196,18 +193,29 @@ export default {
       const data = await listTaskPrint(datas);
       if (data.iPage) {
         this.tableData = data.iPage.records.map(item => {
-          item.extendFields.forEach(field => {
-            item[field.code] = field.value;
+          item.extends = {};
+          const extendFields = item.extendFields
+            ? JSON.parse(item.extendFields)
+            : [];
+          extendFields.forEach(field => {
+            item.extends[field.code] = field.value;
           });
           return item;
         });
         this.total = data.iPage.total;
+      } else {
+        this.tableData = [];
       }
       if (data.examStartTime && data.examEndTime) {
         this.createTime = [data.examStartTime, data.examEndTime];
         this.filter.examStartTime = this.createTime[0];
         this.filter.examEndTime = this.createTime[1];
         this.timeDisabled = true;
+      } else {
+        this.createTime = [];
+        this.filter.examStartTime = "";
+        this.filter.examEndTime = "";
+        this.timeDisabled = false;
       }
     },
     toPage(page) {
@@ -218,6 +226,10 @@ export default {
       this.filter.printPlanName = val.name;
       this.getList();
     },
+    timeChange(val) {
+      this.filter.examStartTime = val[0];
+      this.filter.examEndTime = val[1];
+    },
     cancel() {
       this.modalIsShow = false;
     },
@@ -225,40 +237,30 @@ export default {
       this.modalIsShow = true;
     },
     toAdd() {
-      let item = {
+      if (
+        !this.filter.printPlanId ||
+        !this.filter.examStartTime ||
+        !this.filter.examEndTime
+      ) {
+        this.$message.error("请选择印刷计划和考试时间!");
+        return;
+      }
+
+      this.curRow = {
         examPlace: "",
         examRoom: "",
         invigilatorTeacher: "",
         classId: "",
         className: "",
-        studentCount: 1,
+        studentCount: null,
         printHouseId: null,
+        printHouseName: null,
         ...this.filter
       };
-      this.extendFields.forEach(field => {
-        item[field.code] = "";
-      });
-      this.curRow = item;
-      let unvalidClazzs = [];
-      this.tableData.forEach(item => {
-        unvalidClazzs = [...unvalidClazzs, ...item.classId.split(",")];
-      });
-      this.validClazzes = this.clazzs.filter(
-        item => !unvalidClazzs.includes(item.classId)
-      );
       this.$refs.CreatePrintTask.open();
     },
     toEdit(row) {
-      this.curRow = { ...row };
-      let unvalidClazzs = [];
-      this.tableData
-        .filter(item => item.id !== row.id)
-        .forEach(item => {
-          unvalidClazzs = [...unvalidClazzs, ...item.classId.split(",")];
-        });
-      this.validClazzes = this.clazzs.filter(
-        item => !unvalidClazzs.includes(item.classId)
-      );
+      this.curRow = { ...row, ...this.filter.printPlanName };
       this.$refs.CreatePrintTask.open();
     },
     toPreview(row) {
@@ -266,11 +268,16 @@ export default {
       this.$refs.PrintTaskStudents.open();
     },
     async toDelete(row) {
+      const result = await this.$confirm(`确定要删除当前卷袋吗?`, "提示", {
+        cancelButtonClass: "el-button--danger is-plain",
+        confirmButtonClass: "el-button--primary",
+        type: "warning"
+      }).catch(() => {});
+      if (result !== "confirm") return;
+
       await removeTaskPrint(row.id);
       this.$message.success("删除成功!");
-
-      const pos = this.tableData.findIndex(item => item.id === row.id);
-      this.tableData.splice(pos, 1);
+      this.deletePageLastItem();
     }
   }
 };

+ 7 - 5
src/modules/print/components/ModifyPrintPlan.vue

@@ -49,7 +49,6 @@
           <el-checkbox-group
             v-model="modalForm.printContent"
             :disabled="!editable"
-            @change="printContentChange"
           >
             <el-checkbox
               v-for="(val, key) in PRINT_CONTENT_TYPE"
@@ -60,9 +59,9 @@
           </el-checkbox-group>
         </el-form-item>
         <el-form-item
+          v-if="modalForm.printContent.length"
           prop="backupMethod"
           label="试卷备份方式:"
-          :required="!!modalForm.printContent.length"
         >
           <el-select
             v-model="modalForm.backupMethod"
@@ -92,9 +91,9 @@
           <span>份</span>
         </el-form-item>
         <el-form-item
+          v-if="contentIncludesPaper"
           prop="drawRule"
           label="抽卷规则:"
-          :required="!!modalForm.printContent.length"
         >
           <el-radio-group v-model="modalForm.drawRule" :disabled="!editable">
             <el-radio
@@ -320,6 +319,9 @@ export default {
     },
     editable() {
       return this.editType !== "PREVIEW";
+    },
+    contentIncludesPaper() {
+      return this.modalForm.printContent.includes("PAPER");
     }
   },
   data() {
@@ -395,14 +397,14 @@ export default {
         ],
         backupMethod: [
           {
-            required: false,
+            required: true,
             validator: backupMethodValidator,
             trigger: "change"
           }
         ],
         drawRule: [
           {
-            required: false,
+            required: true,
             message: "请选择抽卷规则",
             trigger: "change"
           }