123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <template>
- <el-dialog
- class="modify-mark-params"
- :visible.sync="modalIsShow"
- top="0"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :show-close="false"
- append-to-body
- fullscreen
- @open="initData"
- >
- <div slot="title">
- <h2 class="el-dialog__title">评卷参数设置</h2>
- <span
- >课程名称:{{ instance.courseName }}({{ instance.courseCode }})</span
- >
- <span class="ml-4">{{ instance.paperType }}卷</span>
- <button class="el-dialog__headerbtn" @click="cancel"></button>
- </div>
- <div v-if="dataReady" class="part-box part-box-pad">
- <el-steps :active="curStepIndex" align-center finish-status="success">
- <el-step
- v-for="(item, ind) in steps"
- :key="item.val"
- :status="item.status"
- >
- <el-button
- slot="title"
- :class="[
- 'step-title',
- {
- 'is-active': curStepIndex === ind,
- },
- ]"
- type="text"
- :disabled="item.disabled"
- @click="changeStep(ind)"
- >
- {{ item.name }}
- </el-button>
- </el-step>
- </el-steps>
- </div>
- <div v-if="dataReady">
- <component
- ref="paramComponentRef"
- :is="currentComponent"
- @next="nextHandler"
- @prev="prevHandler"
- ></component>
- </div>
- <div slot="footer"></div>
- </el-dialog>
- </template>
- <script>
- import { mapMutations } from "vuex";
- import MarkParamStructure from "./MarkParamStructure.vue";
- import MarkParamGroup from "./MarkParamGroup.vue";
- import MarkParamClass from "./MarkParamClass.vue";
- import MarkParamObjectiveAnswer from "./MarkParamObjectiveAnswer.vue";
- import { markStructureList, markSubjectiveList } from "../../api";
- const steps = [
- {
- name: "第一步:设置试卷结构",
- val: "structure",
- disabled: false,
- status: "process",
- },
- {
- name: "第二步:主观题评卷设置",
- val: "group",
- disabled: false,
- status: "wait",
- },
- {
- name: "第三步:分班阅卷设置",
- val: "class",
- disabled: false,
- status: "wait",
- },
- {
- name: "第四步:客观题标答设置",
- val: "objective-answer",
- disabled: false,
- status: "wait",
- },
- ];
- export default {
- name: "modify-mark-params",
- components: {
- MarkParamStructure,
- MarkParamGroup,
- MarkParamClass,
- MarkParamObjectiveAnswer,
- },
- props: {
- instance: {
- type: Object,
- default() {
- return {};
- },
- },
- },
- data() {
- return {
- modalIsShow: false,
- dataReady: false,
- // step
- steps,
- curStepIndex: 0,
- questionSubmit: false,
- };
- },
- computed: {
- currentComponent() {
- return `mark-param-${this.curStep.val}`;
- },
- curStep() {
- return this.steps[this.curStepIndex];
- },
- isFirstStep() {
- return this.curStepIndex === 0;
- },
- isLastStep() {
- return this.curStepIndex === this.lastStep;
- },
- lastStep() {
- return this.steps.length - 1;
- },
- },
- methods: {
- ...mapMutations("markParam", [
- "setBasicInfo",
- "setPaperStructureInfo",
- "setStructureCanEdit",
- "setSubjectiveTaskList",
- "setOpenMergeMarker",
- "setOpenDoubleMark",
- "setOpenClassMark",
- "initStore",
- ]),
- async initData() {
- this.setBasicInfo({ ...this.instance });
- const params = {
- examId: this.instance.examId,
- paperNumber: this.instance.paperNumber,
- };
- // structure
- const structRes = await markStructureList(params);
- let curMainNumber = null;
- const questions = (structRes.questions || []).map((item) => {
- let nitem = {
- ...item,
- mainFirstSub: false,
- };
- if (curMainNumber !== item.mainNumber) {
- curMainNumber = item.mainNumber;
- nitem.mainFirstSub = true;
- }
- return nitem;
- });
- this.setPaperStructureInfo(questions || []);
- this.setStructureCanEdit(structRes.canCreate);
- this.questionSubmit = structRes.questionSubmit;
- if (questions && questions.length) {
- // TODO:这里的判断需要调整
- this.curStepIndex = 1;
- }
- // group
- const subjectRes = await markSubjectiveList(params);
- this.setSubjectiveTaskList(subjectRes.questions || []);
- this.setOpenMergeMarker(!!subjectRes.mergeMarker);
- this.setOpenDoubleMark(!!subjectRes.doubleMark);
- this.setOpenClassMark(!!subjectRes.classMark);
- if (subjectRes.questionsList && subjectRes.questionsList.length) {
- // TODO:这里的判断需要调整
- this.curStepIndex = 2;
- }
- this.initSteps();
- this.dataReady = true;
- },
- initSteps() {
- this.steps = steps.map((step, index) => {
- step.status =
- index === this.curStepIndex
- ? "process"
- : index < this.curStepIndex
- ? "success"
- : "wait";
- step.disabled = step.status === "wait";
- return step;
- });
- },
- changeStep(ind) {
- if (ind === this.curStepIndex) return;
- if (this.curStep.disabled) return;
- const step = ind - this.curStepIndex;
- const absStep = Math.abs(step);
- if (step > 0) {
- this.$refs.paramComponentRef.toNext(absStep);
- } else {
- this.$refs.paramComponentRef.toPrev(absStep);
- }
- },
- nextHandler(step = 1) {
- // 最后一步如何继续下一步就关闭窗口
- if (this.isLastStep && this.curStep.status === "process") {
- this.close();
- return;
- }
- const nextStepIndex = this.curStepIndex + step;
- if (nextStepIndex > this.lastStep) return;
- this.steps[this.curStepIndex].status = "success";
- if (this.steps[nextStepIndex].status === "wait") {
- this.steps[this.curStepIndex].status = "process";
- }
- this.curStepIndex = nextStepIndex;
- this.steps.forEach((item) => {
- item.disabled = item.status === "wait";
- });
- },
- prevHandler(step = 1) {
- if (this.isFirstStep) return;
- const prevStepIndex = this.curStepIndex - step;
- if (prevStepIndex < 0) return;
- this.curStepIndex = prevStepIndex;
- },
- async cancel() {
- const res = await this.$confirm("确定要退出阅卷参数编辑吗?", "提示", {
- type: "warning",
- }).catch(() => {});
- if (res !== "confirm") return;
- this.close();
- },
- close() {
- this.initStore();
- this.dataReady = false;
- this.$emit("modified");
- this.modalIsShow = false;
- },
- open() {
- this.modalIsShow = true;
- },
- },
- };
- </script>
|