Browse Source

feat: 考试时间选择替换

zhangjie 11 months ago
parent
commit
76ab06fe56

+ 20 - 0
src/assets/styles/common-comp.scss

@@ -518,3 +518,23 @@ $--cc-labels-pre: cc-labels;
     min-height: 26px;
     min-height: 26px;
   }
   }
 }
 }
+
+// one-date-time-range
+.one-date-time-range {
+  .el-date-editor--date {
+    width: 120px;
+    .el-input__inner {
+      padding-right: 10px;
+    }
+  }
+  .el-date-editor--time {
+    width: 75px;
+    .el-input__inner {
+      padding: 0 10px;
+    }
+    .el-input__prefix,
+    .el-input__suffix {
+      display: none;
+    }
+  }
+}

+ 125 - 0
src/components/OneDateTimeRange.vue

@@ -0,0 +1,125 @@
+<template>
+  <div class="one-date-time-range">
+    <el-date-picker
+      v-model="curDate"
+      value-format="timestamp"
+      format="yyyy-MM-dd"
+      :placeholder="placeholder"
+      :clearable="false"
+      :default-value="defaultData.curDate"
+      :disabled="disabled"
+      @change="timeChange"
+    >
+    </el-date-picker>
+    <span style="margin-right: 5px"></span>
+    <el-time-picker
+      v-model="startTime"
+      value-format="timestamp"
+      format="HH:mm"
+      placeholder="开始时间"
+      :clearable="false"
+      :default-value="defaultData.startTime"
+      :disabled="disabled"
+      @change="timeChange"
+    >
+    </el-time-picker>
+    <span style="margin: 0 3px">-</span>
+    <el-time-picker
+      v-model="endTime"
+      value-format="timestamp"
+      format="HH:mm"
+      placeholder="结束时间"
+      :clearable="false"
+      :default-value="defaultData.endTime"
+      :disabled="disabled"
+      @change="timeChange"
+    >
+    </el-time-picker>
+  </div>
+</template>
+
+<script>
+import { getTimeDatestamp } from "@/plugins/utils";
+
+export default {
+  name: "one-date-time-range",
+  props: {
+    startDateTime: Number,
+    endDateTime: Number,
+    disabled: Boolean,
+    placeholder: {
+      type: String,
+      default: "考试日期",
+    },
+  },
+  data() {
+    return {
+      curDate: null,
+      startTime: null,
+      endTime: null,
+      defaultData: {
+        curDate: null,
+        startTime: null,
+        endTime: null,
+      },
+    };
+  },
+  created() {
+    this.$watch(
+      function () {
+        return [this.startDateTime, this.endDateTime];
+      },
+      function () {
+        this.updateData();
+      },
+      {
+        immediate: true,
+      }
+    );
+    this.initDefaultTime();
+  },
+  methods: {
+    updateData() {
+      if (this.startDateTime && this.endDateTime) {
+        this.curDate = getTimeDatestamp(this.startDateTime);
+        this.startTime = this.startDateTime;
+        this.endTime = this.endDateTime;
+      } else {
+        this.startTime = null;
+        this.endTime = null;
+      }
+    },
+    initDefaultTime() {
+      const curDate = getTimeDatestamp(Date.now());
+      const hour = 60 * 60 * 1000;
+      const startTime = curDate + 8 * hour;
+      const endTime = curDate + 10 * hour;
+      this.defaultData = {
+        curDate,
+        startTime,
+        endTime,
+      };
+    },
+    timeChange() {
+      if (!this.curDate || !this.startTime || !this.endTime) {
+        this.$emit("update:startDateTime", null);
+        this.$emit("update:endDateTime", null);
+        this.$emit("change", null);
+        return;
+      }
+
+      // console.log(this.curDate, this.startTime, this.endTime);
+
+      const curDate = getTimeDatestamp(this.curDate);
+      const startDate = getTimeDatestamp(this.startTime);
+      const startTime = curDate + this.startTime - startDate;
+      const endDate = getTimeDatestamp(this.endTime);
+      const endTime = curDate + this.endTime - endDate;
+
+      this.$emit("update:startDateTime", startTime);
+      this.$emit("update:endDateTime", endTime);
+      this.$emit("change", [startTime, endTime]);
+    },
+  },
+};
+</script>

+ 22 - 43
src/modules/base/components/ModifyExamStudent.vue

@@ -91,18 +91,11 @@
         prop="examStartTime"
         prop="examStartTime"
         label="考试时间:"
         label="考试时间:"
       >
       >
