123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684 |
- <template>
- <div class="task-print">
- <template v-if="!IS_REBUILD">
- <p v-if="IS_MODEL2" class="tips-info mb-2">
- 考试需要命题老师提交具体印刷份数
- </p>
- <p v-else class="tips-info mb-2">
- 考试需要命题老师提交完整的考务数据,每个卷袋表示一个考场,人数字段为应考人数,备份数量为该考场试卷题卡备用数量
- </p>
- </template>
- <div v-if="IS_MODEL2 || IS_REBUILD" class="part-box">
- <div class="box-justify mb-1">
- <div></div>
- <el-button v-if="editable" type="primary" @click="toSelectClass"
- >选择班级</el-button
- >
- </div>
- <table class="table">
- <colgroup>
- <col width="90" />
- <col width="120" />
- <col width="120" />
- <col width="200" />
- <col width="300" />
- <col width="100" />
- </colgroup>
- <tr>
- <th>卷袋序号</th>
- <th>印刷份数</th>
- <th>备份数量</th>
- <th>印刷室</th>
- <th>班级</th>
- <th>操作</th>
- </tr>
- <tr>
- <td>1</td>
- <td>
- <el-input-number
- v-model="modalForm.totalSubjects"
- class="width-full"
- :min="1"
- :max="999999"
- :step="1"
- step-strictly
- :controls="false"
- :disabled="IS_REBUILD || !editable"
- ></el-input-number>
- </td>
- <td>
- <el-input-number
- v-model="modalForm.backupCount"
- class="width-full"
- :min="infoExamPrintPlan.backupCount"
- :max="999999"
- :step="1"
- step-strictly
- :controls="false"
- :disabled="!editable"
- ></el-input-number>
- </td>
- <td>
- <el-select
- v-model="modalForm.printHouseId"
- placeholder="请选择"
- class="width-full"
- filterable
- :disabled="!editable"
- >
- <el-option
- v-for="room in printHouses"
- :key="room.printHouseId"
- :value="room.printHouseId"
- :label="room.printHouseName"
- ></el-option>
- </el-select>
- </td>
- <td>
- {{ modalForm.className }}
- </td>
- <td>
- <el-button
- class="btn-primary"
- type="text"
- @click="toViewModel2Student"
- >查看考生</el-button
- >
- </td>
- </tr>
- </table>
- </div>
- <div v-else class="part-box">
- <div class="box-justify mb-2">
- <div>
- <p>
- 每个卷袋包含一个考场全部文件(试卷、题卡、卷袋贴、签到表等文件)
- </p>
- <p>
- 共{{ packageInfos.packageCount }}个卷袋,{{
- packageInfos.studentCount
- }}个考生,共印试卷{{ packageInfos.paperCount }}份(正式{{
- packageInfos.paperReleaseCount
- }}份,备用{{ packageInfos.paperBackupCount }}份)
- </p>
- </div>
- <div>
- <el-button
- v-if="
- checkPrivilege(
- 'button',
- 'ExamTaskStudentObject',
- 'TaskApplyManage'
- ) && editable
- "
- type="primary"
- @click="toAdd"
- >新增考试对象</el-button
- >
- </div>
- </div>
- <el-form label-width="90px">
- <el-form-item label="考试时间:">
- <one-date-time-range
- :start-date-time.sync="taskModel.examStartTime"
- :end-date-time.sync="taskModel.examEndTime"
- :disabled="!editable"
- @change="timeChange"
- >
- </one-date-time-range>
- </el-form-item>
- <el-form-item label="印刷室:">
- <el-select
- v-model="taskModel.printHouseId"
- placeholder="请选择"
- filterable
- :disabled="!editable"
- @change="printHouseChange"
- >
- <el-option
- v-for="room in printHouses"
- :key="room.printHouseId"
- :value="room.printHouseId"
- :label="room.printHouseName"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <el-table ref="TableList" :data="tableData" border>
- <el-table-column type="index" width="80" label="卷袋序号">
- </el-table-column>
- <el-table-column prop="className" label="考试对象" width="160">
- </el-table-column>
- <el-table-column prop="studentCount" label="人数" width="60">
- </el-table-column>
- <el-table-column prop="backupCount" label="备份数量" width="90">
- <template slot-scope="scope">
- <el-input-number
- v-model="scope.row.backupCount"
- style="width: 60px"
- :min="scope.row.minBackupCount"
- :max="99999"
- :step="1"
- step-strictly
- :controls="false"
- :disabled="!editable"
- @change="backupCountChange"
- ></el-input-number>
- </template>
- </el-table-column>
- <el-table-column label="考试时间" width="180">
- <template slot-scope="scope">
- <template>
- {{ scope.row.examDate }} {{ scope.row.examTime }}
- </template>
- </template>
- </el-table-column>
- <el-table-column prop="examPlace" label="校区(考点)" width="140">
- <template slot-scope="scope">
- <el-input
- v-model.trim="scope.row.examPlace"
- :maxlength="20"
- clearable
- :disabled="!editable"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column prop="examRoom" label="考试教室(考场)" width="140">
- <template slot-scope="scope">
- <el-input
- v-model.trim="scope.row.examRoom"
- :maxlength="20"
- clearable
- :disabled="!editable"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column prop="printHouseName" label="印刷室" width="140">
- </el-table-column>
- <el-table-column
- label="操作"
- width="120"
- class-name="action-column"
- align="center"
- fixed="right"
- >
- <template slot-scope="scope">
- <el-button
- v-if="editable"
- class="btn-danger"
- type="text"
- @click="toDelete(scope.$index)"
- >取消</el-button
- >
- <el-button
- class="btn-primary"
- type="text"
- @click="toViewStudent(scope.row)"
- >查看考生</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- ModifyExamTaskStudent -->
- <modify-exam-task-student
- v-if="editable"
- ref="ModifyExamTaskStudent"
- :disabled-ids="disabledStudentIds"
- :filter-params="{
- courseId: infoExamTask.courseId,
- examId: infoExamTask.examId,
- teachingRoomId: infoExamTask.teachingRoomId,
- }"
- :show-student="showStudent"
- :selected-ids="IS_MODEL2 || IS_REBUILD ? model2ClassList : null"
- @modified="examStudentModified"
- ></modify-exam-task-student>
- <!-- PreviewTaskStudent -->
- <preview-task-student
- ref="PreviewTaskStudent"
- :student-list="examStudentList"
- :editable="!showStudent && editable"
- @close="previewStudentClosed"
- ></preview-task-student>
- </div>
- </template>
- <script>
- import { mapState } from "vuex";
- import { calcSum, getExamDateTime, getTimeDatestamp } from "@/plugins/utils";
- import { listTaskPrintHouse } from "../../api";
- import { examConfigByExamIdOrgId } from "../../../base/api";
- import ModifyExamTaskStudent from "../createExamAndPrintTask/ModifyExamTaskStudent.vue";
- import PreviewTaskStudent from "../createExamAndPrintTask/PreviewTaskStudent.vue";
- import OneDateTimeRange from "@/components/OneDateTimeRange.vue";
- const initModalForm = {
- paperNumber: "",
- courseName: "",
- courseCode: "",
- courseId: "",
- totalSubjects: 1,
- printHouseId: "",
- backupCount: null,
- className: "",
- basicStudentIds: [],
- };
- export default {
- name: "task-print",
- components: { ModifyExamTaskStudent, PreviewTaskStudent, OneDateTimeRange },
- data() {
- return {
- modalForm: {
- ...initModalForm,
- },
- tableData: [],
- model2ClassList: [],
- model2Students: [],
- curRow: {},
- printHouses: [],
- packageInfos: {
- packageCount: 0,
- studentCount: 0,
- paperCount: 0,
- paperReleaseCount: 0,
- paperBackupCount: 0,
- },
- selectedStudentIds: [],
- disabledStudentIds: [],
- examStudentList: [],
- showStudent: false,
- curCreateTime: [],
- defaultTime: "",
- taskModel: { examStartTime: null, examEndTime: null, printHouseId: "" },
- curHouse: null,
- // exam task content
- infoExamTask: {},
- infoExamTaskDetail: [],
- infoExamPrintPlan: {},
- infoPrintTask: {},
- };
- },
- computed: {
- ...mapState("exam", ["editType", "examTask", "curTaskApply", "taskStatus"]),
- IS_MODEL2() {
- return this.examTask.examModel === "MODEL2";
- },
- IS_REBUILD() {
- return this.examTask.category === "REBUILD";
- },
- editable() {
- return this.taskStatus.IS_APPLY;
- },
- },
- mounted() {
- const curDate = getTimeDatestamp(Date.now());
- const hour = 60 * 60 * 1000;
- this.curCreateTime = [curDate + 8 * hour, curDate + 10 * hour];
- this.defaultTime = curDate;
- this.initData();
- },
- methods: {
- async getPrintHouses() {
- this.printHouses = await listTaskPrintHouse();
- if (this.printHouses.length === 1) {
- this.curHouse = this.printHouses[0];
- this.taskModel.printHouseId = this.curHouse.printHouseId;
- }
- },
- async getInfoPrintTask() {
- const orgInfo = this.$ls.get("user", { orgInfo: {} }).orgInfo;
- const examPrintPlan = await examConfigByExamIdOrgId({
- examId: this.examTask.examId,
- orgId: orgInfo.id,
- });
- this.infoExamPrintPlan = examPrintPlan || {};
- },
- async initData() {
- await this.getPrintHouses();
- await this.getInfoPrintTask();
- if (!this.curTaskApply.examTaskContent) return;
- const { examTask, examTaskDetailList, examDetail } = JSON.parse(
- this.curTaskApply.examTaskContent
- );
- this.infoExamTask = examTask;
- this.infoExamTaskDetail = examTaskDetailList;
- this.infoPrintTask = examDetail;
- this.modalForm = this.$objAssign(initModalForm, this.infoPrintTask);
- if (this.IS_MODEL2 || this.IS_REBUILD) {
- this.model2ClassList = this.infoPrintTask.className.split(",");
- this.model2Students = this.infoPrintTask.model2Students || [];
- return;
- }
- this.tableData = this.infoPrintTask.list;
- this.updatePackageInfos();
- // 数据复现
- if (this.tableData.length) {
- const row = this.tableData[0];
- this.taskModel.printHouseId = row.printHouseId;
- this.taskModel.examStartTime = row.examStartTime;
- this.taskModel.examEndTime = row.examEndTime;
- this.curHouse = this.printHouses.find(
- (item) => item.printHouseId === this.taskModel.printHouseId
- );
- }
- },
- updatePackageInfos() {
- this.packageInfos.packageCount = this.tableData.length;
- this.packageInfos.studentCount = calcSum(
- this.tableData.map((item) => item.studentCount)
- );
- this.packageInfos.paperReleaseCount = this.packageInfos.studentCount;
- this.packageInfos.paperBackupCount = calcSum(
- this.tableData.map((item) => item.backupCount || 0)
- );
- this.packageInfos.paperCount =
- this.packageInfos.paperReleaseCount +
- this.packageInfos.paperBackupCount;
- },
- getBackupCount(studentCount) {
- const { backupCount } = this.infoExamPrintPlan;
- if (backupCount < 1) {
- const count = Math.ceil(backupCount * studentCount);
- return { backupCount: count, minBackupCount: count };
- }
- return { backupCount, minBackupCount: backupCount };
- },
- timeChange() {
- this.tableData.forEach((row) => {
- if (!this.taskModel.examStartTime || !this.taskModel.examEndTime) {
- row.examDate = "";
- row.examTime = "";
- return;
- }
- Object.assign(
- row,
- getExamDateTime(
- this.taskModel.examStartTime,
- this.taskModel.examEndTime
- )
- );
- });
- },
- backupCountChange() {
- this.updatePackageInfos();
- },
- printHouseChange() {
- this.curHouse = this.printHouses.find(
- (item) => item.printHouseId === this.taskModel.printHouseId
- );
- this.tableData.forEach((row) => {
- row.printHouseId = this.curHouse?.printHouseId;
- row.printHouseName = this.curHouse?.printHouseName;
- });
- },
- toAdd() {
- if (!this.infoExamTask.courseId) {
- this.$message.error("请先选择课程");
- return;
- }
- this.disabledStudentIds = this.getTabelStudentIds();
- this.showStudent =
- this.checkPrivilege("button", "SelectStudent") &&
- this.infoExamTask.examModel !== "MODEL1";
- this.$refs.ModifyExamTaskStudent.open();
- },
- getTabelStudentIds() {
- return this.tableData
- .map((item) => {
- return item.examTaskStudentObjectParamList.map((elem) => elem.id);
- })
- .flat();
- },
- getInitTableRow() {
- let modalFormData = { ...this.modalForm };
- delete modalFormData.printHouseId;
- let data = {
- id: this.$randomCode(),
- groupName: "",
- examPlace: "",
- examRoom: "",
- examStartTime: "",
- examEndTime: "",
- examDate: "",
- examTime: "",
- examSetDate: [],
- className: "",
- studentCount: "",
- printHouseId: "",
- printHouseName: "",
- backupCount: 0,
- minBackupCount: 0,
- isSelectStudent: true,
- examTaskStudentObjectParamList: [],
- classNames: [],
- ...modalFormData,
- };
- return data;
- },
- examStudentModified({ selectedStudents }) {
- if (this.IS_MODEL2 || this.IS_REBUILD) {
- this.model2ClassList = selectedStudents.map((item) => item.label);
- this.modalForm.className = this.model2ClassList.join();
- this.model2Students = selectedStudents
- .map((item) => item.children)
- .flat()
- .map((item) => {
- return { ...item, enable: true };
- });
- this.modalForm.basicStudentIds = this.model2Students.map(
- (item) => item.id
- );
- this.modalForm.totalSubjects = this.model2Students.length;
- return;
- }
- this.updateTableData(selectedStudents);
- this.updatePackageInfos();
- },
- updateTableData(selectedStudents) {
- const groupMap = {};
- selectedStudents.forEach((item) => {
- item.children.forEach((student) => {
- const { examRoom, examPlace, examStartTime, examEndTime } = student;
- const groupName = `${examRoom}_${examPlace}_${examStartTime}_${examEndTime}`;
- if (!groupMap[groupName]) {
- groupMap[groupName] = {
- examTaskStudentObjectParamList: [],
- classNames: [],
- examRoom,
- examPlace,
- examStartTime,
- examEndTime,
- groupName,
- };
- }
- // TODO:可能需要简化一下学生信息
- groupMap[groupName].examTaskStudentObjectParamList.push({
- ...student,
- enable: true,
- });
- if (!groupMap[groupName].classNames.includes(item.label)) {
- groupMap[groupName].classNames.push(item.label);
- }
- });
- });
- const tableGroupNames = this.tableData.map((item) => {
- const { examRoom, examPlace, examStartTime, examEndTime } = item;
- return `${examRoom}_${examPlace}_${examStartTime}_${examEndTime}`;
- });
- Object.keys(groupMap).forEach((groupName) => {
- const data = groupMap[groupName];
- const ind = tableGroupNames.indexOf(groupName);
- if (ind !== -1) {
- this.tableData[ind].examTaskStudentObjectParamList.push(
- ...data.examTaskStudentObjectParamList
- );
- const classNameSet = new Set([
- ...this.tableData[ind].classNames,
- ...data.classNames,
- ]);
- const studentCount =
- this.tableData[ind].examTaskStudentObjectParamList.length;
- this.tableData[ind].studentCount = studentCount;
- this.tableData[ind].classNames = Array.from(classNameSet);
- this.tableData[ind].className = this.tableData[ind].classNames.join();
- Object.assign(this.tableData[ind], this.getBackupCount(studentCount));
- return;
- }
- const times =
- data.examStartTime && data.examEndTime
- ? getExamDateTime(data.examStartTime, data.examEndTime)
- : { examSetDate: [...this.curCreateTime] };
- const tableRow = this.$objAssign(this.getInitTableRow(), {
- ...data,
- ...times,
- ...this.getBackupCount(data.examTaskStudentObjectParamList.length),
- className: data.classNames.join(),
- studentCount: data.examTaskStudentObjectParamList.length,
- });
- this.tableData.push(tableRow);
- });
- // 更新考试时间和印刷室
- this.printHouseChange();
- this.timeChange();
- },
- toDelete(index) {
- this.tableData.splice(index, 1);
- this.updatePackageInfos();
- },
- toViewStudent(row) {
- // console.log(row);
- this.curRow = row;
- this.examStudentList = row.examTaskStudentObjectParamList;
- this.$refs.PreviewTaskStudent.open();
- },
- toViewModel2Student() {
- this.examStudentList = this.model2Students;
- this.$refs.PreviewTaskStudent.open();
- },
- previewStudentClosed() {
- const students = this.examStudentList.filter((item) => item.enable);
- const studentCount = students.length;
- if (this.IS_MODEL2 || this.IS_REBUILD) {
- this.modalForm.totalSubjects = studentCount;
- this.modalForm.basicStudentIds = students.map((item) => item.id);
- return;
- }
- Object.assign(this.curRow, {
- ...this.getBackupCount(studentCount),
- studentCount,
- });
- },
- // model2 select class
- toSelectClass() {
- if (!this.infoExamTask.courseId) {
- this.$message.error("请先选择课程");
- return;
- }
- this.disabledStudentIds = [];
- this.showStudent = false;
- this.$refs.ModifyExamTaskStudent.open();
- },
- // action
- getData(examTaskData) {
- const tableData = this.tableData.map((row) => {
- const nrow = { ...row };
- nrow.examTaskStudentObjectParamListIds =
- row.examTaskStudentObjectParamList
- .filter((item) => item.enable)
- .map((item) => item.id);
- return nrow;
- });
- this.infoPrintTask = {
- ...this.modalForm,
- model2Students: this.model2Students,
- list: tableData,
- };
- this.infoExamTaskDetail = examTaskData.examTaskDetailList;
- const examTaskContent = {
- examTask: this.infoExamTask,
- examTaskDetail: this.infoExamTaskDetail,
- examDetail: this.infoPrintTask,
- };
- examTaskContent.examTask.examStartTime = this.infoPrintTask.examStartTime;
- examTaskContent.examTask.examEndTime = this.infoPrintTask.examEndTime;
- return examTaskContent;
- },
- checkData() {
- if (this.IS_MODEL2 || this.IS_REBUILD) {
- if (!this.modalForm.totalSubjects) {
- this.$message.error("请输入印刷份数!");
- return;
- }
- if (!this.modalForm.printHouseId) {
- this.$message.error("请选择印刷室!");
- return;
- }
- if (!this.modalForm.className) {
- this.$message.error("请选择班级!");
- return;
- }
- return true;
- }
- if (!this.tableData.length) {
- this.$message.error("请添加考试对象!");
- return;
- }
- const errorMsg = [];
- this.tableData.forEach((row) => {
- const errorFields = [];
- if (!row.examStartTime || !row.examEndTime) {
- errorFields.push("考试时间");
- }
- if (!row.backupCount) {
- errorFields.push("备份数量");
- }
- if (!row.examPlace) {
- errorFields.push("校区(考点)");
- }
- if (!row.examRoom) {
- errorFields.push("考试教室(考场)");
- }
- if (!row.printHouseId) {
- errorFields.push("印刷室");
- }
- if (errorFields.length) {
- errorMsg.push(
- `考试对象${row.className}中,${errorFields.join("、")}必须填写`
- );
- }
- });
- if (errorMsg.length) {
- this.$message.error(errorMsg.join("。"));
- return;
- }
- return true;
- },
- },
- };
- </script>
|