123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <template>
- <el-dialog
- class="modify-plan-paper"
- :visible.sync="modalIsShow"
- title="关联试卷"
- top="10px"
- width="900px"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- append-to-body
- @open="visibleChange"
- >
- <div class="part-box part-box-pad part-box-border">
- <el-form
- class="form-info"
- ref="modalFormComp"
- label-width="130px"
- :rules="rules"
- :model="modalForm"
- >
- <el-row>
- <el-col :span="12">
- <el-form-item label="课程(代码):">
- <span
- >{{ instance.courseName }}({{ instance.courseCode }})</span
- >
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <!-- <el-form-item label="适用专业(方向):">
- <span>{{ instance.specialty | defaultFieldFilter }}</span>
- </el-form-item> -->
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="题卡规则:">
- <span>{{ instance.cardRuleName }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="命题老师:">
- <span>{{ instance.userName }}</span>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row class="mb-2">
- <el-col :span="12">
- <el-form-item prop="paperNumber" label="试卷编号:">
- <el-select
- v-model="modalForm.paperNumber"
- placeholder="请选择"
- filterable
- @change="paperChange"
- >
- <el-option
- v-for="item in papers"
- :key="item.id"
- :value="item.paperNumber"
- :label="item.paperNumber"
- ></el-option>
- </el-select>
- <!-- <span>{{ instance.paperNumber }}</span> -->
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item prop="relatePaperType" label="关联类型:">
- <el-select
- v-model="modalForm.relatePaperType"
- placeholder="请选择"
- multiple
- :multiple-limit="drawCount"
- >
- <el-option
- v-for="item in paperTypes"
- :key="item"
- :value="item"
- :label="item"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="已曝光类型:">
- <span>{{ instance.exposedPaperType | defaultFieldFilter }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="未曝光类型:">
- <span>{{
- instance.unexposedPaperType | defaultFieldFilter
- }}</span>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <h4 class="part-box-tips">试卷内容:</h4>
- <p class="tips-info tips-dark mb-2">
- 提示:多卷型试卷由于会绑定一个答题卡模板,因此试卷结构必须相同。多卷型试卷之间客观题要求试题内容相同,可允许大题内的小题题序不同。
- </p>
- <table class="table">
- <tr>
- <th>卷型</th>
- <th>试卷</th>
- <th>答题卡</th>
- </tr>
- <tr v-for="(attachment, index) in paperAttachments" :key="index">
- <td>{{ attachment.name }}卷</td>
- <td>
- <el-button
- type="text"
- class="btn-primary"
- @click="downloadPaper(attachment)"
- title="点击查看试卷"
- >
- <i
- class="icon icon-download mr-1"
- v-if="attachment.attachmentId"
- ></i
- >{{ attachment.filename }}
- </el-button>
- </td>
- <td>
- <el-button
- type="text"
- class="btn-primary"
- @click="toViewCard(attachment)"
- >查看答题卡</el-button
- >
- </td>
- </tr>
- </table>
- <div slot="footer">
- <el-button type="primary" :disabled="isSubmit" @click="submit"
- >确认</el-button
- >
- <el-button @click="cancel">取消</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { updatePlanLinkPaper, linkPaperNumberList } from "../api";
- import { taskApplyDetail } from "../../exam/api";
- import { attachmentPreview } from "../../login/api";
- const initModalForm = {
- id: null,
- examId: null,
- paperNumber: "",
- relatePaperType: [],
- };
- export default {
- name: "modify-plan-paper",
- props: {
- instance: {
- type: Object,
- default() {
- return {};
- },
- },
- },
- data() {
- return {
- modalIsShow: false,
- isSubmit: false,
- modalForm: { ...initModalForm },
- papers: [],
- paperTypes: [],
- paperAttachments: [],
- drawCount: 0,
- cardId: "",
- rules: {
- paperNumber: [
- {
- required: true,
- message: "请选择试卷编号",
- trigger: "change",
- },
- ],
- relatePaperType: [
- {
- required: true,
- validator: (rule, value, callback) => {
- if (
- value.length < this.drawCount ||
- value.length > this.drawCount
- ) {
- return callback(
- new Error(`需要选择${this.drawCount}套关联试卷`)
- );
- }
- callback();
- },
- trigger: "change",
- },
- ],
- },
- };
- },
- methods: {
- async getAttachments() {
- const data = await taskApplyDetail(this.instance.id);
- this.paperAttachments = data.paperAttachmentIds
- ? JSON.parse(data.paperAttachmentIds)
- : [];
- this.cardId = data.cardId;
- this.drawCount = data.drawCount;
- },
- // async getPaperTypes() {
- // const papers = await linkPaperNumberList({
- // examTaskId: this.instance.id,
- // printPlanId: this.instance.printPlanId
- // });
- // if (papers && papers[0]) this.paperTypes = papers[0].paperTypes;
- // },
- async getPapers() {
- this.papers = await linkPaperNumberList({
- examTaskId: this.instance.id,
- printPlanId: this.instance.printPlanId,
- courseCode: this.instance.courseCode,
- });
- const paper = this.papers.find(
- (item) => item.paperNumber === this.modalForm.paperNumber
- );
- if (paper) this.paperTypes = paper.paperTypes;
- },
- visibleChange() {
- this.modalForm = this.$objAssign(initModalForm, this.instance);
- this.modalForm.relatePaperType = this.instance.relatePaperType
- ? this.instance.relatePaperType.split(",")
- : [];
- this.getPapers();
- // this.getPaperTypes();
- this.getAttachments();
- this.$nextTick(() => {
- this.$refs.modalFormComp.clearValidate();
- });
- },
- cancel() {
- this.modalIsShow = false;
- },
- open() {
- this.modalIsShow = true;
- },
- paperChange() {
- this.modalForm.relatePaperType = [];
- this.paperTypes = [];
- const paper = this.papers.find(
- (item) => item.paperNumber === this.modalForm.paperNumber
- );
- if (paper) this.paperTypes = paper.paperTypes;
- },
- async downloadPaper(attachment) {
- const data = await attachmentPreview(attachment.attachmentId);
- window.open(data.url);
- },
- toViewCard(attachment) {
- window.open(
- this.getRouterPath({
- name: "CardPreview",
- params: {
- cardId: attachment.cardId,
- viewType: "view",
- },
- })
- );
- },
- async submit() {
- const valid = await this.$refs.modalFormComp.validate().catch(() => {});
- if (!valid) return;
- if (this.isSubmit) return;
- this.isSubmit = true;
- const datas = {
- examTaskId: this.modalForm.id,
- examId: this.modalForm.examId,
- relatePaperType: this.modalForm.relatePaperType.join(),
- paperNumber: this.modalForm.paperNumber,
- printPlanId: this.instance.printPlanId,
- examDetailCourseIds: this.instance.examDetailCourseIds,
- };
- const data = await updatePlanLinkPaper(datas).catch(() => {});
- this.isSubmit = false;
- if (!data) return;
- this.$message.success("保存成功!");
- this.$emit("modified");
- this.cancel();
- },
- },
- };
- </script>
|