ModifyTaskApply.vue 8.2 KB

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