1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141 |
- <template>
- <div>
- <el-form v-if="checkPrivilege('button', 'OpenAb', 'TaskApplyManage')">
- <el-form-item label="启用AB卷:">
- <el-switch
- v-model="openAb"
- :disabled="!taskStatus.IS_APPLY"
- @change="openAbChange"
- ></el-switch>
- </el-form-item>
- </el-form>
- <!-- menu -->
- <div
- v-if="checkPrivilege('button', 'SelectTikuPaper', 'TaskApplyManage')"
- class="mb-4 tab-btns"
- >
- <el-button
- v-for="tab in tabs"
- :key="tab.val"
- size="medium"
- :type="curTab == tab.val ? 'primary' : 'default'"
- @click="selectMenu(tab.val)"
- >{{ tab.name }}
- </el-button>
- </div>
- <!-- table -->
- <table class="table mb-2">
- <colgroup>
- <col width="80" />
- <col width="60" />
- <col width="200" />
- <col />
- <col v-if="taskStatus.IS_APPLY && !taskStatus.IS_REBUILD" width="80" />
- </colgroup>
- <tr>
- <th>备用卷</th>
- <th>卷型</th>
- <th>试卷文件</th>
- <th>
- 答题卡
- <span v-if="examTaskInstr" class="tips-markedness">
- ({{ examTaskInstr }})
- </span>
- </th>
- <th v-if="taskStatus.IS_APPLY && !taskStatus.IS_REBUILD">操作</th>
- </tr>
- <template v-for="(paperAttachment, pindex) in paperAttachments">
- <tr
- v-for="(attachment, index) in paperAttachment.paperAttachmentIds"
- :key="`${pindex}-${index}`"
- >
- <td
- v-if="index === 0"
- :rowspan="paperAttachment.paperAttachmentIds.length"
- >
- 卷{{ paperAttachment.serialNumber }}
- <span class="color-gray-2" v-if="paperAttachment.exposed"
- >(已曝光)</span
- >
- </td>
- <td>
- <span>{{ attachment.name }}</span>
- </td>
- <template v-if="IS_TIKU_TAB">
- <!-- 试卷文件 -->
- <td>
- <template v-if="!paperAttachment.exposed && taskStatus.IS_APPLY">
- <div class="box-justify">
- <el-button
- type="text"
- class="btn-primary box-grow"
- @click="toSelect(attachment)"
- >
- <i
- :class="[
- 'icon',
- attachment.attachmentId
- ? 'icon-files-act'
- : 'icon-files',
- ]"
- ></i
- >{{ attachment.filename || "选择试卷" }}
- </el-button>
- <el-button
- type="text"
- class="btn-primary box-static"
- :disabled="!attachment.paperUrl"
- @click="toViewPaper(attachment)"
- >预览</el-button
- >
- </div>
- </template>
- <el-button
- v-else
- type="text"
- class="btn-primary"
- @click="downloadPaper(attachment)"
- >
- <div
- :class="{
- 'color-primary':
- auditLogCache.paper[attachment.attachmentId],
- }"
- >
- <i
- class="icon icon-download mr-1"
- v-if="attachment.attachmentId"
- ></i>
- {{ attachment.filename }}
- </div>
- </el-button>
- </td>
- <!-- 答题卡 -->
- <td
- v-if="index === 0"
- :rowspan="paperAttachment.paperAttachmentIds.length"
- >
- <template v-if="taskStatus.IS_APPLY">
- <el-select
- v-model="attachment.cardId"
- placeholder="请选择"
- style="width: 260px; margin-right: 10px"
- @change="(val) => tkCardChange(val, attachment)"
- >
- <el-option
- v-for="item in attachment.cards"
- :key="item.id"
- :value="item.id"
- :label="item.title"
- >
- <div class="box-justify">
- <div class="box-grow">{{ item.title }}</div>
- <el-button
- class="btn-danger btn-icon box-static"
- type="text"
- icon="el-icon-remove"
- @click="toDeleteCard(item, attachment)"
- ></el-button>
- </div>
- </el-option>
- </el-select>
- <el-button
- class="btn-primary"
- type="text"
- :disabled="!attachment.cardId"
- @click="toViewCard(attachment)"
- >预览</el-button
- >
- <el-button
- v-if="!taskStatus.IS_REBUILD"
- class="btn-primary"
- type="text"
- :disabled="!attachment.cardId"
- @click="toEditCard(attachment)"
- >编辑</el-button
- >
- </template>
- <el-button
- v-else
- type="text"
- class="btn-primary"
- @click="toViewCard(attachment)"
- ><i
- :class="{
- 'color-primary': auditLogCache.card[attachment.cardId],
- }"
- >{{ attachment.cardTitle || "预览" }}</i
- ></el-button
- >
- </td>
- </template>
- <template v-else>
- <!-- 试卷文件 -->
- <td>
- <el-button
- v-if="!paperAttachment.exposed && taskStatus.IS_APPLY"
- type="text"
- class="btn-primary"
- @click="toUpload(attachment)"
- >
- <i
- :class="[
- 'icon',
- attachment.attachmentId ? 'icon-files-act' : 'icon-files',
- ]"
- ></i
- >{{
- attachment.attachmentId
- ? attachment.filename
- : "点击上传试卷文件"
- }}
- </el-button>
- <el-button
- v-else
- type="text"
- class="btn-primary"
- @click="downloadPaper(attachment)"
- >
- <div
- :class="{
- 'color-primary':
- auditLogCache.paper[attachment.attachmentId],
- }"
- >
- <i
- class="icon icon-download mr-1"
- v-if="attachment.attachmentId"
- ></i>
- {{ attachment.filename }}
- </div>
- </el-button>
- </td>
- <!-- 答题卡 -->
- <td
- v-if="index === 0"
- :rowspan="paperAttachment.paperAttachmentIds.length"
- >
- <template v-if="taskStatus.IS_APPLY">
- <el-select
- class="mr-2"
- v-model="attachment.cardId"
- placeholder="请选择"
- style="width: 200px"
- filterable
- @change="cardChange(attachment)"
- >
- <el-option
- v-for="item in cards"
- :key="item.id"
- :value="item.id"
- :label="item.title"
- :disabled="item.disabled"
- >
- <div class="box-justify">
- <div class="box-grow">
- <span
- :class="[
- item.type === 'GENERIC'
- ? 'color-success'
- : 'color-primary',
- 'mr-1',
- {
- 'color-danger': item.used,
- },
- ]"
- >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
- >
- {{ item.title }}
- </div>
- <el-button
- v-if="item.type !== 'GENERIC'"
- class="btn-danger btn-icon box-static"
- type="text"
- icon="el-icon-remove"
- @click="toDeleteCard(item, attachment)"
- ></el-button>
- </div>
- </el-option>
- </el-select>
- <span
- v-if="attachment.cardId"
- :class="[
- attachment.cardType === 'GENERIC'
- ? 'color-success'
- : 'color-primary',
- 'mr-1',
- {
- 'color-danger': attachment.used,
- },
- ]"
- >[{{ attachment.cardType === "GENERIC" ? "通" : "专" }}]</span
- >
- <el-button
- class="btn-primary"
- type="text"
- :disabled="!attachment.cardId"
- @click="toViewCard(attachment)"
- >预览</el-button
- >
- <template v-if="!taskStatus.IS_REBUILD">
- <el-button
- class="btn-primary"
- type="text"
- :disabled="
- !attachment.cardId ||
- (attachment.cardType === 'GENERIC' &&
- attachment.createMethod !== 'STANDARD')
- "
- @click="toCopyCard(attachment)"
- >复制</el-button
- >
- <el-button
- class="btn-primary"
- type="text"
- :disabled="
- !attachment.cardId ||
- attachment.cardType === 'GENERIC' ||
- (attachment.cardId !== attachment.originCardId &&
- attachment.used)
- "
- @click="toEditCard(attachment)"
- >编辑</el-button
- >
- <el-button
- class="btn-primary"
- type="text"
- :disabled="!taskStatus.CAN_CREATE_CARD"
- @click="toCreateCard(attachment)"
- >新建</el-button
- >
- </template>
- </template>
- <el-button
- v-else
- type="text"
- class="btn-primary"
- @click="toViewCard(attachment)"
- >
- <i
- :class="{
- 'color-primary': auditLogCache.card[attachment.cardId],
- }"
- >
- {{ attachment.cardTitle || "预览" }}
- </i>
- </el-button>
- </td>
- </template>
- <!-- 操作 -->
- <td
- v-if="taskStatus.IS_APPLY && !taskStatus.IS_REBUILD && index === 0"
- :rowspan="paperAttachment.paperAttachmentIds.length"
- class="text-right"
- >
- <el-button
- v-if="index === paperAttachments.length - 1"
- class="btn-primary btn-icon"
- type="text"
- icon="el-icon-circle-plus"
- @click="addAtachment"
- ></el-button>
- <el-button
- v-if="!paperAttachment.exposed"
- class="btn-danger btn-icon"
- type="text"
- icon="el-icon-remove"
- @click="deleteAttachment(index)"
- ></el-button>
- </td>
- </tr>
- </template>
- <tr v-if="!paperAttachments.length">
- <td colspan="5">
- <p class="tips-info text-center">暂无数据</p>
- </td>
- </tr>
- </table>
- <!-- 附件 -->
- <h4 class="mb-2">
- 附件<span v-if="taskStatus.IS_APPLY"
- >(最多4个,仅限{{ attachmentFormat.join("、") }}文件)</span
- >:
- </h4>
- <div>
- <div
- v-for="(item, index) in imageAttachments"
- :key="`image${index}`"
- class="image-item"
- >
- <img
- :src="item.url"
- :alt="item.filename"
- title="点击查看大图"
- @click="toPreview(index)"
- />
- <div v-if="taskStatus.IS_APPLY" class="image-delete">
- <i
- class="el-icon-delete-solid"
- @click="deletePaperConfirmAttachment(item)"
- ></i>
- </div>
- </div>
- <div
- v-if="paperConfirmAttachments.length < 4 && taskStatus.IS_APPLY"
- class="image-item image-add"
- title="上传附件"
- @click="toUploadPaperConfirm"
- >
- <i class="el-icon-plus"></i>
- </div>
- <div
- class="audio-item"
- v-for="(item, index) in audioAttachments"
- :key="`audio${index}`"
- >
- <audio :src="item.url" :alt="item.filename" controls></audio>
- <div v-if="taskStatus.IS_APPLY" class="audio-delete">
- <i
- class="el-icon-delete-solid"
- @click="deletePaperConfirmAttachment(item)"
- ></i>
- </div>
- </div>
- </div>
- <div
- v-if="!taskStatus.IS_APPLY && !paperConfirmAttachments.length"
- class="image-list-none"
- >
- 暂无数据
- </div>
- <!-- 附件说明 -->
- <h4 class="mb-2">附件说明:</h4>
- <el-input
- v-if="taskStatus.IS_APPLY"
- class="mb-2"
- v-model="curTaskApply.remark"
- type="textarea"
- resize="none"
- :rows="2"
- :maxlength="100"
- clearable
- show-word-limit
- placeholder="建议不超过100个字"
- ></el-input>
- <div class="color-gray-2" v-else>
- <p v-if="curTaskApply.remark">{{ curTaskApply.remark }}</p>
- <p v-else>暂无</p>
- </div>
- <template v-if="taskStatus.IS_APPLY">
- <!-- upload-paper-dialog -->
- <upload-paper-dialog
- :paper-attachment="curAttachment"
- :upload-type="curUploadType"
- @confirm="uploadConfirm"
- ref="UploadPaperDialog"
- ></upload-paper-dialog>
- <!-- ModifyCard -->
- <modify-card ref="ModifyCard" @modified="cardModified"></modify-card>
- <!-- SelectTikuPaperDialog -->
- <select-tiku-paper-dialog
- ref="SelectTikuPaperDialog"
- :row="curAttachment"
- @confirm="tikuPaperSelected"
- ></select-tiku-paper-dialog>
- <!-- CardBuildDialog -->
- <card-build-dialog
- ref="CardBuildDialog"
- :presetData="cardBuildPresetData"
- @confirm="cardBuildConfirm"
- ></card-build-dialog>
- </template>
- <!-- card-preview-dialog -->
- <card-preview-dialog
- ref="CardPreviewDialog"
- :card-id="curAttachment.cardId"
- show-watermark
- ></card-preview-dialog>
- <!-- image-preview -->
- <simple-image-preview
- :cur-image="curImage"
- @on-prev="toPrevImage"
- @on-next="toNextImage"
- ref="SimpleImagePreview"
- ></simple-image-preview>
- <!-- PreviewFile -->
- <preview-file ref="PreviewFile" :data="curFile"></preview-file>
- </div>
- </template>
- <script>
- import { mapState, mapMutations, mapActions } from "vuex";
- import { cardForSelectList } from "../../api";
- import { deleteCard } from "../../../base/api";
- import { copyCard } from "../../../card/api";
- import { deepCopy } from "@/plugins/utils";
- import UploadPaperDialog from "../UploadPaperDialog.vue";
- import SelectTikuPaperDialog from "../createExamAndPrintTask/SelectTikuPaperDialog.vue";
- import CardBuildDialog from "../../../card/components/CardBuildDialog.vue";
- import CardPreviewDialog from "../../../card/components/CardPreviewDialog.vue";
- import SimpleImagePreview from "../../../../components/SimpleImagePreview.vue";
- import PreviewFile from "../../../../components/PreviewFile.vue";
- import ModifyCard from "../../../card/components/ModifyCard.vue";
- export default {
- name: "task-paper",
- components: {
- UploadPaperDialog,
- SimpleImagePreview,
- PreviewFile,
- ModifyCard,
- CardBuildDialog,
- CardPreviewDialog,
- SelectTikuPaperDialog,
- },
- data() {
- return {
- tabs: [
- {
- name: "上传本地试卷",
- val: "upload",
- },
- {
- name: "从题库选择试卷",
- val: "tiku",
- },
- ],
- curTab: "upload",
- uuid: "",
- user: {},
- openAb: false,
- paperConfirmAttachmentId: {
- attachmentId: "",
- filename: "",
- url: "",
- fileType: "",
- },
- paperAttachments: [],
- paperConfirmAttachments: [],
- curAttachment: {},
- curUploadType: "paper",
- attachmentLimitCount: 26,
- abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
- cards: [],
- examTaskInstr: this.$ls.get("schoolInfo", { examTaskInstr: "" })
- .examTaskInstr,
- attachmentFormat: ["jpg", "png", "mp3"],
- // card-build
- cardBuildPresetData: {},
- // image-preview
- curImage: {},
- curImageIndex: 0,
- // preview file
- curFile: {
- url: "",
- type: "",
- },
- };
- },
- computed: {
- ...mapState("exam", [
- "editType",
- "examTask",
- "curTaskApply",
- "taskStatus",
- "auditLogCache",
- ]),
- IS_TIKU_TAB() {
- return this.curTab === "tiku";
- },
- imageAttachments() {
- return this.paperConfirmAttachments.filter(
- (item) => item.fileType === "image"
- );
- },
- audioAttachments() {
- return this.paperConfirmAttachments.filter(
- (item) => item.fileType === "audio"
- );
- },
- },
- mounted() {
- this.initData();
- },
- methods: {
- ...mapMutations("exam", ["setEditType", "setExamTask", "setCurTaskApply"]),
- ...mapActions("exam", ["addPreviewLog"]),
- initData() {
- this.user = this.$ls.get("user", {});
- this.paperAttachments = (this.curTaskApply.examTaskDetailList || []).map(
- (item) => {
- const paperAttachmentIds = item.paperAttachmentIds
- ? JSON.parse(item.paperAttachmentIds)
- : [];
- paperAttachmentIds.forEach((aitem) => {
- aitem.serialNumber = item.serialNumber;
- aitem.originCardId = aitem.cardId;
- });
- return {
- ...item,
- paperAttachmentIds,
- };
- }
- );
- this.openAb = this.examTask.openAb;
- if (!this.paperAttachments.length) {
- this.addAtachment();
- }
- const pAttachment = this.paperAttachments.some((item) =>
- item.paperAttachmentIds.some((p) => !!p.paperId)
- );
- if (pAttachment) {
- this.curTab = "tiku";
- this.uuid =
- this.paperAttachments[0]?.paperAttachmentIds[0]?.uuid ||
- this.$randomCode(32);
- } else {
- this.curTab = "upload";
- this.uuid = this.$randomCode(32);
- }
- this.paperConfirmAttachments = this.curTaskApply.paperConfirmAttachmentIds
- ? JSON.parse(this.curTaskApply.paperConfirmAttachmentIds)
- : [];
- if (this.taskStatus.IS_APPLY) this.getCardList();
- },
- openAbChange() {
- if (!this.taskStatus.IS_APPLY) return;
- if (this.openAb) {
- this.paperAttachments.forEach((paperAttachment) => {
- const attachment = paperAttachment.paperAttachmentIds[0];
- attachment.name = "A";
- paperAttachment.paperAttachmentIds.push(
- Object.assign(deepCopy(attachment), {
- name: "B",
- attachmentId: "",
- filename: "",
- paperId: null,
- paperUrl: null,
- pages: 0,
- })
- );
- });
- } else {
- this.paperAttachments.forEach((paperAttachment, index) => {
- paperAttachment.paperAttachmentIds =
- paperAttachment.paperAttachmentIds.slice(0, 1);
- paperAttachment.paperAttachmentIds[0].name = this.abc[index];
- });
- }
- this.setExamTask({ ...this.examTask, openAb: this.openAb });
- this.setCurTaskApply({ ...this.curTaskApply, openAb: this.openAb });
- },
- async selectMenu(tab) {
- if (!this.taskStatus.IS_APPLY) return;
- const attachment = this.paperAttachments[0].paperAttachmentIds[0];
- if (attachment.cardId || attachment.attachmentId) {
- const result = await this.$confirm(
- "更改类型会清空已设置数据,确定要更改类型?",
- "提示",
- {
- type: "warning",
- }
- ).catch(() => {});
- if (result !== "confirm") return;
- this.paperAttachments = [];
- this.addAtachment();
- }
- this.curTab = tab;
- },
- async getCardList() {
- if (!this.curTaskApply.courseId || !this.curTaskApply.examId) return;
- const data = await cardForSelectList({
- courseId: this.curTaskApply.courseId,
- examId: this.curTaskApply.examId,
- paperNumber: this.curTaskApply.paperNumber,
- });
- this.cards = data || [];
- if (this.taskStatus.IS_REBUILD) {
- this.cards = this.cards.filter((item) => item.type === "GENERIC");
- }
- },
- async getTkCardList(attachment) {
- if (
- !this.curTaskApply.courseId ||
- !this.curTaskApply.examId ||
- !attachment.paperId
- )
- return;
- const data = await cardForSelectList({
- courseId: this.curTaskApply.courseId,
- examId: this.curTaskApply.examId,
- paperId: attachment.paperId,
- });
- attachment.cards = (data || []).map((item) => {
- return {
- id: item.id,
- title: item.title,
- type: item.type,
- createId: item.createId,
- makeMethod: item.makeMethod,
- used: item.used,
- };
- });
- },
- getAttachmentPos(attachment) {
- const pindex = this.paperAttachments.findIndex(
- (item) => item.serialNumber === attachment.serialNumber
- );
- if (pindex === -1) return;
- const index = this.paperAttachments[pindex].paperAttachmentIds.findIndex(
- (item) => item.name === attachment.name
- );
- if (index === -1) return;
- return { pindex, index };
- },
- addAtachment() {
- const serialNumber = this.paperAttachments.length + 1;
- const newAttachment = {
- name: "A",
- serialNumber,
- attachmentId: "",
- filename: "",
- paperId: null,
- paperUrl: null,
- uuid: this.examTask.uuid,
- cardId: "",
- cardType: "",
- createMethod: "",
- cardTitle: "",
- pages: 0,
- used: false,
- createId: null,
- cards: [],
- };
- const paperAttachment = {
- serialNumber,
- paperType: "",
- paperAttachmentIds: [],
- };
- paperAttachment.paperAttachmentIds.push(newAttachment);
- if (this.openAb) {
- paperAttachment.paperAttachmentIds.push(
- Object.assign(deepCopy(newAttachment), { name: "B" })
- );
- } else {
- newAttachment.name = this.abc[serialNumber - 1];
- }
- this.paperAttachments.push(paperAttachment);
- },
- deleteAttachment(index) {
- if (this.paperAttachments.length <= 1) {
- this.$message.error("试卷类型数量不得少于1");
- return;
- }
- this.paperAttachments.splice(index, 1);
- this.paperAttachments.forEach((item, itemIndex) => {
- item.serialNumber = itemIndex + 1;
- item.paperAttachmentIds.forEach((attachment) => {
- attachment.serialNumber = item.serialNumber;
- if (!this.openAb) {
- attachment.name = this.abc[item.serialNumber - 1];
- }
- });
- });
- },
- toUpload(attachment) {
- this.curUploadType = "paper";
- this.curAttachment = {
- ...attachment,
- };
- this.$refs.UploadPaperDialog.open();
- },
- toUploadPaperConfirm() {
- if (this.paperConfirmAttachments.length >= 4) return;
- this.curUploadType = "paperConfirm";
- this.curAttachment = {
- ...this.paperConfirmAttachmentId,
- };
- this.$refs.UploadPaperDialog.open();
- },
- uploadConfirm(attachment, uploadType) {
- if (uploadType === "paper") {
- const pos = this.getAttachmentPos(attachment);
- if (!pos) return;
- this.paperAttachments[pos.pindex].paperAttachmentIds.splice(
- pos.index,
- 1,
- {
- ...attachment,
- }
- );
- } else {
- this.paperConfirmAttachments.push(attachment);
- }
- },
- deletePaperConfirmAttachment(data) {
- const index = this.paperConfirmAttachments.findIndex(
- (item) => item.url === data.url
- );
- this.paperConfirmAttachments.splice(index, 1);
- },
- toViewCard(attachment) {
- this.addPreviewLog({ attachment, type: "card" });
- this.curAttachment = { ...attachment };
- this.$refs.CardPreviewDialog.open();
- },
- async toCopyCard(attachment) {
- this.curAttachment = { ...attachment };
- const newCardId = await copyCard(
- attachment.cardId,
- this.curTaskApply.courseId
- );
- this.cardModified({ id: newCardId });
- },
- toEditCard(attachment) {
- this.curAttachment = { ...attachment };
- this.$ls.set("prepareTcPCard", {
- id: attachment.cardId,
- examTaskId: this.curTaskApply.examTaskId,
- courseId: this.curTaskApply.courseId,
- courseName: this.curTaskApply.courseName,
- makeMethod: this.curTaskApply.makeMethod,
- cardRuleId: this.curTaskApply.cardRuleId,
- openAb: this.examTask.openAb,
- type: attachment.cardType,
- createMethod: attachment.createMethod,
- });
- this.$refs.ModifyCard.open();
- },
- async cardModified(data) {
- // data: {id,title}
- if (!data.id) return;
- const pos = this.getAttachmentPos(this.curAttachment);
- if (!pos) return;
- if (this.IS_TIKU_TAB) {
- this.paperAttachments[pos.pindex].paperAttachmentIds[
- pos.index
- ].cardTitle = data.title;
- await this.getTkCardList(this.curAttachment);
- return;
- }
- await this.getCardList();
- let card = this.cards.find((item) => item.id === data.id);
- if (!card) return;
- Object.assign(
- this.paperAttachments[pos.pindex].paperAttachmentIds[pos.index],
- {
- cardId: card.id,
- cardType: card.type,
- createMethod: card.createMethod,
- cardTitle: card.title,
- used: card.used,
- createId: card.createId,
- }
- );
- },
- cardChange(attachment) {
- const card = this.cards.find((item) => item.id === attachment.cardId);
- if (!card) return;
- attachment.cardType = card.type;
- attachment.createMethod = card.createMethod;
- attachment.cardTitle = card.title;
- attachment.used = card.used;
- attachment.createId = card.createId;
- },
- tkCardChange(card, attachment) {
- attachment.cardTitle = card.title;
- },
- async toDeleteCard(card, attachment) {
- const confirm = await this.$confirm(
- `确定要删除题卡【${card.title}】吗?`,
- "提示",
- {
- type: "warning",
- }
- ).catch(() => {});
- if (confirm !== "confirm") return;
- await deleteCard(card.id);
- this.$message.success("删除成功!");
- if (attachment.cardId === card.id) {
- attachment.cardId = null;
- attachment.cardTitle = "";
- }
- if (this.IS_TIKU_TAB) {
- attachment.cards = attachment.cards.filter(
- (item) => item.id !== card.id
- );
- } else {
- await this.getCardList();
- }
- },
- async toCreateCard(attachment) {
- if (!this.examTask.cardRuleId) {
- this.$message.error("题卡规则缺失!");
- return;
- }
- const res = await this.$prompt("确定要提交当前题卡吗?", "提示", {
- type: "warning",
- showInput: true,
- inputPlaceholder: "请输入题卡名称",
- inputValidator: (val) => {
- if (!val) return "请输入题卡名称!";
- if (val.length > 50) return "题卡名称不得超过50个字符!";
- return true;
- },
- }).catch(() => {});
- if (!res || res.action !== "confirm") return;
- this.curAttachment = { ...attachment };
- // 这里只允许新建标准专卡
- this.$ls.set("prepareTcPCard", {
- courseId: this.examTask.courseId,
- courseName: this.examTask.courseName,
- openAb: this.examTask.openAb,
- schoolName: this.$ls.get("schoolName"),
- makeMethod: "SELF",
- cardName: res.value,
- cardRuleId: this.examTask.cardRuleId,
- type: "CUSTOM",
- createMethod: "STANDARD",
- });
- this.$refs.ModifyCard.open();
- },
- async downloadPaper(attachment) {
- if (!attachment.attachmentId) return;
- this.addPreviewLog({ attachment, type: "paper" });
- this.$emit("view-attachment", attachment);
- },
- // select-paper
- toSelect(attachment) {
- if (!this.examTask.courseId) {
- this.$message.error("请先选择课程!");
- return;
- }
- let comparePaperId = null;
- if (this.examTask.openAb) {
- const pos = this.getAttachmentPos(attachment);
- if (!pos) return;
- const paperAttachment = this.paperAttachments[pos.pindex];
- const otherAttachment = paperAttachment.paperAttachmentIds.find(
- (item) => item.name !== attachment.name
- );
- if (otherAttachment) comparePaperId = otherAttachment.paperId;
- }
- this.curAttachment = {
- ...attachment,
- comparePaperId,
- courseId: this.examTask.courseId,
- examId: this.examTask.examId,
- uuid: this.examTask.uuid,
- };
- this.$refs.SelectTikuPaperDialog.open();
- },
- async tikuPaperSelected(data) {
- this.cardBuildPresetData = {
- examId: this.examTask.examId,
- courseId: this.examTask.courseId,
- courseName: this.examTask.courseName,
- schoolName: this.$ls.get("schoolName"),
- makeMethod: "SELF",
- cardName: "",
- cardRuleId: this.examTask.cardRuleId,
- type: "CUSTOM",
- createMethod: "STANDARD",
- paperId: data.id,
- paperName: data.name,
- uuid: this.uuid,
- };
- this.$refs.CardBuildDialog.open();
- },
- cardBuildConfirm(data) {
- if (!data.success) {
- this.$message.error(data.message);
- return;
- }
- const pos = this.getAttachmentPos(this.curAttachment);
- if (!pos) return;
- const info = data.data;
- this.curAttachment = {
- ...this.paperAttachments[pos.pindex].paperAttachmentIds[pos.index],
- };
- Object.assign(
- this.paperAttachments[pos.pindex].paperAttachmentIds[pos.index],
- {
- paperId: this.cardBuildPresetData.paperId,
- cardType: this.cardBuildPresetData.type,
- createMethod: this.cardBuildPresetData.createMethod,
- filename: this.cardBuildPresetData.paperName,
- cardId: info.id,
- cardTitle: info.title,
- uuid: info.uuid,
- attachmentId: info.attachmentId,
- paperUrl: info.paperUrl,
- }
- );
- this.getTkCardList(
- this.paperAttachments[pos.pindex].paperAttachmentIds[pos.index]
- );
- },
- toViewPaper(attachment) {
- if (!attachment.paperUrl) return;
- this.curFile = {
- url: attachment.paperUrl,
- type: "application/pdf",
- };
- this.$refs.PreviewFile.open();
- // window.open(attachment.paperUrl);
- },
- // image-preview
- toPreview(index) {
- this.curImageIndex = index;
- this.selectImage(index);
- this.$refs.SimpleImagePreview.open();
- },
- selectImage(index) {
- this.curImage = this.imageAttachments[index];
- },
- toPrevImage() {
- if (this.curImageIndex === 0) {
- this.curImageIndex = this.imageAttachments.length - 1;
- } else {
- this.curImageIndex--;
- }
- this.selectImage(this.curImageIndex);
- },
- toNextImage() {
- if (this.curImageIndex === this.imageAttachments.length - 1) {
- this.curImageIndex = 0;
- } else {
- this.curImageIndex++;
- }
- this.selectImage(this.curImageIndex);
- },
- // action
- getData() {
- this.updateExamTaskDetail();
- const data = { ...this.curTaskApply };
- data.examTaskDetailList = this.paperAttachments.map((item) => {
- return {
- ...item,
- paperAttachmentIds: JSON.stringify(item.paperAttachmentIds),
- };
- });
- data.paperConfirmAttachmentIds = JSON.stringify(
- this.paperConfirmAttachments
- );
- return data;
- },
- updateExamTaskDetail() {
- this.paperAttachments.forEach((paperAttachment) => {
- if (this.examTask.openAb) {
- const aAttachment = paperAttachment.paperAttachmentIds[0];
- Object.assign(paperAttachment.paperAttachmentIds[1], {
- cardId: aAttachment.cardId,
- cardType: aAttachment.cardType,
- createMethod: aAttachment.createMethod,
- cardTitle: aAttachment.cardTitle,
- used: aAttachment.used,
- createId: aAttachment.createId,
- });
- }
- paperAttachment.paperType = paperAttachment.paperAttachmentIds
- .map((item) => item.name)
- .join();
- });
- },
- checkData() {
- this.updateExamTaskDetail();
- if (
- this.curTaskApply.submitTwoPaper &&
- this.paperAttachments.length < 2
- ) {
- this.$message.error("一个命题任务至少交AB两套试卷");
- return;
- }
- const paperAttachments = this.paperAttachments
- .map((item) => item.paperAttachmentIds)
- .flat();
- if (this.IS_TIKU_TAB) {
- const paperValid = !paperAttachments.some((item) => !item.paperId);
- if (!paperValid) {
- this.$message.error("请完成试卷选择!");
- return;
- }
- const cardValid = !paperAttachments.some((item) => !item.cardId);
- if (!cardValid) {
- this.$message.error("有试卷类型未选择题卡!");
- return;
- }
- } else {
- // 设置了入库强制包含试卷时,校验试卷是否上传。
- // 未设置入库强制包含试卷时,若有试卷上传,则需要上传全部。若无试卷上传,则通过。
- if (this.curTaskApply.includePaper) {
- const attachmentValid = !paperAttachments.some(
- (item) => !item.attachmentId
- );
- if (!attachmentValid) {
- this.$message.error("请完成试卷文件上传!");
- return;
- }
- } else {
- const hasUploadPaperAttachments = paperAttachments.filter(
- (item) => item.attachmentId
- );
- if (
- hasUploadPaperAttachments.length > 0 &&
- hasUploadPaperAttachments.length !== paperAttachments.length
- ) {
- this.$message.error("有试卷文件未完成上传!");
- return;
- }
- }
- const cardValid = !paperAttachments.some((item) => !item.cardId);
- if (!cardValid) {
- this.$message.error("有试卷类型未选择题卡!");
- return;
- }
- }
- return true;
- },
- },
- };
- </script>
|