CreateExamAndPrintTask.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <el-dialog
  3. class="create-exam-and-print-task"
  4. :visible.sync="modalIsShow"
  5. :close-on-click-modal="false"
  6. :close-on-press-escape="false"
  7. :show-close="false"
  8. append-to-body
  9. fullscreen
  10. @open="visibleChange"
  11. @closed="disalogClosed"
  12. >
  13. <div slot="title">
  14. <span class="el-dialog__title">新增命题申请</span>
  15. </div>
  16. <div class="apply-body" v-if="dataReady">
  17. <div class="apply-part">
  18. <h3 class="apply-part-title">命题信息</h3>
  19. <info-exam-task ref="InfoExamTask"></info-exam-task>
  20. </div>
  21. <div class="apply-part">
  22. <h3 class="apply-part-title">考务信息</h3>
  23. <info-print-task ref="InfoPrintTask"></info-print-task>
  24. </div>
  25. <div class="apply-part">
  26. <h3 class="apply-part-title">流程</h3>
  27. <el-timeline>
  28. <el-timeline-item
  29. v-for="flow in flowList"
  30. :key="flow.taskKey"
  31. :type="flow.type"
  32. >
  33. <div class="flow-item">
  34. <h4 class="flow-item-title">{{ flow.taskName }}</h4>
  35. <p class="flow-item-desc">{{ flow.approveUserNames }}</p>
  36. </div>
  37. </el-timeline-item>
  38. </el-timeline>
  39. </div>
  40. </div>
  41. <div class="text-center">
  42. <el-button type="success" :disabled="loading" @click="submit"
  43. >确认提交</el-button
  44. >
  45. <el-button @click="cancel">取消</el-button>
  46. </div>
  47. <div slot="footer"></div>
  48. </el-dialog>
  49. </template>
  50. <script>
  51. import { mapMutations, mapState } from "vuex";
  52. import { examRuleDetail, flowDetailByType } from "../../../base/api";
  53. import { teacherSubmitTaskApply } from "../../api";
  54. import InfoExamTask from "./InfoExamTask";
  55. import InfoPrintTask from "./InfoPrintTask";
  56. const initExamTask = {
  57. semesterId: "",
  58. examId: "",
  59. examModel: "",
  60. courseCode: "",
  61. courseName: "",
  62. paperNumber: "",
  63. cardRuleId: "",
  64. teachingRoomId: "",
  65. teacherName: "",
  66. paperName: ""
  67. };
  68. const initExamTaskDetail = {
  69. operateType: "STAGE",
  70. paperType: "A",
  71. cardId: "",
  72. cardType: "",
  73. paperAttachmentIds: "[]",
  74. paperConfirmAttachmentIds: "[]",
  75. drawCount: 2,
  76. remark: "",
  77. makeMethod: "SELECT",
  78. // 题卡状态
  79. status: "",
  80. // 考务规则
  81. review: false,
  82. includePaper: false,
  83. customCard: false
  84. };
  85. const initPrintPlan = {
  86. printContent: [],
  87. backupMethod: "ROOM",
  88. backupCount: 1,
  89. drawRule: "ONE",
  90. variableContent: [
  91. {
  92. type: "SIGN",
  93. templateId: "",
  94. oldTemplateId: "",
  95. backupMethod: "ROOM",
  96. backupCount: 1
  97. },
  98. {
  99. type: "PACKAGE",
  100. templateId: "",
  101. oldTemplateId: "",
  102. backupMethod: "ROOM",
  103. backupCount: 1
  104. }
  105. ],
  106. ordinaryContent: [
  107. {
  108. type: "CHECK_IN",
  109. templateId: "",
  110. oldTemplateId: "",
  111. backupMethod: "ROOM",
  112. backupCount: 1
  113. }
  114. ]
  115. };
  116. const initPrintTask = {
  117. examStartTime: "",
  118. examEndTime: "",
  119. paperNumber: "",
  120. courseName: "",
  121. courseCode: "",
  122. printCount: 1, // MODEL2专用
  123. printHouseId: "", // MODEL2专用
  124. list: []
  125. };
  126. export default {
  127. name: "create-exam-and-print-task",
  128. components: { InfoExamTask, InfoPrintTask },
  129. data() {
  130. return {
  131. modalIsShow: false,
  132. needReview: false,
  133. examRule: {},
  134. // infos: {},
  135. flowList: [],
  136. flowInfo: {},
  137. loading: false,
  138. dataReady: false
  139. };
  140. },
  141. computed: {
  142. ...mapState("exam", [
  143. "infoExamTask",
  144. "infoExamTaskDetail",
  145. "infoExamPrintPlan",
  146. "infoPrintTask"
  147. ])
  148. },
  149. mounted() {
  150. this.getExamRule();
  151. },
  152. methods: {
  153. ...mapMutations("exam", ["updateTaskInfo"]),
  154. async getExamRule() {
  155. const examRule = await examRuleDetail();
  156. this.examRule = examRule || {};
  157. this.needReview = examRule && examRule.review;
  158. },
  159. async getFlowList() {
  160. const data = await flowDetailByType();
  161. if (!data) return;
  162. this.flowInfo = {
  163. customFlowId: data.id,
  164. version: data.version
  165. };
  166. this.flowList = data.flowTaskResultList || [];
  167. if (this.flowList.length) {
  168. this.flowList[0].type = "success";
  169. }
  170. },
  171. initData() {
  172. const infoExamTaskDetail = Object.assign({}, initExamTaskDetail, {
  173. includePaper: this.examRule.includePaper,
  174. review: this.examRule.review,
  175. customCard: this.examRule.customCard
  176. });
  177. const infos = {
  178. infoExamTask: { ...initExamTask },
  179. infoExamTaskDetail,
  180. infoPrintTask: { ...initPrintTask },
  181. infoExamPrintPlan: { ...initPrintPlan }
  182. };
  183. this.updateTaskInfo(infos);
  184. this.dataReady = true;
  185. },
  186. visibleChange() {
  187. if (!this.flowList.length) this.getFlowList();
  188. this.initData();
  189. },
  190. disalogClosed() {
  191. this.dataReady = false;
  192. this.loading = false;
  193. },
  194. async cancel() {
  195. const result = await this.$confirm("确定取消该任务?", "提示", {
  196. type: "warning"
  197. }).catch(() => {});
  198. if (result !== "confirm") return;
  199. this.close();
  200. },
  201. close() {
  202. this.modalIsShow = false;
  203. },
  204. open() {
  205. this.modalIsShow = true;
  206. },
  207. async submit() {
  208. if (this.loading) return;
  209. const result = await this.$confirm("确定提交该任务?", "提示", {
  210. type: "warning"
  211. }).catch(() => {});
  212. if (result !== "confirm") return;
  213. this.loading = true;
  214. // 数据校验
  215. const validAll = [
  216. this.$refs.InfoExamTask.checkData(),
  217. this.$refs.InfoPrintTask.checkData()
  218. ];
  219. const validResult = await Promise.all(validAll).catch(() => {});
  220. if (!validResult) {
  221. this.loading = false;
  222. return;
  223. }
  224. // 更新infos
  225. this.$refs.InfoExamTask.updeteData();
  226. this.$refs.InfoPrintTask.updeteData();
  227. const examTaskContent = {
  228. examTask: this.infoExamTask,
  229. examTaskDetail: this.infoExamTaskDetail,
  230. examDetail: this.infoPrintTask
  231. };
  232. let datas = {
  233. examTaskContent: JSON.stringify(examTaskContent),
  234. ...this.flowInfo
  235. };
  236. const data = await teacherSubmitTaskApply(datas).catch(() => {});
  237. this.loading = false;
  238. if (!data) return;
  239. this.$message.success("提交成功!");
  240. this.close();
  241. this.$emit("modified");
  242. }
  243. }
  244. };
  245. </script>