ModifyMarkParams.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <el-dialog
  3. class="modify-mark-params"
  4. :visible.sync="modalIsShow"
  5. top="0"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. :show-close="false"
  9. append-to-body
  10. fullscreen
  11. @open="initData"
  12. >
  13. <div slot="title">
  14. <h2 class="el-dialog__title">评卷参数设置</h2>
  15. <span
  16. >课程名称:{{ instance.courseName }}({{ instance.courseCode }})</span
  17. >
  18. <span class="ml-4">{{ instance.paperType }}卷</span>
  19. <button class="el-dialog__headerbtn" @click="cancel"></button>
  20. </div>
  21. <div v-if="dataReady" class="part-box part-box-pad">
  22. <el-steps :active="curStepIndex" align-center finish-status="success">
  23. <el-step
  24. v-for="(item, ind) in steps"
  25. :key="item.val"
  26. :status="item.status"
  27. >
  28. <el-button
  29. slot="title"
  30. :class="[
  31. 'step-title',
  32. {
  33. 'is-active': curStepIndex === ind,
  34. },
  35. ]"
  36. type="text"
  37. :disabled="item.disabled"
  38. @click="changeStep(ind)"
  39. >
  40. {{ item.name }}
  41. </el-button>
  42. </el-step>
  43. </el-steps>
  44. </div>
  45. <div v-if="dataReady">
  46. <component
  47. ref="paramComponentRef"
  48. :is="currentComponent"
  49. @next="nextHandler"
  50. @prev="prevHandler"
  51. ></component>
  52. </div>
  53. <div slot="footer"></div>
  54. </el-dialog>
  55. </template>
  56. <script>
  57. import { mapMutations } from "vuex";
  58. import MarkParamStructure from "./MarkParamStructure.vue";
  59. import MarkParamGroup from "./MarkParamGroup.vue";
  60. import MarkParamClass from "./MarkParamClass.vue";
  61. import MarkParamObjectiveAnswer from "./MarkParamObjectiveAnswer.vue";
  62. import { markStructureList, markSubjectiveList } from "../../api";
  63. const steps = [
  64. {
  65. name: "第一步:设置试卷结构",
  66. val: "structure",
  67. disabled: false,
  68. status: "process",
  69. },
  70. {
  71. name: "第二步:主观题评卷设置",
  72. val: "group",
  73. disabled: false,
  74. status: "wait",
  75. },
  76. {
  77. name: "第三步:分班阅卷设置",
  78. val: "class",
  79. disabled: false,
  80. status: "wait",
  81. },
  82. {
  83. name: "第四步:客观题标答设置",
  84. val: "objective-answer",
  85. disabled: false,
  86. status: "wait",
  87. },
  88. ];
  89. export default {
  90. name: "modify-mark-params",
  91. components: {
  92. MarkParamStructure,
  93. MarkParamGroup,
  94. MarkParamClass,
  95. MarkParamObjectiveAnswer,
  96. },
  97. props: {
  98. instance: {
  99. type: Object,
  100. default() {
  101. return {};
  102. },
  103. },
  104. },
  105. data() {
  106. return {
  107. modalIsShow: false,
  108. dataReady: false,
  109. // step
  110. steps,
  111. curStepIndex: 0,
  112. questionSubmit: false,
  113. };
  114. },
  115. computed: {
  116. currentComponent() {
  117. return `mark-param-${this.curStep.val}`;
  118. },
  119. curStep() {
  120. return this.steps[this.curStepIndex];
  121. },
  122. isFirstStep() {
  123. return this.curStepIndex === 0;
  124. },
  125. isLastStep() {
  126. return this.curStepIndex === this.lastStep;
  127. },
  128. lastStep() {
  129. return this.steps.length - 1;
  130. },
  131. },
  132. methods: {
  133. ...mapMutations("markParam", [
  134. "setBasicInfo",
  135. "setPaperStructureInfo",
  136. "setStructureCanEdit",
  137. "setSubjectiveTaskList",
  138. "setOpenMergeMarker",
  139. "setOpenDoubleMark",
  140. "setOpenClassMark",
  141. "initStore",
  142. ]),
  143. async initData() {
  144. this.setBasicInfo({ ...this.instance });
  145. const params = {
  146. examId: this.instance.examId,
  147. paperNumber: this.instance.paperNumber,
  148. };
  149. // structure
  150. const structRes = await markStructureList(params);
  151. let curMainNumber = null;
  152. const questions = (structRes.questions || []).map((item) => {
  153. let nitem = {
  154. ...item,
  155. mainFirstSub: false,
  156. };
  157. if (curMainNumber !== item.mainNumber) {
  158. curMainNumber = item.mainNumber;
  159. nitem.mainFirstSub = true;
  160. }
  161. return nitem;
  162. });
  163. this.setPaperStructureInfo(questions || []);
  164. this.setStructureCanEdit(structRes.canCreate);
  165. this.questionSubmit = structRes.questionSubmit;
  166. if (questions && questions.length) {
  167. // TODO:这里的判断需要调整
  168. this.curStepIndex = 1;
  169. }
  170. // group
  171. const subjectRes = await markSubjectiveList(params);
  172. this.setSubjectiveTaskList(subjectRes.questions || []);
  173. this.setOpenMergeMarker(!!subjectRes.mergeMarker);
  174. this.setOpenDoubleMark(!!subjectRes.doubleMark);
  175. this.setOpenClassMark(!!subjectRes.classMark);
  176. if (subjectRes.questionsList && subjectRes.questionsList.length) {
  177. // TODO:这里的判断需要调整
  178. this.curStepIndex = 2;
  179. }
  180. this.initSteps();
  181. this.dataReady = true;
  182. },
  183. initSteps() {
  184. this.steps = steps.map((step, index) => {
  185. step.status =
  186. index === this.curStepIndex
  187. ? "process"
  188. : index < this.curStepIndex
  189. ? "success"
  190. : "wait";
  191. step.disabled = step.status === "wait";
  192. return step;
  193. });
  194. },
  195. changeStep(ind) {
  196. if (ind === this.curStepIndex) return;
  197. if (this.curStep.disabled) return;
  198. const step = ind - this.curStepIndex;
  199. const absStep = Math.abs(step);
  200. if (step > 0) {
  201. this.$refs.paramComponentRef.toNext(absStep);
  202. } else {
  203. this.$refs.paramComponentRef.toPrev(absStep);
  204. }
  205. },
  206. nextHandler(step = 1) {
  207. // 最后一步如何继续下一步就关闭窗口
  208. if (this.isLastStep && this.curStep.status === "process") {
  209. this.close();
  210. return;
  211. }
  212. const nextStepIndex = this.curStepIndex + step;
  213. if (nextStepIndex > this.lastStep) return;
  214. this.steps[this.curStepIndex].status = "success";
  215. if (this.steps[nextStepIndex].status === "wait") {
  216. this.steps[this.curStepIndex].status = "process";
  217. }
  218. this.curStepIndex = nextStepIndex;
  219. this.steps.forEach((item) => {
  220. item.disabled = item.status === "wait";
  221. });
  222. },
  223. prevHandler(step = 1) {
  224. if (this.isFirstStep) return;
  225. const prevStepIndex = this.curStepIndex - step;
  226. if (prevStepIndex < 0) return;
  227. this.curStepIndex = prevStepIndex;
  228. },
  229. async cancel() {
  230. const res = await this.$confirm("确定要退出阅卷参数编辑吗?", "提示", {
  231. type: "warning",
  232. }).catch(() => {});
  233. if (res !== "confirm") return;
  234. this.close();
  235. },
  236. close() {
  237. this.initStore();
  238. this.dataReady = false;
  239. this.$emit("modified");
  240. this.modalIsShow = false;
  241. },
  242. open() {
  243. this.modalIsShow = true;
  244. },
  245. },
  246. };
  247. </script>