瀏覽代碼

卡格式修改

zhangjie 3 年之前
父節點
當前提交
f3621c5d5c

+ 7 - 7
src/modules/card/autoBuild/paperCard.js

@@ -36,7 +36,7 @@ const elementModel = {
   },
   FILL_LINE: (presetData) => {
     const model = createFillLine(presetData);
-    return getFillLineElements(model, presetData.questions);
+    return getFillLineElements(model);
   },
   EXPLAIN: (presetData) => {
     const model = createExplain(presetData);
@@ -181,20 +181,20 @@ function buildCardElements(structList) {
 
     if (!struct.isCommon && struct.structType === "TEXT_ANSWER_QUESTION") {
       struct.questions.forEach((qno) => {
-        const tname = `${topicName}、${qno}`;
+        const presetData = {
+          topicName: `${topicName}、${qno}`,
+          paperStruct: { ...struct, questions: [qno] },
+        };
 
-        const elements = elementModel[modelType]({
-          questions: [""],
-          topicName: tname,
-        });
+        const elements = elementModel[modelType](presetData);
         cardElements.push(...elements);
       });
       return;
     }
 
     let presetData = {
-      questions: struct.questions,
       topicName,
+      paperStruct: struct,
     };
     if (struct.structType === "MULTIPLE_ANSWER_QUESTION")
       presetData.isMultiply = true;

+ 1 - 0
src/modules/card/components/CardDesign.vue

@@ -312,6 +312,7 @@ export default {
       const elements = buildPaperCard(initPaperJson);
       this.setTopics([...this.pageDefaultElems.elements, ...elements]);
       // this.setTopics(this.pageDefaultElems.elements || []);
+      this.resetTopicSeries();
       this.$nextTick(() => {
         this.rebuildPages();
         this.setCurPage(0);

+ 15 - 11
src/modules/card/elements/explain/model.js

@@ -1,11 +1,16 @@
-import { getElementId, randomCode, objAssign } from "../../plugins/utils";
+import {
+  getElementId,
+  randomCode,
+  objAssign,
+  deepCopy,
+} from "../../plugins/utils";
 
 const EXPLAIN_PROP = {
   type: "EXPLAIN",
   sign: "subjective",
   topicNo: null,
   topicName: "",
-  questions: [],
+  paperStruct: {},
 };
 // 解答题-小题
 const MODEL = {
@@ -16,6 +21,7 @@ const MODEL = {
   h: 458,
   minHeight: 60,
   sign: "subjective",
+  topicName: "",
   topicNo: null,
   isCovered: false,
   // 是否是小题的最后一个答题区,初始每个小题只有一个答题区,默认为true
@@ -28,29 +34,27 @@ const MODEL = {
   serialNumber: "",
   // 每一个解答题小题都可以包含其他基础元件,这些基础元件都用绝对定位
   elements: [],
-  // 解答题整体信息,EXPLAIN_PROP
-  parent: {},
 };
 // tip属性存在时的条件:parent:大题的小题,container:题目内的子元素
 
 const getModel = (presetData) => {
-  const model = objAssign(EXPLAIN_PROP, presetData);
+  const model = objAssign(deepCopy(EXPLAIN_PROP), presetData);
   model.id = getElementId();
   model.key = randomCode();
 
   return model;
 };
 
-const getFullModel = (explainProp) => {
-  const parent = { ...explainProp };
+const getFullModel = (modelProp) => {
+  const parent = deepCopy(modelProp);
+  const childModel = objAssign(MODEL, parent);
 
   let elements = [];
-  explainProp.questions.forEach((item, index) => {
-    let child = Object.assign({}, MODEL, {
+  const questions = parent.paperStruct.questions || [];
+  questions.forEach((item, index) => {
+    let child = Object.assign({}, childModel, {
       id: getElementId(),
       key: randomCode(),
-      w: parent.w,
-      topicNo: parent.topicNo,
       serialNumber: item,
       showTitle: !index,
       elements: [],

+ 29 - 9
src/modules/card/elements/fill-line/model.js

@@ -1,4 +1,19 @@
-import { getElementId, randomCode, objAssign } from "../../plugins/utils";
+import {
+  getElementId,
+  randomCode,
+  objAssign,
+  deepCopy,
+} from "../../plugins/utils";
+
+const FILL_LINE_PROP = {
+  type: "FILL_LINE",
+  sign: "subjective",
+  topicName: "",
+  topicNo: null,
+  fillCountPerLine: 4,
+  lineSpacing: 40,
+  paperStruct: {},
+};
 
 const MODEL = {
   type: "FILL_LINE",
@@ -15,34 +30,39 @@ const MODEL = {
   questionNo: "1",
   fillCount: 1,
   isCovered: false,
+  isLast: false,
+  isFirst: false,
 };
 
 const getModel = (presetData) => {
-  const model = objAssign(MODEL, presetData);
+  const model = objAssign(deepCopy(FILL_LINE_PROP), presetData);
   model.id = getElementId();
   model.key = randomCode();
   return model;
 };
 
 // questions:[{questionNo,fillCount}]
-const getFullModel = (presetData, questions) => {
-  const parent = getModel(presetData);
+const getFullModel = (modelProp) => {
+  const parent = deepCopy(modelProp);
+  const childModel = objAssign(MODEL, parent);
 
-  const numPerLine = parent.fillCountPerLine;
-  let elements = [];
+  const numPerLine = childModel.fillCountPerLine;
 
+  let elements = [];
+  const questions = parent.paperStruct.questions || [];
   questions.forEach((question, index) => {
     const maxLineNumberPerQuestion = Math.ceil(question.fillCount / numPerLine);
 
-    const questionHeight = parent.lineSpacing * maxLineNumberPerQuestion;
-    let child = Object.assign({}, parent, {
+    const questionHeight = childModel.lineSpacing * maxLineNumberPerQuestion;
+
+    let child = Object.assign({}, childModel, {
       id: getElementId(),
       h: index ? questionHeight : questionHeight + 34,
-      parent: parent,
       isLast: false,
       isFirst: !index,
       questionNo: question.questionNo,
       fillCount: question.fillCount,
+      parent,
     });
     child.minHeight = child.h;
     elements[index] = child;

+ 32 - 12
src/modules/card/elements/fill-question/model.js

@@ -6,6 +6,21 @@ import {
 } from "../../plugins/utils";
 import { BOOLEAN_TYPE, ALPHABET } from "../../enumerate";
 
+const FILL_QUESTION_PROP = {
+  type: "FILL_QUESTION",
+  sign: "objective",
+  topicName: "",
+  topicNo: null,
+  questionCountPerGroup: 5,
+  questionGap: 8,
+  groupGap: 30,
+  optionGap: 12,
+  isBoolean: false, // 是否是判断题
+  booleanType: BOOLEAN_TYPE[0],
+  isMultiply: false, // 是否是多选题
+  paperStruct: {},
+};
+
 const MODEL = {
   type: "FILL_QUESTION",
   x: 0,
@@ -20,12 +35,13 @@ const MODEL = {
   questionGap: 8,
   groupGap: 30,
   optionGap: 12,
-  questions: [], // question: questionNo,optionCount
   questionGroup: [],
   isBoolean: false, // 是否是判断题
   booleanType: BOOLEAN_TYPE[0],
   isMultiply: false, // 是否是多选题
   isCovered: false,
+  isLast: false,
+  isFirst: false,
 };
 
 function getChoiceList(data) {
@@ -37,14 +53,16 @@ function getChoiceList(data) {
 }
 
 const getModel = (presetData) => {
-  const model = objAssign(deepCopy(MODEL), presetData);
+  const model = objAssign(deepCopy(FILL_QUESTION_PROP), presetData);
   model.id = getElementId();
   model.key = randomCode();
   return model;
 };
 
-const getFullModel = (model, { pageSize, columnNumber }) => {
-  const parent = { ...model };
+const getFullModel = (modelProp, { pageSize, columnNumber }) => {
+  const parent = deepCopy(modelProp);
+  const childModel = objAssign(MODEL, parent);
+
   // 不同栏数,不同选项个数,每一行对应的组数
   // 以一行4题,每题4选项为标准展示效果:选项序号占一个选项位置,即一行最多展示20个选项位置。
   // 可扩展其他分栏的最佳展示效果
@@ -57,11 +75,12 @@ const getFullModel = (model, { pageSize, columnNumber }) => {
     },
   };
   const lineMaxOptionCount = lineMaxOptionCountConfig[pageSize][columnNumber];
-  let questionList = model.questions.map((item) => {
+  const questions = parent.paperStruct.questions || [];
+  let questionList = questions.map((item) => {
     const choiceList = getChoiceList({
       ...item,
-      isBoolean: model.isBoolean,
-      booleanType: model.booleanType,
+      isBoolean: parent.isBoolean,
+      booleanType: parent.booleanType,
     });
     return {
       ...item,
@@ -74,7 +93,7 @@ const getFullModel = (model, { pageSize, columnNumber }) => {
     let groupOptionCount = 0;
     let groups = [];
     do {
-      const curGroup = questionList.splice(0, model.questionCountPerGroup);
+      const curGroup = questionList.splice(0, parent.questionCountPerGroup);
       if (curGroup.length) {
         const curGroupMaxOptionCount = Math.max.apply(
           null,
@@ -87,6 +106,7 @@ const getFullModel = (model, { pageSize, columnNumber }) => {
           groupOptionCount += curGroupMaxOptionCount + 1;
           groups.push(curGroup);
         } else {
+          questionList = [...curGroup, ...questionList];
           isEnough = true;
         }
       } else {
@@ -101,21 +121,21 @@ const getFullModel = (model, { pageSize, columnNumber }) => {
 
   while (questionList.length) {
     const questionGroup = getNextGroupQuestions();
-    let child = Object.assign({}, parent, {
+    let child = Object.assign({}, childModel, {
       id: getElementId(),
       key: randomCode(),
-      parent,
       isFirst: !elements.length,
       isLast: false,
       questionGroup,
+      parent,
     });
     const maxOptionCountPerGroup =
       questionGroup.length > 1
-        ? model.questionCountPerGroup
+        ? childModel.questionCountPerGroup
         : questionGroup[0].length;
     const optionsHeight =
       14 * maxOptionCountPerGroup +
-      (maxOptionCountPerGroup - 1) * model.questionGap +
+      (maxOptionCountPerGroup - 1) * childModel.questionGap +
       36;
 
     child.h = elements.length ? optionsHeight : optionsHeight + 34;

+ 31 - 110
src/modules/card/mixins/exchange.js

@@ -23,7 +23,6 @@ export default {
         "FILL_QUESTION",
         "FILL_LINE",
         "EXPLAIN",
-        "COMPOSITION",
       ],
     };
   },
@@ -51,19 +50,15 @@ export default {
           fill_area: [],
           answer_area: [],
         };
-        const elements = [
-          page.globals,
-          ...page.columns.map((column) => column.elements),
-        ];
 
-        elements.forEach((elemGroup) => {
-          elemGroup.forEach((element) => {
+        page.columns.forEach((column) => {
+          column.elements.forEach((element) => {
             if (this.VALID_ELEMENTS_FOR_EXTERNAL.includes(element.type)) {
               const funcName = this.getElementHumpName(element.type);
               console.log(funcName);
               const info = this[`get${funcName}Info`](element);
               Object.entries(info).forEach(([key, vals]) => {
-                exchange[key] = exchange[key].concat(vals);
+                exchange[key] = [...exchange[key], ...vals];
               });
             }
           });
@@ -122,44 +117,10 @@ export default {
       const headArea = this.getOffsetInfo(dom);
       let fill_area = [];
       let barcode = [];
-      // 学生考号
-      if (element.examNumberStyle === "FILL") {
-        // fill_area
-        let listInfos = [];
-        dom
-          .querySelectorAll(".stdno-fill-list")
-          .forEach((questionItem, questionIndex) => {
-            let options = [];
-            questionItem.childNodes.forEach((optionItem, optionIndex) => {
-              options[optionIndex] = this.getOffsetInfo(optionItem);
-            });
-            listInfos[questionIndex] = {
-              main_number: null,
-              sub_number: null,
-              options,
-            };
-          });
 
-        fill_area.push({
-          field: "examNumber",
-          index: this.getFillAreaIndex("examNumber"),
-          single: true,
-          horizontal: false,
-          items: listInfos,
-        });
-      } else {
-        // barcode
-        const stdnoDom =
-          element.columnNumber <= 2
-            ? dom.querySelector(".head-stdno").parentNode
-            : dom.querySelector(".head-stdno");
-        barcode.push({
-          field: "examNumber",
-          area: this.getOffsetInfo(stdnoDom),
-        });
-      }
       // 缺考涂填
-      if (element.examAbsent && !element.isSimple) {
+      // 研究生题卡没有缺考填涂
+      if (element.examAbsent) {
         fill_area.push({
           field: "absent",
           index: this.getFillAreaIndex("absent"),
@@ -178,40 +139,6 @@ export default {
           ],
         });
       }
-      // A/B卷类型
-      if (element.aOrB && !element.isSimple) {
-        if (element.paperType === "PRINT") {
-          // barcode
-          barcode.push({
-            field: "paperType",
-            area: this.getOffsetInfo(
-              document.getElementById("dynamic-aorb-barcode")
-            ),
-          });
-        } else {
-          // fill_area
-          let options = [];
-          document
-            .getElementById("head-dynamic-aorb")
-            .querySelectorAll(".head-dynamic-rect")
-            .forEach((optionItem, optionIndex) => {
-              options[optionIndex] = this.getOffsetInfo(optionItem);
-            });
-          fill_area.push({
-            field: "paperType",
-            index: this.getFillAreaIndex("paperType"),
-            single: true,
-            horizontal: true,
-            items: [
-              {
-                main_number: null,
-                sub_number: null,
-                options,
-              },
-            ],
-          });
-        }
-      }
 
       return {
         info_area: [headArea],
@@ -222,7 +149,7 @@ export default {
     getFillQuestionInfo(element) {
       const dom = this.getPreviewElementById(element.id);
       const single = !element.isMultiply;
-      const horizontal = element.optionDirection === "horizontal";
+      const paperStruct = element.parent.paperStruct;
 
       let fillAreas = [];
       dom.querySelectorAll(".group-item").forEach((groupItem) => {
@@ -236,17 +163,25 @@ export default {
               if (optionIndex)
                 options[optionIndex - 1] = this.getOffsetInfo(optionItem);
             });
-            listInfos[questionIndex] = {
-              main_number: element.topicNo,
+
+            let info = {
+              main_number: paperStruct.detailNo,
               sub_number: questionItem.firstChild.textContent * 1,
               options,
             };
+            if (!paperStruct.isCommon) {
+              info.sub_number = paperStruct.nestedQNo;
+              info.subsub_number = questionItem.firstChild.textContent * 1;
+            }
+            // TODO:结构有变动
+
+            listInfos[questionIndex] = info;
           });
         fillAreas.push({
           field: "question",
           index: this.getFillAreaIndex("question"),
           single,
-          horizontal,
+          horizontal: true,
           items: listInfos,
         });
       });
@@ -257,21 +192,16 @@ export default {
     },
     getFillLineInfo(element) {
       const dom = this.getPreviewElementById(element.id);
-      let sub_numbers = [];
-      for (
-        let i = element.startNumber,
-          len = element.startNumber + element.questionsCount;
-        i < len;
-        i++
-      ) {
-        sub_numbers.push(i);
-      }
+      const paperStruct = element.parent.paperStruct;
+      // TODO:结构有变动
 
       return {
         answer_area: [
           {
-            main_number: element.topicNo,
-            sub_numbers,
+            main_number: paperStruct.detailNo,
+            sub_numbers: paperStruct.isCommon
+              ? [element.questionNo]
+              : [`${paperStruct.nestedQNo}-${element.questionNo}`],
             area: this.getOffsetInfo(dom),
           },
         ],
@@ -279,25 +209,17 @@ export default {
     },
     getExplainInfo(element) {
       const dom = this.getPreviewElementById(element.id);
+      const paperStruct = element.parent.paperStruct;
+      // 多个答题区,会有多个数据
+      // TODO:结构有变动
 
       return {
         answer_area: [
           {
-            main_number: element.topicNo,
-            sub_numbers: [element.serialNumber],
-            area: this.getOffsetInfo(dom),
-          },
-        ],
-      };
-    },
-    getCompositionInfo(element) {
-      const dom = this.getPreviewElementById(element.id);
-
-      return {
-        answer_area: [
-          {
-            main_number: element.topicNo,
-            sub_numbers: [],
+            main_number: paperStruct.detailNo,
+            sub_numbers: paperStruct.isCommon
+              ? [element.serialNumber]
+              : [`${paperStruct.nestedQNo}-${element.serialNumber}`],
             area: this.getOffsetInfo(dom),
           },
         ],
@@ -323,7 +245,7 @@ export default {
 
       return infos.map((num) => num.toFixed(10) * 1);
     },
-    getPageModel({ cardConfig, paperParams, pages }) {
+    getPageModel({ cardConfig, pages }) {
       let npages = this.parsePageExchange(pages);
       npages.forEach((page) => {
         page.exchange.page_size = cardConfig.pageSize;
@@ -332,7 +254,6 @@ export default {
         {
           version: CARD_VERSION,
           cardConfig,
-          paperParams,
           pages: npages,
         },
         (k, v) => (k.startsWith("_") ? undefined : v)

+ 5 - 0
src/modules/portal/views/home/Home.vue

@@ -255,11 +255,16 @@ export default {
   methods: {
     ...mapActions([USER_SIGNOUT, USER_SIGNIN]),
     async onlineSignal() {
+      this.clearSetTs();
+
+      let result = true;
       await this.$httpWithoutBar
         .post(QUESTION_API + "/user/online/signal")
         .catch((error) => {
+          result = false;
           console.log("tag", error);
         });
+      if (!result) return;
 
       this.addSetTime(() => {
         this.onlineSignal();

+ 8 - 0
src/modules/questions/views/EditOtherQuestion.vue

@@ -300,6 +300,14 @@ export default {
       },
     };
   },
+  computed: {
+    saveDisabled() {
+      if (!this.questionId && this.quesModel.quesOptions.length == 0) {
+        return true;
+      }
+      return false;
+    },
+  },
   created() {
     this.paperId = this.$route.params.paperId;
     this.paperDetailId = this.$route.params.paperDetailId;

+ 1 - 1
src/modules/questions/views/EditSelectQuestion.vue

@@ -318,7 +318,7 @@ export default {
       }
       return this.quesModel.quesAnswer;
     },
-    saveDisabled: function () {
+    saveDisabled() {
       if (!this.questionId && this.quesModel.quesOptions.length == 0) {
         return true;
       }