1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012 |
- <template>
- <div class="apply-content task-detail">
- <div class="task-body">
- <div v-if="IS_APPLY" class="mb-2 text-right">
- <el-button
- type="info"
- icon="el-icon-circle-plus-outline"
- @click="addAtachment"
- >增加卷型</el-button
- >
- </div>
- <table class="table mb-2">
- <tr>
- <th>试卷类型</th>
- <th>试卷文件</th>
- <th>答题卡创建方式</th>
- <th>答题卡</th>
- <th v-if="IS_APPLY">操作</th>
- </tr>
- <tr v-for="(attachment, index) in paperAttachments" :key="index">
- <td>
- <span>{{ attachment.name }}卷</span>
- <span class="color-gray-2" v-if="attachment.isExposed"
- >(已曝光)</span
- >
- </td>
- <td>
- <el-button
- v-if="!attachment.isExposed && (IS_APPLY || IS_AUDIT_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)"
- >
- <i
- class="icon icon-download mr-1"
- v-if="attachment.attachmentId"
- ></i>
- <i>{{ attachment.filename }}</i>
- </el-button>
- </td>
- <td :rowspan="paperAttachments.length" v-if="index === 0">
- {{ createCardTypeName }}
- </td>
- <td :rowspan="paperAttachments.length" v-if="index === 0">
- <el-button
- type="text"
- class="btn-primary"
- v-if="!exposedMode && IS_APPLY"
- @click="toCreateOrViewCard"
- >{{ cardTodoName }}</el-button
- >
- <el-button
- v-else
- type="text"
- class="btn-primary"
- @click="toViewCard"
- >
- 查看题卡
- </el-button>
- <el-button
- v-if="
- curTaskApply.makeMethod &&
- curTaskApply.makeMethod !== 'CUST' &&
- !exposedMode &&
- IS_APPLY
- "
- type="text"
- class="btn-danger"
- @click="changeCreateCardType"
- >切换题卡创建方式</el-button
- >
- </td>
- <td v-if="IS_APPLY">
- <el-button
- v-if="attachment.canDelete"
- class="btn-danger"
- type="text"
- @click="deleteAttachment(index)"
- >删除</el-button
- >
- </td>
- </tr>
- <tr v-if="!paperAttachments.length">
- <td colspan="5">
- <p class="tips-info text-center">暂无数据</p>
- </td>
- </tr>
- </table>
- <p class="tips-info tips-dark mb-2">
- 提示:多卷型试卷由于会绑定一个答题卡模板,因此试卷结构必须相同。多卷型试卷之间客观题要求试题内容相同,可允许大题内的小题题序不同。
- </p>
- <el-form>
- <el-form-item label="单次抽卷卷型数量:" label-width="150">
- <el-input-number
- v-model="curTaskApply.drawCount"
- :min="1"
- :max="maxFetchCount"
- :step="1"
- step-strictly
- :controls="false"
- :disabled="!IS_APPLY || exposedMode"
- ></el-input-number>
- </el-form-item>
- </el-form>
- <h4 class="mb-2">附件<span v-if="IS_APPLY">(最多4张)</span>:</h4>
- <div class="image-list">
- <div
- class="image-item"
- v-for="(img, index) in paperConfirmAttachments"
- :key="index"
- >
- <img
- :src="img.url"
- :alt="img.filename"
- title="点击查看大图"
- @click="toPreview(index)"
- />
- <div v-if="IS_APPLY" class="image-delete">
- <i
- class="el-icon-delete-solid"
- @click="deletePaperConfirmAttachment(index)"
- ></i>
- </div>
- </div>
- <div
- v-if="paperConfirmAttachments.length < 4 && IS_APPLY"
- class="image-item image-add"
- title="上传附件"
- @click="toUploadPaperConfirm"
- >
- <i class="el-icon-plus"></i>
- </div>
- </div>
- <div
- v-if="!IS_APPLY && !paperConfirmAttachments.length"
- class="image-list-none"
- >
- 暂无数据
- </div>
- <h4 class="mb-2">附件说明:</h4>
- <el-input
- v-if="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>
- <!-- -->
- <div v-if="IS_APPLY && needSetApproveUser" class="task-audit">
- <el-form>
- <el-form-item label="指定审批人:">
- <el-select
- v-model="approveUserIds"
- placeholder="请选择"
- multiple
- filterable
- clearable
- style="width: 700px"
- >
- <el-option
- v-for="user in approveUserList"
- :key="user.id"
- :value="user.id"
- :label="`${user.realName}(${user.orgName})`"
- >
- {{ user.realName }}({{ user.orgName }})
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- <!-- audit -->
- <div v-if="IS_AUDIT" class="task-audit">
- <el-form
- ref="auditModalComp"
- :model="auditModal"
- :rules="auditRules"
- label-width="90px"
- >
- <el-form-item prop="approvePass" label="审批操作:">
- <el-radio-group
- v-model="auditModal.approvePass"
- @change="approvePassChange"
- >
- <el-radio
- v-for="(val, key) in TASK_AUDIT_RESULT"
- :key="key"
- :label="key"
- >{{ val }}</el-radio
- >
- </el-radio-group>
- </el-form-item>
- <el-form-item
- v-if="auditModal.approvePass === 'REJECT'"
- prop="setup"
- label="驳回节点:"
- >
- <el-select
- v-model="auditModal.setup"
- placeholder="请选择"
- style="width: 100%"
- >
- <el-option
- v-for="item in setups"
- :key="item.taskKey"
- :value="item.setup"
- :label="item.taskName"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- v-if="auditModal.approvePass !== 'EXCHANGE'"
- :key="auditModal.approvePass"
- prop="remark"
- label="审批意见:"
- >
- <el-input
- class="mb-2"
- v-model="auditModal.remark"
- type="textarea"
- resize="none"
- :rows="5"
- :maxlength="1000"
- clearable
- show-word-limit
- placeholder="建议不超过1000个字"
- ref="ReasonInput"
- ></el-input>
- </el-form-item>
- <el-form-item
- v-if="auditModal.approvePass === 'EXCHANGE'"
- prop="userId"
- label="审批人:"
- >
- <el-select
- v-model="auditModal.userId"
- filterable
- placeholder="请选择"
- >
- <el-option
- v-for="user in approveExchangePeople"
- :key="user.id"
- :value="user.id"
- :label="user.realName"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- v-if="needSetApproveUser && auditModal.approvePass === 'PASS'"
- key="approveUserIds"
- label="指定审批人:"
- >
- <el-select
- v-model="approveUserIds"
- placeholder="请选择"
- multiple
- filterable
- clearable
- style="width: 700px"
- >
- <el-option
- v-for="user in approveUserList"
- :key="user.id"
- :value="user.id"
- :label="`${user.realName}(${user.orgName})`"
- >
- {{ user.realName }}({{ user.orgName }})
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- </div>
- <div class="task-action">
- <el-button
- v-if="IS_APPLY"
- type="primary"
- :disabled="isSubmit"
- @click="submit"
- >确认提交</el-button
- >
- <el-button
- v-if="IS_APPLY"
- type="primary"
- :disabled="isSubmit"
- @click="toSave"
- >暂存</el-button
- >
- <el-button
- v-if="IS_AUDIT"
- type="primary"
- :disabled="isSubmit"
- @click="toAuditSubmit"
- >确定</el-button
- >
- <el-button
- v-if="IS_AUDIT_APPLY"
- type="primary"
- :disabled="isSubmit"
- @click="toAuditApply"
- >提交</el-button
- >
- <el-button @click="cancel">取消</el-button>
- </div>
- <!-- 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="task"
- @upload-sample-over="initData"
- @draft-task="silentSave"
- @confirm="cardConfirm"
- ></card-option-dialog>
- <!-- image-preview -->
- <simple-image-preview
- :cur-image="curImage"
- @on-prev="toPrevImage"
- @on-next="toNextImage"
- ref="SimpleImagePreview"
- ></simple-image-preview>
- </div>
- </template>
- <script>
- import UploadPaperDialog from "./UploadPaperDialog";
- import CardOptionDialog from "./CardOptionDialog";
- import {
- taskApplyDetail,
- updateTaskApply,
- updateTaskReview,
- taskAuditApply,
- switchCardCreateMethod,
- taskAllFlowSetups,
- taskAllApproverPeople,
- taskAllApproverExchangePeople,
- taskApproverExchange,
- taskApproverNextPeople
- } from "../api";
- import { attachmentPreview } from "../../login/api";
- import SimpleImagePreview from "@/components/SimpleImagePreview";
- import { CARD_SOURCE_TYPE, TASK_AUDIT_RESULT } from "@/constants/enumerate";
- const initTaskApply = {
- examTaskId: "",
- paperType: "A",
- paperAttachmentIds: "",
- paperConfirmAttachmentIds: "",
- cardId: "",
- cardRuleId: "",
- makeMethod: "",
- remark: "",
- courseCode: "",
- courseName: "",
- drawCount: 1,
- exposedPaperType: "",
- // 流程
- flowId: "",
- setup: 0,
- // 工作台任务id
- flowTaskId: "",
- // 题卡状态
- status: "",
- // 考务规则
- review: false,
- includePaper: false,
- customCard: false,
- // 是否有子流程
- subFlowReject: false
- };
- export default {
- name: "apply-content",
- components: { UploadPaperDialog, CardOptionDialog, SimpleImagePreview },
- props: {
- examTask: {
- type: Object,
- default() {
- return {};
- }
- },
- editType: {
- type: String,
- default: ""
- }
- },
- data() {
- return {
- isSubmit: false,
- curTaskApply: { ...initTaskApply },
- paperConfirmAttachmentId: { attachmentId: "", filename: "", url: "" },
- paperAttachments: [],
- paperConfirmAttachments: [],
- curAttachment: {},
- curUploadType: "paper",
- attachmentLimitCount: 26,
- abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
- task: {},
- reason: "",
- TASK_AUDIT_RESULT: { ...TASK_AUDIT_RESULT, EXCHANGE: "转他人审批" },
- // audit
- flows: [],
- setups: [],
- auditModal: {
- approvePass: "PASS",
- setup: "",
- remark: ""
- },
- auditRules: {
- approvePass: [
- {
- required: true
- }
- ],
- setup: [
- {
- required: true,
- validator: (rule, value, callback) => {
- if (this.auditModal.approvePass === "REJECT" && !value) {
- callback(new Error(`请选择要驳回到的节点`));
- } else {
- callback();
- }
- },
- trigger: "change"
- }
- ],
- remark: [
- {
- required: false,
- validator: (rule, value, callback) => {
- if (this.auditModal.approvePass === "REJECT" && !value) {
- callback(new Error(`请输入审批意见`));
- } else {
- callback();
- }
- },
- trigger: "change"
- }
- ],
- userId: [
- {
- required: true,
- message: "请选择审批人",
- trigger: "change"
- }
- ]
- },
- approveExchangePeople: [],
- needSetApproveUser: false,
- approveUserIds: [],
- approveUserList: [], //审批人
- // image-preview
- curImage: {},
- curImageIndex: 0
- };
- },
- computed: {
- IS_APPLY() {
- return this.editType
- ? this.editType === "APPLY"
- : this.curTaskApply.setup === 1 || this.curTaskApply.setup === null;
- },
- IS_PREVIEW() {
- return this.editType
- ? this.editType === "PREVIEW"
- : this.curTaskApply.setup !== null && this.curTaskApply.setup <= 0;
- },
- IS_AUDIT() {
- const IS_COMMON_AUDIT = this.editType
- ? this.editType === "AUDIT"
- : this.curTaskApply.setup > 1;
- return IS_COMMON_AUDIT && !this.IS_AUDIT_APPLY;
- },
- IS_AUDIT_APPLY() {
- // IS_PRELAST_STEP
- return (
- this.curTaskApply.subFlowReject &&
- this.curTaskApply.setup === this.flows.length - 1
- );
- },
- cardTodoName() {
- let name = "创建答题卡";
- if (this.curTaskApply.cardId) {
- if (this.curTaskApply.makeMethod === "SELECT") {
- name = "选择题卡";
- } else if (this.curTaskApply.makeMethod === "SELF") {
- name = "编辑题卡";
- } else {
- // 已经审核的题卡可以自行编辑,未审核的题卡只能查看
- name =
- this.curTaskApply.status === "SUBMIT" ? "编辑题卡" : "查看题卡";
- }
- }
- return name;
- },
- createCardTypeName() {
- return CARD_SOURCE_TYPE[this.curTaskApply.makeMethod] || "";
- },
- maxFetchCount() {
- return this.paperAttachments.length < 1
- ? 1
- : this.paperAttachments.length;
- },
- exposedMode() {
- return !!this.curTaskApply.exposedPaperType;
- }
- },
- mounted() {
- this.initData();
- },
- methods: {
- async initData() {
- const data = await taskApplyDetail(
- this.examTask.id,
- this.examTask.source
- );
- this.curTaskApply = this.$objAssign(initTaskApply, data || {});
- this.curTaskApply.examTaskId = this.examTask.id;
- this.curTaskApply.courseCode = this.examTask.courseCode;
- this.curTaskApply.courseName = this.examTask.courseName;
- this.curTaskApply.cardRuleId = this.examTask.cardRuleId;
- this.curTaskApply.customCard = this.examTask.customCard;
- this.curTaskApply.setup = this.examTask.setup;
- this.paperAttachments = this.curTaskApply.paperAttachmentIds
- ? JSON.parse(this.curTaskApply.paperAttachmentIds)
- : [];
- const exposedPaperType = data.exposedPaperType || "";
- let exposedPaperTypes = exposedPaperType.split(",");
- exposedPaperTypes.sort((a, b) => (a > b ? -1 : 1));
- const maxExposedPaperType = exposedPaperTypes[0];
- this.paperAttachments.forEach(paper => {
- paper.canDelete = maxExposedPaperType
- ? paper.name > maxExposedPaperType
- : true;
- paper.isExposed = exposedPaperTypes.includes(paper.name);
- });
- this.paperConfirmAttachments = this.curTaskApply.paperConfirmAttachmentIds
- ? JSON.parse(this.curTaskApply.paperConfirmAttachmentIds)
- : [];
- this.buildSteps();
- if (this.IS_AUDIT) this.getExchangeApproverPeople();
- },
- async buildSteps() {
- if (
- !this.curTaskApply.flowId ||
- (this.curTaskApply.setup !== null && this.curTaskApply.setup <= 0)
- ) {
- this.$emit("step-change", []);
- return;
- }
- const flowStatus = {
- wait: "待进行",
- process: "进行中",
- success: "已完成"
- };
- const approveData = await taskAllApproverPeople({
- taskId: this.curTaskApply.flowTaskId
- });
- let approvePeople = {};
- approveData.approveUserList.forEach(item => {
- item.users = item.approveUser.map(
- user => `${user.realName}(${user.orgName})`
- );
- item.firstUser = item.users[0];
- item.moreUser = item.users.length > 1 ? item.users.join(",") : null;
- approvePeople[item.setup] = item;
- });
- const flowData = await taskAllFlowSetups(this.curTaskApply.flowId);
- const curSetup = this.curTaskApply.setup;
- const curStepIsLast = curSetup === flowData.length;
- this.flows = flowData.map(item => {
- item.status =
- curSetup > item.setup
- ? "success"
- : curSetup === item.setup
- ? "process"
- : "wait";
- item.desc = flowStatus[item.status];
- item.isCurrent = curSetup === item.setup;
- item = { ...item, ...approvePeople[item.setup] };
- return item;
- });
- if (!this.flows.length) {
- this.$emit("step-change", this.flows);
- return;
- }
- const curFlow = this.flows.find(item => item.isCurrent);
- if (curFlow) {
- const flows = curStepIsLast
- ? this.flows.slice(-2, -1)
- : this.flows.filter(item => item.setup < curFlow.setup);
- this.setups = flows.map(item => {
- return {
- taskKey: item.taskKey,
- setup: item.setup,
- taskName: `【${item.taskName}】${item.firstUser}`
- };
- });
- }
- // 下一节点审批人
- const nextFlow = this.flows.find(
- item => item.setup > this.curTaskApply.setup
- );
- if (
- (this.IS_APPLY || this.IS_AUDIT) &&
- nextFlow &&
- !nextFlow.approveUser.length
- ) {
- // 获取审批人
- this.needSetApproveUser = true;
- let datas = {};
- if (this.IS_APPLY) {
- datas.courseCode = this.curTaskApply.courseCode;
- }
- if (this.IS_AUDIT) {
- datas.taskId = this.curTaskApply.flowTaskId;
- }
- const data = await taskApproverNextPeople(datas);
- this.approveUserList =
- data && data.approveUserList && data.approveUserList[0].approveUser;
- }
- this.$emit("step-change", this.flows);
- },
- async getExchangeApproverPeople() {
- const data = await taskAllApproverExchangePeople({
- taskId: this.curTaskApply.flowTaskId
- });
- this.approveExchangePeople =
- (data &&
- data.approveUserList &&
- data.approveUserList[0] &&
- data.approveUserList[0].approveUser) ||
- [];
- const userId = this.$ls.get("user", { id: "" }).id;
- this.approveExchangePeople = this.approveExchangePeople.filter(
- user => user.id !== userId
- );
- },
- approvePassChange() {
- this.auditRules.remark[0].required =
- this.auditModal.approvePass === "REJECT";
- },
- addAtachment() {
- if (this.paperAttachments.length >= this.attachmentLimitCount) return;
- const name = this.abc[this.paperAttachments.length];
- const newAttachment = {
- name,
- attachmentId: "",
- filename: "",
- pages: 0,
- canDelete: true,
- isExposed: false
- };
- this.paperAttachments.push(newAttachment);
- },
- deleteAttachment(index) {
- if (this.paperAttachments.length <= 1) {
- this.$message.error("试卷类型数量不得少于1");
- return;
- }
- this.paperAttachments.splice(index, 1);
- this.paperAttachments.forEach((item, itemIndex) => {
- item.name = this.abc[itemIndex];
- });
- if (
- this.curTaskApply.drawCount &&
- this.curTaskApply.drawCount > this.paperAttachments.length
- ) {
- this.curTaskApply.drawCount = this.paperAttachments.length;
- }
- },
- 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 index = this.paperAttachments.findIndex(
- item => item.name === attachment.name
- );
- this.paperAttachments.splice(index, 1, { ...attachment });
- } else {
- this.paperConfirmAttachments.push(attachment);
- }
- },
- deletePaperConfirmAttachment(index) {
- this.paperConfirmAttachments.splice(index, 1);
- },
- toViewCard() {
- window.open(
- this.getRouterPath({
- name: "CardPreview",
- params: {
- cardId: this.curTaskApply.cardId,
- viewType: "view"
- }
- })
- );
- },
- toEditCard() {
- this.cachePrepareTcpCard();
- this.$router.push({
- name: "CardDesign",
- params: {
- cardId: this.curTaskApply.cardId
- }
- });
- },
- cachePrepareTcpCard() {
- this.$ls.set("prepareTcPCard", {
- examTaskId: this.task.examTaskId,
- courseCode: this.task.courseCode,
- courseName: this.task.courseName,
- makeMethod: this.task.makeMethod,
- cardRuleId: this.task.cardRuleId
- });
- },
- async toCreateOrViewCard() {
- await this.silentSave();
- this.task = this.getTaskData();
- if (!this.curTaskApply.cardId) {
- this.$refs.CardOptionDialog.open();
- return;
- }
- if (this.curTaskApply.makeMethod === "SELECT") {
- this.$refs.CardOptionDialog.open();
- } else if (this.curTaskApply.makeMethod === "SELF") {
- this.toEditCard();
- } else {
- // 客服制卡:制作完毕则可以编辑,未制作完毕则可以查看
- if (this.curTaskApply.status === "SUBMIT") {
- this.toEditCard();
- } else {
- this.toViewCard();
- }
- }
- },
- cancel() {
- this.$emit("cancel");
- },
- async downloadPaper(attachment) {
- if (!attachment.attachmentId) return;
- const data = await attachmentPreview(attachment.attachmentId);
- window.open(data.url);
- },
- cardConfirm(data) {
- this.curTaskApply = this.$objAssign(this.curTaskApply, data);
- },
- async changeCreateCardType() {
- const h = this.$createElement;
- const result = await this.$msgbox({
- title: "切换题卡操作说明",
- message: h("div", null, [
- h("p", null, "1、切换题卡会将之前选择题卡数据删除。"),
- h(
- "p",
- null,
- "2、之前选择专卡进行绘制,切换题卡后再次选择专卡,需要重新开始绘制。"
- )
- ]),
- showCancelButton: true,
- type: "warning"
- }).catch(() => {});
- if (result !== "confirm") return;
- await this.clearMakeMethod();
- this.toCreateOrViewCard();
- },
- async clearMakeMethod() {
- // 清除后台记录的题卡
- if (this.curTaskApply.cardId && this.curTaskApply.makeMethod !== "CUST") {
- await switchCardCreateMethod(this.examTask.id);
- }
- this.curTaskApply.makeMethod = "";
- this.curTaskApply.cardId = "";
- },
- getTaskData() {
- let data = { ...this.curTaskApply };
- data.paperType = this.paperAttachments.map(item => item.name).join(",");
- data.paperAttachmentIds = JSON.stringify(this.paperAttachments, (k, v) =>
- k === "url" ? undefined : v
- );
- data.paperConfirmAttachmentIds = JSON.stringify(
- this.paperConfirmAttachments
- );
- if (this.needSetApproveUser) data.approveUserIds = this.approveUserIds;
- return data;
- },
- checkDataValid() {
- const attachmentValid = !this.paperAttachments.some(
- item => !item.attachmentId
- );
- // 设置了入库强制包含试卷时,校验试卷是否上传。
- if (this.curTaskApply.includePaper && !attachmentValid) {
- this.$message.error("请完成试卷文件上传!");
- return;
- }
- // if (!this.paperConfirmAttachments.length) {
- // 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;
- }
- if (this.needSetApproveUser && !this.approveUserIds.length) {
- this.$message.error("请指定审批人!");
- return;
- }
- return true;
- },
- async toSave() {
- if (this.isSubmit) return;
- this.isSubmit = true;
- const datas = this.getTaskData();
- datas.operateType = "STAGE";
- const data = await updateTaskApply(datas).catch(() => {});
- this.isSubmit = false;
- if (!data) return;
- this.$message.success("保存成功!");
- },
- async silentSave() {
- const datas = this.getTaskData();
- datas.operateType = "STAGE";
- await updateTaskApply(datas).catch(() => {});
- },
- async submit() {
- if (!this.checkDataValid()) return;
- const result = await this.$confirm(
- "任务确定提交后,则不可更改试卷及答题卡内容,确定提交该任务?",
- "提示",
- {
- type: "warning"
- }
- ).catch(() => {});
- if (result !== "confirm") return;
- const datas = this.getTaskData();
- datas.operateType = "SUBMIT";
- const data = await updateTaskApply(datas).catch(() => {});
- if (!data) return;
- this.$message.success("提交成功!");
- this.$emit("modified");
- },
- async toAuditSubmit() {
- const valid = await this.$refs.auditModalComp.validate().catch(() => {});
- if (!valid) return;
- if (
- this.auditModal.approvePass === "PASS" &&
- this.needSetApproveUser &&
- !this.approveUserIds.length
- ) {
- this.$message.error("请指定审批人!");
- return;
- }
- const actionName = this.TASK_AUDIT_RESULT[this.auditModal.approvePass];
- const result = await this.$confirm(
- `确定${actionName}该申请吗?`,
- "提示",
- {
- type: "warning"
- }
- ).catch(() => {});
- if (result !== "confirm") return;
- if (this.auditModal.approvePass === "EXCHANGE") {
- let datas = {
- taskId: this.curTaskApply.flowTaskId,
- userId: this.auditModal.userId
- };
- const data = await taskApproverExchange(datas).catch(() => {});
- if (!data) return;
- } else {
- let datas = { ...this.auditModal };
- datas.taskId = this.curTaskApply.flowTaskId;
- if (this.auditModal.approvePass === "PASS")
- datas.approveUserIds = this.approveUserIds;
- const data = await updateTaskReview(datas).catch(() => {});
- if (!data) return;
- }
- this.$message.success("审批成功!");
- this.$emit("modified");
- },
- async toAuditApply() {
- const result = await this.$confirm("确定提交该任务吗?", "提示", {
- type: "warning"
- }).catch(() => {});
- if (result !== "confirm") return;
- const datas = {
- examTaskDetail: this.getTaskData(),
- flowTaskId: this.curTaskApply.flowTaskId,
- approvePass: "PASS"
- };
- const data = await taskAuditApply(datas).catch(() => {});
- if (!data) return;
- this.$message.success("审批成功!");
- this.$emit("modified");
- },
- // image-preview
- toPreview(index) {
- this.curImageIndex = index;
- this.selectImage(index);
- this.$refs.SimpleImagePreview.open();
- },
- selectImage(index) {
- this.curImage = this.paperConfirmAttachments[index];
- },
- toPrevImage() {
- if (this.curImageIndex === 0) {
- this.curImageIndex = this.paperConfirmAttachments.length - 1;
- } else {
- this.curImageIndex--;
- }
- this.selectImage(this.curImageIndex);
- },
- toNextImage() {
- if (this.curImageIndex === this.paperConfirmAttachments.length - 1) {
- this.curImageIndex = 0;
- } else {
- this.curImageIndex++;
- }
- this.selectImage(this.curImageIndex);
- }
- }
- };
- </script>
|