CreateTaskApply.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <el-dialog
  3. class="create-task-apply"
  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. destroy-on-close
  11. @open="visibleChange"
  12. >
  13. <div slot="title">
  14. <span class="el-dialog__title">新增命题申请</span>
  15. <button class="el-dialog__headerbtn" @click="close"></button>
  16. </div>
  17. <el-steps class="apply-step" :active="current" align-center>
  18. <el-step
  19. v-for="step in steps"
  20. :key="step.name"
  21. :title="step.name"
  22. :description="step.title"
  23. >
  24. </el-step>
  25. </el-steps>
  26. <component
  27. :is="currentComponent"
  28. :ref="currentComponent"
  29. @next-step="toNext"
  30. @on-ready="compReady"
  31. ></component>
  32. <div slot="footer">
  33. <el-button v-if="!isFirstStep" type="primary" @click="prevStep"
  34. >上一步</el-button
  35. >
  36. <el-button
  37. v-if="isLastStep"
  38. type="success"
  39. :disabled="isSubmit"
  40. @click="submit"
  41. >确认提交</el-button
  42. >
  43. <el-button v-else type="primary" @click="nextStep" :disabled="nextHolder"
  44. >下一步</el-button
  45. >
  46. <el-button @click="cancel">取消</el-button>
  47. </div>
  48. </el-dialog>
  49. </template>
  50. <script>
  51. import { examRuleDetail } from "../../base/api";
  52. import { teacherCreateTaskApply, teacherCancelTaskApply } from "../api";
  53. const STEPS_LIST = [
  54. {
  55. name: "exam-task",
  56. title: "命题信息"
  57. },
  58. {
  59. name: "print",
  60. title: "备卷印品信息"
  61. },
  62. {
  63. name: "exam-business",
  64. title: "考务信息"
  65. }
  66. ];
  67. const initExamTask = {
  68. id: null,
  69. courseCode: "",
  70. courseName: "",
  71. paperNumber: "",
  72. cardRuleId: "",
  73. teachingRoomId: "",
  74. teacherName: "",
  75. lecturerName: ""
  76. };
  77. const initExamTaskDetail = {
  78. operateType: "STAGE",
  79. paperType: "A",
  80. cardId: "",
  81. paperAttachmentIds: [],
  82. paperConfirmAttachmentIds: [],
  83. drawCount: 2,
  84. remark: "",
  85. makeMethod: "",
  86. // 题卡状态
  87. status: "",
  88. // 考务规则
  89. review: false,
  90. includePaper: false,
  91. customCard: false
  92. };
  93. const initPrintPlan = {
  94. id: null,
  95. name: "",
  96. examStartTime: "",
  97. examEndTime: "",
  98. printContent: [],
  99. backupMethod: "ROOM",
  100. backupCount: 1,
  101. drawRule: "ONE",
  102. variableContent: [
  103. {
  104. type: "SIGN",
  105. templateId: [],
  106. oldTemplateId: [],
  107. backupMethod: "ROOM",
  108. backupCount: 1
  109. },
  110. {
  111. type: "PACKAGE",
  112. templateId: [],
  113. oldTemplateId: [],
  114. backupMethod: "ROOM",
  115. backupCount: 1
  116. }
  117. ],
  118. ordinaryContent: [
  119. {
  120. type: "CHECK_IN",
  121. templateId: [],
  122. oldTemplateId: [],
  123. backupMethod: "ROOM",
  124. backupCount: 1
  125. }
  126. ]
  127. };
  128. const initPrintTask = {
  129. printPlanName: "",
  130. printPlanId: "",
  131. examStartTime: "",
  132. examEndTime: "",
  133. paperNumber: "",
  134. courseName: "",
  135. courseCode: "",
  136. list: []
  137. };
  138. export default {
  139. name: "create-task-apply",
  140. data() {
  141. return {
  142. modalIsShow: false,
  143. isSubmit: false,
  144. needReview: false,
  145. examRule: {},
  146. infos: {},
  147. // step
  148. steps: STEPS_LIST,
  149. current: 0,
  150. nextHolder: false,
  151. isPaying: false,
  152. dataReady: true
  153. };
  154. },
  155. computed: {
  156. currentComponent() {
  157. return `info-${this.steps[this.current].name}`;
  158. },
  159. isFirstStep() {
  160. return this.current === 0;
  161. },
  162. isLastStep() {
  163. return this.current === this.lastStep;
  164. },
  165. lastStep() {
  166. return this.steps.length - 1;
  167. },
  168. isFree() {
  169. return this.infos.free || !this.infos.fee;
  170. },
  171. payBtnName() {
  172. return this.isFree ? "确认并提交" : "确认并缴费";
  173. }
  174. },
  175. created() {
  176. this.getExamRule();
  177. },
  178. methods: {
  179. async getExamRule() {
  180. const examRule = await examRuleDetail();
  181. this.examRule = examRule || {};
  182. this.needReview = examRule && examRule.review;
  183. },
  184. initData() {
  185. const examTaskDetail = Object.assign({}, initExamTaskDetail, {
  186. includePaper: this.examRule.includePaper,
  187. review: this.examRule.review,
  188. customCard: this.examRule.customCard
  189. });
  190. this.infos = {
  191. examTask: { ...initExamTask },
  192. examTaskDetail,
  193. printPlan: { ...initPrintPlan },
  194. printTask: { ...initPrintTask }
  195. };
  196. },
  197. visibleChange() {
  198. this.initData();
  199. },
  200. prevStep() {
  201. if (this.isFirstStep) return;
  202. this.current -= 1;
  203. },
  204. nextStep() {
  205. if (this.isLastStep) return;
  206. this.$refs[this.currentComponent].checkForm();
  207. },
  208. toNext() {
  209. if (this.isLastStep) return;
  210. this.current += 1;
  211. this.nextHolder = true;
  212. },
  213. compReady(type = false) {
  214. this.nextHolder = type;
  215. },
  216. checkData() {
  217. return this.$refs.examTaskComp.validate().catch(() => {});
  218. },
  219. async cancel() {
  220. if (this.examTask.id) {
  221. await teacherCancelTaskApply(this.examTask.id);
  222. this.$message.success("取消命题申请成功!");
  223. }
  224. this.close();
  225. },
  226. close() {
  227. this.modalIsShow = false;
  228. },
  229. open() {
  230. this.modalIsShow = true;
  231. },
  232. async toSave(silent) {
  233. const valid = await this.$refs.examTaskComp.validate().catch(() => {});
  234. if (!valid) return;
  235. if (this.isSubmit) return;
  236. this.isSubmit = true;
  237. this.getTaskDetailData();
  238. const datas = {
  239. examTaskDetail: this.examTaskDetail,
  240. examTask: this.examTask
  241. };
  242. const data = await teacherCreateTaskApply(datas).catch(() => {});
  243. this.isSubmit = false;
  244. if (!data) return;
  245. this.examTask = this.$objAssign(this.examTask, data);
  246. if (!silent) this.$message.success("保存成功!");
  247. return true;
  248. },
  249. async submit() {
  250. const valid = await this.$refs.examTaskComp.validate().catch(() => {});
  251. if (!valid) return;
  252. if (!this.checkDataValid()) return;
  253. this.$confirm(
  254. "任务确定提交后,则不可更改试卷及答题卡内容,确定提交该任务?",
  255. "提示",
  256. {
  257. type: "warning"
  258. }
  259. )
  260. .then(async () => {
  261. this.getTaskDetailData();
  262. this.examTaskDetail.operateType = "SUBMIT";
  263. const datas = {
  264. examTaskDetail: this.examTaskDetail,
  265. examTask: this.examTask
  266. };
  267. const data = await teacherCreateTaskApply(datas).catch(() => {});
  268. if (!data) return;
  269. this.$message.success("提交成功!");
  270. this.close();
  271. this.$emit("modified");
  272. })
  273. .catch(() => {});
  274. }
  275. }
  276. };
  277. </script>