ModifyTaskApply.vue 8.9 KB

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