-        <el-date-picker
-          v-model="examSetDate"
-          type="datetimerange"
-          value-format="timestamp"
-          format="yyyy-MM-dd HH:mm"
-          placeholder="考试日期"
-          :clearable="false"
-          start-placeholder="考试开始时间"
-          end-placeholder="考试结束时间"
-          @change="timeChange"
+        <one-date-time-range
+          :start-date-time.sync="modalForm.examStartTime"
+          :end-date-time.sync="modalForm.examEndTime"
         >
         >
-        </el-date-picker>
+        </one-date-time-range>
       </el-form-item>
       </el-form-item>
       <el-form-item
       <el-form-item
         v-if="checkRequiredFieldValid('examRoom')"
         v-if="checkRequiredFieldValid('examRoom')"
@@ -188,7 +181,7 @@
 
 
 <script>
 <script>
 import { updateExamStudent, examRuleDetail, courseQuery } from "../api";
 import { updateExamStudent, examRuleDetail, courseQuery } from "../api";
-import { getTimeDatestamp } from "@/plugins/utils";
+import OneDateTimeRange from "@/components/OneDateTimeRange.vue";
 
 
 const requiredModalForm = {
 const requiredModalForm = {
   id: null,
   id: null,
@@ -197,8 +190,8 @@ const requiredModalForm = {
   studentName: "",
   studentName: "",
   studentCode: "",
   studentCode: "",
   courseId: "",
   courseId: "",
-  examEndTime: "",
-  examStartTime: "",
+  examEndTime: null,
+  examStartTime: null,
   collegeName: "",
   collegeName: "",
   examRoom: "",
   examRoom: "",
   teachClassName: "",
   teachClassName: "",
@@ -208,6 +201,7 @@ const requiredModalForm = {
 
 
 export default {
 export default {
   name: "modify-exam-student",
   name: "modify-exam-student",
+  components: { OneDateTimeRange },
   props: {
   props: {
     instance: {
     instance: {
       type: Object,
       type: Object,
@@ -284,8 +278,20 @@ export default {
         examStartTime: [
         examStartTime: [
           {
           {
             required: true,
             required: true,
-            message: "请输入考试时间",
-            trigger: "change",
+            validator: (rule, value, callback) => {
+              if (
+                !this.modalForm.examStartTime ||
+                !this.modalForm.examEndTime
+              ) {
+                return callback(new Error("请选择考试时间"));
+              }
+
+              if (this.modalForm.examStartTime >= this.modalForm.examEndTime) {
+                return callback(new Error("开始时间要早于结束时间"));
+              }
+
+              return callback();
+            },
           },
           },
         ],
         ],
         examRoom: [
         examRoom: [
@@ -367,8 +373,6 @@ export default {
       optionalFields: [],
       optionalFields: [],
       extendFields: [],
       extendFields: [],
       courseList: [],
       courseList: [],
-      // date-picker
-      examSetDate: [],
     };
     };
   },
   },
   methods: {
   methods: {
@@ -378,13 +382,6 @@ export default {
       if (val.id) {
       if (val.id) {
         this.modalForm = this.$objAssign(this.initModalForm, val);
         this.modalForm = this.$objAssign(this.initModalForm, val);
 
 
-        const { examStartTime, examEndTime } = val;
-        if (examStartTime && examEndTime) {
-          this.examSetDate = [examStartTime, examEndTime];
-        } else {
-          this.getInitCreateTime();
-        }
-
         const extendFieldData = val.extendFields
         const extendFieldData = val.extendFields
           ? JSON.parse(val.extendFields)
           ? JSON.parse(val.extendFields)
           : [];
           : [];
@@ -394,7 +391,6 @@ export default {
         await this.getCourses();
         await this.getCourses();
       } else {
       } else {
         this.modalForm = { ...this.initModalForm };
         this.modalForm = { ...this.initModalForm };
-        this.getInitCreateTime();
         this.courseList = [];
         this.courseList = [];
       }
       }
 
 
@@ -430,11 +426,6 @@ export default {
     checkRequiredFieldValid(fieldName) {
     checkRequiredFieldValid(fieldName) {
       return this.requiredFields.includes(fieldName);
       return this.requiredFields.includes(fieldName);
     },
     },
-    getInitCreateTime() {
-      const curDate = getTimeDatestamp(Date.now());
-      const hour = 60 * 60 * 1000;
-      this.examSetDate = [curDate + 8 * hour, curDate + 10 * hour];
-    },
     visibleChange() {
     visibleChange() {
       this.initData(this.instance);
       this.initData(this.instance);
     },
     },
@@ -480,18 +471,6 @@ export default {
     updateClazz() {
     updateClazz() {
       this.modalForm.clazzId = "";
       this.modalForm.clazzId = "";
     },
     },
-    timeChange() {
-      if (!this.examSetDate) {
-        this.modalForm.examStartTime = "";
-        this.modalForm.examEndTime = "";
-        return;
-      }
-
-      this.modalForm.examStartTime = this.examSetDate[0];
-      this.modalForm.examEndTime = this.examSetDate[1];
-
-      // this.$refs.modalFormComp.validateField("examStartTime", () => {});
-    },
     getModelData() {
     getModelData() {
       const data = this.$objAssign(requiredModalForm, this.modalForm);
       const data = this.$objAssign(requiredModalForm, this.modalForm);
       this.optionalFields.forEach((item) => {
       this.optionalFields.forEach((item) => {

+ 4 - 4
src/modules/base/views/ExamStudentManage.vue

@@ -149,7 +149,7 @@
         <el-table-column
         <el-table-column
           prop="courseName"
           prop="courseName"
           label="课程名称"
           label="课程名称"
-          min-width="100"
+          min-width="300"
         ></el-table-column>
         ></el-table-column>
         <el-table-column
         <el-table-column
           prop="courseCode"
           prop="courseCode"
@@ -169,12 +169,12 @@
         <el-table-column
         <el-table-column
           prop="collegeName"
           prop="collegeName"
           label="学院"
           label="学院"
-          min-width="120"
+          min-width="180"
         ></el-table-column>
         ></el-table-column>
         <el-table-column
         <el-table-column
           prop="majorName"
           prop="majorName"
           label="专业"
           label="专业"
-          min-width="120"
+          min-width="180"
         ></el-table-column>
         ></el-table-column>
         <el-table-column
         <el-table-column
           prop="teachClassName"
           prop="teachClassName"
@@ -199,7 +199,7 @@
         <el-table-column
         <el-table-column
           prop="paperType"
           prop="paperType"
           label="卷型"
           label="卷型"
-          width="120"
+          width="80"
         ></el-table-column>
         ></el-table-column>
         <el-table-column
         <el-table-column
           prop="teacherName"
           prop="teacherName"

+ 8 - 17
src/modules/exam/components/createExamAndPrintTask/InfoPrintTask.vue

@@ -128,24 +128,18 @@
             ></el-input-number>
             ></el-input-number>
           </template>
           </template>
         </el-table-column>
         </el-table-column>
-        <el-table-column label="考试时间" width="240">
+        <el-table-column label="考试时间" width="300">
           <template slot-scope="scope">
           <template slot-scope="scope">
             <template v-if="!scope.row.canEditTime">
             <template v-if="!scope.row.canEditTime">
               {{ scope.row.examDate }} {{ scope.row.examTime }}
               {{ scope.row.examDate }} {{ scope.row.examTime }}
             </template>
             </template>
             <template v-else>
             <template v-else>
-              <el-date-picker
-                v-model="scope.row.examSetDate"
-                type="datetimerange"
-                value-format="timestamp"
-                format="yyyy-MM-dd HH:mm"
-                placeholder="考试日期"
-                :clearable="false"
-                start-placeholder="考试开始时间"
-                end-placeholder="考试结束时间"
+              <one-date-time-range
+                :start-date-time.sync="scope.row.examStartTime"
+                :end-date-time.sync="scope.row.examEndTime"
                 @change="timeChange(scope.row)"
                 @change="timeChange(scope.row)"
               >
               >
-              </el-date-picker>
+              </one-date-time-range>
             </template>
             </template>
           </template>
           </template>
         </el-table-column>
         </el-table-column>
@@ -238,6 +232,7 @@ import { calcSum, getExamDateTime, getTimeDatestamp } from "@/plugins/utils";
 import { listTaskPrintHouse } from "../../api";
 import { listTaskPrintHouse } from "../../api";
 import ModifyExamTaskStudent from "./ModifyExamTaskStudent.vue";
 import ModifyExamTaskStudent from "./ModifyExamTaskStudent.vue";
 import PreviewTaskStudent from "./PreviewTaskStudent.vue";
 import PreviewTaskStudent from "./PreviewTaskStudent.vue";
+import OneDateTimeRange from "@/components/OneDateTimeRange.vue";
 
 
 const initModalForm = {
 const initModalForm = {
   paperNumber: "",
   paperNumber: "",
@@ -252,7 +247,7 @@ const initModalForm = {
 
 
 export default {
 export default {
   name: "info-print-task",
   name: "info-print-task",
-  components: { ModifyExamTaskStudent, PreviewTaskStudent },
+  components: { ModifyExamTaskStudent, PreviewTaskStudent, OneDateTimeRange },
   data() {
   data() {
     return {
     return {
       modalForm: {
       modalForm: {
@@ -434,16 +429,12 @@ export default {
       this.printHouses = await listTaskPrintHouse();
       this.printHouses = await listTaskPrintHouse();
     },
     },
     timeChange(row) {
     timeChange(row) {
-      if (!row.examSetDate) {
-        row.examStartTime = null;
-        row.examEndTime = null;
+      if (!row.examStartTime || !row.examEndTime) {
         row.examDate = "";
         row.examDate = "";
         row.examTime = "";
         row.examTime = "";
         return;
         return;
       }
       }
 
 
-      row.examStartTime = row.examSetDate[0];
-      row.examEndTime = row.examSetDate[1];
       Object.assign(row, getExamDateTime(row.examStartTime, row.examEndTime));
       Object.assign(row, getExamDateTime(row.examStartTime, row.examEndTime));
     },
     },
     backupCountChange() {
     backupCountChange() {

+ 12 - 0
src/modules/mark/components/markParam/MarkParamStructure.vue

@@ -113,6 +113,18 @@
           width="80"
           width="80"
         ></el-table-column>
         ></el-table-column>
         <el-table-column label="每题分值" width="120">
         <el-table-column label="每题分值" width="120">
+          <template slot="header">
+            <span>每题分值</span>
+            <el-tooltip effect="dark" placement="top">
+              <div slot="content" class="tooltip-area">
+                <p>每题分值,属于批量设置</p>
+                <p>
+                  输入每题分值后,比如2按回车键或鼠标点击输入框外其他地方,系统会自动设置该大题下每个小题的分值为2。
+                </p>
+              </div>
+              <i class="el-icon-info ml-1 tooltip-info-icon"></i>
+            </el-tooltip>
+          </template>
           <template slot-scope="scope" v-if="scope.row.mainFirstSub">
           <template slot-scope="scope" v-if="scope.row.mainFirstSub">
             <el-input-number
             <el-input-number
               v-model="scoresPerTopic[scope.row.mainId]"
               v-model="scoresPerTopic[scope.row.mainId]"

+ 6 - 5
src/modules/mark/components/markParam/ModifyMarkGroup.vue

@@ -161,6 +161,7 @@
                         mainItem.children.length
                         mainItem.children.length
                       "
                       "
                       v-model="mainItem.selected"
                       v-model="mainItem.selected"
+                      :disabled="mainItem.disabled"
                       title="全选"
                       title="全选"
                       @change="
                       @change="
                         (checked) => selectQuestionAll(checked, mainItem)
                         (checked) => selectQuestionAll(checked, mainItem)
@@ -168,11 +169,7 @@
                     ></el-checkbox>
                     ></el-checkbox>
                   </div>
                   </div>
                   <div
                   <div
-                    v-if="
-                      mainItem.children &&
-                      mainItem.children.length &&
-                      mainItem.questionType !== 4
-                    "
+                    v-if="mainItem.children && mainItem.children.length"
                     class="struct-questions"
                     class="struct-questions"
                   >
                   >
                     <template v-if="canSelectQuestion">
                     <template v-if="canSelectQuestion">
@@ -556,6 +553,7 @@ export default {
             mainNumber: item.mainNumber,
             mainNumber: item.mainNumber,
             questionType: item.questionType,
             questionType: item.questionType,
             selected: false,
             selected: false,
+            disabled: false,
             children: [],
             children: [],
           };
           };
         }
         }
@@ -566,6 +564,9 @@ export default {
         });
         });
       });
       });
       if (struct) paperStructs.push(struct);
       if (struct) paperStructs.push(struct);
+      paperStructs.forEach((item) => {
+        item.disabled = !item.children.some((elem) => !elem.disabled);
+      });
       this.paperStructs = paperStructs;
       this.paperStructs = paperStructs;
     },
     },
     selectQuestionAll(checked, mainItem) {
     selectQuestionAll(checked, mainItem) {