Explorar o código

生词关联课件id

natasha hai 1 día
pai
achega
e60d38811d

+ 60 - 1
src/views/book/courseware/create/components/question/new_word/NewWord.vue

@@ -10,6 +10,16 @@
           toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
         />
       </div>
+      <div style="margin-bottom: 12px">
+        <label>跨页关联课文所在内容节点:</label>
+        <el-cascader
+          v-model="data.source_courseware_id_list"
+          :options="node_list"
+          :show-all-levels="false"
+          @change="handleChange"
+        >
+        </el-cascader>
+      </div>
       <el-table :data="data.new_word_list" border style="width: 100%">
         <el-table-column fixed prop="number" label="序号" width="70">
           <template slot-scope="scope">
@@ -157,7 +167,7 @@ import { getNewWordData, getOption } from '@/views/book/courseware/data/newWord'
 import SelectUpload from '@/views/book/courseware/create/components/common/SelectUpload.vue';
 import { GetStaticResources } from '@/api/app';
 import cnchar from 'cnchar';
-
+import { ChapterGetBookChapterStruct } from '@/api/book';
 export default {
   name: 'NewWordPage',
   components: {
@@ -170,6 +180,7 @@ export default {
   data() {
     return {
       data: getNewWordData(),
+      node_list: [],
     };
   },
   watch: {
@@ -340,6 +351,54 @@ export default {
       });
       this.data.mind_map.node_list = node_list;
     },
+    /**
+     * 得到教材章节结构展开列表
+     */
+    getBookChapterStructExpandList() {
+      ChapterGetBookChapterStruct({
+        book_id: this.$route.query.project_id,
+        node_deep_mode: 0,
+        is_contain_producer: 'false',
+        is_contain_auditor: 'false',
+      }).then(({ nodes }) => {
+        this.node_list = nodes;
+        nodes.forEach((item) => {
+          item.label = item.name;
+          item.pid = '';
+          item.nodexIndex = 0;
+          item.isLeaf = item.is_leaf === 'true';
+          item.value = item.id;
+          if (item.nodes) {
+            item.children = item.nodes;
+            item.lists = item.nodes;
+            this.handleData(item, 1);
+          }
+        });
+      });
+    },
+    // 递归
+    handleData(data, nodeIndex) {
+      if (data.nodes) {
+        data.nodes.forEach((item) => {
+          item.label = item.name;
+          item.pid = data.id;
+          item.nodexIndex = nodeIndex;
+          item.isLeaf = item.is_leaf === 'true';
+          item.value = item.id;
+          if (item.nodes) {
+            item.children = item.nodes;
+            item.lists = item.nodes;
+            this.handleData(item, nodeIndex + 1);
+          }
+        });
+      }
+    },
+    handleChange(val) {
+      this.data.source_courseware_id = val[val.length - 1];
+    },
+  },
+  created() {
+    this.getBookChapterStructExpandList();
   },
 };
 </script>

+ 2 - 0
src/views/book/courseware/data/newWord.js

@@ -76,6 +76,8 @@ export function getNewWordData() {
   return {
     type: 'new_word',
     title: '生词组件',
+    source_courseware_id_list:[],
+    source_courseware_id:'', // 生词关联课件id,即跨页高亮生词
     property: getNewWordProperty(),
     title_con: '',
     new_word_list: [getOption()],