ModifyTaskApply.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div>
  3. <el-dialog
  4. class="modify-task-apply"
  5. :visible.sync="modalIsShow"
  6. :title="title"
  7. top="10px"
  8. width="900px"
  9. :close-on-click-modal="false"
  10. :close-on-press-escape="false"
  11. append-to-body
  12. @open="visibleChange"
  13. @close="closeHandle"
  14. >
  15. <div v-if="dataReady" class="apply-content task-detail">
  16. <task-info></task-info>
  17. <task-paper
  18. ref="TaskPaper"
  19. @view-attachment="toViewAttachment"
  20. ></task-paper>
  21. <task-print v-if="showTaskPrint" ref="TaskPrint"></task-print>
  22. <task-flow
  23. ref="TaskFlow"
  24. @view-attachment="toViewAttachment"
  25. ></task-flow>
  26. </div>
  27. <div slot="footer">
  28. <el-button
  29. v-if="taskStatus.IS_APPLY"
  30. type="primary"
  31. :disabled="loading"
  32. @click="submit"
  33. >确认提交</el-button
  34. >
  35. <el-button
  36. v-if="taskStatus.IS_AUDIT"
  37. type="primary"
  38. :disabled="loading"
  39. @click="toAuditSubmit"
  40. >确定</el-button
  41. >
  42. <el-button @click="cancel">取消</el-button>
  43. </div>
  44. </el-dialog>
  45. <!-- PreviewFile -->
  46. <preview-file ref="PreviewFile" :data="curFile"></preview-file>
  47. </div>
  48. </template>
  49. <script>
  50. import { mapState, mapMutations } from "vuex";
  51. import {
  52. taskFlowApproverExchange,
  53. taskFlowApprover,
  54. examRuleDetail,
  55. } from "../../../base/api";
  56. import { taskApplyDetail, updateTaskApply } from "../../api";
  57. import { COMMON_CARD_RULE_ID } from "@/constants/enumerate";
  58. import TaskInfo from "./TaskInfo.vue";
  59. import TaskPaper from "./TaskPaper.vue";
  60. import TaskPrint from "./TaskPrint.vue";
  61. import TaskFlow from "./TaskFlow.vue";
  62. import PreviewFile from "@/components/PreviewFile.vue";
  63. const initExamTask = {
  64. id: null,
  65. examId: "",
  66. examName: "",
  67. className: "",
  68. examModel: "",
  69. category: "",
  70. semesterId: "",
  71. semesterName: "",
  72. courseId: "",
  73. courseCode: "",
  74. courseName: "",
  75. specialty: "",
  76. paperNumber: "",
  77. startTime: "",
  78. endTime: "",
  79. cardRuleId: "",
  80. cardRuleName: "",
  81. flowId: "",
  82. setup: null,
  83. userId: "",
  84. userName: "",
  85. propositionName: "",
  86. auditStatus: "",
  87. reviewStatus: "",
  88. source: "",
  89. teachingRoomName: "",
  90. teacherName: "",
  91. lecturerName: "",
  92. openAb: false,
  93. };
  94. const initTaskApply = {
  95. examId: "",
  96. examTaskId: "",
  97. category: "",
  98. paperNumber: "",
  99. paperType: "A",
  100. paperAttachmentIds: "",
  101. paperConfirmAttachmentIds: "",
  102. cardId: "",
  103. cardRuleId: "",
  104. makeMethod: "",
  105. remark: "",
  106. courseId: "",
  107. courseCode: "",
  108. courseName: "",
  109. drawCount: 1,
  110. exposedPaperType: "",
  111. auditContent: [],
  112. examTaskDetailList: [],
  113. openAb: false,
  114. // 入库申请中新建的命题任务提交信息
  115. examTaskContent: "",
  116. // 流程
  117. flowId: "",
  118. flowStatus: "",
  119. setup: null,
  120. // 工作台任务id
  121. flowTaskId: "",
  122. // 题卡状态
  123. status: "",
  124. // 考务规则
  125. review: false,
  126. includePaper: false,
  127. customCard: false,
  128. // 一个命题任务至少交AB两套试卷
  129. twoPaperEnable: false,
  130. // 作废
  131. taskStatus: "",
  132. cancelRemark: "",
  133. };
  134. export default {
  135. name: "modify-task-apply",
  136. components: {
  137. TaskInfo,
  138. TaskPaper,
  139. TaskFlow,
  140. TaskPrint,
  141. PreviewFile,
  142. },
  143. props: {
  144. rowData: {
  145. type: Object,
  146. default() {
  147. return {};
  148. },
  149. },
  150. type: {
  151. type: String,
  152. validate(val) {
  153. return ["APPLY", "PREVIEW", "AUDIT"].includes(val);
  154. },
  155. },
  156. },
  157. computed: {
  158. ...mapState("exam", ["editType", "examTask", "curTaskApply", "taskStatus"]),
  159. title() {
  160. // editType为主
  161. if (this.editType) {
  162. const names = {
  163. APPLY: "提交入库申请",
  164. PREVIEW: "入库申请详情",
  165. AUDIT: "审核入库申请",
  166. };
  167. return names[this.editType];
  168. }
  169. if (this.examTask.setup === 1 || this.examTask.setup === null) {
  170. return "提交入库申请";
  171. } else if (this.examTask.setup <= 0) {
  172. return "入库申请详情";
  173. } else {
  174. return "审核入库申请";
  175. }
  176. },
  177. showTaskPrint() {
  178. return Boolean(
  179. this.examTask.examModel !== "MODEL3" &&
  180. this.curTaskApply.examTaskContent
  181. );
  182. },
  183. },
  184. data() {
  185. return {
  186. modalIsShow: false,
  187. loading: false,
  188. examRule: {},
  189. dataReady: false,
  190. // preview file
  191. curFile: {
  192. id: "",
  193. type: "",
  194. },
  195. };
  196. },
  197. created() {
  198. this.getExamRule();
  199. },
  200. methods: {
  201. ...mapMutations("exam", [
  202. "setEditType",
  203. "setExamTask",
  204. "setCurTaskApply",
  205. "setTaskStatus",
  206. ]),
  207. async getExamRule() {
  208. const examRule = await examRuleDetail();
  209. this.examRule = examRule || {};
  210. },
  211. async initData() {
  212. this.setEditType(this.type);
  213. const data = await taskApplyDetail(this.rowData.id, this.rowData.source);
  214. const examTask = this.$objAssign(initExamTask, {
  215. ...this.rowData,
  216. review: this.examRule.review,
  217. customCard: this.examRule.customCard,
  218. setup: data.setup,
  219. semesterName: data.semesterName,
  220. examId: data.examId,
  221. examName: data.examName,
  222. examModel: data.examModel,
  223. });
  224. // curTaskApply
  225. const curTaskApply = this.$objAssign(initTaskApply, {
  226. ...data,
  227. examTaskId: examTask.id,
  228. courseId: examTask.courseId,
  229. courseName: examTask.courseName,
  230. cardRuleId: examTask.cardRuleId,
  231. customCard: examTask.customCard,
  232. paperNumber: examTask.paperNumber,
  233. auditContent: JSON.parse(data.auditContent || "[]"),
  234. includePaper: data.printContent.indexOf("PAPER") !== -1,
  235. });
  236. examTask.openAb = data.openAb;
  237. this.setExamTask(examTask);
  238. this.setCurTaskApply(curTaskApply);
  239. this.updateStatus();
  240. this.dataReady = true;
  241. },
  242. updateStatus() {
  243. const IS_APPLY = this.editType
  244. ? this.editType === "APPLY"
  245. : this.curTaskApply.setup === 1 || this.curTaskApply.setup === null;
  246. const IS_PREVIEW = this.editType
  247. ? this.editType === "PREVIEW"
  248. : this.curTaskApply.setup !== null && this.curTaskApply.setup <= 0;
  249. const IS_AUDIT = this.editType
  250. ? this.editType === "AUDIT"
  251. : this.curTaskApply.setup > 1;
  252. const CAN_CREATE_CARD =
  253. this.curTaskApply.courseId &&
  254. this.curTaskApply.examId &&
  255. this.curTaskApply.cardRuleId !== COMMON_CARD_RULE_ID;
  256. const IS_EXPOSED_MODE = !!this.curTaskApply.exposedPaperType;
  257. const IS_REBUILD = this.curTaskApply.category === "REBUILD";
  258. this.setTaskStatus({
  259. IS_APPLY,
  260. IS_PREVIEW,
  261. IS_AUDIT,
  262. CAN_CREATE_CARD,
  263. IS_EXPOSED_MODE,
  264. IS_REBUILD,
  265. });
  266. },
  267. visibleChange() {
  268. this.initData();
  269. },
  270. closeHandle() {
  271. this.dataReady = false;
  272. },
  273. cancel() {
  274. this.modalIsShow = false;
  275. },
  276. open() {
  277. this.modalIsShow = true;
  278. },
  279. modified() {
  280. this.cancel();
  281. this.$emit("modified");
  282. },
  283. async toViewAttachment(attachment) {
  284. if (!attachment.attachmentId) {
  285. this.$message.error("附件丢失!");
  286. return;
  287. }
  288. this.curFile = {
  289. id: attachment.attachmentId,
  290. type: "application/pdf",
  291. };
  292. this.$refs.PreviewFile.open();
  293. },
  294. async submit() {
  295. if (!this.$refs.TaskPaper.checkData()) return;
  296. if (this.showTaskPrint && !this.$refs.TaskPrint.checkData()) return;
  297. if (!this.$refs.TaskFlow.checkData()) return;
  298. const result = await this.$confirm(
  299. "任务确定提交后,则不可更改试卷及答题卡内容,确定提交该任务?",
  300. "提示",
  301. {
  302. type: "warning",
  303. }
  304. ).catch(() => {});
  305. if (result !== "confirm") return;
  306. const paperData = this.$refs.TaskPaper.getData();
  307. const flowData = this.$refs.TaskFlow.getData();
  308. const datas = {
  309. ...this.curTaskApply,
  310. ...paperData,
  311. ...flowData,
  312. operateType: "SUBMIT",
  313. };
  314. if (this.showTaskPrint) {
  315. const examTaskContent = this.$refs.TaskPrint.getData(datas);
  316. datas.examTaskContent = JSON.stringify(examTaskContent);
  317. }
  318. const data = await updateTaskApply(datas).catch(() => {});
  319. if (!data) return;
  320. this.$message.success("提交成功!");
  321. this.modified();
  322. },
  323. async toAuditSubmit() {
  324. const valid = await this.$refs.TaskFlow.checkAuditData();
  325. if (!valid) return;
  326. const datas = this.$refs.TaskFlow.getAuditData();
  327. const result = await this.$confirm(
  328. `确定${datas.actionName}该申请吗?`,
  329. "提示",
  330. {
  331. type: "warning",
  332. }
  333. ).catch(() => {});
  334. if (result !== "confirm") return;
  335. const apiFunc =
  336. datas.approvePass === "EXCHANGE"
  337. ? taskFlowApproverExchange
  338. : taskFlowApprover;
  339. const data = await apiFunc(datas).catch(() => {});
  340. if (!data) return;
  341. this.$message.success("审批成功!");
  342. this.modified();
  343. },
  344. },
  345. };
  346. </script>