Pārlūkot izejas kodu

feat: 卷库预览

zhangjie 8 mēneši atpakaļ
vecāks
revīzija
f6a5b8c786

+ 0 - 1567
src/modules/exam/components/ApplyContent.vue

@@ -1,1567 +0,0 @@
-<template>
-  <div class="apply-content task-detail">
-    <div class="task-body">
-      <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 class="table mb-2">
-        <colgroup>
-          <col width="100" />
-          <col width="240" />
-          <col />
-          <col v-if="IS_APPLY && !IS_REBUILD" width="80" />
-        </colgroup>
-        <tr>
-          <th>试卷类型</th>
-          <th>试卷文件</th>
-          <th>答题卡</th>
-          <th v-if="IS_APPLY && !IS_REBUILD">操作</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>
-          <template v-if="IS_TIKU_TAB">
-            <td>
-              <el-button
-                v-if="!attachment.isExposed && IS_APPLY"
-                type="text"
-                class="btn-primary"
-                @click="toSelect(attachment)"
-              >
-                <i
-                  :class="[
-                    'icon',
-                    attachment.attachmentId ? 'icon-files-act' : 'icon-files',
-                  ]"
-                ></i
-                >{{ 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>
-              <template v-if="IS_APPLY">
-                <el-select
-                  v-model="attachment.cardId"
-                  placeholder="请选择"
-                  style="width: 260px; margin-right: 10px"
-                >
-                  <el-option
-                    v-if="attachment.cardId"
-                    :value="attachment.cardId"
-                    :label="attachment.cardTitle"
-                  >
-                  </el-option>
-                </el-select>
-                <el-button
-                  class="btn-primary"
-                  type="text"
-                  :disabled="!attachment.cardId"
-                  @click="toViewCard(attachment)"
-                  >预览</el-button
-                >
-                <el-button
-                  v-if="!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="!attachment.isExposed && 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>
-              <template v-if="IS_APPLY">
-                <el-select
-                  class="mr-2"
-                  v-model="attachment.cardId"
-                  placeholder="请选择"
-                  style="width: 200px"
-                  filterable
-                  @visible-change="
-                    (visible) => cardOptionOpened(visible, attachment)
-                  "
-                  @change="cardChange(attachment)"
-                >
-                  <el-option
-                    v-for="item in cards"
-                    :key="item.id"
-                    :value="item.id"
-                    :label="item.title"
-                    :disabled="item.disabled"
-                  >
-                    <span
-                      :class="[
-                        item.type === 'GENERIC'
-                          ? 'color-success'
-                          : 'color-primary',
-                        'mr-1',
-                        {
-                          'color-danger': item.used,
-                        },
-                      ]"
-                      >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
-                    >
-                    {{ item.title }}
-                  </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="!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.used && attachment.createId === user.id)
-                    "
-                    @click="toEditCard(attachment)"
-                    >编辑</el-button
-                  >
-                  <el-button
-                    class="btn-primary"
-                    type="text"
-                    :disabled="!canCreateCard"
-                    @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="IS_APPLY && !IS_REBUILD" 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="attachment.canDelete"
-              class="btn-danger btn-icon"
-              type="text"
-              icon="el-icon-remove"
-              @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>
-
-      <el-form v-if="!IS_REBUILD">
-        <el-form-item label="单次抽卷卷型数量:" label-width="150">
-          <el-input-number
-            v-model="curTaskApply.drawCount"
-            :min="1"
-            :max="maxFetchCount"
-            :step="1"
-            :controls="false"
-            step-strictly
-            :disabled="!IS_APPLY || exposedMode"
-          ></el-input-number>
-          <!-- :disabled="!IS_APPLY || exposedMode" -->
-        </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>
-      <!-- 作废 -->
-      <el-alert
-        v-if="curTaskApply.taskStatus === 'CANCEL'"
-        class="mt-1"
-        :title="`已作废,原因:${curTaskApply.cancelRemark || ''}`"
-        type="error"
-        :closable="false"
-      >
-      </el-alert>
-
-      <!-- 入库申请-审核阶段 -->
-      <!-- audit history -->
-      <div
-        v-if="flowHistoryList.length && curTaskApply.flowStatus !== 'START'"
-        class="task-audit-history flow-timeline"
-      >
-        <h4 class="mb-4">审核记录:</h4>
-        <el-timeline>
-          <el-timeline-item
-            v-for="flow in flowHistoryList"
-            :key="flow.stepKey"
-            :type="flow.type"
-            hide-timestamp
-            size="large"
-            placement="top"
-            :class="{ 'timeline-item-stop': flow.nextIsNewFlow }"
-          >
-            <div class="flow-item">
-              <div class="flow-item-content">
-                <p v-if="flow.createTime" class="flow-item-time">
-                  {{ flow.createTime | timestampFilter }}
-                </p>
-                <h4 class="flow-item-title">{{ flow.approveUserName }}</h4>
-                <p class="flow-item-desc">
-                  <span
-                    v-if="flow.approveOperation"
-                    :class="{
-                      'color-danger': flow.approveOperation === 'REJECT',
-                    }"
-                    >{{
-                      flow.approveOperation | flowApproveOperationTypeFilter
-                    }}</span
-                  >
-                  <span>{{ flow.approveRemark }}</span>
-                </p>
-                <div
-                  v-if="flow.attachments.length"
-                  class="flow-item-attachment"
-                >
-                  <span>附件:</span>
-                  <more-btn
-                    v-for="item in flow.attachments"
-                    :key="item.name"
-                    type="text"
-                    class="btn-primary"
-                    :data="`${item.name}卷:${item.filename}`"
-                    :show-count="20"
-                    @click="downloadPaper(item)"
-                  ></more-btn>
-                </div>
-                <div
-                  v-if="flow.isApproveSetFlowNextNode && approveUsers.length"
-                  class="flow-item-users"
-                >
-                  <span>审批人:</span>
-                  <el-tag
-                    v-for="user in approveUsers"
-                    :key="user.id"
-                    size="small"
-                    :disable-transitions="false"
-                  >
-                    {{ user.name }}
-                  </el-tag>
-                </div>
-              </div>
-              <div
-                v-if="
-                  flow.isApproveSetFlowNextNode &&
-                  ((IS_AUDIT && auditModal.approvePass === 'PASS') ||
-                    curTaskApply.flowStatus === 'REJECT' ||
-                    curTaskApply.flowStatus === 'CANCEL')
-                "
-                class="flow-item-action"
-              >
-                <el-button
-                  class="user-select"
-                  icon="el-icon-plus"
-                  @click="toSelectNextFlowUser"
-                ></el-button>
-                <p v-if="!approveUsers.length" class="tips-info tips-error">
-                  请选择审核人
-                </p>
-              </div>
-            </div>
-          </el-timeline-item>
-        </el-timeline>
-      </div>
-      <!-- 入库申请-申请阶段 -->
-      <div
-        v-if="flowList.length && curTaskApply.flowStatus === 'START'"
-        class="task-audit-history flow-timeline"
-      >
-        <h4 class="mb-4">流程:</h4>
-        <el-timeline>
-          <el-timeline-item
-            v-for="flow in flowList"
-            :key="flow.taskKey"
-            :type="flow.type"
-          >
-            <div class="flow-item">
-              <div class="flow-item-content">
-                <h4 class="flow-item-title">{{ flow.taskName }}</h4>
-                <p v-if="flow.approveUserNames" class="flow-item-desc">
-                  {{ flow.approveUserNames }}
-                </p>
-                <div
-                  v-if="flow.isApproveSetFlowNextNode && approveUsers.length"
-                  class="flow-item-users"
-                >
-                  <span>审批人:</span>
-                  <el-tag
-                    v-for="user in approveUsers"
-                    :key="user.id"
-                    size="small"
-                    :disable-transitions="false"
-                  >
-                    {{ user.name }}
-                  </el-tag>
-                </div>
-              </div>
-              <div
-                v-if="flow.isApproveSetFlowNextNode"
-                class="flow-item-action"
-              >
-                <el-button
-                  class="user-select"
-                  icon="el-icon-plus"
-                  @click="toSelectNextFlowUser"
-                ></el-button>
-                <p v-if="!approveUsers.length" class="tips-info tips-error">
-                  请选择审核人
-                </p>
-              </div>
-            </div>
-          </el-timeline-item>
-        </el-timeline>
-      </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 rejectSetupList"
-                :key="item.taskKey"
-                :value="item.setup"
-                :label="item.name"
-              >
-              </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="100"
-              clearable
-              show-word-limit
-              placeholder="建议不超过100个字"
-              ref="ReasonInput"
-            ></el-input>
-          </el-form-item>
-          <el-form-item
-            v-if="auditModal.approvePass === 'EXCHANGE'"
-            prop="userId"
-            label="审批人:"
-          >
-            <el-tag
-              v-for="user in exchangeUsers"
-              :key="user.id"
-              :disable-transitions="false"
-              size="medium"
-            >
-              {{ user.name }}
-            </el-tag>
-            <el-button
-              class="ml-2"
-              size="mini"
-              type="primary"
-              @click="toSelectExchangeUser"
-              >选择用户</el-button
-            >
-          </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>
-    <!-- image-preview -->
-    <simple-image-preview
-      :cur-image="curImage"
-      @on-prev="toPrevImage"
-      @on-next="toNextImage"
-      ref="SimpleImagePreview"
-    ></simple-image-preview>
-    <!-- select-user-dialog -->
-    <select-user-dialog
-      v-if="IS_AUDIT || IS_NEED_SELECT_APPROVE_USER"
-      ref="SelectUserDialog"
-      :user-limit-count="userLimitCount"
-      :filter-roles="userFilterRoles"
-      :users="curSelectedUsers"
-      @modified="userSelected"
-    ></select-user-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>
-  </div>
-</template>
-
-<script>
-import UploadPaperDialog from "./UploadPaperDialog";
-import SelectTikuPaperDialog from "./createExamAndPrintTask/SelectTikuPaperDialog.vue";
-import CardBuildDialog from "../../card/components/CardBuildDialog.vue";
-
-import {
-  taskApplyDetail,
-  updateTaskApply,
-  taskAuditApply,
-  cardForSelectList,
-  savePreviewLog,
-} from "../api";
-import { attachmentPreview } from "../../login/api";
-import SimpleImagePreview from "@/components/SimpleImagePreview";
-import SelectUserDialog from "../../base/components/SelectUserDialog";
-import ModifyCard from "../../card/components/ModifyCard";
-import { TASK_AUDIT_RESULT, COMMON_CARD_RULE_ID } from "@/constants/enumerate";
-import {
-  taskFlowDetail,
-  taskFlowApproverExchange,
-  taskFlowNodeInfo,
-  taskFlowApprover,
-  flowDetailByFlowId,
-} from "../../base/api";
-import { copyCard } from "../../card/api";
-
-const initTaskApply = {
-  examId: "",
-  examTaskId: "",
-  category: "",
-  paperNumber: "",
-  paperType: "A",
-  paperAttachmentIds: "",
-  paperConfirmAttachmentIds: "",
-  cardId: "",
-  cardRuleId: "",
-  makeMethod: "",
-  remark: "",
-  courseId: "",
-  courseCode: "",
-  courseName: "",
-  drawCount: 1,
-  exposedPaperType: "",
-  auditContent: [],
-  // 流程
-  flowId: "",
-  flowStatus: "",
-  setup: null,
-  // 工作台任务id
-  flowTaskId: "",
-  // 题卡状态
-  status: "",
-  // 考务规则
-  review: false,
-  includePaper: false,
-  customCard: false,
-  // 作废
-  taskStatus: "",
-  cancelRemark: "",
-};
-
-export default {
-  name: "apply-content",
-  components: {
-    UploadPaperDialog,
-    SimpleImagePreview,
-    SelectUserDialog,
-    ModifyCard,
-    CardBuildDialog,
-    SelectTikuPaperDialog,
-  },
-  props: {
-    examTask: {
-      type: Object,
-      default() {
-        return {};
-      },
-    },
-    editType: {
-      type: String,
-      default: "",
-    },
-  },
-  data() {
-    return {
-      isSubmit: false,
-      tabs: [
-        {
-          name: "上传本地试卷",
-          val: "upload",
-        },
-        {
-          name: "从题库选择试卷",
-          val: "tiku",
-        },
-      ],
-      curTab: "upload",
-      user: {},
-      curTaskApply: { ...initTaskApply },
-      paperConfirmAttachmentId: { attachmentId: "", filename: "", url: "" },
-      paperAttachments: [],
-      paperConfirmAttachments: [],
-      curAttachment: {},
-      curUploadType: "paper",
-      attachmentLimitCount: 26,
-      abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
-      cards: [],
-      task: {},
-      reason: "",
-      TASK_AUDIT_RESULT: { ...TASK_AUDIT_RESULT, EXCHANGE: "转他人审批" },
-      // audit
-      flowList: [],
-      flowInfo: {},
-      auditModal: {
-        approvePass: "PASS",
-        setup: "",
-        remark: "",
-        userId: "",
-      },
-      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",
-          },
-        ],
-      },
-      flowHistoryList: [],
-      rejectSetupList: [], // 可以驳回的节点
-      exchangeUsers: [],
-      selectUserType: "exchange", // exchange:转审,approve:下一节点审核
-      curSelectedUsers: [],
-      auditLogCache: { paper: {}, card: {} },
-      // card-build
-      cardBuildPresetData: {},
-      // 选择下一节点审批人
-      IS_NEED_SELECT_APPROVE_USER: false,
-      nextFlowTaskResult: {}, //下一节点信息
-      approveUsers: [],
-      userLimitCount: 1,
-      userFilterRoles: [],
-      // 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;
-    },
-    FLOW_IS_OVER() {
-      return ["END", "FINISH"].includes(this.curTaskApply.flowStatus);
-    },
-    IS_TIKU_TAB() {
-      return this.curTab === "tiku";
-    },
-    maxFetchCount() {
-      return this.paperAttachments.length < 1
-        ? 1
-        : this.paperAttachments.length;
-    },
-    canCreateCard() {
-      return (
-        this.curTaskApply.courseId &&
-        this.curTaskApply.examId &&
-        this.curTaskApply.cardRuleId !== COMMON_CARD_RULE_ID
-      );
-    },
-    exposedMode() {
-      return !!this.curTaskApply.exposedPaperType;
-    },
-    IS_REBUILD() {
-      return this.curTaskApply.category === "REBUILD";
-    },
-  },
-  mounted() {
-    this.user = this.$ls.get("user", {});
-    this.initData();
-  },
-  methods: {
-    async initData() {
-      const data = await taskApplyDetail(
-        this.examTask.id,
-        this.examTask.source
-      );
-      this.$emit("info-update", {
-        setup: data.setup,
-        semesterName: data.semesterName,
-        examId: data.examId,
-        examName: data.examName,
-        examModel: data.examModel,
-      });
-      this.curTaskApply = this.$objAssign(initTaskApply, data || {});
-      this.curTaskApply.examId =
-        this.curTaskApply.examId || this.examTask.examId;
-      this.curTaskApply.examTaskId = this.examTask.id;
-      this.curTaskApply.courseId = this.examTask.courseId;
-      this.curTaskApply.courseName = this.examTask.courseName;
-      this.curTaskApply.cardRuleId = this.examTask.cardRuleId;
-      this.curTaskApply.customCard = this.examTask.customCard;
-      this.curTaskApply.paperNumber = this.examTask.paperNumber;
-      this.curTaskApply.auditContent = JSON.parse(
-        this.curTaskApply.auditContent || "[]"
-      );
-      this.curTaskApply.includePaper =
-        data.printContent.indexOf("PAPER") !== -1;
-      this.paperAttachments = this.curTaskApply.paperAttachmentIds
-        ? JSON.parse(this.curTaskApply.paperAttachmentIds)
-        : [];
-
-      if (!this.paperAttachments.length) {
-        this.addAtachment();
-      }
-
-      const pAttachment = this.paperAttachments.some((item) => !!item.paperId);
-      if (pAttachment) {
-        this.curTab = "tiku";
-        this.curTaskApply.uuid = pAttachment.uuid || this.$randomCode(32);
-      } else {
-        this.curTab = "upload";
-        this.curTaskApply.uuid = this.$randomCode(32);
-      }
-
-      const exposedPaperType = data.exposedPaperType || "";
-      let exposedPaperTypes = exposedPaperType.split(",");
-      exposedPaperTypes.sort((a, b) => (a > b ? -1 : 1));
-      const maxExposedPaperType = exposedPaperTypes[0];
-      let auditLogCache = { paper: {}, card: {} };
-      this.paperAttachments.forEach((paper) => {
-        paper.canDelete = maxExposedPaperType
-          ? paper.name > maxExposedPaperType
-          : true;
-        paper.isExposed = exposedPaperTypes.includes(paper.name);
-        if (
-          paper.attachmentId &&
-          this.curTaskApply.auditContent.includes("PAPER")
-        )
-          auditLogCache.paper[paper.attachmentId] = false;
-        if (paper.cardId && this.curTaskApply.auditContent.includes("CARD"))
-          auditLogCache.card[paper.cardId] = false;
-      });
-      this.auditLogCache = auditLogCache;
-
-      this.paperConfirmAttachments = this.curTaskApply.paperConfirmAttachmentIds
-        ? JSON.parse(this.curTaskApply.paperConfirmAttachmentIds)
-        : [];
-
-      if (this.IS_APPLY) this.getCardList();
-
-      // flow
-      if (this.curTaskApply.flowStatus === "START") {
-        await this.getFlowList();
-      } else {
-        await this.getFlowHistory();
-        if (!this.IS_PREVIEW && this.curTaskApply.review)
-          this.getCurFlowNodeInfo();
-      }
-
-      // if (this.IS_AUDIT) this.getCurFlowNodeInfo();
-    },
-    async selectMenu(tab) {
-      if (!this.IS_APPLY) return;
-
-      const attachment = this.paperAttachments[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.IS_REBUILD) {
-        this.cards = this.cards.filter((item) => item.type === "GENERIC");
-      }
-    },
-    async getFlowHistory() {
-      if (!this.curTaskApply.flowId) return;
-
-      const data = await taskFlowDetail(this.curTaskApply.flowId).catch(
-        () => {}
-      );
-      if (!data) return;
-
-      const FLOW_STATUS = {
-        SUBMIT: "success",
-        APPROVE: "success",
-        EXCHANGE: "success",
-        REJECT: "danger",
-        END: "success",
-      };
-      let nextFlowId = "";
-      this.flowHistoryList = data.tfFlowViewLogResultList.map((item, index) => {
-        const nextItem = data.tfFlowViewLogResultList[index + 1];
-        nextFlowId = nextItem ? nextItem.flowId : item.flowId;
-        item.nextIsNewFlow = nextFlowId !== item.flowId;
-        item.type = FLOW_STATUS[item.approveOperation];
-        item.attachments = item.paperAttachmentId
-          ? JSON.parse(item.paperAttachmentId)
-          : [];
-        item.isApproveSetFlowNextNode = false;
-        return item;
-      });
-      const flowIsEnd = data.currFlowTaskResult.taskKey === "end";
-      this.flowHistoryList.push({
-        type: flowIsEnd ? "success" : "current",
-        stepKey: this.$randomCode(),
-        approveSetup: data.currFlowTaskResult.setup, //审批人节点
-        approveRemark: data.currFlowTaskResult.taskName, //审批信息
-        approveOperation: flowIsEnd ? "END" : "",
-        approveUserName: data.currFlowTaskResult.approveUserNames, //审批人
-        createTime: null,
-        nextIsNewFlow: false,
-        isApproveSetFlowNextNode: false,
-        attachments: [],
-      });
-    },
-    async getFlowList() {
-      if (!this.curTaskApply.flowId) return;
-      const data = await flowDetailByFlowId(this.curTaskApply.flowId);
-      if (!data) return;
-
-      const modelType =
-        data.flowTaskResultList[0] && data.flowTaskResultList[0].modelType;
-      this.flowInfo = {
-        customFlowId: data.id,
-        version: data.version,
-      };
-      const nextFlowNodeIndex = 1;
-      this.IS_NEED_SELECT_APPROVE_USER = modelType === "APPROVE_SET";
-      const flowList = data.flowTaskResultList || [];
-      this.flowList = flowList.map((flow, index) => {
-        flow.isApproveSetFlowNextNode =
-          this.IS_NEED_SELECT_APPROVE_USER && index === nextFlowNodeIndex;
-        return flow;
-      });
-
-      if (this.flowList.length) {
-        this.flowList[0].type = "success";
-      }
-
-      this.nextFlowTaskResult = this.flowList[nextFlowNodeIndex];
-    },
-    async getCurFlowNodeInfo() {
-      const data = await taskFlowNodeInfo(this.curTaskApply.flowTaskId);
-      this.rejectSetupList = (data && data.rejectSetupList) || [];
-      this.rejectSetupList.forEach((item) => {
-        item.name = `【${item.taskName}】${item.approveUserNames}`;
-      });
-      this.nextFlowTaskResult = data.nextFlowTaskResult;
-      // 被打回给命题老师之后,命题老师只能通过。
-      if (data.setup === 1 && !this.rejectSetupList.length) {
-        this.TASK_AUDIT_RESULT = { PASS: "通过" };
-        this.auditModal.approvePass = "PASS";
-      }
-      // 判断发起人自选,不管approveUserNames有没有值,都可以选择下个审核人员
-      const { modelType, taskKey } = this.nextFlowTaskResult;
-      this.IS_NEED_SELECT_APPROVE_USER =
-        modelType === "APPROVE_SET" && taskKey.toLowerCase() !== "end";
-      this.flowHistoryList[
-        this.flowHistoryList.length - 1
-      ].isApproveSetFlowNextNode = this.IS_NEED_SELECT_APPROVE_USER;
-    },
-    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: "",
-        paperId: null,
-        uuid: null,
-        cardId: "",
-        cardType: "",
-        createMethod: "",
-        cardTitle: "",
-        pages: 0,
-        canDelete: true,
-        isExposed: false,
-        used: false,
-        createId: null,
-      };
-      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(attachment) {
-      this.addPreviewLog(attachment, "card");
-      window.open(
-        this.getRouterPath({
-          name: "CardPreview",
-          params: {
-            cardId: attachment.cardId,
-          },
-        })
-      );
-    },
-    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,
-        type: attachment.cardType,
-        createMethod: attachment.createMethod,
-      });
-      this.$refs.ModifyCard.open();
-    },
-    async cardModified(data) {
-      // data: {id,title}
-      if (!data.id) return;
-
-      if (this.IS_TIKU_TAB) {
-        const aind = this.paperAttachments.findIndex(
-          (item) => item.name === this.curAttachment.name
-        );
-        this.paperAttachments[aind].cardTitle = data.title;
-        return;
-      }
-
-      await this.getCardList();
-      let card = this.cards.find((item) => item.id === data.id);
-
-      const aind = this.paperAttachments.findIndex(
-        (item) => item.name === this.curAttachment.name
-      );
-      if (aind !== -1 && card) {
-        this.paperAttachments[aind].cardId = card.id;
-        this.paperAttachments[aind].cardType = card.type;
-        this.paperAttachments[aind].createMethod = card.createMethod;
-        this.paperAttachments[aind].cardTitle = card.title;
-        this.paperAttachments[aind].used = card.used;
-        this.paperAttachments[aind].createId = card.createId;
-      }
-    },
-    cardChange(attachment) {
-      const card = this.cards.find((item) => item.id === attachment.cardId);
-      if (card) {
-        attachment.cardType = card.type;
-        attachment.createMethod = card.createMethod;
-        attachment.cardTitle = card.title;
-        attachment.used = card.used;
-        attachment.createId = card.createId;
-      }
-    },
-    cardOptionOpened(visible, attachment) {
-      if (!visible) return;
-
-      //   const selectedCardIds = this.paperAttachments.map((item) => item.cardId);
-      //   this.cards = this.cards.map((card) => {
-      //     card.disabled =
-      //       card.id !== attachment.cardId &&
-      //       selectedCardIds.includes(card.id) &&
-      //       card.type !== "GENERIC";
-      //     return card;
-      //   });
-    },
-    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,
-        schoolName: this.$ls.get("schoolName"),
-        makeMethod: "SELF",
-        cardName: res.value,
-        cardRuleId: this.examTask.cardRuleId,
-        type: "CUSTOM",
-        createMethod: "STANDARD",
-      });
-      this.$refs.ModifyCard.open();
-    },
-    cancel() {
-      this.$emit("cancel");
-    },
-    async downloadPaper(attachment) {
-      if (!attachment.attachmentId) return;
-      this.addPreviewLog(attachment, "paper");
-      const data = await attachmentPreview(attachment.attachmentId);
-      window.open(data[0]?.url);
-    },
-    toSelectNextFlowUser() {
-      if (!this.IS_NEED_SELECT_APPROVE_USER) return;
-
-      this.userLimitCount =
-        this.nextFlowTaskResult.approveUserCountType === "ONE" ? 1 : 0;
-      this.userFilterRoles =
-        this.nextFlowTaskResult.approveUserSelectRange === "ROLE"
-          ? this.nextFlowTaskResult.approveUserSelectRoles.map(
-              (item) => item.id
-            )
-          : [];
-      this.selectUserType = "approve";
-      this.curSelectedUsers = this.approveUsers;
-      this.$refs.SelectUserDialog.open();
-    },
-    toSelectExchangeUser() {
-      this.userLimitCount = 1;
-      this.userFilterRoles = [];
-      this.curSelectedUsers = this.exchangeUsers;
-      this.selectUserType = "exchange";
-      this.$refs.SelectUserDialog.open();
-    },
-    userSelected(users) {
-      if (this.selectUserType === "exchange") {
-        this.exchangeUsers = users;
-        this.auditModal.userId = users[0].id;
-      } else {
-        this.approveUsers = users;
-      }
-    },
-    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.IS_NEED_SELECT_APPROVE_USER)
-        data.approveUserIds = this.approveUsers.map((item) => item.id);
-      return data;
-    },
-    checkDataValid() {
-      if (this.IS_TIKU_TAB) {
-        const attachmentValid = !this.paperAttachments.some(
-          (item) => !item.cardId
-        );
-        if (!attachmentValid) {
-          this.$message.error("请完成试卷选择!");
-          return;
-        }
-      } else {
-        // 设置了入库强制包含试卷时,校验试卷是否上传。
-        // 未设置入库强制包含试卷时,若有试卷上传,则需要上传全部。若无试卷上传,则通过。
-        if (this.curTaskApply.includePaper) {
-          const attachmentValid = !this.paperAttachments.some(
-            (item) => !item.attachmentId
-          );
-          if (!attachmentValid) {
-            this.$message.error("请完成试卷文件上传!");
-            return;
-          }
-        } else {
-          const hasUploadPaperAttachments = this.paperAttachments.filter(
-            (item) => item.attachmentId
-          );
-          if (
-            hasUploadPaperAttachments.length > 0 &&
-            hasUploadPaperAttachments.length !== this.paperAttachments.length
-          ) {
-            this.$message.error("有试卷文件未完成上传!");
-            return;
-          }
-        }
-
-        const cardValid = !this.paperAttachments.some((item) => !item.cardId);
-        if (!cardValid) {
-          this.$message.error("有试卷类型未选择题卡!");
-          return;
-        }
-      }
-
-      if (this.IS_NEED_SELECT_APPROVE_USER && !this.approveUsers.length) {
-        this.$message.error("请设置审核人员!");
-        return;
-      }
-
-      return true;
-    },
-    // select-paper
-    toSelect(attachment) {
-      this.curAttachment = {
-        ...attachment,
-        courseId: this.examTask.courseId,
-      };
-      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.curTaskApply.uuid,
-      };
-      this.$refs.CardBuildDialog.open();
-    },
-    cardBuildConfirm(data) {
-      if (!data.success) {
-        this.$message.error(data.message);
-        return;
-      }
-      const ind = this.paperAttachments.findIndex(
-        (item) => item.name === this.curAttachment.name
-      );
-      if (ind === -1) return;
-
-      const info = data.data;
-      this.curAttachment = { ...this.paperAttachments[ind] };
-      this.paperAttachments[ind] = Object.assign(this.paperAttachments[ind], {
-        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,
-      });
-    },
-    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() {
-      if (this.IS_AUDIT && !this.checkAllFilePreview()) {
-        this.$message.error(
-          "还有未被查看过的题卡或试卷,请点击试卷及题卡进行查看审核"
-        );
-        return;
-      }
-
-      const valid = await this.$refs.auditModalComp.validate().catch(() => {});
-      if (!valid) return;
-
-      if (
-        this.auditModal.approvePass === "PASS" &&
-        this.IS_NEED_SELECT_APPROVE_USER &&
-        !this.approveUsers.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 taskFlowApproverExchange(datas).catch(() => {});
-        if (!data) return;
-      } else {
-        let datas = { ...this.auditModal };
-        datas.taskId = this.curTaskApply.flowTaskId;
-
-        if (
-          this.auditModal.approvePass === "PASS" &&
-          this.IS_NEED_SELECT_APPROVE_USER
-        )
-          datas.approveUserIds = this.approveUsers.map((item) => item.id);
-
-        const data = await taskFlowApprover(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");
-    },
-    // audit preview log
-    async addPreviewLog(attachment, type) {
-      if (!this.IS_AUDIT) return;
-      const id = type === "paper" ? attachment.attachmentId : attachment.cardId;
-      if (!Object.prototype.hasOwnProperty.call(this.auditLogCache[type], id))
-        return;
-
-      this.auditLogCache[type][id] = true;
-      await savePreviewLog({
-        examTaskId: this.curTaskApply.examTaskId,
-        paperType: attachment.name,
-        type,
-      });
-    },
-    checkAllFilePreview() {
-      return (
-        !Object.values(this.auditLogCache.paper).some((item) => !item) &&
-        !Object.values(this.auditLogCache.card).some((item) => !item)
-      );
-    },
-    // 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>

+ 0 - 293
src/modules/exam/components/ModifyTaskApply.vue

@@ -1,293 +0,0 @@
-<template>
-  <el-dialog
-    class="modify-task-apply"
-    :visible.sync="modalIsShow"
-    :title="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 part-box-gray">
-      <el-form class="form-info mb-4" label-width="120px">
-        <el-row>
-          <el-col :span="12">
-            <el-form-item label="课程(代码):">
-              <span
-                >{{ modalForm.courseName }}({{ modalForm.courseCode }})</span
-              >
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="机构:">
-              <span>{{ modalForm.teachingRoomName | defaultFieldFilter }}</span>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row>
-          <el-col :span="12">
-            <el-form-item label="使用学期:">
-              <span>{{ modalForm.semesterName || "--" }}</span>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="考试:">
-              <span>{{ modalForm.examName || "--" }}</span>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row>
-          <el-col :span="12">
-            <el-form-item label="拟卷教师:">
-              <span>{{ modalForm.teacherName | defaultFieldFilter }}</span>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="命题老师:">
-              <span>{{ modalForm.propositionName || modalForm.userName }}</span>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row>
-          <el-col :span="12">
-            <el-form-item label="考试时间:">
-              <span v-if="modalForm.examDate && modalForm.examTime">
-                {{ modalForm.examDate }} <i class="mr-1"></i>
-                {{ modalForm.examTime }}
-              </span>
-              <span v-else>--</span>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="审核状态:">
-              <span>{{ modalForm.auditStatus | auditStatusFilter }}</span>
-            </el-form-item>
-          </el-col>
-        </el-row>
-      </el-form>
-
-      <div v-if="examRoomInfoList.length && !IS_MODEL2" class="task-exam-room">
-        <el-table
-          :data="examRoomInfoList"
-          border
-          style="width: 100%"
-          max-height="300px"
-        >
-          <el-table-column
-            v-if="hasClassInfo"
-            prop="clazzNames"
-            label="使用班级"
-            min-width="400"
-          ></el-table-column>
-          <el-table-column
-            prop="studentCount"
-            label="人数"
-            min-width="100"
-          ></el-table-column>
-          <el-table-column
-            prop="printCount"
-            label="总印份数"
-            min-width="100"
-          ></el-table-column>
-        </el-table>
-      </div>
-
-      <div
-        class="part-box part-box-pad task-exam-room"
-        v-if="examRoomInfoList.length && IS_MODEL2"
-      >
-        <p>
-          正式考生{{ examRoomInfoList[0].studentCount }}个,总印份数{{
-            examRoomInfoList[0].printCount
-          }}份(正式考生{{ examRoomInfoList[0].studentCount }}份,备用卷{{
-            examRoomInfoList[0].backupCount
-          }}份)
-        </p>
-        <p>考试对象:{{ examRoomInfoList[0].clazzNames }}</p>
-      </div>
-    </div>
-
-    <apply-content
-      v-if="modalIsShow"
-      ref="ApplyContent"
-      :exam-task="modalForm"
-      :edit-type="editType"
-      @info-update="modalInfoUpdate"
-      @cancel="cancel"
-      @modified="modified"
-    ></apply-content>
-
-    <div slot="footer"></div>
-  </el-dialog>
-</template>
-
-<script>
-import ApplyContent from "./ApplyContent";
-import { examRuleDetail } from "../../base/api";
-import { cancelOrRestartTaskApply, taskApplyExamObject } from "../api";
-import { parseTimeRangeDateAndTime } from "@/plugins/utils";
-
-const initModalForm = {
-  id: null,
-  examId: "",
-  examName: "",
-  examModel: "",
-  category: "",
-  semesterId: "",
-  semesterName: "",
-  courseId: "",
-  courseCode: "",
-  courseName: "",
-  specialty: "",
-  paperNumber: "",
-  startTime: "",
-  endTime: "",
-  cardRuleId: "",
-  cardRuleName: "",
-  flowId: "",
-  setup: null,
-  userId: "",
-  userName: "",
-  propositionName: "",
-  auditStatus: "",
-  reviewStatus: "",
-  source: "",
-  teachingRoomName: "",
-  teacherName: "",
-  lecturerName: "",
-  paperName: "",
-  examDate: "",
-  examTime: "",
-};
-
-export default {
-  name: "modify-task-apply",
-  components: { ApplyContent },
-  props: {
-    instance: {
-      type: Object,
-      default() {
-        return {};
-      },
-    },
-    editType: {
-      type: String,
-      default: "",
-    },
-  },
-  computed: {
-    title() {
-      // editType为主
-      if (this.editType) {
-        const names = {
-          APPLY: "提交入库申请",
-          PREVIEW: "入库申请详情",
-          AUDIT: "审核入库申请",
-        };
-        return names[this.editType];
-      }
-
-      if (this.modalForm.setup === 1 || this.modalForm.setup === null) {
-        return "提交入库申请";
-      } else if (this.modalForm.setup <= 0) {
-        return "入库申请详情";
-      } else {
-        return "审核入库申请";
-      }
-    },
-    IS_MODEL2() {
-      return this.modalForm.examModel === "MODEL2";
-    },
-  },
-  data() {
-    return {
-      modalIsShow: false,
-      modalForm: {},
-      examRule: {},
-      hasClassInfo: false,
-      examRoomInfoList: [],
-      printTotalCount: 0,
-    };
-  },
-  created() {
-    this.getExamRule();
-  },
-  methods: {
-    async getExamRule() {
-      const examRule = await examRuleDetail();
-      this.examRule = examRule || {};
-    },
-    modalInfoUpdate(data) {
-      this.modalForm = this.$objAssign(this.modalForm, data);
-      this.getExamRoomInfo();
-    },
-    initData(val) {
-      this.modalForm = this.$objAssign(initModalForm, val);
-      this.modalForm.review = this.examRule.review;
-      this.modalForm.customCard = this.examRule.customCard;
-    },
-    visibleChange() {
-      this.initData(this.instance);
-    },
-    async getExamRoomInfo() {
-      const data = await taskApplyExamObject({
-        paperNumber: this.modalForm.paperNumber,
-        examId: this.modalForm.examId,
-      });
-
-      if (this.IS_MODEL2) {
-        const { printCount, clazzNames } = data.examRoomInfoList[0];
-        const nums = printCount.split("+").map((item) => item * 1);
-        this.examRoomInfoList = [
-          {
-            backupCount: nums[1],
-            studentCount: nums[0],
-            printCount: nums[0] + nums[1],
-            clazzNames,
-          },
-        ];
-      } else {
-        this.examRoomInfoList = data.examRoomInfoList || [];
-        this.hasClassInfo = this.examRoomInfoList.some(
-          (item) => item.clazzNames
-        );
-      }
-      this.printTotalCount = data.printTotalCount;
-      this.modalForm.paperName = data.paperName || "";
-      const { date, time } = parseTimeRangeDateAndTime(
-        data.examStartTime,
-        data.examEndTime
-      );
-
-      this.modalForm.examDate = date;
-      this.modalForm.examTime = time;
-    },
-    cancel() {
-      this.modalIsShow = false;
-    },
-    open() {
-      this.modalIsShow = true;
-    },
-    toCancel() {
-      this.$confirm("确定要撤销当前申请吗?", "提示", {
-        type: "warning",
-      })
-        .then(async () => {
-          const data = await cancelOrRestartTaskApply({
-            id: this.instance.id,
-          }).catch(() => {});
-          if (!data) return;
-          this.$message.success("操作成功!");
-          this.modified();
-        })
-        .catch(() => {});
-    },
-    modified() {
-      this.cancel();
-      this.$emit("modified");
-    },
-  },
-};
-</script>

+ 0 - 656
src/modules/exam/components/ModifyTaskPaper.vue

@@ -1,656 +0,0 @@
-<template>
-  <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">
-        <el-form class="form-info" label-width="100px">
-          <el-row>
-            <el-col :span="12">
-              <el-form-item label="试卷编号:">
-                <span>{{ instance.paperNumber }}</span>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="课程(代码):">
-                <span>
-                  {{ instance.courseName }}({{ instance.courseCode }})
-                </span>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="12">
-              <el-form-item label="卷型:">
-                <span>{{ instance.paperType }}</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>
-            <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>
-
-      <div>
-        <div v-if="IS_EDIT && !IS_REBUILD" class="mb-2 text-right">
-          <el-button
-            type="info"
-            icon="el-icon-circle-plus-outline"
-            @click="addAtachment"
-            >增加卷型</el-button
-          >
-        </div>
-        <table class="table">
-          <colgroup>
-            <col width="100" />
-            <col width="280" />
-            <col />
-            <col v-if="IS_EDIT" width="60" />
-          </colgroup>
-          <tr>
-            <th>试卷类型</th>
-            <th>试卷文件</th>
-            <th>答题卡</th>
-            <th v-if="IS_EDIT">操作</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_EDIT"
-                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="toViewAttachment(attachment)"
-              >
-                <i
-                  class="icon icon-download mr-1"
-                  v-if="attachment.attachmentId"
-                ></i>
-                {{ attachment.filename }}
-              </el-button>
-            </td>
-            <td>
-              <template v-if="CAN_EDIT_CARD">
-                <el-select
-                  class="mr-2"
-                  v-model="attachment.cardId"
-                  placeholder="请选择"
-                  style="width: 200px"
-                  filterable
-                  @visible-change="
-                    (visible) => cardOptionOpened(visible, attachment)
-                  "
-                  @change="cardChange(attachment)"
-                >
-                  <el-option
-                    v-for="item in cards"
-                    :key="item.id"
-                    :value="item.id"
-                    :label="item.title"
-                    :disabled="item.disabled"
-                  >
-                    <span
-                      :class="[
-                        item.type === 'GENERIC'
-                          ? 'color-success'
-                          : 'color-primary',
-                        'mr-1',
-                        {
-                          'color-danger': item.used,
-                        },
-                      ]"
-                      >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
-                    >
-                    {{ item.title }}
-                  </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
-                >
-                <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.used && attachment.createId === user.id) ||
-                    !(
-                      attachment.used &&
-                      attachment.savedCardId &&
-                      attachment.savedCardId === attachment.cardId
-                    )
-                  "
-                  @click="toEditCard(attachment)"
-                  >编辑</el-button
-                >
-                <el-button
-                  class="btn-primary"
-                  type="text"
-                  :disabled="!canCreateCard"
-                  @click="toCreateCard(attachment)"
-                  >新建</el-button
-                >
-              </template>
-              <el-button
-                v-else
-                type="text"
-                class="btn-primary"
-                @click="toViewCard(attachment)"
-              >
-                {{ attachment.cardTitle || "预览" }}
-              </el-button>
-            </td>
-            <td v-if="IS_EDIT">
-              <el-button
-                v-if="attachment.canDelete"
-                class="btn-danger btn-icon"
-                type="text"
-                icon="el-icon-remove"
-                @click="deleteAttachment(index)"
-              ></el-button>
-            </td>
-          </tr>
-        </table>
-
-        <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_EDIT || exposedMode"
-            ></el-input-number>
-          </el-form-item>
-        </el-form>
-      </div>
-
-      <div slot="footer">
-        <el-button
-          v-if="IS_EDIT"
-          type="primary"
-          :disabled="isSubmit"
-          @click="submit"
-          >确认提交</el-button
-        >
-        <el-button @click="cancel">取消</el-button>
-      </div>
-    </el-dialog>
-
-    <!-- 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>
-    <!-- card-preview-dialog -->
-    <card-preview-dialog
-      ref="CardPreviewDialog"
-      :card-id="curAttachment.cardId"
-      show-watermark
-    ></card-preview-dialog>
-
-    <!-- PreviewAttachment -->
-    <preview-attachment
-      ref="PreviewAttachment"
-      :attachment-ids="attachmentIds"
-    ></preview-attachment>
-  </div>
-</template>
-
-<script>
-import UploadPaperDialog from "./UploadPaperDialog";
-import ModifyCard from "../../card/components/ModifyCard";
-import CardPreviewDialog from "../../card/components/CardPreviewDialog.vue";
-import PreviewAttachment from "@/components/PreviewAttachment.vue";
-import { taskApplyDetail, taskPaperApplyEdit, cardForSelectList } from "../api";
-import { COMMON_CARD_RULE_ID } from "@/constants/enumerate";
-import { copyCard } from "../../card/api";
-
-const initTaskApply = {
-  examId: "",
-  examTaskId: "",
-  category: "",
-  paperType: "A",
-  paperAttachmentIds: "",
-  cardId: "",
-  cardRuleId: "",
-  makeMethod: "",
-  courseId: "",
-  courseCode: "",
-  courseName: "",
-  drawCount: 1,
-  exposedPaperType: "",
-  // 题卡状态
-  status: "",
-  // 考务规则
-  includePaper: false,
-  customCard: false,
-};
-
-export default {
-  name: "modify-task-paper",
-  components: {
-    UploadPaperDialog,
-    ModifyCard,
-    CardPreviewDialog,
-    PreviewAttachment,
-  },
-  props: {
-    instance: {
-      type: Object,
-      default() {
-        return {};
-      },
-    },
-    editType: {
-      type: String,
-      default: "PREVIEW",
-      validator: (val) => ["EDIT", "PREVIEW"].includes(val),
-    },
-  },
-  computed: {
-    title() {
-      const names = {
-        EDIT: "申请编辑卷库",
-        PREVIEW: "卷库详情",
-      };
-      return names[this.editType];
-    },
-    IS_PREVIEW() {
-      return this.editType === "PREVIEW";
-    },
-    IS_EDIT() {
-      return this.editType === "EDIT";
-    },
-    CAN_EDIT_CARD() {
-      return this.editType === "EDIT" && !this.instance.exposedPaperType;
-    },
-    maxFetchCount() {
-      return this.paperAttachments.length < 1
-        ? 1
-        : this.paperAttachments.length;
-    },
-    canCreateCard() {
-      return (
-        this.curTaskApply.courseId &&
-        this.curTaskApply.examId &&
-        this.curTaskApply.cardRuleId !== COMMON_CARD_RULE_ID
-      );
-    },
-    exposedMode() {
-      return !!this.curTaskApply.exposedPaperType;
-    },
-    IS_REBUILD() {
-      return this.curTaskApply.category === "REBUILD";
-    },
-  },
-  data() {
-    return {
-      isSubmit: false,
-      modalIsShow: false,
-      curTaskApply: { ...initTaskApply },
-      paperAttachments: [],
-      curAttachment: {},
-      curUploadType: "paper",
-      abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
-      cards: [],
-      user: this.$ls.get("user", {}),
-      // attachmentId preview
-      attachmentIds: [],
-    };
-  },
-  methods: {
-    async getCardList() {
-      if (!this.curTaskApply.courseId || !this.curTaskApply.examId) return;
-      const data = await cardForSelectList({
-        courseId: this.curTaskApply.courseId,
-        examId: this.curTaskApply.examId,
-        paperNumber: this.instance.paperNumber,
-      });
-      this.cards = data || [];
-      if (this.IS_REBUILD) {
-        this.cards = this.cards.filter((item) => item.type === "GENERIC");
-      }
-    },
-    async visibleChange() {
-      const data = await taskApplyDetail(this.instance.id);
-      this.curTaskApply = this.$objAssign(initTaskApply, data || {});
-      this.curTaskApply.courseId = this.instance.courseId;
-      this.curTaskApply.courseName = this.instance.courseName;
-      this.curTaskApply.cardRuleId = this.instance.cardRuleId;
-      this.curTaskApply.includePaper =
-        data.printContent.indexOf("PAPER") !== -1;
-      this.paperAttachments = data.paperAttachmentIds
-        ? JSON.parse(data.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);
-        paper.savedCardId = paper.cardId;
-      });
-
-      this.$nextTick(() => {
-        if (this.CAN_EDIT_CARD) {
-          this.getCardList();
-        }
-      });
-    },
-    cancel() {
-      this.modalIsShow = false;
-    },
-    open() {
-      this.modalIsShow = true;
-    },
-    addAtachment() {
-      if (this.paperAttachments.length >= this.abc.length) return;
-
-      const name = this.abc[this.paperAttachments.length];
-      const newAttachment = {
-        name,
-        attachmentId: "",
-        filename: "",
-        savedCardId: null,
-        cardId: "",
-        cardType: "",
-        createMethod: "",
-        cardTitle: "",
-        pages: 0,
-        canDelete: true,
-        isExposed: false,
-        used: false,
-        createId: null,
-      };
-      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();
-    },
-    uploadConfirm(attachment, uploadType) {
-      if (uploadType === "paper") {
-        const index = this.paperAttachments.findIndex(
-          (item) => item.name === attachment.name
-        );
-        this.paperAttachments.splice(index, 1, { ...attachment });
-      }
-    },
-    toViewAttachment(attachment) {
-      if (!attachment.jpgAttachmentId) {
-        this.$message.error("附件丢失!");
-        return;
-      }
-      const datas = JSON.parse(attachment.jpgAttachmentId);
-      this.attachmentIds = datas.map((item) => item.attachmentId);
-      this.$refs.PreviewAttachment.open();
-    },
-    toViewCard(attachment) {
-      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,
-        paperType: this.paperAttachments.map((item) => item.name).join(","),
-        type: attachment.cardType,
-        createMethod: attachment.createMethod,
-      });
-      this.$refs.ModifyCard.open();
-    },
-    async cardModified(data) {
-      if (!data.id) return;
-      await this.getCardList();
-      let card = this.cards.find((item) => item.id === data.id);
-
-      const aind = this.paperAttachments.findIndex(
-        (item) => item.name === this.curAttachment.name
-      );
-      if (aind !== -1 && card) {
-        this.paperAttachments[aind].cardId = card.id;
-        this.paperAttachments[aind].cardType = card.type;
-        this.paperAttachments[aind].createMethod = card.createMethod;
-        this.paperAttachments[aind].cardTitle = card.title;
-        this.paperAttachments[aind].used = card.used;
-        this.paperAttachments[aind].createId = card.createId;
-      }
-    },
-    async toCreateCard(attachment) {
-      if (!this.curTaskApply.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.curTaskApply.courseId,
-        courseName: this.curTaskApply.courseName,
-        schoolName: this.$ls.get("schoolName"),
-        makeMethod: "SELF",
-        cardName: res.value,
-        cardRuleId: this.curTaskApply.cardRuleId,
-        type: "CUSTOM",
-        createMethod: "STANDARD",
-      });
-      this.$refs.ModifyCard.open();
-    },
-    cardChange(attachment) {
-      const card = this.cards.find((item) => item.id === attachment.cardId);
-      if (card) {
-        attachment.cardType = card.type;
-        attachment.createMethod = card.createMethod;
-        attachment.cardTitle = card.title;
-        attachment.used = card.used;
-        attachment.createId = card.createId;
-      }
-    },
-    cardOptionOpened(visible, attachment) {
-      if (!visible) return;
-
-      //   const selectedCardIds = this.paperAttachments.map((item) => item.cardId);
-      //   this.cards = this.cards.map((card) => {
-      //     card.disabled =
-      //       card.id !== attachment.cardId &&
-      //       selectedCardIds.includes(card.id) &&
-      //       card.type !== "GENERIC";
-      //     return card;
-      //   });
-    },
-    checkDataValid() {
-      // 设置了入库强制包含试卷时,校验试卷是否上传。
-      // 未设置入库强制包含试卷时,若有试卷上传,则需要上传全部。若无试卷上传,则通过。
-      if (this.curTaskApply.includePaper) {
-        const attachmentValid = !this.paperAttachments.some(
-          (item) => !item.attachmentId
-        );
-        if (!attachmentValid) {
-          this.$message.error("请完成试卷文件上传!");
-          return;
-        }
-      } else {
-        const hasUploadPaperAttachments = this.paperAttachments.filter(
-          (item) => item.attachmentId
-        );
-        if (
-          hasUploadPaperAttachments.length > 0 &&
-          hasUploadPaperAttachments.length !== this.paperAttachments.length
-        ) {
-          this.$message.error("有试卷文件未完成上传!");
-          return;
-        }
-      }
-
-      let cardValid = !this.paperAttachments.some((item) => !item.cardId);
-      if (!cardValid) {
-        this.$message.error("有试卷类型未选择题卡!");
-        return;
-      }
-
-      //   const usedCards = this.paperAttachments
-      //     .filter((item) => item.cardId && item.used)
-      //     .map((item) => item.name);
-      //   if (usedCards.length) {
-      //     this.$message.error(`${usedCards.join()}卷选择的题卡已经被使用过!`);
-      //     return;
-      //   }
-
-      return true;
-    },
-    async submit() {
-      if (!this.checkDataValid()) return;
-
-      this.$confirm("确定要提交申请修改当前任务吗?", "提示", {
-        type: "warning",
-      })
-        .then(async () => {
-          const datas = {
-            examTaskId: this.curTaskApply.examTaskId,
-            drawCount: this.curTaskApply.drawCount,
-            paperType: this.paperAttachments.map((item) => item.name).join(","),
-            paperAttachmentIds: JSON.stringify(this.paperAttachments),
-          };
-          const data = await taskPaperApplyEdit(datas).catch(() => {});
-          if (!data) return;
-          this.$message.success("提交成功!");
-          this.$emit("modified");
-          this.cancel();
-        })
-        .catch(() => {});
-    },
-  },
-};
-</script>

