ApplyContent.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  1. <template>
  2. <div class="apply-content task-detail">
  3. <div class="task-body">
  4. <div v-if="IS_APPLY" class="mb-2 text-right">
  5. <el-button
  6. type="info"
  7. icon="el-icon-circle-plus-outline"
  8. @click="addAtachment"
  9. >增加卷型</el-button
  10. >
  11. </div>
  12. <table class="table mb-2">
  13. <tr>
  14. <th>试卷类型</th>
  15. <th>试卷文件</th>
  16. <th>答题卡</th>
  17. <th v-if="IS_APPLY">操作</th>
  18. </tr>
  19. <tr v-for="(attachment, index) in paperAttachments" :key="index">
  20. <td>
  21. <span>{{ attachment.name }}卷</span>
  22. <span class="color-gray-2" v-if="attachment.isExposed"
  23. >(已曝光)</span
  24. >
  25. </td>
  26. <td>
  27. <el-button
  28. v-if="!attachment.isExposed && IS_APPLY"
  29. type="text"
  30. class="btn-primary"
  31. @click="toUpload(attachment)"
  32. >
  33. <i
  34. :class="[
  35. 'icon',
  36. attachment.attachmentId ? 'icon-files-act' : 'icon-files'
  37. ]"
  38. ></i
  39. >{{
  40. attachment.attachmentId
  41. ? attachment.filename
  42. : "点击上传试卷文件"
  43. }}
  44. </el-button>
  45. <el-button
  46. v-else
  47. type="text"
  48. class="btn-primary"
  49. @click="downloadPaper(attachment)"
  50. >
  51. <i
  52. class="icon icon-download mr-1"
  53. v-if="attachment.attachmentId"
  54. ></i>
  55. <i>{{ attachment.filename }}</i>
  56. </el-button>
  57. </td>
  58. <td>
  59. <template v-if="IS_APPLY">
  60. <el-select
  61. class="mr-2"
  62. v-model="attachment.cardId"
  63. placeholder="请选择"
  64. style="width: 200px"
  65. filterable
  66. @change="cardChange(attachment)"
  67. >
  68. <el-option
  69. v-for="item in cards"
  70. :key="item.id"
  71. :value="item.id"
  72. :label="item.title"
  73. >
  74. </el-option>
  75. </el-select>
  76. <el-button
  77. class="btn-primary"
  78. type="text"
  79. :disabled="!attachment.cardId"
  80. @click="toViewCard(attachment)"
  81. >预览</el-button
  82. >
  83. <el-button
  84. class="btn-primary"
  85. type="text"
  86. :disabled="
  87. !attachment.cardId || attachment.cardType === 'GENERIC'
  88. "
  89. @click="toEditCard(attachment)"
  90. >编辑</el-button
  91. >
  92. <el-button
  93. class="btn-primary"
  94. type="text"
  95. :disabled="!canCreateCard"
  96. @click="toCreateCard(attachment)"
  97. >新建</el-button
  98. >
  99. </template>
  100. <el-button
  101. v-else
  102. type="text"
  103. class="btn-primary"
  104. @click="toViewCard(attachment)"
  105. >{{ attachment.cardTitle || "预览" }}</el-button
  106. >
  107. </td>
  108. <td v-if="IS_APPLY">
  109. <el-button
  110. v-if="attachment.canDelete"
  111. class="btn-danger"
  112. type="text"
  113. @click="deleteAttachment(index)"
  114. >删除</el-button
  115. >
  116. </td>
  117. </tr>
  118. <tr v-if="!paperAttachments.length">
  119. <td colspan="5">
  120. <p class="tips-info text-center">暂无数据</p>
  121. </td>
  122. </tr>
  123. </table>
  124. <p class="tips-info tips-dark mb-2">
  125. 提示:多卷型试卷由于会绑定一个答题卡模板,因此试卷结构必须相同。多卷型试卷之间客观题要求试题内容相同,可允许大题内的小题题序不同。
  126. </p>
  127. <el-form>
  128. <el-form-item label="单次抽卷卷型数量:" label-width="150">
  129. <el-input-number
  130. v-model="curTaskApply.drawCount"
  131. :min="1"
  132. :max="maxFetchCount"
  133. :step="1"
  134. :controls="false"
  135. step-strictly
  136. disabled
  137. ></el-input-number>
  138. <!-- :disabled="!IS_APPLY || exposedMode" -->
  139. </el-form-item>
  140. </el-form>
  141. <h4 class="mb-2">附件<span v-if="IS_APPLY">(最多4张)</span>:</h4>
  142. <div class="image-list">
  143. <div
  144. class="image-item"
  145. v-for="(img, index) in paperConfirmAttachments"
  146. :key="index"
  147. >
  148. <img
  149. :src="img.url"
  150. :alt="img.filename"
  151. title="点击查看大图"
  152. @click="toPreview(index)"
  153. />
  154. <div v-if="IS_APPLY" class="image-delete">
  155. <i
  156. class="el-icon-delete-solid"
  157. @click="deletePaperConfirmAttachment(index)"
  158. ></i>
  159. </div>
  160. </div>
  161. <div
  162. v-if="paperConfirmAttachments.length < 4 && IS_APPLY"
  163. class="image-item image-add"
  164. title="上传附件"
  165. @click="toUploadPaperConfirm"
  166. >
  167. <i class="el-icon-plus"></i>
  168. </div>
  169. </div>
  170. <div
  171. v-if="!IS_APPLY && !paperConfirmAttachments.length"
  172. class="image-list-none"
  173. >
  174. 暂无数据
  175. </div>
  176. <h4 class="mb-2">附件说明:</h4>
  177. <el-input
  178. v-if="IS_APPLY"
  179. class="mb-2"
  180. v-model="curTaskApply.remark"
  181. type="textarea"
  182. resize="none"
  183. :rows="2"
  184. :maxlength="100"
  185. clearable
  186. show-word-limit
  187. placeholder="建议不超过100个字"
  188. ></el-input>
  189. <div class="color-gray-2" v-else>
  190. <p v-if="curTaskApply.remark">{{ curTaskApply.remark }}</p>
  191. <p v-else>暂无</p>
  192. </div>
  193. <!-- 入库申请-审核阶段 -->
  194. <!-- audit history -->
  195. <div
  196. v-if="flowHistoryList.length && curTaskApply.flowStatus !== 'START'"
  197. class="task-audit-history flow-timeline"
  198. >
  199. <h4 class="mb-4">审核记录:</h4>
  200. <el-timeline>
  201. <el-timeline-item
  202. v-for="flow in flowHistoryList"
  203. :key="flow.stepKey"
  204. :type="flow.type"
  205. hide-timestamp
  206. size="large"
  207. placement="top"
  208. :class="{ 'timeline-item-stop': flow.nextIsNewFlow }"
  209. >
  210. <div class="flow-item">
  211. <div class="flow-item-content">
  212. <p v-if="flow.createTime" class="flow-item-time">
  213. {{ flow.createTime | timestampFilter }}
  214. </p>
  215. <h4 class="flow-item-title">{{ flow.approveUserName }}</h4>
  216. <p class="flow-item-desc">
  217. <span
  218. v-if="flow.approveOperation"
  219. :class="{
  220. 'color-danger': flow.approveOperation === 'REJECT'
  221. }"
  222. >{{
  223. flow.approveOperation | flowApproveOperationTypeFilter
  224. }}</span
  225. >
  226. <span>{{ flow.approveRemark }}</span>
  227. </p>
  228. <div
  229. v-if="flow.attachments.length"
  230. class="flow-item-attachment"
  231. >
  232. <span>附件:</span>
  233. <el-button
  234. v-for="item in flow.attachments"
  235. :key="item.name"
  236. type="text"
  237. class="btn-primary"
  238. @click="downloadPaper(item)"
  239. >{{ item.name }}卷:{{ item.filename }}</el-button
  240. >
  241. </div>
  242. <div
  243. v-if="flow.isApproveSetFlowNextNode && approveUsers.length"
  244. class="flow-item-users"
  245. >
  246. <span>审批人:</span>
  247. <el-tag
  248. v-for="user in approveUsers"
  249. :key="user.id"
  250. size="small"
  251. :disable-transitions="false"
  252. >
  253. {{ user.name }}
  254. </el-tag>
  255. </div>
  256. </div>
  257. <div
  258. v-if="
  259. flow.isApproveSetFlowNextNode &&
  260. auditModal.approvePass === 'PASS'
  261. "
  262. class="flow-item-action"
  263. >
  264. <el-button
  265. class="user-select"
  266. icon="el-icon-plus"
  267. @click="toSelectNextFlowUser"
  268. ></el-button>
  269. <p v-if="!approveUsers.length" class="tips-info tips-error">
  270. 请选择审核人
  271. </p>
  272. </div>
  273. </div>
  274. </el-timeline-item>
  275. </el-timeline>
  276. </div>
  277. <!-- 入库申请-申请阶段 -->
  278. <div
  279. v-if="flowList.length && curTaskApply.flowStatus === 'START'"
  280. class="task-audit-history flow-timeline"
  281. >
  282. <h4 class="mb-4">流程:</h4>
  283. <el-timeline>
  284. <el-timeline-item
  285. v-for="flow in flowList"
  286. :key="flow.taskKey"
  287. :type="flow.type"
  288. >
  289. <div class="flow-item">
  290. <div class="flow-item-content">
  291. <h4 class="flow-item-title">{{ flow.taskName }}</h4>
  292. <p v-if="flow.approveUserNames" class="flow-item-desc">
  293. {{ flow.approveUserNames }}
  294. </p>
  295. <div
  296. v-if="flow.isApproveSetFlowNextNode && approveUsers.length"
  297. class="flow-item-users"
  298. >
  299. <span>审批人:</span>
  300. <el-tag
  301. v-for="user in approveUsers"
  302. :key="user.id"
  303. size="small"
  304. :disable-transitions="false"
  305. >
  306. {{ user.name }}
  307. </el-tag>
  308. </div>
  309. </div>
  310. <div
  311. v-if="flow.isApproveSetFlowNextNode"
  312. class="flow-item-action"
  313. >
  314. <el-button
  315. class="user-select"
  316. icon="el-icon-plus"
  317. @click="toSelectNextFlowUser"
  318. ></el-button>
  319. <p v-if="!approveUsers.length" class="tips-info tips-error">
  320. 请选择审核人
  321. </p>
  322. </div>
  323. </div>
  324. </el-timeline-item>
  325. </el-timeline>
  326. </div>
  327. <!-- audit -->
  328. <div v-if="IS_AUDIT" class="task-audit">
  329. <el-form
  330. ref="auditModalComp"
  331. :model="auditModal"
  332. :rules="auditRules"
  333. label-width="90px"
  334. >
  335. <el-form-item prop="approvePass" label="审批操作:">
  336. <el-radio-group
  337. v-model="auditModal.approvePass"
  338. @change="approvePassChange"
  339. >
  340. <el-radio
  341. v-for="(val, key) in TASK_AUDIT_RESULT"
  342. :key="key"
  343. :label="key"
  344. >{{ val }}</el-radio
  345. >
  346. </el-radio-group>
  347. </el-form-item>
  348. <el-form-item
  349. v-if="auditModal.approvePass === 'REJECT'"
  350. prop="setup"
  351. label="驳回节点:"
  352. >
  353. <el-select
  354. v-model="auditModal.setup"
  355. placeholder="请选择"
  356. style="width: 100%"
  357. >
  358. <el-option
  359. v-for="item in rejectSetupList"
  360. :key="item.taskKey"
  361. :value="item.setup"
  362. :label="item.name"
  363. >
  364. </el-option>
  365. </el-select>
  366. </el-form-item>
  367. <el-form-item
  368. v-if="auditModal.approvePass !== 'EXCHANGE'"
  369. :key="auditModal.approvePass"
  370. prop="remark"
  371. label="审批意见:"
  372. >
  373. <el-input
  374. class="mb-2"
  375. v-model="auditModal.remark"
  376. type="textarea"
  377. resize="none"
  378. :rows="5"
  379. :maxlength="100"
  380. clearable
  381. show-word-limit
  382. placeholder="建议不超过100个字"
  383. ref="ReasonInput"
  384. ></el-input>
  385. </el-form-item>
  386. <el-form-item
  387. v-if="auditModal.approvePass === 'EXCHANGE'"
  388. prop="userId"
  389. label="审批人:"
  390. >
  391. <el-tag
  392. v-for="user in exchangeUsers"
  393. :key="user.id"
  394. :disable-transitions="false"
  395. size="medium"
  396. >
  397. {{ user.name }}
  398. </el-tag>
  399. <el-button
  400. class="ml-2"
  401. size="mini"
  402. type="primary"
  403. @click="toSelectExchangeUser"
  404. >选择用户</el-button
  405. >
  406. </el-form-item>
  407. </el-form>
  408. </div>
  409. </div>
  410. <div class="task-action">
  411. <el-button
  412. v-if="IS_APPLY"
  413. type="primary"
  414. :disabled="isSubmit"
  415. @click="submit"
  416. >确认提交</el-button
  417. >
  418. <el-button
  419. v-if="IS_APPLY"
  420. type="primary"
  421. :disabled="isSubmit"
  422. @click="toSave"
  423. >暂存</el-button
  424. >
  425. <el-button
  426. v-if="IS_AUDIT"
  427. type="primary"
  428. :disabled="isSubmit"
  429. @click="toAuditSubmit"
  430. >确定</el-button
  431. >
  432. <!-- <el-button
  433. v-if="IS_AUDIT_APPLY"
  434. type="primary"
  435. :disabled="isSubmit"
  436. @click="toAuditApply"
  437. >提交</el-button
  438. > -->
  439. <el-button @click="cancel">取消</el-button>
  440. </div>
  441. <!-- upload-paper-dialog -->
  442. <upload-paper-dialog
  443. :paper-attachment="curAttachment"
  444. :upload-type="curUploadType"
  445. @confirm="uploadConfirm"
  446. ref="UploadPaperDialog"
  447. ></upload-paper-dialog>
  448. <!-- card-option-dialog -->
  449. <card-option-dialog
  450. ref="CardOptionDialog"
  451. :data="task"
  452. @confirm="cardConfirm"
  453. ></card-option-dialog>
  454. <!-- image-preview -->
  455. <simple-image-preview
  456. :cur-image="curImage"
  457. @on-prev="toPrevImage"
  458. @on-next="toNextImage"
  459. ref="SimpleImagePreview"
  460. ></simple-image-preview>
  461. <!-- select-user-dialog -->
  462. <select-user-dialog
  463. v-if="IS_AUDIT || IS_NEED_SELECT_APPROVE_USER"
  464. ref="SelectUserDialog"
  465. :user-limit-count="userLimitCount"
  466. :filter-roles="userFilterRoles"
  467. :users="curSelectedUsers"
  468. @modified="userSelected"
  469. ></select-user-dialog>
  470. <!-- ModifyCard -->
  471. <modify-card ref="ModifyCard" @modified="cardModified"></modify-card>
  472. </div>
  473. </template>
  474. <script>
  475. import UploadPaperDialog from "./UploadPaperDialog";
  476. import CardOptionDialog from "./CardOptionDialog";
  477. import {
  478. taskApplyDetail,
  479. updateTaskApply,
  480. taskAuditApply,
  481. cardForSelectList
  482. } from "../api";
  483. import { attachmentPreview } from "../../login/api";
  484. import SimpleImagePreview from "@/components/SimpleImagePreview";
  485. import SelectUserDialog from "../../base/components/SelectUserDialog";
  486. import ModifyCard from "../../card/components/ModifyCard";
  487. import { TASK_AUDIT_RESULT, COMMON_CARD_RULE_ID } from "@/constants/enumerate";
  488. import {
  489. taskFlowDetail,
  490. taskFlowApproverExchange,
  491. taskFlowNodeInfo,
  492. taskFlowApprover,
  493. flowDetailByFlowId
  494. } from "../../base/api";
  495. const initTaskApply = {
  496. examId: "",
  497. examTaskId: "",
  498. paperType: "A",
  499. paperAttachmentIds: "",
  500. paperConfirmAttachmentIds: "",
  501. cardId: "",
  502. cardRuleId: "",
  503. makeMethod: "",
  504. remark: "",
  505. courseCode: "",
  506. courseName: "",
  507. drawCount: 1,
  508. exposedPaperType: "",
  509. // 流程
  510. flowId: "",
  511. flowStatus: "",
  512. setup: 0,
  513. // 工作台任务id
  514. flowTaskId: "",
  515. // 题卡状态
  516. status: "",
  517. // 考务规则
  518. review: false,
  519. includePaper: false,
  520. customCard: false
  521. };
  522. export default {
  523. name: "apply-content",
  524. components: {
  525. UploadPaperDialog,
  526. CardOptionDialog,
  527. SimpleImagePreview,
  528. SelectUserDialog,
  529. ModifyCard
  530. },
  531. props: {
  532. examTask: {
  533. type: Object,
  534. default() {
  535. return {};
  536. }
  537. },
  538. editType: {
  539. type: String,
  540. default: ""
  541. }
  542. },
  543. data() {
  544. return {
  545. isSubmit: false,
  546. curTaskApply: { ...initTaskApply },
  547. paperConfirmAttachmentId: { attachmentId: "", filename: "", url: "" },
  548. paperAttachments: [],
  549. paperConfirmAttachments: [],
  550. curAttachment: {},
  551. curUploadType: "paper",
  552. attachmentLimitCount: 26,
  553. abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
  554. cards: [],
  555. task: {},
  556. reason: "",
  557. TASK_AUDIT_RESULT: { ...TASK_AUDIT_RESULT, EXCHANGE: "转他人审批" },
  558. // audit
  559. flowList: [],
  560. flowInfo: {},
  561. auditModal: {
  562. approvePass: "PASS",
  563. setup: "",
  564. remark: "",
  565. userId: ""
  566. },
  567. auditRules: {
  568. approvePass: [
  569. {
  570. required: true
  571. }
  572. ],
  573. setup: [
  574. {
  575. required: true,
  576. validator: (rule, value, callback) => {
  577. if (this.auditModal.approvePass === "REJECT" && !value) {
  578. callback(new Error(`请选择要驳回到的节点`));
  579. } else {
  580. callback();
  581. }
  582. },
  583. trigger: "change"
  584. }
  585. ],
  586. remark: [
  587. {
  588. required: false,
  589. validator: (rule, value, callback) => {
  590. if (this.auditModal.approvePass === "REJECT" && !value) {
  591. callback(new Error(`请输入审批意见`));
  592. } else {
  593. callback();
  594. }
  595. },
  596. trigger: "change"
  597. }
  598. ],
  599. userId: [
  600. {
  601. required: true,
  602. message: "请选择审批人",
  603. trigger: "change"
  604. }
  605. ]
  606. },
  607. flowHistoryList: [],
  608. rejectSetupList: [], // 可以驳回的节点
  609. exchangeUsers: [],
  610. selectUserType: "exchange", // exchange:转审,approve:下一节点审核
  611. curSelectedUsers: [],
  612. // 选择下一节点审批人
  613. IS_NEED_SELECT_APPROVE_USER: false,
  614. nextFlowTaskResult: {}, //下一节点信息
  615. approveUsers: [],
  616. userLimitCount: 1,
  617. userFilterRoles: [],
  618. // image-preview
  619. curImage: {},
  620. curImageIndex: 0
  621. };
  622. },
  623. computed: {
  624. IS_APPLY() {
  625. return this.editType
  626. ? this.editType === "APPLY"
  627. : this.curTaskApply.setup === 1 || this.curTaskApply.setup === null;
  628. },
  629. IS_PREVIEW() {
  630. return this.editType
  631. ? this.editType === "PREVIEW"
  632. : this.curTaskApply.setup !== null && this.curTaskApply.setup <= 0;
  633. },
  634. IS_AUDIT() {
  635. const IS_COMMON_AUDIT = this.editType
  636. ? this.editType === "AUDIT"
  637. : this.curTaskApply.setup > 1;
  638. return IS_COMMON_AUDIT;
  639. },
  640. maxFetchCount() {
  641. return this.paperAttachments.length < 1
  642. ? 1
  643. : this.paperAttachments.length;
  644. },
  645. canCreateCard() {
  646. return (
  647. this.curTaskApply.courseCode &&
  648. this.curTaskApply.examId &&
  649. this.curTaskApply.cardRuleId !== COMMON_CARD_RULE_ID
  650. );
  651. },
  652. exposedMode() {
  653. return !!this.curTaskApply.exposedPaperType;
  654. }
  655. },
  656. mounted() {
  657. this.initData();
  658. },
  659. methods: {
  660. async initData() {
  661. const data = await taskApplyDetail(
  662. this.examTask.id,
  663. this.examTask.source
  664. );
  665. this.$emit("info-update", {
  666. semesterName: data.semesterName,
  667. examName: data.examName,
  668. examModel: data.examModel
  669. });
  670. this.curTaskApply = this.$objAssign(initTaskApply, data || {});
  671. this.curTaskApply.examId =
  672. this.curTaskApply.examId || this.examTask.examId;
  673. this.curTaskApply.examTaskId = this.examTask.id;
  674. this.curTaskApply.courseCode = this.examTask.courseCode;
  675. this.curTaskApply.courseName = this.examTask.courseName;
  676. this.curTaskApply.cardRuleId = this.examTask.cardRuleId;
  677. this.curTaskApply.customCard = this.examTask.customCard;
  678. this.curTaskApply.setup = this.examTask.setup;
  679. this.paperAttachments = this.curTaskApply.paperAttachmentIds
  680. ? JSON.parse(this.curTaskApply.paperAttachmentIds)
  681. : [];
  682. const exposedPaperType = data.exposedPaperType || "";
  683. let exposedPaperTypes = exposedPaperType.split(",");
  684. exposedPaperTypes.sort((a, b) => (a > b ? -1 : 1));
  685. const maxExposedPaperType = exposedPaperTypes[0];
  686. this.paperAttachments.forEach(paper => {
  687. paper.canDelete = maxExposedPaperType
  688. ? paper.name > maxExposedPaperType
  689. : true;
  690. paper.isExposed = exposedPaperTypes.includes(paper.name);
  691. });
  692. this.paperConfirmAttachments = this.curTaskApply.paperConfirmAttachmentIds
  693. ? JSON.parse(this.curTaskApply.paperConfirmAttachmentIds)
  694. : [];
  695. this.getCardList();
  696. // flow
  697. if (this.curTaskApply.flowStatus === "START") {
  698. await this.getFlowList();
  699. } else {
  700. await this.getFlowHistory();
  701. }
  702. if (this.IS_AUDIT) this.getCurFlowNodeInfo();
  703. },
  704. async getCardList() {
  705. if (!this.curTaskApply.courseCode || !this.curTaskApply.examId) return;
  706. const data = await cardForSelectList({
  707. courseCode: this.curTaskApply.courseCode,
  708. examId: this.curTaskApply.examId
  709. });
  710. this.cards = data || [];
  711. },
  712. async getFlowHistory() {
  713. if (!this.curTaskApply.flowId) return;
  714. const data = await taskFlowDetail(
  715. this.curTaskApply.flowId
  716. ).catch(() => {});
  717. if (!data) return;
  718. const FLOW_STATUS = {
  719. SUBMIT: "success",
  720. APPROVE: "success",
  721. EXCHANGE: "success",
  722. REJECT: "danger",
  723. END: "success"
  724. };
  725. let nextFlowId = "";
  726. this.flowHistoryList = data.tfFlowViewLogResultList.map((item, index) => {
  727. const nextItem = data.tfFlowViewLogResultList[index + 1];
  728. nextFlowId = nextItem ? nextItem.flowId : item.flowId;
  729. item.nextIsNewFlow = nextFlowId !== item.flowId;
  730. item.type = FLOW_STATUS[item.approveOperation];
  731. item.attachments = item.paperAttachmentId
  732. ? JSON.parse(item.paperAttachmentId)
  733. : [];
  734. item.isApproveSetFlowNextNode = false;
  735. return item;
  736. });
  737. const flowIsEnd = data.currFlowTaskResult.taskKey === "end";
  738. this.flowHistoryList.push({
  739. type: flowIsEnd ? "success" : "current",
  740. stepKey: this.$randomCode(),
  741. approveSetup: data.currFlowTaskResult.setup, //审批人节点
  742. approveRemark: data.currFlowTaskResult.taskName, //审批信息
  743. approveOperation: flowIsEnd ? "END" : "",
  744. approveUserName: data.currFlowTaskResult.approveUserNames, //审批人
  745. createTime: null,
  746. nextIsNewFlow: false,
  747. isApproveSetFlowNextNode: false,
  748. attachments: []
  749. });
  750. },
  751. async getFlowList() {
  752. if (!this.curTaskApply.flowId) return;
  753. const data = await flowDetailByFlowId(this.curTaskApply.flowId);
  754. if (!data) return;
  755. const modelType =
  756. data.flowTaskResultList[0] && data.flowTaskResultList[0].modelType;
  757. this.flowInfo = {
  758. customFlowId: data.id,
  759. version: data.version
  760. };
  761. const nextFlowNodeIndex = 1;
  762. this.IS_NEED_SELECT_APPROVE_USER = modelType === "APPROVE_SET";
  763. const flowList = data.flowTaskResultList || [];
  764. this.flowList = flowList.map((flow, index) => {
  765. flow.isApproveSetFlowNextNode =
  766. this.IS_NEED_SELECT_APPROVE_USER && index === nextFlowNodeIndex;
  767. return flow;
  768. });
  769. if (this.flowList.length) {
  770. this.flowList[0].type = "success";
  771. }
  772. this.nextFlowTaskResult = this.flowList[nextFlowNodeIndex];
  773. },
  774. async getCurFlowNodeInfo() {
  775. const data = await taskFlowNodeInfo(this.curTaskApply.flowTaskId);
  776. this.rejectSetupList = (data && data.rejectSetupList) || [];
  777. this.rejectSetupList.forEach(item => {
  778. item.name = `【${item.taskName}】${item.approveUserNames}`;
  779. });
  780. this.nextFlowTaskResult = data.nextFlowTaskResult;
  781. // 被打回给命题老师之后,命题老师只能通过。
  782. if (data.setup === 1 && !this.rejectSetupList.length) {
  783. this.TASK_AUDIT_RESULT = { PASS: "通过" };
  784. this.auditModal.approvePass = "PASS";
  785. }
  786. // 判断发起人自选,是否需要选择下个审核人员
  787. const { modelType, approveUserNames, taskKey } = this.nextFlowTaskResult;
  788. this.IS_NEED_SELECT_APPROVE_USER =
  789. modelType === "APPROVE_SET" &&
  790. taskKey.toLowerCase() !== "end" &&
  791. !approveUserNames;
  792. this.flowHistoryList[
  793. this.flowHistoryList.length - 1
  794. ].isApproveSetFlowNextNode = this.IS_NEED_SELECT_APPROVE_USER;
  795. },
  796. approvePassChange() {
  797. this.auditRules.remark[0].required =
  798. this.auditModal.approvePass === "REJECT";
  799. },
  800. addAtachment() {
  801. if (this.paperAttachments.length >= this.attachmentLimitCount) return;
  802. const name = this.abc[this.paperAttachments.length];
  803. const newAttachment = {
  804. name,
  805. attachmentId: "",
  806. filename: "",
  807. cardId: "",
  808. cardType: "",
  809. pages: 0,
  810. canDelete: true,
  811. isExposed: false
  812. };
  813. this.paperAttachments.push(newAttachment);
  814. },
  815. deleteAttachment(index) {
  816. if (this.paperAttachments.length <= 1) {
  817. this.$message.error("试卷类型数量不得少于1");
  818. return;
  819. }
  820. this.paperAttachments.splice(index, 1);
  821. this.paperAttachments.forEach((item, itemIndex) => {
  822. item.name = this.abc[itemIndex];
  823. });
  824. if (
  825. this.curTaskApply.drawCount &&
  826. this.curTaskApply.drawCount > this.paperAttachments.length
  827. ) {
  828. this.curTaskApply.drawCount = this.paperAttachments.length;
  829. }
  830. },
  831. toUpload(attachment) {
  832. this.curUploadType = "paper";
  833. this.curAttachment = {
  834. ...attachment
  835. };
  836. this.$refs.UploadPaperDialog.open();
  837. },
  838. toUploadPaperConfirm() {
  839. if (this.paperConfirmAttachments.length >= 4) return;
  840. this.curUploadType = "paperConfirm";
  841. this.curAttachment = {
  842. ...this.paperConfirmAttachmentId
  843. };
  844. this.$refs.UploadPaperDialog.open();
  845. },
  846. uploadConfirm(attachment, uploadType) {
  847. if (uploadType === "paper") {
  848. const index = this.paperAttachments.findIndex(
  849. item => item.name === attachment.name
  850. );
  851. this.paperAttachments.splice(index, 1, { ...attachment });
  852. } else {
  853. this.paperConfirmAttachments.push(attachment);
  854. }
  855. },
  856. deletePaperConfirmAttachment(index) {
  857. this.paperConfirmAttachments.splice(index, 1);
  858. },
  859. toViewCard(attachment) {
  860. window.open(
  861. this.getRouterPath({
  862. name: "CardPreview",
  863. params: {
  864. cardId: attachment.cardId,
  865. viewType: "view"
  866. }
  867. })
  868. );
  869. },
  870. toEditCard(attachment) {
  871. this.curAttachment = { ...attachment };
  872. this.$ls.set("prepareTcPCard", {
  873. cardId: this.task.cardId,
  874. examTaskId: this.task.examTaskId,
  875. courseCode: this.task.courseCode,
  876. courseName: this.task.courseName,
  877. makeMethod: this.task.makeMethod,
  878. cardRuleId: this.task.cardRuleId,
  879. type: "CUSTOM",
  880. createMethod: "STANDARD"
  881. });
  882. this.$refs.ModifyCard.open();
  883. },
  884. async cardModified(cardId) {
  885. if (!cardId) return;
  886. let card = this.cards.find(item => item.id === cardId);
  887. if (!card) {
  888. await this.getCardList();
  889. card = this.cards.find(item => item.id === cardId);
  890. }
  891. const aind = this.paperAttachments.findIndex(
  892. item => item.name === this.curAttachment.name
  893. );
  894. if (aind !== -1) {
  895. this.paperAttachments[aind].cardId = card && card.id;
  896. }
  897. },
  898. cardChange(attachment) {
  899. const card = this.cards.find(item => item.id === attachment.cardId);
  900. if (card) {
  901. attachment.cardType = card.type;
  902. attachment.cardTitle = card.title;
  903. }
  904. },
  905. toCreateCard(attachment) {
  906. if (!this.examTask.cardRuleId) {
  907. this.$message.error("题卡规则缺失!");
  908. return;
  909. }
  910. this.curAttachment = { ...attachment };
  911. this.$ls.set("prepareTcPCard", {
  912. courseCode: this.examTask.courseCode,
  913. courseName: this.examTask.courseName,
  914. schoolName: this.$ls.get("schoolName"),
  915. makeMethod: "SELF",
  916. cardRuleId: this.examTask.cardRuleId,
  917. type: "CUSTOM",
  918. createMethod: "STANDARD"
  919. });
  920. this.$refs.ModifyCard.open();
  921. },
  922. cancel() {
  923. this.$emit("cancel");
  924. },
  925. async downloadPaper(attachment) {
  926. if (!attachment.attachmentId) return;
  927. const data = await attachmentPreview(attachment.attachmentId);
  928. window.open(data.url);
  929. },
  930. cardConfirm(data) {
  931. const { makeMethod } = data;
  932. if (makeMethod === "CUST") {
  933. this.silentSave();
  934. this.curTaskApply = this.$objAssign(this.curTaskApply, data);
  935. } else if (makeMethod === "SELECT") {
  936. this.curTaskApply = this.$objAssign(this.curTaskApply, data);
  937. } else {
  938. this.$ls.set("prepareTcPCard", data);
  939. this.$refs.ModifyCard.open();
  940. }
  941. },
  942. toSelectNextFlowUser() {
  943. if (!this.IS_NEED_SELECT_APPROVE_USER) return;
  944. this.userLimitCount =
  945. this.nextFlowTaskResult.approveUserCountType === "ONE" ? 1 : 0;
  946. this.userFilterRoles =
  947. this.nextFlowTaskResult.approveUserSelectRange === "ROLE"
  948. ? this.nextFlowTaskResult.approveUserSelectRoles.map(item => item.id)
  949. : [];
  950. this.selectUserType = "approve";
  951. this.curSelectedUsers = this.approveUsers;
  952. this.$refs.SelectUserDialog.open();
  953. },
  954. toSelectExchangeUser() {
  955. this.userLimitCount = 1;
  956. this.userFilterRoles = [];
  957. this.curSelectedUsers = this.exchangeUsers;
  958. this.selectUserType = "exchange";
  959. this.$refs.SelectUserDialog.open();
  960. },
  961. userSelected(users) {
  962. if (this.selectUserType === "exchange") {
  963. this.exchangeUsers = users;
  964. this.auditModal.userId = users[0].id;
  965. } else {
  966. this.approveUsers = users;
  967. }
  968. },
  969. getTaskData() {
  970. let data = { ...this.curTaskApply };
  971. data.paperType = this.paperAttachments.map(item => item.name).join(",");
  972. data.paperAttachmentIds = JSON.stringify(this.paperAttachments, (k, v) =>
  973. k === "url" ? undefined : v
  974. );
  975. data.paperConfirmAttachmentIds = JSON.stringify(
  976. this.paperConfirmAttachments
  977. );
  978. if (this.IS_NEED_SELECT_APPROVE_USER)
  979. data.approveUserIds = this.approveUsers.map(item => item.id);
  980. return data;
  981. },
  982. checkDataValid() {
  983. const attachmentValid = !this.paperAttachments.some(
  984. item => !item.attachmentId
  985. );
  986. // 设置了入库强制包含试卷时,校验试卷是否上传。
  987. if (this.curTaskApply.includePaper && !attachmentValid) {
  988. this.$message.error("请完成试卷文件上传!");
  989. return;
  990. }
  991. // if (!this.paperConfirmAttachments.length) {
  992. // this.$message.error("请上传附件!");
  993. // return;
  994. // }
  995. const cardValid = !this.paperAttachments.some(item => !item.cardId);
  996. if (!cardValid) {
  997. this.$message.error("有试卷类型未选择题卡!");
  998. return;
  999. }
  1000. if (this.IS_NEED_SELECT_APPROVE_USER && !this.approveUsers.length) {
  1001. this.$message.error("请设置审核人员!");
  1002. return;
  1003. }
  1004. return true;
  1005. },
  1006. async toSave() {
  1007. if (this.isSubmit) return;
  1008. this.isSubmit = true;
  1009. const datas = this.getTaskData();
  1010. datas.operateType = "STAGE";
  1011. const data = await updateTaskApply(datas).catch(() => {});
  1012. this.isSubmit = false;
  1013. if (!data) return;
  1014. this.$message.success("保存成功!");
  1015. },
  1016. async silentSave() {
  1017. const datas = this.getTaskData();
  1018. datas.operateType = "STAGE";
  1019. await updateTaskApply(datas).catch(() => {});
  1020. },
  1021. async submit() {
  1022. if (!this.checkDataValid()) return;
  1023. const result = await this.$confirm(
  1024. "任务确定提交后,则不可更改试卷及答题卡内容,确定提交该任务?",
  1025. "提示",
  1026. {
  1027. type: "warning"
  1028. }
  1029. ).catch(() => {});
  1030. if (result !== "confirm") return;
  1031. const datas = this.getTaskData();
  1032. datas.operateType = "SUBMIT";
  1033. const data = await updateTaskApply(datas).catch(() => {});
  1034. if (!data) return;
  1035. this.$message.success("提交成功!");
  1036. this.$emit("modified");
  1037. },
  1038. async toAuditSubmit() {
  1039. const valid = await this.$refs.auditModalComp.validate().catch(() => {});
  1040. if (!valid) return;
  1041. if (
  1042. this.auditModal.approvePass === "PASS" &&
  1043. this.IS_NEED_SELECT_APPROVE_USER &&
  1044. !this.approveUsers.length
  1045. ) {
  1046. this.$message.error("请设置审核人员!");
  1047. return;
  1048. }
  1049. const actionName = this.TASK_AUDIT_RESULT[this.auditModal.approvePass];
  1050. const result = await this.$confirm(
  1051. `确定${actionName}该申请吗?`,
  1052. "提示",
  1053. {
  1054. type: "warning"
  1055. }
  1056. ).catch(() => {});
  1057. if (result !== "confirm") return;
  1058. if (this.auditModal.approvePass === "EXCHANGE") {
  1059. let datas = {
  1060. taskId: this.curTaskApply.flowTaskId,
  1061. userId: this.auditModal.userId
  1062. };
  1063. const data = await taskFlowApproverExchange(datas).catch(() => {});
  1064. if (!data) return;
  1065. } else {
  1066. let datas = { ...this.auditModal };
  1067. datas.taskId = this.curTaskApply.flowTaskId;
  1068. if (
  1069. this.auditModal.approvePass === "PASS" &&
  1070. this.IS_NEED_SELECT_APPROVE_USER
  1071. )
  1072. datas.approveUserIds = this.approveUsers.map(item => item.id);
  1073. const data = await taskFlowApprover(datas).catch(() => {});
  1074. if (!data) return;
  1075. }
  1076. this.$message.success("审批成功!");
  1077. this.$emit("modified");
  1078. },
  1079. async toAuditApply() {
  1080. const result = await this.$confirm("确定提交该任务吗?", "提示", {
  1081. type: "warning"
  1082. }).catch(() => {});
  1083. if (result !== "confirm") return;
  1084. const datas = {
  1085. examTaskDetail: this.getTaskData(),
  1086. flowTaskId: this.curTaskApply.flowTaskId,
  1087. approvePass: "PASS"
  1088. };
  1089. const data = await taskAuditApply(datas).catch(() => {});
  1090. if (!data) return;
  1091. this.$message.success("审批成功!");
  1092. this.$emit("modified");
  1093. },
  1094. // image-preview
  1095. toPreview(index) {
  1096. this.curImageIndex = index;
  1097. this.selectImage(index);
  1098. this.$refs.SimpleImagePreview.open();
  1099. },
  1100. selectImage(index) {
  1101. this.curImage = this.paperConfirmAttachments[index];
  1102. },
  1103. toPrevImage() {
  1104. if (this.curImageIndex === 0) {
  1105. this.curImageIndex = this.paperConfirmAttachments.length - 1;
  1106. } else {
  1107. this.curImageIndex--;
  1108. }
  1109. this.selectImage(this.curImageIndex);
  1110. },
  1111. toNextImage() {
  1112. if (this.curImageIndex === this.paperConfirmAttachments.length - 1) {
  1113. this.curImageIndex = 0;
  1114. } else {
  1115. this.curImageIndex++;
  1116. }
  1117. this.selectImage(this.curImageIndex);
  1118. }
  1119. }
  1120. };
  1121. </script>