Browse Source

文章思维导图数据

natasha 2 days ago
parent
commit
5cbfb810a5

+ 12 - 1
src/views/book/courseware/create/components/question/article/Article.vue

@@ -114,7 +114,9 @@ export default {
       editWordIndex: 0,
     };
   },
-  watch: {},
+  watch: {
+    'data.content': 'handleMindMap',
+  },
   created() {},
   methods: {
     // 解析输入内容
@@ -426,6 +428,15 @@ export default {
     sureNotes(data) {
       this.data.notes_list = data;
     },
+    handleMindMap() {
+      // 思维导图数据
+      let node_list = [];
+      node_list.push({
+        name: this.data.content,
+        id: Math.random().toString(36).substring(2, 12),
+      });
+      this.data.mind_map.node_list = node_list;
+    },
   },
 };
 </script>

+ 16 - 0
src/views/book/courseware/create/components/question/dialogue_article/Article.vue

@@ -377,6 +377,7 @@ export default {
         sentencesEn: [],
       });
       this.textInput = '';
+      this.handleMindMap();
     },
 
     /**
@@ -716,6 +717,21 @@ export default {
     sureNotes(data) {
       this.data.notes_list = data;
     },
+    handleMindMap() {
+      // 思维导图数据
+      let node_list = [];
+      this.data.detail.forEach((item) => {
+        if (item.para) {
+          node_list.push({
+            name: item.para,
+            id: Math.random().toString(36).substring(2, 12),
+          });
+        }
+      });
+      console.log(node_list);
+
+      this.data.mind_map.node_list = node_list;
+    },
   },
 };
 </script>

+ 34 - 2
src/views/book/courseware/create/components/question/table/Table.vue

@@ -70,8 +70,9 @@
               :inline="true"
               toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
               v-if="data.mode === 'normal'"
+              @handleRichTextBlur="handleBlurCon"
             />
-            <el-input v-else v-model="li.content"></el-input>
+            <el-input v-else v-model="li.content" @blur="handleBlurCon"></el-input>
           </div>
         </div>
         <div class="table-node">
@@ -89,7 +90,13 @@
 <script>
 import ModuleMixin from '../../common/ModuleMixin';
 
-import { getTableData, getOption, tableTypeList, fontFamilyList } from '@/views/book/courseware/data/table';
+import {
+  getTableData,
+  getOption,
+  tableTypeList,
+  fontFamilyList,
+  getAnswerOption,
+} from '@/views/book/courseware/data/table';
 
 export default {
   name: 'Table',
@@ -107,10 +114,12 @@ export default {
       handler(val) {
         if (val < this.data.option_list.length) {
           this.data.option_list = this.data.option_list.slice(0, val);
+          this.data.answer_list = this.data.answer_list.slice(0, val);
         } else {
           const diff = val - this.data.option_list.length;
           for (let i = 0; i < diff; i++) {
             this.data.option_list.push(Array.from({ length: this.data.property.column_count }, getOption));
+            this.data.answer_list.push(Array.from({ length: this.data.property.column_count }, getAnswerOption));
           }
         }
       },
@@ -132,6 +141,14 @@ export default {
 
           return row.concat(Array.from({ length: diff }, getOption));
         });
+        this.data.answer_list = this.data.answer_list.map((row) => {
+          if (val < row.length) {
+            return row.slice(0, val);
+          }
+          const diff = val - row.length;
+
+          return row.concat(Array.from({ length: diff }, getAnswerOption));
+        });
       },
     },
   },
@@ -191,6 +208,21 @@ export default {
       return arr;
     },
     // 思维导图数据
+    handleMindMap() {
+      let node_list = [];
+      this.data.option_list.forEach((item) => {
+        item.forEach((items) => {
+          node_list.push({
+            name: items.content.replace(/<[^>]*>?/gm, ''),
+            id: Math.random().toString(36).substring(2, 12),
+          });
+        });
+      });
+      this.data.mind_map.node_list = node_list;
+    },
+    handleBlurCon() {
+      this.handleMindMap();
+    },
   },
 };
 </script>

+ 9 - 1
src/views/book/courseware/data/table.js

@@ -45,7 +45,14 @@ export function getOption() {
   return {
     content: '',
     mark: getRandomNumber(),
-    
+    model_essay:[]
+  };
+}
+
+export function getAnswerOption () {
+  return {
+    answer: '',
+    answer_list:[]
   };
 }
 
@@ -55,6 +62,7 @@ export function getTableData() {
     title: '表格',
     option_list: Array.from({ length: 2 }, () => Array.from({ length: 3 }, getOption)),
     record_list: [],
+    answer_list:Array.from({ length: 2 }, () => Array.from({ length: 3 }, getAnswerOption)),
     mode: tableTypeList[0].value,
     styles: {
       fontFamily: 'Arial',