ModifyMarkParams.vue 7.8 KB

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