|
@@ -91,18 +91,11 @@
|
|
|
prop="examStartTime"
|
|
|
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
|
|
|
v-if="checkRequiredFieldValid('examRoom')"
|
|
@@ -188,7 +181,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { updateExamStudent, examRuleDetail, courseQuery } from "../api";
|
|
|
-import { getTimeDatestamp } from "@/plugins/utils";
|
|
|
+import OneDateTimeRange from "@/components/OneDateTimeRange.vue";
|
|
|
|
|
|
const requiredModalForm = {
|
|
|
id: null,
|
|
@@ -197,8 +190,8 @@ const requiredModalForm = {
|
|
|
studentName: "",
|
|
|
studentCode: "",
|
|
|
courseId: "",
|
|
|
- examEndTime: "",
|
|
|
- examStartTime: "",
|
|
|
+ examEndTime: null,
|
|
|
+ examStartTime: null,
|
|
|
collegeName: "",
|
|
|
examRoom: "",
|
|
|
teachClassName: "",
|
|
@@ -208,6 +201,7 @@ const requiredModalForm = {
|
|
|
|
|
|
export default {
|
|
|
name: "modify-exam-student",
|
|
|
+ components: { OneDateTimeRange },
|
|
|
props: {
|
|
|
instance: {
|
|
|
type: Object,
|
|
@@ -284,8 +278,20 @@ export default {
|
|
|
examStartTime: [
|
|
|
{
|
|
|
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: [
|
|
@@ -367,8 +373,6 @@ export default {
|
|
|
optionalFields: [],
|
|
|
extendFields: [],
|
|
|
courseList: [],
|
|
|
- // date-picker
|
|
|
- examSetDate: [],
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
@@ -378,13 +382,6 @@ export default {
|
|
|
if (val.id) {
|
|
|
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
|
|
|
? JSON.parse(val.extendFields)
|
|
|
: [];
|
|
@@ -394,7 +391,6 @@ export default {
|
|
|
await this.getCourses();
|
|
|
} else {
|
|
|
this.modalForm = { ...this.initModalForm };
|
|
|
- this.getInitCreateTime();
|
|
|
this.courseList = [];
|
|
|
}
|
|
|
|
|
@@ -430,11 +426,6 @@ export default {
|
|
|
checkRequiredFieldValid(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() {
|
|
|
this.initData(this.instance);
|
|
|
},
|
|
@@ -480,18 +471,6 @@ export default {
|
|
|
updateClazz() {
|
|
|
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() {
|
|
|
const data = this.$objAssign(requiredModalForm, this.modalForm);
|
|
|
this.optionalFields.forEach((item) => {
|