|
@@ -1,5 +1,13 @@
|
|
<template>
|
|
<template>
|
|
- <div class="chart-content-chat heightFull d-flex flex-column">
|
|
|
|
|
|
+ <div class="chart-content-chat heightFull d-flex flex-column position-relative overflow-hidden">
|
|
|
|
+ <v-btn
|
|
|
|
+ class="history"
|
|
|
|
+ color="indigo lighten-1"
|
|
|
|
+ dark
|
|
|
|
+ @click.stop="drawer = !drawer"
|
|
|
|
+ >
|
|
|
|
+ 最近会话
|
|
|
|
+ </v-btn>
|
|
<div class="chart-content-chat-title mb-3">
|
|
<div class="chart-content-chat-title mb-3">
|
|
<v-tabs>
|
|
<v-tabs>
|
|
<v-tab>AI 取数</v-tab>
|
|
<v-tab>AI 取数</v-tab>
|
|
@@ -222,19 +230,49 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <v-navigation-drawer
|
|
|
|
+ v-model="drawer"
|
|
|
|
+ absolute
|
|
|
|
+ temporary
|
|
|
|
+ right
|
|
|
|
+ width="300"
|
|
|
|
+ overlay-opacity="0"
|
|
|
|
+ >
|
|
|
|
+ <v-list dense>
|
|
|
|
+ <v-list-item-group
|
|
|
|
+ v-model="selected"
|
|
|
|
+ color="primary"
|
|
|
|
+ @change="onSelectConversation"
|
|
|
|
+ >
|
|
|
|
+ <v-list-item
|
|
|
|
+ v-for="(conversation) in conversationList"
|
|
|
|
+ :key="conversation.conversation_id"
|
|
|
|
+ >
|
|
|
|
+ <v-list-item-content>
|
|
|
|
+ <v-list-item-title>{{ conversation.conversation_title }}</v-list-item-title>
|
|
|
|
+ </v-list-item-content>
|
|
|
|
+ </v-list-item>
|
|
|
|
+ </v-list-item-group>
|
|
|
|
+ </v-list>
|
|
|
|
+ </v-navigation-drawer>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import {
|
|
import {
|
|
getAsk,
|
|
getAsk,
|
|
- addFeedback
|
|
|
|
|
|
+ addFeedback,
|
|
|
|
+ getConversations,
|
|
|
|
+ getConversationsById
|
|
} from '@/api/dataChart'
|
|
} from '@/api/dataChart'
|
|
import { mapGetters } from 'vuex'
|
|
import { mapGetters } from 'vuex'
|
|
export default {
|
|
export default {
|
|
name: 'dataChartEditChat',
|
|
name: 'dataChartEditChat',
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
|
|
+ selected: null,
|
|
|
|
+ lastSelected: null,
|
|
|
|
+ drawer: false,
|
|
routingMode: undefined,
|
|
routingMode: undefined,
|
|
chips: [
|
|
chips: [
|
|
{ text: '聊天模式', value: 'chat_direct' },
|
|
{ text: '聊天模式', value: 'chat_direct' },
|
|
@@ -256,13 +294,17 @@ export default {
|
|
}
|
|
}
|
|
],
|
|
],
|
|
abortController: null,
|
|
abortController: null,
|
|
- conversationId: undefined
|
|
|
|
|
|
+ conversationId: undefined,
|
|
|
|
+ conversationList: []
|
|
// trueData: false
|
|
// trueData: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapGetters(['userInfo'])
|
|
...mapGetters(['userInfo'])
|
|
},
|
|
},
|
|
|
|
+ created () {
|
|
|
|
+ this.getConversationList()
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
onNew () {
|
|
onNew () {
|
|
this.abortController.abort('')
|
|
this.abortController.abort('')
|
|
@@ -366,10 +408,53 @@ export default {
|
|
}
|
|
}
|
|
const { typeAxis, dataAxis } = model
|
|
const { typeAxis, dataAxis } = model
|
|
const data = {
|
|
const data = {
|
|
- type: typeAxis ? content.rows.map(e => e[typeAxis]) : [],
|
|
|
|
- data: dataAxis ? dataAxis.map(e => content.rows.map(r => r[e])) : []
|
|
|
|
|
|
+ type: typeAxis ? content.records.rows.map(e => e[typeAxis]) : [],
|
|
|
|
+ data: dataAxis ? dataAxis.map(e => content.records.rows.map(r => r[e])) : []
|
|
}
|
|
}
|
|
this.$emit('render', data)
|
|
this.$emit('render', data)
|
|
|
|
+ },
|
|
|
|
+ async getConversationList () {
|
|
|
|
+ try {
|
|
|
|
+ const { data } = await getConversations({ limit: 5 })
|
|
|
|
+ this.conversationList = data.conversations
|
|
|
|
+ } catch (error) {
|
|
|
|
+ this.$snackbar.error(error)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async onSelectConversation (index) {
|
|
|
|
+ if (!index) {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.selected = this.lastSelected
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.lastSelected = index
|
|
|
|
+ try {
|
|
|
|
+ const { data } = await getConversationsById(this.conversationList[index].conversation_id)
|
|
|
|
+ this.items.splice(1, this.items.length - 1, ...data.messages.map(e => {
|
|
|
|
+ if (e.role === 'user') {
|
|
|
|
+ return {
|
|
|
|
+ type: 2,
|
|
|
|
+ user: '游客',
|
|
|
|
+ content: e.content
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ type: 1,
|
|
|
|
+ content: e.metadata,
|
|
|
|
+ showSnackbar: false,
|
|
|
|
+ dataValidation: false,
|
|
|
|
+ question: e.content, // 记录当前问题
|
|
|
|
+ showMenu: false,
|
|
|
|
+ model: {
|
|
|
|
+ dataAxis: null,
|
|
|
|
+ typeAxis: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }))
|
|
|
|
+ } catch (error) {
|
|
|
|
+ this.$snackbar.error(error)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -446,4 +531,10 @@ export default {
|
|
.element::-webkit-scrollbar {
|
|
.element::-webkit-scrollbar {
|
|
display: none; /* Chrome/Safari/Opera */
|
|
display: none; /* Chrome/Safari/Opera */
|
|
}
|
|
}
|
|
|
|
+.history {
|
|
|
|
+ position: absolute;
|
|
|
|
+ right: 20px;
|
|
|
|
+ top: 20px;
|
|
|
|
+ z-index: 1;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|