ModifyMarkParams.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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="['step-title', { 'is-active': curStepIndex === ind }]"
  31. type="text"
  32. :disabled="item.disabled"
  33. @click="changeStep(ind)"
  34. >{{ item.name }}</el-button
  35. >
  36. </el-step>
  37. </el-steps>
  38. </div>
  39. <div v-if="dataReady">
  40. <component
  41. :is="currentComponent"
  42. @next="nextHandler"
  43. @prev="prevHandler"
  44. ></component>
  45. </div>
  46. <div slot="footer"></div>
  47. </el-dialog>
  48. </template>
  49. <script>
  50. import { mapState, mapMutations } from "vuex";
  51. import MarkParamStructure from "./MarkParamStructure.vue";
  52. import MarkParamGroup from "./MarkParamGroup.vue";
  53. import MarkParamClass from "./MarkParamClass.vue";
  54. import MarkParamObjectiveAnswer from "./MarkParamObjectiveAnswer.vue";
  55. import { markStructureList, markSubjectiveList } from "../../api";
  56. const steps = [
  57. {
  58. name: "第一步:设置试卷结构",
  59. val: "structure",
  60. disabled: false,
  61. status: "process",
  62. },
  63. {
  64. name: "第二步:主观题评卷设置",
  65. val: "group",
  66. disabled: false,
  67. status: "wait",
  68. },
  69. {
  70. name: "第三步:分班阅卷设置",
  71. val: "class",
  72. disabled: false,
  73. status: "wait",
  74. },
  75. {
  76. name: "第四步:客观题标答设置",
  77. val: "objective-answer",
  78. disabled: false,
  79. status: "wait",
  80. },
  81. ];
  82. export default {
  83. name: "modify-mark-params",
  84. components: {
  85. MarkParamStructure,
  86. MarkParamGroup,
  87. MarkParamClass,
  88. MarkParamObjectiveAnswer,
  89. },
  90. props: {
  91. instance: {
  92. type: Object,
  93. default() {
  94. return {};
  95. },
  96. },
  97. },
  98. data() {
  99. return {
  100. modalIsShow: false,
  101. dataReady: false,
  102. // step
  103. steps,
  104. curStepIndex: 0,
  105. questionSubmit: false,
  106. };
  107. },
  108. computed: {
  109. ...mapState("markParam", ["openMarkClass"]),
  110. currentComponent() {
  111. return `mark-param-${this.curStep.val}`;
  112. },
  113. curStep() {
  114. return this.steps[this.curStepIndex];
  115. },
  116. isFirstStep() {
  117. return this.curStepIndex === 0;
  118. },
  119. isLastStep() {
  120. return this.curStepIndex === this.lastStep;
  121. },
  122. lastStep() {
  123. return this.steps.length - 1;
  124. },
  125. },
  126. methods: {
  127. ...mapMutations("markParam", [
  128. "setBasicInfo",
  129. "setPaperStructureInfo",
  130. "setStructureCanEdit",
  131. "setSubjectiveTaskList",
  132. "setOpenMergeMarker",
  133. "setOpenDoubleMarking",
  134. "setOpenMarkClass",
  135. "initStore",
  136. ]),
  137. async initData() {
  138. this.setBasicInfo({ ...this.instance });
  139. const params = {
  140. examId: this.instance.examId,
  141. paperNumber: this.instance.paperNumber,
  142. };
  143. // structure
  144. const structRes = await markStructureList(params);
  145. let curMainNumber = null;
  146. const questions = (structRes.questions || []).map((item) => {
  147. let nitem = {
  148. ...item,
  149. mainFirstSub: false,
  150. };
  151. if (curMainNumber !== item.mainNumber) {
  152. curMainNumber = item.mainNumber;
  153. nitem.mainFirstSub = true;
  154. }
  155. return nitem;
  156. });
  157. this.setPaperStructureInfo(questions || []);
  158. this.setStructureCanEdit(structRes.canCreate);
  159. this.questionSubmit = structRes.questionSubmit;
  160. if (questions && questions.length) {
  161. // TODO:这里的判断需要调整
  162. this.curStepIndex = 1;
  163. }
  164. // group
  165. const subjectRes = await markSubjectiveList(params);
  166. this.setSubjectiveTaskList(subjectRes.questionsList || []);
  167. this.setOpenMergeMarker(!!subjectRes.openMergeMarker);
  168. this.setOpenDoubleMarking(!!subjectRes.openDoubleMarking);
  169. this.setOpenMarkClass(!!subjectRes.openMarkClass);
  170. if (subjectRes.questionsList && subjectRes.questionsList.length) {
  171. // TODO:这里的判断需要调整
  172. this.curStepIndex = 2;
  173. }
  174. this.initSteps();
  175. this.dataReady = true;
  176. },
  177. initSteps() {
  178. this.steps = steps.map((step, index) => {
  179. step.status =
  180. index === this.curStepIndex
  181. ? "process"
  182. : index < this.curStepIndex
  183. ? "success"
  184. : "wait";
  185. step.disabled = step.status === "wait";
  186. return step;
  187. });
  188. },
  189. changeStep(ind) {
  190. if (ind === this.curStepIndex) return;
  191. this.curStepIndex = ind;
  192. },
  193. nextHandler() {
  194. if (this.isLastStep && this.curStep.status === "process") {
  195. this.close();
  196. return;
  197. }
  198. this.steps[this.curStepIndex].status = "success";
  199. if (
  200. this.curStepIndex !== this.steps.length - 1 &&
  201. this.steps[this.curStepIndex + 1].status === "wait"
  202. ) {
  203. this.curStepIndex += 1;
  204. this.steps[this.curStepIndex].status = "process";
  205. }
  206. this.steps.forEach((item) => {
  207. item.disabled = item.status === "wait";
  208. });
  209. },
  210. prevHandler() {
  211. if (this.isFirstStep) return;
  212. this.curStepIndex -= 1;
  213. this.steps[this.curStepIndex].status = "process";
  214. },
  215. async cancel() {
  216. const res = await this.$confirm("确定要退出阅卷参数编辑吗?", "提示", {
  217. type: "warning",
  218. }).catch(() => {});
  219. if (res !== "confirm") return;
  220. this.close();
  221. },
  222. close() {
  223. this.initStore();
  224. this.dataReady = false;
  225. this.$emit("modified");
  226. this.modalIsShow = false;
  227. },
  228. open() {
  229. this.modalIsShow = true;
  230. },
  231. },
  232. };
  233. </script>