|
@@ -1,62 +1,145 @@
|
|
<template>
|
|
<template>
|
|
- <el-dialog
|
|
|
|
- class="modify-task-paper task-detail"
|
|
|
|
- :visible.sync="modalIsShow"
|
|
|
|
- :title="title"
|
|
|
|
- top="10vh"
|
|
|
|
- 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">
|
|
|
|
- <div v-if="IS_EDIT" class="mb-2 text-right">
|
|
|
|
|
|
+ <div class="modify-task-paper">
|
|
|
|
+ <el-dialog
|
|
|
|
+ class="task-detail"
|
|
|
|
+ :visible.sync="modalIsShow"
|
|
|
|
+ :title="title"
|
|
|
|
+ top="10vh"
|
|
|
|
+ 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">
|
|
|
|
+ <div v-if="IS_EDIT" class="mb-2 text-right">
|
|
|
|
+ <el-button
|
|
|
|
+ type="primary"
|
|
|
|
+ icon="el-icon-circle-plus-outline"
|
|
|
|
+ @click="addAtachment"
|
|
|
|
+ >增加卷型</el-button
|
|
|
|
+ >
|
|
|
|
+ </div>
|
|
|
|
+ <table class="table">
|
|
|
|
+ <tr>
|
|
|
|
+ <th>试卷类型</th>
|
|
|
|
+ <th>试卷文件</th>
|
|
|
|
+ <th>答题卡</th>
|
|
|
|
+ <th v-if="IS_EDIT">操作</th>
|
|
|
|
+ </tr>
|
|
|
|
+ <tr v-for="(attachment, index) in paperAttachments" :key="index">
|
|
|
|
+ <td>{{ attachment.name }}卷</td>
|
|
|
|
+ <td class="td-link">
|
|
|
|
+ <span
|
|
|
|
+ v-if="attachment.editable && IS_EDIT"
|
|
|
|
+ @click="toUpload(attachment)"
|
|
|
|
+ title="点击上传试卷"
|
|
|
|
+ >
|
|
|
|
+ <i
|
|
|
|
+ :class="[
|
|
|
|
+ 'icon',
|
|
|
|
+ attachment.attachmentId ? 'icon-files-act' : 'icon-files'
|
|
|
|
+ ]"
|
|
|
|
+ ></i
|
|
|
|
+ >{{
|
|
|
|
+ attachment.attachmentId
|
|
|
|
+ ? attachment.filename
|
|
|
|
+ : "点击上传试卷文件"
|
|
|
|
+ }}
|
|
|
|
+ </span>
|
|
|
|
+ <span
|
|
|
|
+ v-else
|
|
|
|
+ @click="downloadPaper(attachment)"
|
|
|
|
+ title="点击查看试卷"
|
|
|
|
+ >
|
|
|
|
+ <i
|
|
|
|
+ class="icon icon-download-act"
|
|
|
|
+ v-if="attachment.attachmentId"
|
|
|
|
+ ></i>
|
|
|
|
+ <i>{{ attachment.filename }}</i>
|
|
|
|
+ </span>
|
|
|
|
+ </td>
|
|
|
|
+ <td
|
|
|
|
+ class="td-link"
|
|
|
|
+ :rowspan="paperAttachments.length"
|
|
|
|
+ v-if="index === 0"
|
|
|
|
+ >
|
|
|
|
+ <span v-if="CAN_EDIT_CARD" @click="toCreateOrViewCard"
|
|
|
|
+ ><i class="icon icon-plus-act"></i>{{ cardTodoName }}</span
|
|
|
|
+ >
|
|
|
|
+ <span v-else @click="toViewCard">
|
|
|
|
+ <i class="icon icon-circle-right"></i>
|
|
|
|
+ <i>查看题卡</i>
|
|
|
|
+ </span>
|
|
|
|
+ </td>
|
|
|
|
+ <td v-if="IS_EDIT">
|
|
|
|
+ <el-button
|
|
|
|
+ v-if="attachment.editable"
|
|
|
|
+ class="btn-table-icon"
|
|
|
|
+ type="text"
|
|
|
|
+ icon="icon icon-delete"
|
|
|
|
+ title="删除"
|
|
|
|
+ @click="deleteAttachment(index)"
|
|
|
|
+ ></el-button>
|
|
|
|
+ </td>
|
|
|
|
+ </tr>
|
|
|
|
+ </table>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div slot="footer">
|
|
<el-button
|
|
<el-button
|
|
|
|
+ v-if="IS_EDIT"
|
|
type="primary"
|
|
type="primary"
|
|
- icon="el-icon-circle-plus-outline"
|
|
|
|
- @click="addAtachment"
|
|
|
|
- >增加卷型</el-button
|
|
|
|
|
|
+ :disabled="isSubmit"
|
|
|
|
+ @click="submit"
|
|
|
|
+ >确认提交</el-button
|
|
>
|
|
>
|
|
|
|
+ <el-button type="danger" @click="cancel" plain>取消</el-button>
|
|
</div>
|
|
</div>
|
|
- <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 class="td-link">
|
|
|
|
- <span @click="downloadPaper(attachment)" title="点击下载试卷">
|
|
|
|
- <i class="icon icon-download-act"></i>
|
|
|
|
- <i>{{ attachment.filename }}</i>
|
|
|
|
- </span>
|
|
|
|
- </td>
|
|
|
|
- <td
|
|
|
|
- class="td-link"
|
|
|
|
- :rowspan="paperAttachments.length"
|
|
|
|
- v-if="index === 0"
|
|
|
|
- >
|
|
|
|
- <span @click="toViewCard">
|
|
|
|
- <i class="icon icon-circle-right"></i>
|
|
|
|
- <i>查看题卡</i>
|
|
|
|
- </span>
|
|
|
|
- </td>
|
|
|
|
- </tr>
|
|
|
|
- </table>
|
|
|
|
- </div>
|
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
|
- <div slot="footer"></div>
|
|
|
|
- </el-dialog>
|
|
|
|
|
|
+ <!-- upload-paper-dialog -->
|
|
|
|
+ <upload-paper-dialog
|
|
|
|
+ :paper-attachment="curAttachment"
|
|
|
|
+ :upload-type="curUploadType"
|
|
|
|
+ @confirm="uploadConfirm"
|
|
|
|
+ ref="UploadPaperDialog"
|
|
|
|
+ ></upload-paper-dialog>
|
|
|
|
+ <!-- card-option-dialog -->
|
|
|
|
+ <card-option-dialog
|
|
|
|
+ ref="CardOptionDialog"
|
|
|
|
+ :data="curTaskApply"
|
|
|
|
+ @confirm="cardConfirm"
|
|
|
|
+ ></card-option-dialog>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { taskApplyDetail } from "../api";
|
|
|
|
|
|
+import UploadPaperDialog from "./UploadPaperDialog";
|
|
|
|
+import CardOptionDialog from "./CardOptionDialog";
|
|
|
|
+import { taskApplyDetail, taskPaperApplyEdit } from "../api";
|
|
import { attachmentPreview } from "../../login/api";
|
|
import { attachmentPreview } from "../../login/api";
|
|
|
|
+import { examRuleDetail } from "../../base/api";
|
|
|
|
+
|
|
|
|
+const initTaskApply = {
|
|
|
|
+ examTaskId: "",
|
|
|
|
+ paperType: "A",
|
|
|
|
+ paperAttachmentIds: "",
|
|
|
|
+ cardId: "",
|
|
|
|
+ cardRuleId: "",
|
|
|
|
+ makeMethod: "",
|
|
|
|
+ courseCode: "",
|
|
|
|
+ courseName: "",
|
|
|
|
+ // 题卡状态
|
|
|
|
+ status: "",
|
|
|
|
+ // 考务规则 TODO:
|
|
|
|
+ includePaper: false,
|
|
|
|
+ customCard: false
|
|
|
|
+};
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "preview-task-paper",
|
|
name: "preview-task-paper",
|
|
|
|
+ components: { UploadPaperDialog, CardOptionDialog },
|
|
props: {
|
|
props: {
|
|
instance: {
|
|
instance: {
|
|
type: Object,
|
|
type: Object,
|
|
@@ -73,7 +156,7 @@ export default {
|
|
computed: {
|
|
computed: {
|
|
title() {
|
|
title() {
|
|
const names = {
|
|
const names = {
|
|
- EDIT: "编辑卷库",
|
|
|
|
|
|
+ EDIT: "申请编辑卷库",
|
|
PREVIEW: "卷库详情"
|
|
PREVIEW: "卷库详情"
|
|
};
|
|
};
|
|
return names[this.editType];
|
|
return names[this.editType];
|
|
@@ -86,22 +169,54 @@ export default {
|
|
},
|
|
},
|
|
CAN_EDIT_CARD() {
|
|
CAN_EDIT_CARD() {
|
|
return this.editType === "EDIT" && !this.instance.exposedPaperType;
|
|
return this.editType === "EDIT" && !this.instance.exposedPaperType;
|
|
|
|
+ },
|
|
|
|
+ cardTodoName() {
|
|
|
|
+ let name = "查看题卡";
|
|
|
|
+ if (this.CAN_EDIT_CARD) {
|
|
|
|
+ if (this.curTaskApply.makeMethod === "SELECT") {
|
|
|
|
+ name = "选择题卡";
|
|
|
|
+ } else {
|
|
|
|
+ name = "编辑题卡";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return name;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ isSubmit: false,
|
|
modalIsShow: false,
|
|
modalIsShow: false,
|
|
- cardId: "",
|
|
|
|
- paperAttachments: []
|
|
|
|
|
|
+ curTaskApply: { ...initTaskApply },
|
|
|
|
+ paperAttachments: [],
|
|
|
|
+ paperConfirmAttachments: [],
|
|
|
|
+ curAttachment: {},
|
|
|
|
+ curUploadType: "paper",
|
|
|
|
+ abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
|
|
|
|
+ includePaper: false
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ created() {
|
|
|
|
+ this.getExamRule();
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
|
|
+ async getExamRule() {
|
|
|
|
+ const examRule = await examRuleDetail();
|
|
|
|
+ this.includePaper = examRule && examRule.includePaper;
|
|
|
|
+ },
|
|
async visibleChange() {
|
|
async visibleChange() {
|
|
const data = await taskApplyDetail(this.instance.id);
|
|
const data = await taskApplyDetail(this.instance.id);
|
|
- this.cardId = data.cardId;
|
|
|
|
|
|
+ this.curTaskApply = this.$objAssign(initTaskApply, data || {});
|
|
|
|
+ this.curTaskApply.courseCode = this.instance.courseCode;
|
|
|
|
+ this.curTaskApply.courseName = this.instance.courseName;
|
|
|
|
+ this.curTaskApply.cardRuleId = this.instance.cardRuleId;
|
|
|
|
+ this.curTaskApply.includePaper = this.includePaper;
|
|
this.paperAttachments = data.paperAttachmentIds
|
|
this.paperAttachments = data.paperAttachmentIds
|
|
? JSON.parse(data.paperAttachmentIds)
|
|
? JSON.parse(data.paperAttachmentIds)
|
|
: [];
|
|
: [];
|
|
|
|
+ const exposedPaperType = this.instance.exposedPaperType || "";
|
|
|
|
+ this.paperAttachments.forEach(paper => {
|
|
|
|
+ paper.editable = !exposedPaperType.includes(paper.name);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
cancel() {
|
|
cancel() {
|
|
this.modalIsShow = false;
|
|
this.modalIsShow = false;
|
|
@@ -110,15 +225,21 @@ export default {
|
|
this.modalIsShow = true;
|
|
this.modalIsShow = true;
|
|
},
|
|
},
|
|
addAtachment() {
|
|
addAtachment() {
|
|
- if (this.paperAttachments.length >= this.attachmentLimitCount) return;
|
|
|
|
|
|
+ if (this.paperAttachments.length >= this.abc.length) return;
|
|
|
|
+
|
|
|
|
+ const paperType = this.paperAttachments.map(item => item.name);
|
|
|
|
+ const name = this.abc.split("").find(code => !paperType.includes(code));
|
|
|
|
|
|
const newAttachment = {
|
|
const newAttachment = {
|
|
- name: this.abc[this.paperAttachments.length],
|
|
|
|
|
|
+ name,
|
|
attachmentId: "",
|
|
attachmentId: "",
|
|
filename: "",
|
|
filename: "",
|
|
- pages: 0
|
|
|
|
|
|
+ pages: 0,
|
|
|
|
+ editable: true
|
|
};
|
|
};
|
|
this.paperAttachments.push(newAttachment);
|
|
this.paperAttachments.push(newAttachment);
|
|
|
|
+
|
|
|
|
+ this.paperAttachments.sort((a, b) => (a.name < b.name ? -1 : 1));
|
|
},
|
|
},
|
|
deleteAttachment(index) {
|
|
deleteAttachment(index) {
|
|
if (this.paperAttachments.length <= 1) {
|
|
if (this.paperAttachments.length <= 1) {
|
|
@@ -126,9 +247,6 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.paperAttachments.splice(index, 1);
|
|
this.paperAttachments.splice(index, 1);
|
|
- this.paperAttachments.forEach((item, itemIndex) => {
|
|
|
|
- item.name = this.abc[itemIndex];
|
|
|
|
- });
|
|
|
|
},
|
|
},
|
|
toUpload(attachment) {
|
|
toUpload(attachment) {
|
|
this.curUploadType = "paper";
|
|
this.curUploadType = "paper";
|
|
@@ -137,25 +255,16 @@ export default {
|
|
};
|
|
};
|
|
this.$refs.UploadPaperDialog.open();
|
|
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) {
|
|
uploadConfirm(attachment, uploadType) {
|
|
if (uploadType === "paper") {
|
|
if (uploadType === "paper") {
|
|
const index = this.paperAttachments.findIndex(
|
|
const index = this.paperAttachments.findIndex(
|
|
item => item.name === attachment.name
|
|
item => item.name === attachment.name
|
|
);
|
|
);
|
|
this.paperAttachments.splice(index, 1, { ...attachment });
|
|
this.paperAttachments.splice(index, 1, { ...attachment });
|
|
- } else {
|
|
|
|
- this.paperConfirmAttachments.push(attachment);
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async downloadPaper(attachment) {
|
|
async downloadPaper(attachment) {
|
|
|
|
+ if (!attachment.attachmentId) return;
|
|
const data = await attachmentPreview(attachment.attachmentId);
|
|
const data = await attachmentPreview(attachment.attachmentId);
|
|
window.open(data.url);
|
|
window.open(data.url);
|
|
},
|
|
},
|
|
@@ -164,11 +273,99 @@ export default {
|
|
this.getRouterPath({
|
|
this.getRouterPath({
|
|
name: "CardPreview",
|
|
name: "CardPreview",
|
|
params: {
|
|
params: {
|
|
- cardId: this.cardId,
|
|
|
|
|
|
+ cardId: this.curTaskApply.cardId,
|
|
viewType: "view"
|
|
viewType: "view"
|
|
}
|
|
}
|
|
})
|
|
})
|
|
);
|
|
);
|
|
|
|
+ },
|
|
|
|
+ toEditCard() {
|
|
|
|
+ this.cachePrepareTcpCard();
|
|
|
|
+ this.$router.push({
|
|
|
|
+ name: "CardDesign",
|
|
|
|
+ params: {
|
|
|
|
+ cardId: this.curTaskApply.cardId
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ cachePrepareTcpCard() {
|
|
|
|
+ this.$ls.set("prepareTcPCard", {
|
|
|
|
+ examTaskId: this.curTaskApply.examTaskId,
|
|
|
|
+ courseCode: this.curTaskApply.courseCode,
|
|
|
|
+ courseName: this.curTaskApply.courseName,
|
|
|
|
+ makeMethod: this.curTaskApply.makeMethod,
|
|
|
|
+ cardRuleId: this.curTaskApply.cardRuleId,
|
|
|
|
+ paperType: this.paperAttachments.map(item => item.name).join(",")
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ async toCreateOrViewCard() {
|
|
|
|
+ this.task = this.getTaskData();
|
|
|
|
+ if (this.CAN_EDIT_CARD) {
|
|
|
|
+ if (this.curTaskApply.makeMethod === "SELECT") {
|
|
|
|
+ this.$refs.CardOptionDialog.open();
|
|
|
|
+ } else {
|
|
|
|
+ this.toEditCard();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.toViewCard();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ cardConfirm(data) {
|
|
|
|
+ this.curTaskApply = this.$objAssign(this.curTaskApply, data);
|
|
|
|
+ },
|
|
|
|
+ getTaskData() {
|
|
|
|
+ let data = { ...this.curTaskApply };
|
|
|
|
+
|
|
|
|
+ return data;
|
|
|
|
+ },
|
|
|
|
+ checkDataValid() {
|
|
|
|
+ const attachmentValid = !this.paperAttachments.some(
|
|
|
|
+ item => !item.attachmentId
|
|
|
|
+ );
|
|
|
|
+ // 设置了入库强制包含试卷时,校验试卷是否上传。
|
|
|
|
+ if (this.curTaskApply.includePaper && !attachmentValid) {
|
|
|
|
+ this.$message.error("请完成试卷文件上传!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!this.curTaskApply.cardId) {
|
|
|
|
+ this.$message.error("请选择题卡创建方式!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (
|
|
|
|
+ this.curTaskApply.makeMethod !== "SELECT" &&
|
|
|
|
+ this.curTaskApply.status !== "SUBMIT"
|
|
|
|
+ ) {
|
|
|
|
+ this.$message.error("请先提交题卡!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
|
|
+ async submit() {
|
|
|
|
+ if (!this.checkDataValid()) return;
|
|
|
|
+
|
|
|
|
+ this.$confirm("确定要提交申请修改当前任务吗?", "提示", {
|
|
|
|
+ cancelButtonClass: "el-button--danger is-plain",
|
|
|
|
+ confirmButtonClass: "el-button--primary",
|
|
|
|
+ type: "warning"
|
|
|
|
+ })
|
|
|
|
+ .then(async () => {
|
|
|
|
+ const datas = {
|
|
|
|
+ examTaskId: this.curTaskApply.examTaskId,
|
|
|
|
+ cardId: this.curTaskApply.cardId,
|
|
|
|
+ paperType: this.paperAttachments.map(item => item.name).join(","),
|
|
|
|
+ paperAttachmentIds: JSON.stringify(this.paperAttachments, (k, v) =>
|
|
|
|
+ k === "editable" || k === "url" ? undefined : v
|
|
|
|
+ )
|
|
|
|
+ };
|
|
|
|
+ const data = await taskPaperApplyEdit(datas).catch(() => {});
|
|
|
|
+ if (!data) return;
|
|
|
|
+ this.$message.success("提交成功!");
|
|
|
|
+ this.$emit("modified");
|
|
|
|
+ this.cancel();
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|