Browse Source

优化生词宽度

natasha 4 days ago
parent
commit
d8bec479f7

+ 26 - 26
src/views/book/courseware/preview/components/new_word/NewWordPreview.vue

@@ -1703,10 +1703,10 @@ export default {
           if (index < 2) {
             this.rowWidth = this.rowWidth > Number(item.value) ? this.rowWidth : Number(item.value);
           } else {
-            this.rowWidth += Number(item.value);
+            this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
           }
         } else {
-          this.rowWidth += Number(item.value);
+          this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
         }
       });
       this.rowWidth += 132;
@@ -1832,7 +1832,27 @@ export default {
           this.$set(this.showObj, item.key, true);
         });
       }
-
+      // 判断每列是否有内容
+      let pinyin_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.pinyin}`, '');
+      let new_word_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.new_word}`, '');
+      let cixing_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.cixing}`, '');
+      let def_str_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.def_str}`, '');
+      let collocation_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.collocation}`, '');
+      let liju_list_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.liju_list}`, '');
+      this.colHasContent = [
+        pinyin_col ? true : false,
+        new_word_col ? true : false,
+        cixing_col ? true : false,
+        def_str_col ? true : false,
+        collocation_col ? true : false,
+        liju_list_col ? true : false,
+      ];
+      if (this.data.addCol) {
+        this.data.addCol.forEach((item) => {
+          let str_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss[item.key]}`, '');
+          this.colHasContent.push(str_col ? true : false);
+        });
+      }
       this.data.col_width.forEach((item, index) => {
         if (
           this.data.property.pinyin_position &&
@@ -1841,10 +1861,10 @@ export default {
           if (index < 2) {
             this.rowWidth = this.rowWidth > Number(item.value) ? this.rowWidth : Number(item.value);
           } else {
-            this.rowWidth += Number(item.value);
+            this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
           }
         } else {
-          this.rowWidth += Number(item.value);
+          this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
         }
       });
       this.rowWidth += 132;
@@ -1912,27 +1932,7 @@ export default {
       });
       this.optionRes = JSON.parse(JSON.stringify(optionRes));
       this.$set(this.data, 'option_list', option_list);
-      // 判断每列是否有内容
-      let pinyin_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.pinyin}`, '');
-      let new_word_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.new_word}`, '');
-      let cixing_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.cixing}`, '');
-      let def_str_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.def_str}`, '');
-      let collocation_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.collocation}`, '');
-      let liju_list_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss.liju_list}`, '');
-      this.colHasContent = [
-        pinyin_col ? true : false,
-        new_word_col ? true : false,
-        cixing_col ? true : false,
-        def_str_col ? true : false,
-        collocation_col ? true : false,
-        liju_list_col ? true : false,
-      ];
-      if (this.data.addCol) {
-        this.data.addCol.forEach((item) => {
-          let str_col = this.data.new_word_list.reduce((acc, itemss) => `${acc + itemss[item.key]}`, '');
-          this.colHasContent.push(str_col ? true : false);
-        });
-      }
+
       if (!this.isJudgingRightWrong) {
         this.answer.answer_list = Bookanswer;
       }