瀏覽代碼

搜索内容

zq 3 周之前
父節點
當前提交
c12fe1152a
共有 2 個文件被更改,包括 61 次插入5 次删除
  1. 7 0
      src/api/book.js
  2. 54 5
      src/web_preview/index.vue

+ 7 - 0
src/api/book.js

@@ -359,3 +359,10 @@ export function GetBookKnowledgeGraph(data) {
 export function SaveBookKnowledgeGraph(data) {
   return http.post(`${process.env.VUE_APP_EepServer}?MethodName=book_content_manager-SaveBookKnowledgeGraph`, data);
 }
+/**
+ * @description 搜索教材内容文本
+ * @param {object} data
+ */
+export function SearchBookContentText(data) {
+  return http.post(`${process.env.VUE_APP_EepServer}?MethodName=book_content_manager-SearchBookContentText`, data);
+}

+ 54 - 5
src/web_preview/index.vue

@@ -140,6 +140,34 @@
           </div>
         </aside>
         <div class="content">
+          <div v-if="curToolbarIcon === 'search'" class="resource_box">
+            <h5>{{ drawerTitle }}</h5>
+            <div style="height: 40px"></div>
+            <el-row :gutter="10" style="margin: 5px -5px">
+              <el-col :span="16">
+                <el-input v-model="searchContent" placeholder="请输入文本内容" clearable />
+              </el-col>
+              <el-col :span="4">
+                <el-button type="primary" @click="querySearchList"> 查询 </el-button>
+              </el-col>
+            </el-row>
+            <div>
+              <el-table :data="searchList">
+                <el-table-column v-if="false" prop="text" label="文字">
+                  <template slot-scope="{ $row }">
+                    {{ searchContent }}
+                  </template>
+                </el-table-column>
+                <el-table-column prop="courseware_name" label="课件" />
+                <el-table-column prop="component_type" label="组件" />
+                <el-table-column label="" width="50">
+                  <template #default="{ row }">
+                    <el-link type="primary" @click="handLocation(row, 3)">定位</el-link>
+                  </template>
+                </el-table-column>
+              </el-table>
+            </div>
+          </div>
           <div v-if="['image', 'audio', 'video'].includes(curToolbarIcon)" class="resource_box">
             <h5>{{ drawerTitle }}</h5>
             <div style="height: 40px"></div>
@@ -275,6 +303,7 @@ import {
   AddMyCollect,
   GetMyCollectList,
   DeleteMyCollect,
+  SearchBookContentText,
 } from '@/api/book';
 import { getLocalStore } from '@/utils/auth';
 
@@ -303,6 +332,7 @@ export default {
       // { icon: 'search', title: '搜索', handle: '', param: {} },
       { icon: 'mindmap', title: '思维导图', handle: 'openMindMap', param: {} },
       { icon: 'knowledge', title: '知识图谱', handle: 'openVisNetwork', param: {} },
+      { icon: 'search', title: '搜索', handle: 'getSearch', param: { type: '5' } },
       // { icon: 'totalResources', title: '总资源', handle: '', param: {} },
       { icon: 'collect', title: '收藏', handle: 'getCollect', param: { type: '3' } },
       { icon: 'audio', title: '音频', handle: 'openDrawer', param: { type: '1' } },
@@ -342,6 +372,8 @@ export default {
       content_group_row_list: [],
       remark_list: [],
       remark_list_obj: {}, // 存放以组件为对象的数组
+      searchList: [],
+      searchContent: '',
       visible: false,
       remark_content: '',
       submit_loading: false,
@@ -481,7 +513,7 @@ export default {
         ({ courseware_info }) => {
           this.courseware_info = { ...this.courseware_info, ...courseware_info };
           this.getLangList();
-        },
+        }
       );
     },
     /**
@@ -510,7 +542,7 @@ export default {
       GetLanguageTypeList({ book_id: this.courseware_info.book_id, is_contain_zh: 'true' }).then(
         ({ language_type_list }) => {
           this.langList = language_type_list;
-        },
+        }
       );
     },
 
@@ -574,7 +606,7 @@ export default {
       this.$refs.courserware.handleResult(
         this.$refs.previewMain.scrollTop,
         this.$refs.previewMain.scrollLeft,
-        this.select_node,
+        this.select_node
       );
     },
 
@@ -790,6 +822,11 @@ export default {
     },
 
     handLocation(item, type) {
+      if (type == 3) {
+        var did = item.courseware_id + '#' + item.component_id;
+        this.handleNodeClick(did);
+        return;
+      }
       if (this.$refs.courserware && this.$refs.courserware.handLocation) {
         item.type = type;
         this.$refs.courserware.handLocation(item);
@@ -828,7 +865,7 @@ export default {
           x.coursewareId === note.coursewareId &&
           x.blockId === note.blockId &&
           x.startIndex === note.startIndex &&
-          x.endIndex === note.endIndex,
+          x.endIndex === note.endIndex
       );
       if (old) {
         this.oldRichData = old;
@@ -922,7 +959,7 @@ export default {
           x.coursewareId === collect.coursewareId &&
           x.blockId === collect.blockId &&
           x.startIndex === collect.startIndex &&
-          x.endIndex === collect.endIndex,
+          x.endIndex === collect.endIndex
       );
       if (old) {
         this.$message({
@@ -968,6 +1005,18 @@ export default {
         })
         .catch(() => {});
     },
+    getSearch(params) {
+      if (params && params.type) this.drawerType = Number(params.type);
+    },
+    async querySearchList() {
+      this.searchList = [];
+      if (!this.searchContent) return;
+      await SearchBookContentText({ book_id: this.projectId, text: this.searchContent }).then((res) => {
+        if (res.status === 1) {
+          this.searchList = res.courseware_component_list;
+        }
+      });
+    },
   },
 };
 </script>