123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- <template>
- <el-dialog
- class="modify-mark-params"
- :visible.sync="modalIsShow"
- top="0"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- append-to-body
- fullscreen
- :before-close="beforeClose"
- @open="initData"
- >
- <div slot="title">
- <h2 class="el-dialog__title">评卷参数设置</h2>
- <span
- >课程名称:{{ instance.courseName }}({{ instance.courseCode }})</span
- >
- </div>
- <div class="mb-4 tab-btns">
- <el-button
- v-for="tab in tabs"
- :key="tab.val"
- size="medium"
- :type="curTab == tab.val ? 'primary' : 'default'"
- @click="selectMenu(tab.val)"
- >{{ tab.name }}
- </el-button>
- </div>
- <div v-if="dataReady">
- <component
- :is="currentComponent"
- def="MarkParamRef"
- @cancel="cancel"
- @confirm="confirm"
- ></component>
- </div>
- <div slot="footer"></div>
- </el-dialog>
- </template>
- <script>
- import { mapMutations } from "vuex";
- import MarkParamStructure from "./MarkParamStructure.vue";
- import MarkParamMarker from "./MarkParamMarker.vue";
- import MarkParamMarkerLeader from "./MarkParamMarkerLeader.vue";
- import MarkParamObjectiveAnswer from "./MarkParamObjectiveAnswer.vue";
- import MarkParamUploadAnswer from "./MarkParamUploadAnswer.vue";
- import { cardDetail } from "../../../card/api";
- import { examStructureStatus } from "../../api";
- export default {
- name: "modify-mark-params",
- components: {
- MarkParamStructure,
- MarkParamMarker,
- MarkParamMarkerLeader,
- MarkParamObjectiveAnswer,
- MarkParamUploadAnswer,
- },
- props: {
- instance: {
- type: Object,
- default() {
- return {};
- },
- },
- },
- data() {
- return {
- modalIsShow: false,
- dataReady: false,
- // step
- curTab: "structure",
- tabs: [
- {
- name: "评卷参数设置",
- val: "structure",
- },
- {
- name: "科组长设置",
- val: "marker-leader",
- },
- {
- name: "评卷员管理",
- val: "marker",
- },
- {
- name: "客观题标答设置",
- val: "objective-answer",
- },
- {
- name: "主观题标答设置",
- val: "upload-answer",
- },
- ],
- current: 0,
- };
- },
- computed: {
- currentComponent() {
- return `mark-param-${this.curTab}`;
- },
- isFirstStep() {
- return this.current === 0;
- },
- isLastStep() {
- return this.current === this.lastStep;
- },
- lastStep() {
- return this.tabs.length - 1;
- },
- },
- watch: {
- curTab() {
- this.updateMarkStatus();
- },
- },
- methods: {
- ...mapMutations("markParam", [
- "setMarkParamInfos",
- "setObjectiveStructure",
- "setMarkStatus",
- "setMarkLeader",
- "initStore",
- ]),
- async initData() {
- this.initStore();
- if (this.instance.paperInfoJson) {
- const { paperStructureInfo, groupInfo, classInfo, structureCanEdit } =
- JSON.parse(this.instance.paperInfoJson);
- const infos = {
- structureCanEdit,
- paperStructureInfo: [
- ...paperStructureInfo.objectiveQuestionList,
- ...paperStructureInfo.subjectiveQuestionList,
- ],
- groupInfo: groupInfo || [],
- classInfo: classInfo || [],
- basicPaperInfo: this.instance,
- };
- this.setMarkParamInfos(infos);
- } else {
- const detData = await cardDetail(this.instance.cardId);
- const cardContent = JSON.parse(detData.content);
- let infos = {};
- if (
- (detData.type === "GENERIC" && detData.createMethod === "STANDARD") ||
- detData.type === "CUSTOM"
- ) {
- infos.structureCanEdit = false;
- infos.paperStructureInfo = this.parsePaperStructureFromCard(
- cardContent.pages
- );
- }
- this.setMarkParamInfos(infos);
- }
- if (this.instance.status) {
- const data = JSON.parse(this.instance.status);
- this.setMarkStatus(data);
- }
- if (this.instance.markLeader) {
- const data = JSON.parse(this.instance.markLeader);
- this.setMarkLeader(data);
- }
- const objectiveStructure = JSON.parse(
- this.instance.objectiveStructure || "[]"
- );
- this.setObjectiveStructure(objectiveStructure);
- this.dataReady = true;
- },
- async updateMarkStatus() {
- const res = await examStructureStatus(this.instance.id).catch(() => {});
- if (!res) return;
- const data = JSON.parse(res);
- this.setMarkStatus(data);
- },
- parsePaperStructureFromCard(pages) {
- let structData = [];
- let curTopicId = 0;
- pages.forEach((page) => {
- page.columns.forEach((column) => {
- column.elements.forEach((topic) => {
- if (!topic.parent) return;
- if (curTopicId === topic.parent.id) return;
- curTopicId = topic.parent.id;
- let questionsCount = 1,
- startNumber = 1;
- if (topic.type === "COMPOSITION") {
- // 相同大题号的作文题合并处理
- const compositionData = structData.find(
- (struct) =>
- struct.cardTopicType === "COMPOSITION" &&
- struct.mainNumber === topic.parent.topicNo * 1
- );
- if (compositionData) return;
- } else {
- questionsCount = topic.parent.questionsCount;
- startNumber = topic.parent.startNumber || 1;
- }
- const typeInfo = this.getQuestionType(topic);
- if (!typeInfo) return;
- let data = {
- mainNumber: topic.parent.topicNo * 1,
- mainTitle: topic.parent.topicName,
- questionsCount,
- startNumber,
- cardTopicType: topic.type,
- ...typeInfo,
- };
- if (topic.type === "FILL_QUESTION") {
- data.optionCount = topic.optionCount;
- }
- structData.push(data);
- });
- });
- });
- // console.log(structData);
- let structure = [];
- let mainIds = {};
- structData.forEach((struct) => {
- const { startNumber, questionsCount, qType, mainNumber, mainTitle } =
- struct;
- if (!mainIds[mainNumber]) {
- mainIds[mainNumber] = this.$randomCode();
- }
- for (let i = 0; i < questionsCount; i++) {
- structure.push({
- id: this.$randomCode(),
- qType,
- mainId: mainIds[mainNumber],
- mainTitle,
- mainNumber,
- subNumber: startNumber + i,
- type: struct.type,
- typeName: struct.typeName,
- optionCount: struct.optionCount || null,
- totalScore: undefined,
- mainFirstSub: false,
- expandSub: true,
- });
- }
- });
- structure.sort(
- (a, b) => a.mainNumber - b.mainNumber || a.subNumber - b.subNumber
- );
- let curMainId = null;
- structure.forEach((item) => {
- if (curMainId !== item.mainId) {
- curMainId = item.mainId;
- item.mainFirstSub = true;
- }
- });
- return structure;
- },
- selectMenu(val) {
- this.curTab = val;
- this.current = this.tabs.findIndex((item) => item.val === val);
- },
- async cancel() {
- const res = await this.$confirm("确定要退出阅卷参数编辑吗?", "提示", {
- type: "warning",
- }).catch(() => {});
- if (res !== "confirm") return;
- this.modalIsShow = false;
- },
- open() {
- this.modalIsShow = true;
- },
- async beforeClose(done) {
- const res = await this.$confirm("确定要退出阅卷参数编辑吗?", "提示", {
- type: "warning",
- }).catch(() => {});
- if (res !== "confirm") return;
- this.dataReady = false;
- done();
- },
- confirm() {
- if (this.isLastStep) return;
- this.selectMenu(this.tabs[this.current + 1].val);
- },
- },
- };
- </script>
|