|
@@ -19,7 +19,7 @@
|
|
|
<el-form
|
|
|
:model="item"
|
|
|
:ref="'form' + index"
|
|
|
- :rules="rules"
|
|
|
+ :rules="rules(index)"
|
|
|
label-position="right"
|
|
|
inline
|
|
|
v-for="(item, index) in form"
|
|
@@ -44,7 +44,7 @@
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="考试时长" prop="prepareSeconds">
|
|
|
+ <el-form-item label="考试时长" prop="maxDurationSeconds">
|
|
|
<MinuteInput
|
|
|
v-model="item.maxDurationSeconds"
|
|
|
style="width: 125px;"
|
|
@@ -53,7 +53,7 @@
|
|
|
<el-form-item label="候考时间" prop="prepareSeconds">
|
|
|
<MinuteInput v-model="item.prepareSeconds" style="width: 125px;" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="迟到时长" prop="prepareSeconds">
|
|
|
+ <el-form-item label="迟到时长" prop="openingSeconds">
|
|
|
<MinuteInput v-model="item.openingSeconds" style="width: 125px;" />
|
|
|
</el-form-item>
|
|
|
</div>
|
|
@@ -99,7 +99,48 @@ export default {
|
|
|
maxDurationSeconds: 0,
|
|
|
},
|
|
|
],
|
|
|
- rules: {
|
|
|
+
|
|
|
+ exam: {},
|
|
|
+ activity: {},
|
|
|
+ loading: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ try {
|
|
|
+ this.exam = (await getExamDetail({ id: this.examId }))?.data.data;
|
|
|
+ this.form[0].prepareSeconds = this.exam.prepareSeconds;
|
|
|
+ this.form[0].openingSeconds = this.exam.openingSeconds;
|
|
|
+ this.form[0].maxDurationSeconds = this.exam.maxDurationSeconds;
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ this.$notify({ type: "error", title: "获取考试详情失败" });
|
|
|
+ }
|
|
|
+
|
|
|
+ // if (this.isEdit) {
|
|
|
+ // try {
|
|
|
+ // this.activity = (
|
|
|
+ // await getActivityDetail({ id: this.activityId })
|
|
|
+ // )?.data.data.records[0];
|
|
|
+ // this.form = this.activity;
|
|
|
+ // } catch (error) {
|
|
|
+ // console.log(error);
|
|
|
+ // this.$notify({ type: "error", title: "获取场次详情失败" });
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // this.form = {
|
|
|
+ // id: "",
|
|
|
+ // startTime: null,
|
|
|
+ // finishTime: null,
|
|
|
+ // prepareSeconds: 0,
|
|
|
+ // openingSeconds: 0,
|
|
|
+ // maxDurationSeconds: 0,
|
|
|
+ // enable: 0,
|
|
|
+ // };
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ rules(index) {
|
|
|
+ return {
|
|
|
startTime: [
|
|
|
{ required: true, message: "开始时间必填" },
|
|
|
{
|
|
@@ -119,22 +160,6 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- // type: "date",
|
|
|
- // asyncValidator: (rule, value) => {
|
|
|
- // console.log(value);
|
|
|
- // return new Promise((resolve, reject) => {
|
|
|
- // if (
|
|
|
- // moment(value).isBetween(
|
|
|
- // moment(that.exam.startTime),
|
|
|
- // moment(that.exam.endTime)
|
|
|
- // )
|
|
|
- // ) {
|
|
|
- // resolve(); // reject with error message
|
|
|
- // } else {
|
|
|
- // reject();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // },
|
|
|
message: "场次的开始时间不在考试的时间范围",
|
|
|
},
|
|
|
],
|
|
@@ -160,49 +185,33 @@ export default {
|
|
|
message: "场次的交卷时间不在考试的时间范围",
|
|
|
},
|
|
|
],
|
|
|
- maxDurationSeconds: [{ required: true, message: "考试时长必填" }],
|
|
|
+ maxDurationSeconds: [
|
|
|
+ { required: true, message: "考试时长必填" },
|
|
|
+ {
|
|
|
+ validator: (rule, value) => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ console.log(
|
|
|
+ moment(this.form[index].finishTime) -
|
|
|
+ moment(this.form[index].startTime)
|
|
|
+ );
|
|
|
+ if (
|
|
|
+ moment(this.form[index].finishTime) -
|
|
|
+ moment(this.form[index].startTime) >=
|
|
|
+ value * 1000
|
|
|
+ ) {
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ reject("reject");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ message: "考试时长超出考试时间范围",
|
|
|
+ },
|
|
|
+ ],
|
|
|
prepareSeconds: [{ required: true, message: "候考时间必填" }],
|
|
|
openingSeconds: [{ required: true, message: "迟到时长必填" }],
|
|
|
- },
|
|
|
- exam: {},
|
|
|
- activity: {},
|
|
|
- loading: false,
|
|
|
- };
|
|
|
- },
|
|
|
- async created() {
|
|
|
- try {
|
|
|
- this.exam = (await getExamDetail({ id: this.examId }))?.data.data;
|
|
|
- this.form[0].prepareSeconds = this.exam.prepareSeconds;
|
|
|
- this.form[0].openingSeconds = this.exam.openingSeconds;
|
|
|
- this.form[0].maxDurationSeconds = this.exam.maxDurationSeconds;
|
|
|
- } catch (error) {
|
|
|
- console.log(error);
|
|
|
- this.$notify({ type: "error", title: "获取考试详情失败" });
|
|
|
- }
|
|
|
-
|
|
|
- // if (this.isEdit) {
|
|
|
- // try {
|
|
|
- // this.activity = (
|
|
|
- // await getActivityDetail({ id: this.activityId })
|
|
|
- // )?.data.data.records[0];
|
|
|
- // this.form = this.activity;
|
|
|
- // } catch (error) {
|
|
|
- // console.log(error);
|
|
|
- // this.$notify({ type: "error", title: "获取场次详情失败" });
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // this.form = {
|
|
|
- // id: "",
|
|
|
- // startTime: null,
|
|
|
- // finishTime: null,
|
|
|
- // prepareSeconds: 0,
|
|
|
- // openingSeconds: 0,
|
|
|
- // maxDurationSeconds: 0,
|
|
|
- // enable: 0,
|
|
|
- // };
|
|
|
- // }
|
|
|
- },
|
|
|
- methods: {
|
|
|
+ };
|
|
|
+ },
|
|
|
addActivity() {
|
|
|
this.form.push({
|
|
|
id: "",
|