소스 검색

场次新增:开始/结束时间校验

Michael Wang 4 년 전
부모
커밋
bd19427133
1개의 변경된 파일21개의 추가작업 그리고 1개의 파일을 삭제
  1. 21 1
      src/modules/examwork/view/stageSpecialSettings.vue

+ 21 - 1
src/modules/examwork/view/stageSpecialSettings.vue

@@ -338,6 +338,7 @@
                     start-placeholder="开始日期"
                     end-placeholder="结束日期"
                     value-format="yyyy-MM-dd"
+                    :picker-options="repeatDatePickOptions()"
                   ></el-date-picker>
                 </el-form-item>
               </el-row>
@@ -570,6 +571,7 @@
 import { EXAM_WORK_API } from "@/constants/constants.js";
 import { mapState } from "vuex";
 import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
+import moment from "moment";
 
 let _this = null;
 export default {
@@ -596,6 +598,7 @@ export default {
       editStageVisible: false,
       editStageCommonSettingVisible: false,
       selectedExamStageIds: [],
+      exam: {},
       examName: "",
       examTypeName: "",
       formSearch: {
@@ -697,6 +700,16 @@ export default {
     }
   },
   methods: {
+    repeatDatePickOptions() {
+      return {
+        disabledDate: time => {
+          return !moment(time).isBetween(
+            moment(this.exam.beginTime),
+            moment(this.exam.endTime)
+          );
+        }
+      };
+    },
     handleSubmitDuration() {
       this.editStageCommonSettingForm.submitDuration = this.editStageCommonSettingForm.submitDuration.replace(
         /[^\d]/g,
@@ -1120,11 +1133,18 @@ export default {
       let dt = new Date(date);
       dt.setDate(dt.getDate() + days);
       return dt.getFullYear() + "-" + (dt.getMonth() + 1) + "-" + dt.getDate();
+    },
+    async getExamDetail(examId) {
+      let url = EXAM_WORK_API + "/exam/" + examId;
+      return this.$httpWithMsg.get(url).then(response => {
+        this.exam = response.data;
+      });
     }
   },
   //初始化查询
-  created() {
+  async created() {
     this.formSearch.examId = this.$route.params.id;
+    await this.getExamDetail(this.formSearch.examId);
     this.examName = this.$route.params.examName;
     this.examTypeName = this.$route.params.examTypeName;
     this.searchForm();