|
@@ -34,6 +34,7 @@
|
|
|
placeholder="考试"
|
|
|
:disabled="isEdit"
|
|
|
class="width-full"
|
|
|
+ @change="examChange"
|
|
|
></exam-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
@@ -195,6 +196,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { deepCopy } from "@/plugins/utils";
|
|
|
import { updateExamStudent, examRuleDetail, courseQuery } from "../api";
|
|
|
import OneDateTimeRange from "@/components/OneDateTimeRange.vue";
|
|
|
|
|
@@ -295,13 +297,16 @@ export default {
|
|
|
required: true,
|
|
|
validator: (rule, value, callback) => {
|
|
|
if (
|
|
|
- !this.modalForm.examStartTime ||
|
|
|
- !this.modalForm.examEndTime
|
|
|
+ rule.required &&
|
|
|
+ (!this.modalForm.examStartTime || !this.modalForm.examEndTime)
|
|
|
) {
|
|
|
return callback(new Error("请选择考试时间"));
|
|
|
}
|
|
|
|
|
|
- if (this.modalForm.examStartTime >= this.modalForm.examEndTime) {
|
|
|
+ if (
|
|
|
+ (this.modalForm.examStartTime || this.modalForm.examEndTime) &&
|
|
|
+ this.modalForm.examStartTime >= this.modalForm.examEndTime
|
|
|
+ ) {
|
|
|
return callback(new Error("开始时间要早于结束时间"));
|
|
|
}
|
|
|
|
|
@@ -388,6 +393,7 @@ export default {
|
|
|
optionalFields: [],
|
|
|
extendFields: [],
|
|
|
courseList: [],
|
|
|
+ curExam: null,
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
@@ -458,11 +464,17 @@ export default {
|
|
|
|
|
|
this.courseList = res.basicCourseList || [];
|
|
|
},
|
|
|
+ examChange(val) {
|
|
|
+ this.curExam = val || null;
|
|
|
+ this.updateRules();
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.modalFormComp.clearValidate();
|
|
|
+ });
|
|
|
+ },
|
|
|
updateRules() {
|
|
|
- // const paperNumberRequired = this.curExam.examModel === "MODEL4";
|
|
|
- const rules = { ...this.requiredRules };
|
|
|
+ const nrules = { ...this.requiredRules };
|
|
|
[...this.optionalFields, ...this.extendFields].forEach((item) => {
|
|
|
- rules[item.code] = [
|
|
|
+ nrules[item.code] = [
|
|
|
// {
|
|
|
// required: false,
|
|
|
// message: `请输入${item.name}`,
|
|
@@ -475,6 +487,17 @@ export default {
|
|
|
},
|
|
|
];
|
|
|
});
|
|
|
+
|
|
|
+ const rules = deepCopy(nrules);
|
|
|
+ if (this.curExam?.examModel === "MODEL4") {
|
|
|
+ const unRequireFields = ["examStartTime", "examRoom", "collegeName"];
|
|
|
+ Object.keys(rules)
|
|
|
+ .filter((k) => unRequireFields.includes(k))
|
|
|
+ .forEach((k) => {
|
|
|
+ rules[k][0].required = false;
|
|
|
+ });
|
|
|
+ rules.paperNumber[0].required = true;
|
|
|
+ }
|
|
|
this.rules = rules;
|
|
|
},
|
|
|
cancel() {
|