|
@@ -7,7 +7,7 @@
|
|
|
<v-tab>AI 取数</v-tab>
|
|
|
</v-tabs>
|
|
|
</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
|
|
|
v-for="(item, index) in items"
|
|
@@ -18,9 +18,41 @@
|
|
|
<span class="white--text">{{ item.type === 1 ? 'AI' : 'T' }}</span>
|
|
|
</v-avatar>
|
|
|
<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 }">
|
|
|
- {{ 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>
|
|
@@ -52,6 +84,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import {
|
|
|
+ getAsk
|
|
|
+} from '@/api/dataChart'
|
|
|
export default {
|
|
|
name: 'dataChartEditChat',
|
|
|
data () {
|
|
@@ -60,12 +95,10 @@ export default {
|
|
|
items: [
|
|
|
{
|
|
|
type: 1,
|
|
|
- user: 'AI助手',
|
|
|
content: '您好,我是AI助手,请问有什么可以帮助您的吗?'
|
|
|
},
|
|
|
{
|
|
|
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.'
|
|
|
}
|
|
|
]
|
|
@@ -82,7 +115,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- handleSendMsg () {
|
|
|
+ async handleSendMsg () {
|
|
|
if (!this.question) {
|
|
|
return
|
|
|
}
|
|
@@ -91,9 +124,26 @@ export default {
|
|
|
user: '游客',
|
|
|
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 = ''
|
|
|
+ const { columns, ...obj } = data
|
|
|
+ ask.content = {
|
|
|
+ ...obj,
|
|
|
+ columns: columns.map(e => ({ label: e, prop: e, value: e }))
|
|
|
+ }
|
|
|
this.$nextTick(() => {
|
|
|
- const box = document.querySelector('.chart-content-chat-box')
|
|
|
+ const box = this.$refs.chatBox
|
|
|
box.scrollTop = box.scrollHeight
|
|
|
})
|
|
|
}
|