CreateExamAndPrintTask.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div>
  3. <el-dialog
  4. class="create-exam-and-print-task"
  5. :visible.sync="modalIsShow"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. :show-close="false"
  9. append-to-body
  10. fullscreen
  11. @open="visibleChange"
  12. @closed="disalogClosed"
  13. >
  14. <div slot="title">
  15. <span class="el-dialog__title">新增命题申请</span>
  16. </div>
  17. <div class="apply-body" v-if="dataReady">
  18. <div class="apply-part">
  19. <h3 class="apply-part-title">命题信息</h3>
  20. <info-exam-task ref="InfoExamTask"></info-exam-task>
  21. </div>
  22. <div v-if="!IS_MODEL3" class="apply-part">
  23. <h3 class="apply-part-title">考务信息</h3>
  24. <info-print-task ref="InfoPrintTask"></info-print-task>
  25. </div>
  26. <div v-if="infoExamTask.review" class="apply-part flow-timeline">
  27. <h3 class="apply-part-title">流程</h3>
  28. <el-timeline>
  29. <el-timeline-item
  30. v-for="flow in flowList"
  31. :key="flow.taskKey"
  32. :type="flow.type"
  33. >
  34. <div class="flow-item">
  35. <div class="flow-item-content">
  36. <h4 class="flow-item-title">{{ flow.taskName }}</h4>
  37. <p v-if="flow.approveUserNames" class="flow-item-desc">
  38. {{ flow.approveUserNames }}
  39. </p>
  40. <div
  41. v-if="flow.isApproveSetFlowNextNode && approveUsers.length"
  42. class="flow-item-users"
  43. >
  44. <span>审批人:</span>
  45. <el-tag
  46. v-for="user in approveUsers"
  47. :key="user.id"
  48. size="small"
  49. :disable-transitions="false"
  50. >
  51. {{ user.name }}
  52. </el-tag>
  53. </div>
  54. </div>
  55. <div
  56. v-if="flow.isApproveSetFlowNextNode"
  57. class="flow-item-action"
  58. >
  59. <el-button
  60. class="user-select"
  61. icon="el-icon-plus"
  62. @click="toSelectNextFlowUser"
  63. ></el-button>
  64. <p v-if="!approveUsers.length" class="tips-info tips-error">
  65. 请选择审核人
  66. </p>
  67. </div>
  68. </div>
  69. </el-timeline-item>
  70. </el-timeline>
  71. </div>
  72. </div>
  73. <div class="text-center">
  74. <el-button type="success" :disabled="loading" @click="submit"
  75. >确认提交</el-button
  76. >
  77. <el-button @click="cancel">取消</el-button>
  78. </div>
  79. <div slot="footer"></div>
  80. </el-dialog>
  81. <!-- SelectUserDialog -->
  82. <select-user-dialog
  83. v-if="IS_NEED_SELECT_APPROVE_USER"
  84. ref="SelectUserDialog"
  85. :users="approveUsers"
  86. :user-limit-count="userLimitCount"
  87. :filter-roles="userFilterRoles"
  88. @modified="userSelected"
  89. ></select-user-dialog>
  90. </div>
  91. </template>
  92. <script>
  93. import { mapMutations, mapState } from "vuex";
  94. import { examRuleDetail, flowDetailByType } from "../../../base/api";
  95. import { teacherSubmitTaskApply } from "../../api";
  96. import InfoExamTask from "./InfoExamTask";
  97. import InfoPrintTask from "./InfoPrintTask";
  98. import SelectUserDialog from "../../../base/components/SelectUserDialog.vue";
  99. import { randomCode } from "@/plugins/utils";
  100. const initExamTask = {
  101. semesterId: "",
  102. examId: "",
  103. examModel: "",
  104. category: "",
  105. courseId: "",
  106. courseCode: "",
  107. courseName: "",
  108. paperNumber: "",
  109. cardRuleId: "",
  110. teachingRoomId: "",
  111. teacherName: "",
  112. paperName: "",
  113. uuid: "",
  114. openAb: false,
  115. paperConfirmAttachmentIds: "[]",
  116. remark: "",
  117. // 题卡状态
  118. status: "",
  119. // 考务规则
  120. review: false,
  121. includePaper: false,
  122. customCard: false,
  123. };
  124. // const examTaskDetailItem = {
  125. // serialNumber: 1,
  126. // paperType: "A",
  127. // paperAttachmentIds: "[]",
  128. // };
  129. // const initExamTaskDetail = []; // examTaskDetailItem[]
  130. const initPrintPlan = {
  131. printContent: [],
  132. backupMethod: "ROOM",
  133. backupCount: 1,
  134. drawRule: "ONE",
  135. variableContent: [
  136. {
  137. type: "SIGN",
  138. templateId: "",
  139. oldTemplateId: "",
  140. backupMethod: "ROOM",
  141. backupCount: 1,
  142. },
  143. {
  144. type: "PACKAGE",
  145. templateId: "",
  146. oldTemplateId: "",
  147. backupMethod: "ROOM",
  148. backupCount: 1,
  149. },
  150. ],
  151. ordinaryContent: [
  152. {
  153. type: "CHECK_IN",
  154. templateId: "",
  155. oldTemplateId: "",
  156. backupMethod: "ROOM",
  157. backupCount: 1,
  158. },
  159. ],
  160. };
  161. const initPrintTask = {
  162. examStartTime: "",
  163. examEndTime: "",
  164. paperNumber: "",
  165. courseName: "",
  166. courseCode: "",
  167. courseId: "",
  168. printCount: 1, // MODEL2专用
  169. printHouseId: "", // MODEL2专用
  170. classId: "", // MODEL2专用
  171. className: "", // MODEL2专用
  172. basicStudentIds: [], // MODEL2专用
  173. list: [],
  174. };
  175. export default {
  176. name: "create-exam-and-print-task",
  177. components: { InfoExamTask, InfoPrintTask, SelectUserDialog },
  178. data() {
  179. return {
  180. modalIsShow: false,
  181. needReview: false,
  182. examRule: {},
  183. flowList: [],
  184. flowInfo: {},
  185. loading: false,
  186. dataReady: false,
  187. // 选择下一节点审批人
  188. IS_NEED_SELECT_APPROVE_USER: false,
  189. nextFlowTaskResult: {}, //下一节点信息
  190. approveUsers: [],
  191. userLimitCount: 1,
  192. userFilterRoles: [],
  193. };
  194. },
  195. computed: {
  196. ...mapState("exam", [
  197. "infoExamTask",
  198. "infoExamTaskDetail",
  199. "infoExamPrintPlan",
  200. "infoPrintTask",
  201. ]),
  202. IS_MODEL3() {
  203. return this.infoExamTask.examModel === "MODEL3";
  204. },
  205. },
  206. mounted() {
  207. this.getExamRule();
  208. },
  209. methods: {
  210. ...mapMutations("exam", ["updateTaskInfo"]),
  211. async getExamRule() {
  212. const examRule = await examRuleDetail();
  213. this.examRule = examRule || {};
  214. this.needReview = examRule && examRule.review;
  215. },
  216. async getFlowList() {
  217. const data = await flowDetailByType();
  218. if (!data) return;
  219. const modelType =
  220. data.flowTaskResultList[0] && data.flowTaskResultList[0].modelType;
  221. this.flowInfo = {
  222. customFlowId: data.id,
  223. version: data.version,
  224. };
  225. const nextFlowNodeIndex = 1;
  226. this.IS_NEED_SELECT_APPROVE_USER = modelType === "APPROVE_SET";
  227. const flowList = data.flowTaskResultList || [];
  228. this.flowList = flowList.map((flow, index) => {
  229. flow.isApproveSetFlowNextNode =
  230. this.IS_NEED_SELECT_APPROVE_USER && index === nextFlowNodeIndex;
  231. return flow;
  232. });
  233. if (this.flowList.length) {
  234. this.flowList[0].type = "success";
  235. }
  236. this.nextFlowTaskResult = this.flowList[nextFlowNodeIndex];
  237. },
  238. initData() {
  239. this.approveUsers = [];
  240. this.userLimitCount = 1;
  241. this.userFilterRoles = [];
  242. const infos = {
  243. infoExamTask: {
  244. ...initExamTask,
  245. uuid: randomCode(32),
  246. review: this.examRule.review,
  247. customCard: this.examRule.customCard,
  248. },
  249. infoExamTaskDetail: [],
  250. infoPrintTask: { ...initPrintTask },
  251. infoExamPrintPlan: { ...initPrintPlan },
  252. };
  253. this.updateTaskInfo(infos);
  254. this.dataReady = true;
  255. },
  256. async visibleChange() {
  257. if (!this.flowList.length) await this.getFlowList();
  258. this.initData();
  259. },
  260. disalogClosed() {
  261. this.dataReady = false;
  262. this.loading = false;
  263. },
  264. async cancel() {
  265. const result = await this.$confirm("确定取消该任务?", "提示", {
  266. type: "warning",
  267. }).catch(() => {});
  268. if (result !== "confirm") return;
  269. this.close();
  270. },
  271. close() {
  272. this.modalIsShow = false;
  273. },
  274. open() {
  275. this.modalIsShow = true;
  276. },
  277. toSelectNextFlowUser() {
  278. if (!this.IS_NEED_SELECT_APPROVE_USER) return;
  279. this.userLimitCount =
  280. this.nextFlowTaskResult.approveUserCountType === "ONE" ? 1 : 0;
  281. this.userFilterRoles =
  282. this.nextFlowTaskResult.approveUserSelectRange === "ROLE"
  283. ? this.nextFlowTaskResult.approveUserSelectRoles.map(
  284. (item) => item.id
  285. )
  286. : [];
  287. this.$refs.SelectUserDialog.open();
  288. },
  289. userSelected(users) {
  290. this.approveUsers = users;
  291. },
  292. async submit() {
  293. if (this.loading) return;
  294. const result = await this.$confirm("确定提交该任务?", "提示", {
  295. type: "warning",
  296. }).catch(() => {});
  297. if (result !== "confirm") return;
  298. this.loading = true;
  299. // 数据校验
  300. let validAll = [this.$refs.InfoExamTask.checkData()];
  301. if (!this.IS_MODEL3) validAll.push(this.$refs.InfoPrintTask.checkData());
  302. const validResult = await Promise.all(validAll).catch(() => {});
  303. if (!validResult) {
  304. this.loading = false;
  305. return;
  306. }
  307. // 更新infos
  308. this.$refs.InfoExamTask.updateData();
  309. if (!this.IS_MODEL3) this.$refs.InfoPrintTask.updateData();
  310. let examTaskContent = {
  311. examTask: this.infoExamTask,
  312. examTaskDetailList: this.infoExamTaskDetail,
  313. };
  314. if (!this.IS_MODEL3) {
  315. examTaskContent.examDetail = this.infoPrintTask;
  316. examTaskContent.examTask.examStartTime =
  317. this.infoPrintTask.examStartTime;
  318. examTaskContent.examTask.examEndTime = this.infoPrintTask.examEndTime;
  319. }
  320. let datas = {
  321. examTaskContent: JSON.stringify(examTaskContent),
  322. ...this.flowInfo,
  323. };
  324. if (this.IS_NEED_SELECT_APPROVE_USER)
  325. datas.approveUserIds = this.approveUsers.map((item) => item.id);
  326. const data = await teacherSubmitTaskApply(datas).catch(() => {});
  327. this.loading = false;
  328. if (!data) return;
  329. this.$message.success("提交成功!");
  330. this.close();
  331. this.$emit("modified");
  332. },
  333. },
  334. };
  335. </script>