Jelajahi Sumber

入库结果、问答

Rmengdi 3 bulan lalu
induk
melakukan
0e1cb22002

+ 5 - 0
src/api/als/knowledgeExtraction.js

@@ -69,3 +69,8 @@ export const removeExtractInfo = async (id) => {
 export const addER = async (data) => {
   return await post('/als/kGraphEntity', data)
 }
+
+// 获取图谱可视化
+export const getVisually = async (data) => {
+  return await post('/kgqa/ossId/show', data)
+}

+ 31 - 31
src/views/als/intelligentQA/index.vue

@@ -193,37 +193,37 @@ export default {
           answer: '正在解析您的问题,请稍后......'
         })
         this.questionInput = ''
-        // const { code, data } = await handlerAsk(sendInput)
-        const { code, data } = {
-          code: 200,
-          msg: '',
-          data: {
-            user_id: 'user',
-            answer: '解决办法为:更换电池或遥控器',
-            file_name: '排故手册',
-            ossID: '227701077942149120', //pdf
-            // ossID: '227692224508796928', //word
-            graph: {
-              data: [
-                { name: '202310150010', category: 'HMC' },
-                { name: '电视', category: '成品' },
-                { name: '电视遥控器失灵', category: '故障描述' },
-                { name: '家用电器', category: '系统' },
-                { name: '更换电池或遥控器', category: '维修策略' }
-              ],
-              links: [
-                { source: '202310150010', target: '电视', value: '成品' },
-                { source: '202310150010', target: '电视遥控器失灵', value: '故障描述' },
-                { source: '202310150010', target: '家用电器', value: '系统' },
-                { source: '202310150010', target: '更换电池或遥控器', value: '维修策略' }
-              ]
-            }
-          }
-        }
+        const { code, data } = await handlerAsk(sendInput)
+        // const { code, data } = {
+        //   code: 200,
+        //   msg: '',
+        //   data: {
+        //     user_id: 'user',
+        //     answer: '解决办法为:更换电池或遥控器',
+        //     file_name: '排故手册',
+        //     ossID: '227701077942149120', //pdf
+        //     // ossID: '227692224508796928', //word
+        //     graph: {
+        //       data: [
+        //         { name: '202310150010', category: 'HMC' },
+        //         { name: '电视', category: '成品' },
+        //         { name: '电视遥控器失灵', category: '故障描述' },
+        //         { name: '家用电器', category: '系统' },
+        //         { name: '更换电池或遥控器', category: '维修策略' }
+        //       ],
+        //       links: [
+        //         { source: '202310150010', target: '电视', value: '成品' },
+        //         { source: '202310150010', target: '电视遥控器失灵', value: '故障描述' },
+        //         { source: '202310150010', target: '家用电器', value: '系统' },
+        //         { source: '202310150010', target: '更换电池或遥控器', value: '维修策略' }
+        //       ]
+        //     }
+        //   }
+        // }
 
         if (code == 200) {
-          // const newData = this.handleData(JSON.parse(data))
-          const newData = this.handleData(data)
+          const newData = this.handleData(JSON.parse(data))
+          // const newData = this.handleData(data)
           this.chatInfo.pop()
           this.chatInfo.push(newData)
           // this.getHistoryAll()
@@ -238,8 +238,8 @@ export default {
 
     handleData(data) {
       if (data.graph) {
-        // const graphData = eval('(' + data.graph + ')')
-        // data.graph = graphData
+        const graphData = eval('(' + data.graph + ')')
+        data.graph = graphData
         const categories = []
         data.graph.data.forEach((node) => {
           const flag = categories.find((item) => {

+ 48 - 5
src/views/als/knowledgeExtraction/index.vue

@@ -70,6 +70,7 @@
             :options="clauseOptions"
             :pagination="clauseTableRequest"
           ></LTable>
+          <graphECharts v-if="active === 3" style="margin: 0 auto" :width="1400" :height="500" :graphData="graphData" class="charts"></graphECharts>
           <!-- <LTable ref="extractTable" v-if="active === 2" @selection-change="extractSelection" :defaultFetch="false" :fetch="fetch" :columns="extractColumns" :dataSource="extractTableData" :options="extractOptions" :pagination="extractTableRequest"></LTable> -->
         </div>
 
@@ -146,10 +147,10 @@
 </template>
 
 <script>
-import { getTaskList, addTask, updateTask, removeTask, taskPro, removeClause, updateClause, getClauseList, getExtractList, updateExtractInfo, removeExtractInfo, addER } from '@/api/als/knowledgeExtraction'
+import { getTaskList, addTask, updateTask, removeTask, taskPro, getVisually, removeClause, updateClause, getClauseList, getExtractList, updateExtractInfo, removeExtractInfo, addER } from '@/api/als/knowledgeExtraction'
 import { getAllEntityClass } from '@/api/als/entityManage'
 import { getAllRelationClass } from '@/api/als/ERManage'
-
+import graphECharts from '@/views/als/components/Charts/graph.vue'
 import { getAtlasFile } from '@/api/als/atlasFile'
 import { getOssIdDataAPI } from '@/api/als/algorithm'
 import { deepClone, debounce } from '@/utils/index'
@@ -157,7 +158,7 @@ import { deepClone, debounce } from '@/utils/index'
 
 export default {
   name: 'KnowledgeExtraction',
-  components: {},
+  components: { graphECharts },
   data() {
     // 这里存放数据
     return {
@@ -485,7 +486,8 @@ export default {
         relation: '',
         tailEntity: '',
         tailEntityClass: ''
-      }
+      },
+      graphData: {}
     }
   },
   watch: {
@@ -905,9 +907,10 @@ export default {
           this.twoTitle = '入库中'
           break
         case '6':
-          this.active = 3
           this.twoTitle = '审核'
           this.threeTitle = '已入库'
+          this.getVisuallyAPI(row)
+          this.active = 3
           break
 
         default:
@@ -916,6 +919,46 @@ export default {
       this.detailDialogVisible = true
     },
 
+    async getVisuallyAPI(row) {
+      try {
+        const { code, data } = await getVisually({ ossId: row.ossId })
+        if (code === 200) {
+          // const newData = this.handleData(JSON.parse(data))
+          // console.log('newData', newData)
+          const categories = []
+          data.data.forEach((node) => {
+            const flag = categories.find((item) => {
+              return item.name === node.category
+            })
+            if (!flag) {
+              categories.push({ name: node.category })
+            }
+          })
+          data.categories = categories
+          this.graphData = data
+          console.log('this.graphData', this.graphData)
+        }
+      } catch (error) {}
+    },
+
+    handleData(data) {
+      if (data) {
+        // const newData = eval('(' + data + ')')
+        // data.data = graphData
+        const categories = []
+        data.data.forEach((node) => {
+          const flag = categories.find((item) => {
+            return item.name === node.category
+          })
+          if (!flag) {
+            categories.push({ name: node.category })
+          }
+        })
+        data.categories = categories
+      }
+      return data
+    },
+
     detailHandleClose() {
       this.detailDialogVisible = false
       this.taskForm = {