InfoExamTask.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. <template>
  2. <div class="info-exam-task">
  3. <div class="part-box part-box-pad part-box-border part-box-gray">
  4. <el-form
  5. ref="examTaskComp"
  6. :model="examTask"
  7. :rules="rules"
  8. label-width="120px"
  9. >
  10. <el-row>
  11. <el-col :span="12">
  12. <el-form-item prop="semesterId" label="使用学期:">
  13. <semester-select
  14. v-model="examTask.semesterId"
  15. class="width-full"
  16. default-select-in-used
  17. @change="semesterChange"
  18. ></semester-select>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="12">
  22. <el-form-item prop="examId" label="考试:">
  23. <exam-select
  24. v-model="examTask.examId"
  25. :semester-id="examTask.semesterId"
  26. :clearable="false"
  27. class="width-full"
  28. @change="examChange"
  29. ></exam-select>
  30. </el-form-item>
  31. </el-col>
  32. </el-row>
  33. <el-row>
  34. <el-col :span="12">
  35. <el-form-item label="部门:">
  36. {{ teachingRoomName }}
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="12">
  40. <el-form-item prop="courseCode" label="课程(代码):">
  41. <el-select
  42. v-model="examTask.courseCode"
  43. placeholder="请选择"
  44. filterable
  45. class="width-full"
  46. :disabled="!examTask.examId"
  47. @change="courseChange"
  48. >
  49. <el-option
  50. v-for="item in courses"
  51. :key="item.code"
  52. :value="item.code"
  53. :label="`${item.name}(${item.code})`"
  54. >
  55. </el-option>
  56. </el-select>
  57. </el-form-item>
  58. </el-col>
  59. </el-row>
  60. <el-row>
  61. <el-col :span="12">
  62. <el-form-item prop="paperNumber" label="试卷编号:">
  63. <el-input
  64. v-model.trim="examTask.paperNumber"
  65. placeholder="试卷编号不填写时会自动生成"
  66. :maxlength="50"
  67. clearable
  68. ></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="12">
  72. <el-form-item prop="teacherName" label="拟卷教师:">
  73. <el-input
  74. v-model.trim="examTask.teacherName"
  75. placeholder="请输入拟卷教师"
  76. :maxlength="50"
  77. clearable
  78. ></el-input>
  79. </el-form-item>
  80. </el-col>
  81. </el-row>
  82. </el-form>
  83. </div>
  84. <div class="apply-content task-detail">
  85. <div class="task-body">
  86. <div class="mb-2 text-right">
  87. <el-button
  88. type="info"
  89. icon="el-icon-circle-plus-outline"
  90. @click="addAtachment"
  91. >增加卷型</el-button
  92. >
  93. </div>
  94. <table class="table mb-2">
  95. <colgroup>
  96. <col width="100" />
  97. <col width="280" />
  98. <col />
  99. <col width="60" />
  100. </colgroup>
  101. <tr>
  102. <th>试卷类型</th>
  103. <th>试卷文件</th>
  104. <th>答题卡</th>
  105. <th>操作</th>
  106. </tr>
  107. <tr v-for="(attachment, index) in paperAttachments" :key="index">
  108. <td>{{ attachment.name }}卷</td>
  109. <td>
  110. <el-button
  111. type="text"
  112. class="btn-primary"
  113. @click="toUpload(attachment)"
  114. >
  115. <i
  116. :class="[
  117. 'icon',
  118. attachment.attachmentId ? 'icon-files-act' : 'icon-files'
  119. ]"
  120. ></i
  121. >{{
  122. attachment.attachmentId
  123. ? attachment.filename
  124. : "点击上传试卷文件"
  125. }}
  126. </el-button>
  127. </td>
  128. <td>
  129. <el-select
  130. class="mr-2"
  131. v-model="attachment.cardId"
  132. placeholder="请选择"
  133. style="width: 200px"
  134. filterable
  135. @visible-change="
  136. visible => cardOptionOpened(visible, attachment)
  137. "
  138. @change="cardChange(attachment)"
  139. >
  140. <el-option
  141. v-for="item in cards"
  142. :key="item.id"
  143. :value="item.id"
  144. :label="item.title"
  145. :disabled="item.disabled"
  146. >
  147. <span
  148. :class="[
  149. item.type === 'GENERIC'
  150. ? 'color-success'
  151. : 'color-primary',
  152. 'mr-1'
  153. ]"
  154. >[{{ item.type === "GENERIC" ? "通" : "专" }}]</span
  155. >
  156. {{ item.title }}
  157. </el-option>
  158. </el-select>
  159. <span
  160. v-if="attachment.cardId"
  161. :class="[
  162. attachment.cardType === 'GENERIC'
  163. ? 'color-success'
  164. : 'color-primary',
  165. 'mr-1'
  166. ]"
  167. >[{{ attachment.cardType === "GENERIC" ? "通" : "专" }}]</span
  168. >
  169. <el-button
  170. class="btn-primary"
  171. type="text"
  172. :disabled="!attachment.cardId"
  173. @click="toViewCard(attachment)"
  174. >预览</el-button
  175. >
  176. <el-button
  177. class="btn-primary"
  178. type="text"
  179. :disabled="
  180. !attachment.cardId ||
  181. (attachment.cardType === 'GENERIC' &&
  182. attachment.createMethod !== 'STANDARD')
  183. "
  184. @click="toCopyCard(attachment)"
  185. >复制</el-button
  186. >
  187. <el-button
  188. class="btn-primary"
  189. type="text"
  190. :disabled="
  191. !attachment.cardId ||
  192. attachment.cardType === 'GENERIC' ||
  193. !(!attachment.used && attachment.createId === user.id)
  194. "
  195. @click="toEditCard(attachment)"
  196. >编辑</el-button
  197. >
  198. <el-button
  199. class="btn-primary"
  200. type="text"
  201. :disabled="!canCreateCard"
  202. @click="toCreateCard(attachment)"
  203. >新建</el-button
  204. >
  205. </td>
  206. <td>
  207. <el-button
  208. class="btn-danger"
  209. type="text"
  210. @click="deleteAttachment(index)"
  211. >删除</el-button
  212. >
  213. </td>
  214. </tr>
  215. <tr v-if="!paperAttachments.length">
  216. <td colspan="5">
  217. <p class="tips-info text-center">暂无数据</p>
  218. </td>
  219. </tr>
  220. </table>
  221. <el-form>
  222. <el-form-item label="单次抽卷卷型数量:" label-width="150">
  223. <el-input-number
  224. v-model="examTaskDetail.drawCount"
  225. :min="1"
  226. :max="maxFetchCount"
  227. :step="1"
  228. step-strictly
  229. :controls="false"
  230. ></el-input-number>
  231. </el-form-item>
  232. </el-form>
  233. <h4 class="mb-2">附件<span>(最多4张)</span>:</h4>
  234. <div class="image-list">
  235. <div
  236. class="image-item"
  237. v-for="(img, index) in paperConfirmAttachments"
  238. :key="index"
  239. >
  240. <img
  241. :src="img.url"
  242. :alt="img.filename"
  243. title="点击查看大图"
  244. @click="toPreview(index)"
  245. />
  246. <div class="image-delete">
  247. <i
  248. class="el-icon-delete-solid"
  249. @click="deletePaperConfirmAttachment(index)"
  250. ></i>
  251. </div>
  252. </div>
  253. <div
  254. v-if="paperConfirmAttachments.length < 4"
  255. class="image-item image-add"
  256. title="上传入库审核表"
  257. @click="toUploadPaperConfirm"
  258. >
  259. <i class="el-icon-plus"></i>
  260. </div>
  261. </div>
  262. <h4 class="mb-2">附件说明:</h4>
  263. <el-input
  264. class="mb-2"
  265. v-model="examTaskDetail.remark"
  266. type="textarea"
  267. resize="none"
  268. :rows="2"
  269. :maxlength="100"
  270. clearable
  271. show-word-limit
  272. placeholder="建议不超过100个字"
  273. ></el-input>
  274. </div>
  275. </div>
  276. <!-- upload-paper-dialog -->
  277. <upload-paper-dialog
  278. :paper-attachment="curAttachment"
  279. :upload-type="curUploadType"
  280. @confirm="uploadConfirm"
  281. ref="UploadPaperDialog"
  282. ></upload-paper-dialog>
  283. <!-- image-preview -->
  284. <simple-image-preview
  285. :cur-image="curImage"
  286. @on-prev="toPrevImage"
  287. @on-next="toNextImage"
  288. ref="SimpleImagePreview"
  289. ></simple-image-preview>
  290. <!-- ModifyCard -->
  291. <modify-card ref="ModifyCard" @modified="cardModified"></modify-card>
  292. </div>
  293. </template>
  294. <script>
  295. import UploadPaperDialog from "../UploadPaperDialog";
  296. import SimpleImagePreview from "@/components/SimpleImagePreview";
  297. import ModifyCard from "../../../card/components/ModifyCard";
  298. import { COMMON_CARD_RULE_ID } from "../../../../constants/enumerate";
  299. import { cardForSelectList } from "../../api";
  300. import { courseQuery, examConfigByExamIdOrgId } from "../../../base/api";
  301. import { mapState, mapMutations } from "vuex";
  302. import { copyCard } from "../../../card/api";
  303. // type=GENERIC时, 为通卡,不可复制,不可编辑,可预览。
  304. // type=CUSTOM时,可复制,不可编辑,如果是当前自己任务的题卡,才可编辑。
  305. export default {
  306. name: "info-exam-task",
  307. components: { UploadPaperDialog, SimpleImagePreview, ModifyCard },
  308. data() {
  309. return {
  310. user: {},
  311. task: {},
  312. rules: {
  313. semesterId: [
  314. {
  315. required: true,
  316. message: "请选择使用学期",
  317. trigger: "change"
  318. }
  319. ],
  320. examId: [
  321. {
  322. required: true,
  323. message: "请选择考试",
  324. trigger: "change"
  325. }
  326. ],
  327. teachingRoomId: [
  328. {
  329. required: true,
  330. message: "请选择机构",
  331. trigger: "change"
  332. }
  333. ],
  334. courseCode: [
  335. {
  336. required: true,
  337. message: "请选择课程",
  338. trigger: "change"
  339. }
  340. ],
  341. paperNumber: [
  342. {
  343. message: "试卷编号不能超过50个字符",
  344. max: 50,
  345. trigger: "change"
  346. }
  347. ],
  348. teacherName: [
  349. {
  350. message: "拟卷教师不能超过50个字符",
  351. max: 50,
  352. trigger: "change"
  353. }
  354. ]
  355. },
  356. examTask: {},
  357. cards: [],
  358. courses: [],
  359. semesters: [],
  360. teachingRoomName: "",
  361. cardRuleName: "全部通卡",
  362. // exam-task-detail
  363. examTaskDetail: { makeMethod: "" },
  364. paperConfirmAttachmentId: { attachmentId: "", filename: "", url: "" },
  365. paperAttachments: [],
  366. paperConfirmAttachments: [],
  367. curAttachment: {},
  368. curUploadType: "paper",
  369. attachmentLimitCount: 26,
  370. abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
  371. // image-preview
  372. curImage: {},
  373. curImageIndex: 0
  374. };
  375. },
  376. computed: {
  377. ...mapState("exam", [
  378. "infoExamTask",
  379. "infoExamTaskDetail",
  380. "infoExamPrintPlan"
  381. ]),
  382. maxFetchCount() {
  383. return this.paperAttachments.length < 1
  384. ? 1
  385. : this.paperAttachments.length;
  386. },
  387. canCreateCard() {
  388. return (
  389. this.examTask.courseCode &&
  390. this.examTask.examId &&
  391. this.examTask.cardRuleId !== COMMON_CARD_RULE_ID
  392. );
  393. }
  394. },
  395. watch: {
  396. "examTask.examId": function(val, oldval) {
  397. if (val !== oldval) this.examAndRoomChange();
  398. },
  399. "examTask.teachingRoomId": function(val, oldval) {
  400. if (val !== oldval) this.examAndRoomChange();
  401. }
  402. },
  403. mounted() {
  404. this.initData();
  405. },
  406. methods: {
  407. ...mapMutations("exam", ["updateTaskInfo"]),
  408. initData() {
  409. this.user = this.$ls.get("user", {});
  410. const userOrg = this.user.orgInfo;
  411. this.teachingRoomName = userOrg.name;
  412. this.examTask = { ...this.infoExamTask, teachingRoomId: userOrg.id };
  413. this.examTaskDetail = { ...this.infoExamTaskDetail };
  414. this.paperAttachments = this.examTaskDetail.paperAttachmentIds
  415. ? JSON.parse(this.examTaskDetail.paperAttachmentIds)
  416. : [];
  417. if (!this.paperAttachments.length) {
  418. this.addAtachment();
  419. }
  420. this.paperConfirmAttachments = this.examTaskDetail
  421. .paperConfirmAttachmentIds
  422. ? JSON.parse(this.examTaskDetail.paperConfirmAttachmentIds)
  423. : [];
  424. this.getCourses();
  425. this.getCardList();
  426. this.$nextTick(() => {
  427. this.$refs.examTaskComp.clearValidate();
  428. });
  429. },
  430. async getCardList() {
  431. if (!this.examTask.courseCode || !this.examTask.examId) return;
  432. const data = await cardForSelectList({
  433. courseCode: this.examTask.courseCode,
  434. examId: this.examTask.examId
  435. });
  436. this.cards = data || [];
  437. },
  438. async getCourses() {
  439. if (!this.examTask.teachingRoomId) return;
  440. const res = await courseQuery({
  441. teachingRoomId: this.examTask.teachingRoomId
  442. });
  443. this.courses = res || [];
  444. },
  445. semesterChange(val) {
  446. this.examTask.paperName = val.name;
  447. },
  448. examChange(val) {
  449. console.log(val);
  450. if (!val.id) return;
  451. this.examTask.examModel = val.examModel;
  452. this.paperAttachments.forEach(item => {
  453. item.cardId = "";
  454. item.cardType = "";
  455. item.createMethod = "";
  456. item.cardTitle = "";
  457. });
  458. this.cards = [];
  459. this.getCardList();
  460. },
  461. teachingRoomChange() {
  462. this.examTask.courseCode = "";
  463. this.examTask.courseName = "";
  464. this.courses = [];
  465. this.paperAttachments.forEach(item => {
  466. item.cardId = "";
  467. item.cardType = "";
  468. item.createMethod = "";
  469. item.cardTitle = "";
  470. });
  471. this.cards = [];
  472. this.getCourses();
  473. },
  474. courseChange(val) {
  475. if (val) {
  476. const course = this.courses.find(item => item.code === val);
  477. this.examTask.courseName = course.name;
  478. } else {
  479. this.examTask.courseName = "";
  480. }
  481. this.paperAttachments.forEach(item => {
  482. item.cardId = "";
  483. item.cardType = "";
  484. item.createMethod = "";
  485. item.cardTitle = "";
  486. });
  487. this.cards = [];
  488. this.getCardList();
  489. this.updateTaskInfo({ infoExamTask: this.examTask });
  490. },
  491. async examAndRoomChange() {
  492. this.updateTaskInfo({ infoExamTask: this.examTask });
  493. const { examId, teachingRoomId } = this.examTask;
  494. if (examId && teachingRoomId) {
  495. const examPrintPlan = await examConfigByExamIdOrgId({
  496. examId,
  497. orgId: teachingRoomId
  498. });
  499. this.examTask.cardRuleId = examPrintPlan.cardRuleId;
  500. this.examTaskDetail.includePaper =
  501. examPrintPlan.printContent.indexOf("PAPER") !== -1;
  502. this.updateTaskInfo({
  503. infoExamPrintPlan: Object.assign(
  504. {},
  505. this.infoExamPrintPlan,
  506. examPrintPlan
  507. ),
  508. infoExamTask: this.examTask
  509. });
  510. }
  511. },
  512. cardChange(attachment) {
  513. const card = this.cards.find(item => item.id === attachment.cardId);
  514. if (card) {
  515. attachment.cardType = card.type;
  516. attachment.createMethod = card.createMethod;
  517. attachment.cardTitle = card.title;
  518. attachment.used = card.used;
  519. attachment.createId = card.createId;
  520. }
  521. },
  522. cardOptionOpened(visible, attachment) {
  523. if (!visible) return;
  524. const selectedCardIds = this.paperAttachments.map(item => item.cardId);
  525. this.cards = this.cards.map(card => {
  526. card.disabled =
  527. card.id !== attachment.cardId &&
  528. selectedCardIds.includes(card.id) &&
  529. card.type !== "GENERIC";
  530. return card;
  531. });
  532. },
  533. toCreateCard(attachment) {
  534. if (!this.examTask.cardRuleId) {
  535. this.$message.error("题卡规则缺失!");
  536. return;
  537. }
  538. this.curAttachment = { ...attachment };
  539. this.$ls.set("prepareTcPCard", {
  540. courseCode: this.examTask.courseCode,
  541. courseName: this.examTask.courseName,
  542. schoolName: this.$ls.get("schoolName"),
  543. makeMethod: "SELF",
  544. cardRuleId: this.examTask.cardRuleId,
  545. type: "CUSTOM",
  546. createMethod: "STANDARD"
  547. });
  548. this.$refs.ModifyCard.open();
  549. },
  550. toEditCard(attachment) {
  551. this.curAttachment = { ...attachment };
  552. // 这里只允许新建标准专卡
  553. this.$ls.set("prepareTcPCard", {
  554. id: attachment.cardId,
  555. courseCode: this.examTask.courseCode,
  556. courseName: this.examTask.courseName,
  557. schoolName: this.$ls.get("schoolName"),
  558. makeMethod: "SELF",
  559. cardRuleId: this.examTask.cardRuleId,
  560. type: "CUSTOM",
  561. createMethod: "STANDARD"
  562. });
  563. this.$refs.ModifyCard.open();
  564. },
  565. toViewCard(attachment) {
  566. window.open(
  567. this.getRouterPath({
  568. name: "CardPreview",
  569. params: {
  570. cardId: attachment.cardId,
  571. viewType: "view"
  572. }
  573. })
  574. );
  575. },
  576. async toCopyCard(attachment) {
  577. this.curAttachment = { ...attachment };
  578. const newCardId = await copyCard(
  579. attachment.cardId,
  580. this.examTask.courseCode
  581. );
  582. this.cardModified(newCardId);
  583. },
  584. async cardModified(cardId) {
  585. if (!cardId) return;
  586. await this.getCardList();
  587. let card = this.cards.find(item => item.id === cardId);
  588. const aind = this.paperAttachments.findIndex(
  589. item => item.name === this.curAttachment.name
  590. );
  591. if (aind !== -1 && card) {
  592. this.paperAttachments[aind].cardId = card.id;
  593. this.paperAttachments[aind].cardType = card.type;
  594. this.paperAttachments[aind].createMethod = card.createMethod;
  595. this.paperAttachments[aind].cardTitle = card.title;
  596. }
  597. },
  598. async checkData() {
  599. const valid = await this.$refs.examTaskComp.validate().catch(() => {});
  600. if (!valid) return Promise.reject();
  601. // 设置了入库强制包含试卷时,校验试卷是否上传。
  602. // 未设置入库强制包含试卷时,若有试卷上传,则需要上传全部。若无试卷上传,则通过。
  603. if (this.examTaskDetail.includePaper) {
  604. const attachmentValid = !this.paperAttachments.some(
  605. item => !item.attachmentId
  606. );
  607. if (!attachmentValid) {
  608. this.$message.error("请完成试卷文件上传!");
  609. return Promise.reject();
  610. }
  611. } else {
  612. const hasUploadPaperAttachments = this.paperAttachments.filter(
  613. item => item.attachmentId
  614. );
  615. if (
  616. hasUploadPaperAttachments.length > 0 &&
  617. hasUploadPaperAttachments.length !== this.paperAttachments.length
  618. ) {
  619. this.$message.error("有试卷文件未完成上传!");
  620. return Promise.reject();
  621. }
  622. }
  623. // if (!this.paperConfirmAttachments.length) {
  624. // this.$message.error("请上传附件!");
  625. // return;
  626. // }
  627. let cardValid = !this.paperAttachments.some(item => !item.cardId);
  628. if (!cardValid) {
  629. this.$message.error("有试卷类型未选择题卡!");
  630. return Promise.reject();
  631. }
  632. const usedCards = this.paperAttachments
  633. .filter(item => item.cardId && item.used)
  634. .map(item => item.name);
  635. if (!usedCards.length) {
  636. this.$message.error(`${usedCards.join()}卷选择的题卡已经被使用过!`);
  637. return Promise.reject();
  638. }
  639. return Promise.resolve(true);
  640. },
  641. updateData() {
  642. let data = {
  643. infoExamTask: this.examTask,
  644. infoExamTaskDetail: this.getTaskDetailData()
  645. };
  646. this.updateTaskInfo(data);
  647. },
  648. emitRelateInfo(type) {
  649. this.$emit("relate-info-change", this.getData(), type);
  650. },
  651. // exam-task-detail edit
  652. addAtachment() {
  653. if (this.paperAttachments.length >= this.attachmentLimitCount) return;
  654. const newAttachment = {
  655. name: this.abc[this.paperAttachments.length],
  656. attachmentId: "",
  657. cardId: "",
  658. cardType: "",
  659. createMethod: "",
  660. cardTitle: "",
  661. filename: "",
  662. pages: 0,
  663. used: false,
  664. createId: null
  665. };
  666. this.paperAttachments.push(newAttachment);
  667. },
  668. deleteAttachment(index) {
  669. if (this.paperAttachments.length <= 1) {
  670. this.$message.error("试卷类型数量不得少于1");
  671. return;
  672. }
  673. this.paperAttachments.splice(index, 1);
  674. this.paperAttachments.forEach((item, itemIndex) => {
  675. item.name = this.abc[itemIndex];
  676. });
  677. if (
  678. this.examTaskDetail.drawCount &&
  679. this.examTaskDetail.drawCount > this.paperAttachments.length
  680. ) {
  681. this.examTaskDetail.drawCount = this.paperAttachments.length;
  682. }
  683. },
  684. toUpload(attachment) {
  685. this.curUploadType = "paper";
  686. this.curAttachment = {
  687. ...attachment
  688. };
  689. this.$refs.UploadPaperDialog.open();
  690. },
  691. toUploadPaperConfirm() {
  692. if (this.paperConfirmAttachments.length >= 4) return;
  693. this.curUploadType = "paperConfirm";
  694. this.curAttachment = {
  695. ...this.paperConfirmAttachmentId
  696. };
  697. this.$refs.UploadPaperDialog.open();
  698. },
  699. uploadConfirm(attachment, uploadType) {
  700. if (uploadType === "paper") {
  701. const index = this.paperAttachments.findIndex(
  702. item => item.name === attachment.name
  703. );
  704. this.paperAttachments.splice(index, 1, { ...attachment });
  705. } else {
  706. this.paperConfirmAttachments.push(attachment);
  707. }
  708. },
  709. deletePaperConfirmAttachment(index) {
  710. this.paperConfirmAttachments.splice(index, 1);
  711. },
  712. // cardConfirm(data) {
  713. // this.examTaskDetail = this.$objAssign(this.examTaskDetail, data);
  714. // },
  715. getTaskDetailData() {
  716. let data = { ...this.examTaskDetail };
  717. data.paperType = this.paperAttachments.map(item => item.name).join(",");
  718. data.paperAttachmentIds = JSON.stringify(this.paperAttachments, (k, v) =>
  719. k === "url" ? undefined : v
  720. );
  721. data.paperConfirmAttachmentIds = JSON.stringify(
  722. this.paperConfirmAttachments
  723. );
  724. return data;
  725. },
  726. // image-preview
  727. toPreview(index) {
  728. this.curImageIndex = index;
  729. this.selectImage(index);
  730. this.$refs.SimpleImagePreview.open();
  731. },
  732. selectImage(index) {
  733. this.curImage = this.paperConfirmAttachments[index];
  734. },
  735. toPrevImage() {
  736. if (this.curImageIndex === 0) {
  737. this.curImageIndex = this.paperConfirmAttachments.length - 1;
  738. } else {
  739. this.curImageIndex--;
  740. }
  741. this.selectImage(this.curImageIndex);
  742. },
  743. toNextImage() {
  744. if (this.curImageIndex === this.paperConfirmAttachments.length - 1) {
  745. this.curImageIndex = 0;
  746. } else {
  747. this.curImageIndex++;
  748. }
  749. this.selectImage(this.curImageIndex);
  750. }
  751. }
  752. };
  753. </script>