CreateExamAndPrintTask.vue 7.2 KB

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