CreateExamAndPrintTask.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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 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";
  99. const initExamTask = {
  100. semesterId: "",
  101. examId: "",
  102. examModel: "",
  103. courseCode: "",
  104. courseName: "",
  105. paperNumber: "",
  106. cardRuleId: "",
  107. teachingRoomId: "",
  108. teacherName: "",
  109. paperName: ""
  110. };
  111. const initExamTaskDetail = {
  112. operateType: "STAGE",
  113. paperType: "A",
  114. paperAttachmentIds: "[]",
  115. paperConfirmAttachmentIds: "[]",
  116. drawCount: 2,
  117. remark: "",
  118. makeMethod: "SELECT",
  119. // 题卡状态
  120. status: "",
  121. // 考务规则
  122. review: false,
  123. includePaper: false,
  124. customCard: false
  125. };
  126. const initPrintPlan = {
  127. printContent: [],
  128. backupMethod: "ROOM",
  129. backupCount: 1,
  130. drawRule: "ONE",
  131. variableContent: [
  132. {
  133. type: "SIGN",
  134. templateId: "",
  135. oldTemplateId: "",
  136. backupMethod: "ROOM",
  137. backupCount: 1
  138. },
  139. {
  140. type: "PACKAGE",
  141. templateId: "",
  142. oldTemplateId: "",
  143. backupMethod: "ROOM",
  144. backupCount: 1
  145. }
  146. ],
  147. ordinaryContent: [
  148. {
  149. type: "CHECK_IN",
  150. templateId: "",
  151. oldTemplateId: "",
  152. backupMethod: "ROOM",
  153. backupCount: 1
  154. }
  155. ]
  156. };
  157. const initPrintTask = {
  158. examStartTime: "",
  159. examEndTime: "",
  160. paperNumber: "",
  161. courseName: "",
  162. courseCode: "",
  163. printCount: 1, // MODEL2专用
  164. printHouseId: "", // MODEL2专用
  165. list: []
  166. };
  167. export default {
  168. name: "create-exam-and-print-task",
  169. components: { InfoExamTask, InfoPrintTask, SelectUserDialog },
  170. data() {
  171. return {
  172. modalIsShow: false,
  173. needReview: false,
  174. examRule: {},
  175. flowList: [],
  176. flowInfo: {},
  177. loading: false,
  178. dataReady: false,
  179. // 选择下一节点审批人
  180. IS_NEED_SELECT_APPROVE_USER: false,
  181. nextFlowTaskResult: {}, //下一节点信息
  182. approveUsers: [],
  183. userLimitCount: 1,
  184. userFilterRoles: []
  185. };
  186. },
  187. computed: {
  188. ...mapState("exam", [
  189. "infoExamTask",
  190. "infoExamTaskDetail",
  191. "infoExamPrintPlan",
  192. "infoPrintTask"
  193. ]),
  194. IS_MODEL3() {
  195. return this.infoExamTask.examModel === "MODEL3";
  196. }
  197. },
  198. mounted() {
  199. this.getExamRule();
  200. },
  201. methods: {
  202. ...mapMutations("exam", ["updateTaskInfo"]),
  203. async getExamRule() {
  204. const examRule = await examRuleDetail();
  205. this.examRule = examRule || {};
  206. this.needReview = examRule && examRule.review;
  207. },
  208. async getFlowList() {
  209. const data = await flowDetailByType();
  210. if (!data) return;
  211. const modelType =
  212. data.flowTaskResultList[0] && data.flowTaskResultList[0].modelType;
  213. this.flowInfo = {
  214. customFlowId: data.id,
  215. version: data.version
  216. };
  217. const nextFlowNodeIndex = 1;
  218. this.IS_NEED_SELECT_APPROVE_USER = modelType === "APPROVE_SET";
  219. const flowList = data.flowTaskResultList || [];
  220. this.flowList = flowList.map((flow, index) => {
  221. flow.isApproveSetFlowNextNode =
  222. this.IS_NEED_SELECT_APPROVE_USER && index === nextFlowNodeIndex;
  223. return flow;
  224. });
  225. if (this.flowList.length) {
  226. this.flowList[0].type = "success";
  227. }
  228. this.nextFlowTaskResult = this.flowList[nextFlowNodeIndex];
  229. },
  230. initData() {
  231. this.approveUsers = [];
  232. this.userLimitCount = 1;
  233. this.userFilterRoles = [];
  234. const infoExamTaskDetail = Object.assign({}, initExamTaskDetail, {
  235. review: this.examRule.review,
  236. customCard: this.examRule.customCard
  237. });
  238. const infos = {
  239. infoExamTask: { ...initExamTask },
  240. infoExamTaskDetail,
  241. infoPrintTask: { ...initPrintTask },
  242. infoExamPrintPlan: { ...initPrintPlan }
  243. };
  244. this.updateTaskInfo(infos);
  245. this.dataReady = true;
  246. },
  247. async visibleChange() {
  248. if (!this.flowList.length) await this.getFlowList();
  249. this.initData();
  250. },
  251. disalogClosed() {
  252. this.dataReady = false;
  253. this.loading = false;
  254. },
  255. async cancel() {
  256. const result = await this.$confirm("确定取消该任务?", "提示", {
  257. type: "warning"
  258. }).catch(() => {});
  259. if (result !== "confirm") return;
  260. this.close();
  261. },
  262. close() {
  263. this.modalIsShow = false;
  264. },
  265. open() {
  266. this.modalIsShow = true;
  267. },
  268. toSelectNextFlowUser() {
  269. if (!this.IS_NEED_SELECT_APPROVE_USER) return;
  270. this.userLimitCount =
  271. this.nextFlowTaskResult.approveUserCountType === "ONE" ? 1 : 0;
  272. this.userFilterRoles =
  273. this.nextFlowTaskResult.approveUserSelectRange === "ROLE"
  274. ? this.nextFlowTaskResult.approveUserSelectRoles.map(item => item.id)
  275. : [];
  276. this.$refs.SelectUserDialog.open();
  277. },
  278. userSelected(users) {
  279. this.approveUsers = users;
  280. },
  281. async submit() {
  282. if (this.loading) return;
  283. const result = await this.$confirm("确定提交该任务?", "提示", {
  284. type: "warning"
  285. }).catch(() => {});
  286. if (result !== "confirm") return;
  287. this.loading = true;
  288. // 数据校验
  289. let validAll = [this.$refs.InfoExamTask.checkData()];
  290. if (!this.IS_MODEL3) validAll.push(this.$refs.InfoPrintTask.checkData());
  291. const validResult = await Promise.all(validAll).catch(() => {});
  292. if (!validResult) {
  293. this.loading = false;
  294. return;
  295. }
  296. // 更新infos
  297. this.$refs.InfoExamTask.updateData();
  298. if (!this.IS_MODEL3) this.$refs.InfoPrintTask.updateData();
  299. let examTaskContent = {
  300. examTask: this.infoExamTask,
  301. examTaskDetail: this.infoExamTaskDetail
  302. };
  303. if (!this.IS_MODEL3) examTaskContent.examDetail = this.infoPrintTask;
  304. let datas = {
  305. examTaskContent: JSON.stringify(examTaskContent),
  306. ...this.flowInfo
  307. };
  308. if (this.IS_NEED_SELECT_APPROVE_USER)
  309. datas.approveUserIds = this.approveUsers.map(item => item.id);
  310. const data = await teacherSubmitTaskApply(datas).catch(() => {});
  311. this.loading = false;
  312. if (!data) return;
  313. this.$message.success("提交成功!");
  314. this.close();
  315. this.$emit("modified");
  316. }
  317. }
  318. };
  319. </script>