|
@@ -1,42 +1,56 @@
|
|
|
<template>
|
|
|
<div class="exam-modify part-box part-box-border part-box-pad">
|
|
|
- <el-form ref="ModalForm" label-width="170px">
|
|
|
- <el-form-item label="考试名称:">
|
|
|
+ <el-form
|
|
|
+ ref="ModalForm"
|
|
|
+ :model="modalForm"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="180px"
|
|
|
+ style="min-width:800px;"
|
|
|
+ >
|
|
|
+ <el-form-item prop="examName" label="考试名称:">
|
|
|
<el-input
|
|
|
style="width: 439px;"
|
|
|
- v-model.trim="modalForm.title"
|
|
|
- placeholder="请输入内容"
|
|
|
+ v-model.trim="modalForm.examName"
|
|
|
+ placeholder="请输入考试名称"
|
|
|
clearable
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="考务文件:">
|
|
|
- <el-input
|
|
|
- style="width: 439px;margin-right:18px;"
|
|
|
- v-model.trim="modalForm.title"
|
|
|
- disabled=""
|
|
|
- ></el-input>
|
|
|
- <el-button>选择</el-button>
|
|
|
- <el-button>预览</el-button>
|
|
|
+ <el-form-item prop="examCodeTemp" label="考务文件:">
|
|
|
+ <exam-business-upload
|
|
|
+ :upload-url="uploadUrl"
|
|
|
+ :upload-data="uploadData"
|
|
|
+ @upload-error="uplaodError"
|
|
|
+ @upload-success="uploadSuccess"
|
|
|
+ ref="ExamBusinessUpload"
|
|
|
+ ></exam-business-upload>
|
|
|
+ <el-button @click="toPreview" style="margin-left:16px;">预览</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="考试开始时间:">
|
|
|
+ <p class="form-item-content">{{ modalForm.beginTime }}</p>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="考试开始时间:"><p>2020-5-7 9:00</p> </el-form-item>
|
|
|
- <el-form-item label="打印时间:">
|
|
|
+ <el-form-item prop="printTime" label="打印时间:">
|
|
|
<el-date-picker
|
|
|
v-model="modalForm.printTime"
|
|
|
- type="date"
|
|
|
+ type="datetime"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
placeholder="请选择日期"
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="备用方式:">
|
|
|
- <el-radio-group v-model="modalForm.type">
|
|
|
- <el-radio :label="3">考试任务备用方式</el-radio>
|
|
|
- <el-radio :label="6">考场备用方式</el-radio>
|
|
|
+ <el-form-item prop="backup" label="备用方式:">
|
|
|
+ <el-radio-group v-model="modalForm.backup">
|
|
|
+ <el-radio
|
|
|
+ v-for="(val, key) in RESERVE_TYPE"
|
|
|
+ :key="key"
|
|
|
+ :label="key"
|
|
|
+ >{{ val }}</el-radio
|
|
|
+ >
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="备用各科试卷题卡份数:">
|
|
|
+ <el-form-item prop="backupCard" label="备用各科试卷题卡份数:">
|
|
|
<el-input-number
|
|
|
style="width:220px;"
|
|
|
- v-model="modalForm.startNumber"
|
|
|
+ v-model="modalForm.backupCard"
|
|
|
:min="1"
|
|
|
:max="1000"
|
|
|
:step="1"
|
|
@@ -44,33 +58,26 @@
|
|
|
:controls="false"
|
|
|
></el-input-number>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="指派命题老师:">
|
|
|
- <el-table
|
|
|
- :data="courses"
|
|
|
- style="width: 420px;line-height:23px;"
|
|
|
- border
|
|
|
- stripe
|
|
|
- >
|
|
|
+ <el-form-item prop="teacher" label="指派命题老师:">
|
|
|
+ <el-table :data="courses" style="width: 420px;" border stripe>
|
|
|
<el-table-column
|
|
|
width="154"
|
|
|
- prop="name"
|
|
|
+ prop="courseName"
|
|
|
label="科目"
|
|
|
></el-table-column>
|
|
|
<el-table-column label="命题老师">
|
|
|
<template slot-scope="scope">
|
|
|
<el-select
|
|
|
- v-model="scope.row.teacher"
|
|
|
+ v-model="scope.row.teacherId"
|
|
|
size="small"
|
|
|
style="width: 156px;"
|
|
|
placeholder="请选择"
|
|
|
- @change="teacherSelect"
|
|
|
- clearable
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="(val, key) in teachers"
|
|
|
- :key="key"
|
|
|
- :value="key"
|
|
|
- :label="val"
|
|
|
+ v-for="user in scope.row.users"
|
|
|
+ :key="user.id"
|
|
|
+ :value="user.id"
|
|
|
+ :label="user.name"
|
|
|
></el-option>
|
|
|
</el-select>
|
|
|
</template>
|
|
@@ -79,38 +86,190 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" @click="save">保存</el-button>
|
|
|
+ <el-button type="primary" :disabled="isSubmit" @click="save"
|
|
|
+ >保存</el-button
|
|
|
+ >
|
|
|
<el-button @click="goback">返回</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
+
|
|
|
+ <!-- business-data -->
|
|
|
+ <business-data
|
|
|
+ :exam-code="modalForm.examCodeTemp"
|
|
|
+ ref="BusinessData"
|
|
|
+ ></business-data>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { RESERVE_TYPE } from "@/constants/enumerate";
|
|
|
+import { uploadExam, examDetail } from "../api";
|
|
|
+import BusinessData from "../components/BusinessData";
|
|
|
+import ExamBusinessUpload from "../components/ExamBusinessUpload";
|
|
|
+
|
|
|
export default {
|
|
|
name: "exam-modify",
|
|
|
+ components: { BusinessData, ExamBusinessUpload },
|
|
|
data() {
|
|
|
+ const printTimeValidator = (rule, value, callback) => {
|
|
|
+ if (!this.checkDateRangeValid(value, this.modalForm.beginTime)) {
|
|
|
+ callback(new Error("打印时间不能为空,且不得晚于考试开始时间"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const teacherValidator = (rule, value, callback) => {
|
|
|
+ if (!this.checkTeacherSelected()) {
|
|
|
+ callback(new Error("请选择各科目的命题老师"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
return {
|
|
|
- modalForm: {},
|
|
|
- teachers: [],
|
|
|
- courses: [
|
|
|
- {
|
|
|
- id: "",
|
|
|
- name: "语文",
|
|
|
- teacher: ""
|
|
|
- },
|
|
|
- {
|
|
|
- id: "",
|
|
|
- name: "语文1",
|
|
|
- teacher: ""
|
|
|
- }
|
|
|
- ]
|
|
|
+ examId: this.$route.params.examId,
|
|
|
+ modalForm: {
|
|
|
+ examName: "",
|
|
|
+ beginTime: "",
|
|
|
+ printTime: "",
|
|
|
+ backup: "0",
|
|
|
+ backupCard: "",
|
|
|
+ examCodeTemp: "",
|
|
|
+ attachmentId: ""
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ examName: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入考试名称",
|
|
|
+ trigger: "change"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ examCode: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请上传考务文件",
|
|
|
+ trigger: "change"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ printTime: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ validator: printTimeValidator,
|
|
|
+ trigger: "change"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ backup: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请选择备用方式",
|
|
|
+ trigger: "change"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ backupCard: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入备用各科试卷题卡份数",
|
|
|
+ trigger: "change"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ teacher: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ validator: teacherValidator
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ RESERVE_TYPE,
|
|
|
+ courses: [],
|
|
|
+ isSubmit: false,
|
|
|
+ // import
|
|
|
+ uploadUrl: "/api/print/exam/exam/impExamData",
|
|
|
+ uploadData: {
|
|
|
+ schoolId: this.$ls.get("schoolId"),
|
|
|
+ userId: this.$ls.get("user", { id: "" }).id
|
|
|
+ }
|
|
|
};
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ isEdit() {
|
|
|
+ return !!this.examId;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ if (this.isEdit) {
|
|
|
+ this.getExamDetail();
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
- save() {},
|
|
|
- teacherSelect() {
|
|
|
- // TODO: 修改teachers数据;
|
|
|
+ async getExamDetail() {
|
|
|
+ const data = await examDetail(this.examId);
|
|
|
+ this.modalForm = Object.assign({}, this.modalForm, data.tcPExam);
|
|
|
+ this.modalForm.backup += "";
|
|
|
+ this.courses = data.userCourses;
|
|
|
+ this.$refs.ExamBusinessUpload.setAttachmentName(
|
|
|
+ `${data.tcPAttachment.name}${data.tcPAttachment.type}`
|
|
|
+ );
|
|
|
+ },
|
|
|
+ checkDateRangeValid(startTime, endTime) {
|
|
|
+ if (startTime && endTime) {
|
|
|
+ var st = new Date(startTime.replace(/-/g, "/")).getTime();
|
|
|
+ var et = new Date(endTime.replace(/-/g, "/")).getTime();
|
|
|
+
|
|
|
+ return st < et;
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ },
|
|
|
+ checkTeacherSelected() {
|
|
|
+ return !this.courses.some(course => !course.teacherId);
|
|
|
+ },
|
|
|
+ async save() {
|
|
|
+ const valid = await this.$refs["ModalForm"].validate().catch(() => {});
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ if (this.isSubmit) return;
|
|
|
+ this.isSubmit = true;
|
|
|
+ const datas = {
|
|
|
+ tcPExam: this.modalForm,
|
|
|
+ tcPExamCourseUsers: this.courses.map(course => {
|
|
|
+ return {
|
|
|
+ courseName: course.courseName,
|
|
|
+ courseCode: course.courseCode,
|
|
|
+ userId: course.teacherId
|
|
|
+ };
|
|
|
+ })
|
|
|
+ };
|
|
|
+ const data = await uploadExam(datas).catch(() => {});
|
|
|
+ this.isSubmit = false;
|
|
|
+ if (!data) return;
|
|
|
+ this.$message.success("保存成功!");
|
|
|
+ this.goback();
|
|
|
+ },
|
|
|
+ toPreview() {
|
|
|
+ if (!this.modalForm.examCode) {
|
|
|
+ this.$message.error("请先上传考务文件!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$refs.BusinessData.open();
|
|
|
+ },
|
|
|
+ // upload-handler
|
|
|
+ uplaodError(msg) {
|
|
|
+ this.$message.error(msg);
|
|
|
+ },
|
|
|
+ uploadSuccess(res) {
|
|
|
+ this.$message.success("上传成功!");
|
|
|
+ const data = res.data;
|
|
|
+
|
|
|
+ this.modalForm.beginTime = data.startTime;
|
|
|
+ this.modalForm.examCodeTemp = data.examCode;
|
|
|
+ this.modalForm.attachmentId = data.attachmentId;
|
|
|
+ console.log(`data.attachmentId=${data.attachmentId}`);
|
|
|
+ this.$refs["ModalForm"].validateField("examCodeTemp");
|
|
|
+
|
|
|
+ this.courses = data.userCourses.map(item => {
|
|
|
+ item.teacherId = "";
|
|
|
+ return item;
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|