+ 249 - 0
src/modules/exam/components/PreviewTaskPaper.vue

@@ -0,0 +1,249 @@
+<template>
+  <div class="preview-task-paper">
+    <el-dialog
+      class="task-detail"
+      :visible.sync="modalIsShow"
+      title="预览"
+      top="10vh"
+      width="900px"
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      append-to-body
+      @open="visibleChange"
+      @close="closeHandle"
+    >
+      <div class="part-box part-box-pad part-box-border">
+        <el-form class="form-info" label-width="100px">
+          <el-row>
+            <el-col :span="12">
+              <el-form-item label="试卷编号:">
+                <span>{{ rowData.paperNumber }}</span>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="课程(代码):">
+                <span>
+                  {{ rowData.courseName }}({{ rowData.courseCode }})
+                </span>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="12">
+              <el-form-item label="卷型:">
+                <span>{{ rowData.paperType }}</span>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="命题老师:">
+                <span>{{ rowData.userName }}</span>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="12">
+              <el-form-item label="已曝光:">
+                <span>{{ rowData.exposedPaperType | defaultFieldFilter }}</span>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="未曝光:">
+                <span>{{
+                  rowData.unexposedPaperType | defaultFieldFilter
+                }}</span>
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+      </div>
+
+      <task-paper
+        v-if="dataReady"
+        ref="TaskPaper"
+        @view-attachment="toViewAttachment"
+      ></task-paper>
+
+      <div slot="footer">
+        <el-button @click="cancel">取消</el-button>
+      </div>
+    </el-dialog>
+
+    <!-- PreviewAttachment -->
+    <preview-attachment
+      ref="PreviewAttachment"
+      :attachment-ids="attachmentIds"
+    ></preview-attachment>
+  </div>
+</template>
+
+<script>
+import { mapState, mapMutations } from "vuex";
+import PreviewAttachment from "@/components/PreviewAttachment.vue";
+import TaskPaper from "./taskApply/TaskPaper.vue";
+import { taskApplyDetail } from "../api";
+
+const initExamTask = {
+  id: null,
+  examId: "",
+  examName: "",
+  examModel: "",
+  category: "",
+  semesterId: "",
+  semesterName: "",
+  courseId: "",
+  courseCode: "",
+  courseName: "",
+  specialty: "",
+  paperNumber: "",
+  startTime: "",
+  endTime: "",
+  cardRuleId: "",
+  cardRuleName: "",
+  flowId: "",
+  setup: null,
+  userId: "",
+  userName: "",
+  propositionName: "",
+  auditStatus: "",
+  reviewStatus: "",
+  source: "",
+  teachingRoomName: "",
+  teacherName: "",
+  lecturerName: "",
+  openAb: false,
+};
+
+const initTaskApply = {
+  examId: "",
+  examTaskId: "",
+  category: "",
+  paperNumber: "",
+  paperType: "A",
+  paperAttachmentIds: "",
+  paperConfirmAttachmentIds: "",
+  cardId: "",
+  cardRuleId: "",
+  makeMethod: "",
+  remark: "",
+  courseId: "",
+  courseCode: "",
+  courseName: "",
+  drawCount: 1,
+  exposedPaperType: "",
+  auditContent: [],
+  examTaskDetailList: [],
+  openAb: false,
+  // 入库申请中新建的命题任务提交信息
+  examTaskContent: "",
+
+  // 流程
+  flowId: "",
+  flowStatus: "",
+  setup: null,
+  // 工作台任务id
+  flowTaskId: "",
+  // 题卡状态
+  status: "",
+  // 考务规则
+  review: false,
+  includePaper: false,
+  customCard: false,
+  // 作废
+  taskStatus: "",
+  cancelRemark: "",
+};
+
+export default {
+  name: "preview-task-paper",
+  components: {
+    PreviewAttachment,
+    TaskPaper,
+  },
+  props: {
+    rowData: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+  },
+  computed: {
+    ...mapState("exam", ["examTask", "curTaskApply", "taskStatus"]),
+  },
+  data() {
+    return {
+      isSubmit: false,
+      modalIsShow: false,
+      dataReady: false,
+      attachmentIds: [],
+    };
+  },
+  methods: {
+    ...mapMutations("exam", [
+      "setExamTask",
+      "setCurTaskApply",
+      "setTaskStatus",
+    ]),
+    visibleChange() {
+      this.initData();
+    },
+    async initData() {
+      const data = await taskApplyDetail(this.rowData.id);
+      const examTask = this.$objAssign(initExamTask, {
+        ...this.rowData,
+        setup: data.setup,
+        semesterName: data.semesterName,
+        examId: data.examId,
+        examName: data.examName,
+        examModel: data.examModel,
+      });
+
+      const curTaskApply = this.$objAssign(initTaskApply, {
+        ...data,
+        examTaskId: examTask.id,
+        courseId: examTask.courseId,
+        courseName: examTask.courseName,
+        cardRuleId: examTask.cardRuleId,
+        customCard: examTask.customCard,
+        paperNumber: examTask.paperNumber,
+        auditContent: JSON.parse(data.auditContent || "[]"),
+        includePaper: data.printContent.indexOf("PAPER") !== -1,
+      });
+
+      examTask.openAb = data.openAb;
+      this.setExamTask(examTask);
+      this.setCurTaskApply(curTaskApply);
+
+      this.setTaskStatus({
+        IS_APPLY: false,
+        IS_PREVIEW: true,
+        IS_AUDIT: false,
+        IS_REBUILD: curTaskApply.category === "REBUILD",
+      });
+      this.dataReady = true;
+    },
+    closeHandle() {
+      this.dataReady = false;
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    toViewAttachment(attachment) {
+      if (!attachment.jpgAttachmentId) {
+        this.$message.error("附件丢失!");
+        return;
+      }
+      const datas = JSON.parse(attachment.jpgAttachmentId);
+      this.attachmentIds = datas.map((item) => item.attachmentId);
+      this.$refs.PreviewAttachment.open();
+    },
+    toViewCard(attachment) {
+      this.curAttachment = { ...attachment };
+      this.$refs.CardPreviewDialog.open();
+    },
+  },
+};
+</script>

+ 32 - 32
src/modules/exam/components/taskApply/TaskPaper.vue

@@ -4,7 +4,7 @@
       <el-form-item label="启用AB卷:">
         <el-switch
           v-model="openAb"
-          :disabled="!this.taskStatus.IS_APPLY"
+          :disabled="!taskStatus.IS_APPLY"
           @change="openAbChange"
         ></el-switch>
       </el-form-item>
@@ -361,7 +361,7 @@
         >(最多4个,仅限{{ attachmentFormat.join("、") }}文件)</span
       >:
     </h4>
-    <div class="image-list">
+    <div>
       <div
         v-for="(item, index) in imageAttachments"
         :key="`image${index}`"
@@ -388,7 +388,6 @@
       >
         <i class="el-icon-plus"></i>
       </div>
-      <br />
       <div
         class="audio-item"
         v-for="(item, index) in audioAttachments"
@@ -429,35 +428,29 @@
       <p v-else>暂无</p>
     </div>
 
-    <!-- upload-paper-dialog -->
-    <upload-paper-dialog
-      :paper-attachment="curAttachment"
-      :upload-type="curUploadType"
-      @confirm="uploadConfirm"
-      ref="UploadPaperDialog"
-    ></upload-paper-dialog>
-    <!-- image-preview -->
-    <simple-image-preview
-      :cur-image="curImage"
-      @on-prev="toPrevImage"
-      @on-next="toNextImage"
-      ref="SimpleImagePreview"
-    ></simple-image-preview>
-    <!-- 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 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
@@ -465,6 +458,13 @@
       :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>
   </div>
 </template>
 

+ 9 - 25
src/modules/exam/views/TaskPaperManage.vue

@@ -128,13 +128,6 @@
               @click="toPreview(scope.row)"
               >预览</el-button
             >
-            <el-button
-              v-if="checkPrivilege('link', 'edit')"
-              class="btn-primary"
-              type="text"
-              @click="toEdit(scope.row)"
-              >编辑</el-button
-            >
             <el-button
               v-if="checkPrivilege('link', 'enable')"
               :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
@@ -190,14 +183,12 @@
       </div>
     </div>
 
-    <!-- ModifyTaskPaper -->
-    <modify-task-paper
-      v-if="checkPrivilege('link', 'edit') || checkPrivilege('link', 'preview')"
-      :instance="curPaper"
-      :edit-type="editType"
-      ref="ModifyTaskPaper"
-      @modified="getList"
-    ></modify-task-paper>
+    <!-- PreviewTaskPaper -->
+    <preview-task-paper
+      v-if="checkPrivilege('link', 'preview')"
+      ref="PreviewTaskPaper"
+      :row-data="curPaper"
+    ></preview-task-paper>
     <!-- PublishPrintTask -->
     <publish-print-task
       v-if="checkPrivilege('link', 'publish')"
@@ -225,12 +216,12 @@ import {
 import pickerOptions from "@/constants/datePickerOptions";
 import { downloadByApi } from "@/plugins/download";
 import { CARD_SOURCE_TYPE } from "@/constants/enumerate";
-import ModifyTaskPaper from "../components/ModifyTaskPaper";
+import PreviewTaskPaper from "../components/PreviewTaskPaper.vue";
 import PublishPrintTask from "../components/PublishPrintTask";
 
 export default {
   name: "task-paper-manage",
-  components: { ModifyTaskPaper, PublishPrintTask },
+  components: { PreviewTaskPaper, PublishPrintTask },
   data() {
     return {
       filter: {
@@ -250,7 +241,6 @@ export default {
       papers: [],
       curPaper: {},
       loading: false,
-      editType: "EDIT",
       CARD_SOURCE_TYPE,
       IS_QUESTION_TEACHER: this.$ls
         .get("user", { roleList: [] })
@@ -384,15 +374,9 @@ export default {
       this.$message.success("操作成功!");
       this.getList();
     },
-    toEdit(row) {
-      this.curPaper = row;
-      this.editType = "EDIT";
-      this.$refs.ModifyTaskPaper.open();
-    },
     toPreview(row) {
       this.curPaper = row;
-      this.editType = "PREVIEW";
-      this.$refs.ModifyTaskPaper.open();
+      this.$refs.PreviewTaskPaper.open();
     },
     toPublishPrintTask(row) {
       this.curPaper = row;