zhengnaiwen_citu 1 month ago
parent
commit
31cb4fea5b

+ 7 - 0
src/api/dataChart.js

@@ -0,0 +1,7 @@
+
+import http from '@/utils/request'
+
+// vanna 问答
+export function getAsk (data) {
+  return http.post('/v0/ask', data)
+}

+ 48 - 0
src/router/routes.js

@@ -2377,6 +2377,54 @@ export default {
       alwaysShow: 0,
       alwaysShow: 0,
       metastr: '{"allowClick":false,"enName":"data book","title":"数据目录","target":false}',
       metastr: '{"allowClick":false,"enName":"data book","title":"数据目录","target":false}',
       open: null
       open: null
+    },
+    {
+      hidden: 0,
+      rootId: 0,
+      icon: 'mdi-robot-outline',
+      type: 0,
+      path: '/model',
+      children: [
+        {
+          hidden: 1,
+          icon: '',
+          type: 1,
+          title: '模型',
+          path: '/model',
+          children: [],
+          enName: 'model',
+          redirect: '',
+          active: '',
+          label: '模型',
+          sort: 0,
+          component: 'modelManage',
+          meta: {
+            roles: [],
+            enName: 'model',
+            icon: '',
+            title: '模型',
+            fullScreen: false
+          },
+          name: 'index',
+          alwaysShow: 0
+        }
+      ],
+      enName: 'model',
+      redirect: '',
+      active: '',
+      sort: 0,
+      component: 'Layout',
+      meta: {
+        allowClick: false,
+        roles: [],
+        enName: 'model',
+        icon: 'mdi-robot-outline',
+        title: '模型',
+        target: false,
+        effectiveStatus: true
+      },
+      name: 'model',
+      alwaysShow: 0
     }
     }
   ],
   ],
   permission: [
   permission: [

+ 57 - 7
src/views/dataChart/dataChartEditChat.vue

@@ -7,7 +7,7 @@
           <v-tab>AI 取数</v-tab>
           <v-tab>AI 取数</v-tab>
         </v-tabs>
         </v-tabs>
       </div>
       </div>
-      <div class="chart-content-chat-box overflow-y-auto">
+      <div class="chart-content-chat-box overflow-y-auto" ref="chatBox">
         <div class="pa-3">
         <div class="pa-3">
           <div
           <div
             v-for="(item, index) in items"
             v-for="(item, index) in items"
@@ -18,9 +18,41 @@
               <span class="white--text">{{ item.type === 1 ? 'AI' : 'T' }}</span>
               <span class="white--text">{{ item.type === 1 ? 'AI' : 'T' }}</span>
             </v-avatar>
             </v-avatar>
             <div :class="[item.type === 1 ? 'ml-3' : 'mr-3 box-length-70']">
             <div :class="[item.type === 1 ? 'ml-3' : 'mr-3 box-length-70']">
-              <div :class="`text-${item.type === 1 ? 'left' : 'right'}`">{{ item.user }}</div>
+              <div :class="`text-${item.type === 1 ? 'left' : 'right'}`">{{ item.type === 1 ? 'AI助手' : '游客' }}</div>
               <div class="mt-2" :class="{ 'indigo lighten-5 pa-3 rounded': item.type !== 1 }">
               <div class="mt-2" :class="{ 'indigo lighten-5 pa-3 rounded': item.type !== 1 }">
-                {{ item.content }}
+                <template v-if="typeof item.content === 'string'">
+                  {{ item.content }}
+                </template>
+                <template v-else-if="Object.keys(item.content).length === 0">
+                  <div>
+                    正在思考中...
+                  </div>
+                </template>
+                <template v-else>
+                  <div>
+                    {{ item.content.sql }}
+                  </div>
+                  <div class="mt-3">
+                    <!-- <m-table
+                      clearHeader
+                      size="small"
+                      shadow="never"
+                      :headers="item.content.columns"
+                      :items="item.content.rows"
+                    ></m-table>
+                    <el-popover
+                      placement="bottom"
+                      width="200"
+                      trigger="click"
+                    >
+                      <m-form :ref="`form${i}`" label-width="60px" :items="formItems(item.content.columns)" v-model="item.model"></m-form>
+                      <div style="text-align: right; margin: 0">
+                        <m-button type="primary" size="mini" @click="onRender($refs[`form${i}`], item)">生成图表</m-button>
+                      </div>
+                      <m-button type="primary" text slot="reference">我要作图</m-button>
+                    </el-popover> -->
+                  </div>
+                </template>
               </div>
               </div>
             </div>
             </div>
           </div>
           </div>
@@ -52,6 +84,9 @@
 </template>
 </template>
 
 
 <script>
 <script>
+import {
+  getAsk
+} from '@/api/dataChart'
 export default {
 export default {
   name: 'dataChartEditChat',
   name: 'dataChartEditChat',
   data () {
   data () {
@@ -60,12 +95,10 @@ export default {
       items: [
       items: [
         {
         {
           type: 1,
           type: 1,
-          user: 'AI助手',
           content: '您好,我是AI助手,请问有什么可以帮助您的吗?'
           content: '您好,我是AI助手,请问有什么可以帮助您的吗?'
         },
         },
         {
         {
           type: 2,
           type: 2,
-          user: '游客',
           content: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed deserunt explicabo corrupti iure nesciunt autem quaerat unde, fugit, ipsa magni consequatur beatae vero ea culpa nisi aliquid aliquam consectetur aut.'
           content: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed deserunt explicabo corrupti iure nesciunt autem quaerat unde, fugit, ipsa magni consequatur beatae vero ea culpa nisi aliquid aliquam consectetur aut.'
         }
         }
       ]
       ]
@@ -82,7 +115,7 @@ export default {
         }
         }
       }
       }
     },
     },
-    handleSendMsg () {
+    async handleSendMsg () {
       if (!this.question) {
       if (!this.question) {
         return
         return
       }
       }
@@ -91,9 +124,26 @@ export default {
         user: '游客',
         user: '游客',
         content: this.question
         content: this.question
       })
       })
+      const ask = {
+        type: 1,
+        content: {},
+        model: {
+          dataAxis: null,
+          typeAxis: null
+        }
+      }
+      this.items.push(ask)
+      const { data } = await getAsk({
+        question: this.question
+      })
       this.question = ''
       this.question = ''
+      const { columns, ...obj } = data
+      ask.content = {
+        ...obj,
+        columns: columns.map(e => ({ label: e, prop: e, value: e }))
+      }
       this.$nextTick(() => {
       this.$nextTick(() => {
-        const box = document.querySelector('.chart-content-chat-box')
+        const box = this.$refs.chatBox
         box.scrollTop = box.scrollHeight
         box.scrollTop = box.scrollHeight
       })
       })
     }
     }

+ 15 - 0
src/views/modelManage/index.vue

@@ -0,0 +1,15 @@
+<template>
+  <div>
+
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'modelManage'
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>