|
@@ -71,7 +71,7 @@
|
|
{{ item.content.sql }}
|
|
{{ item.content.sql }}
|
|
</div>
|
|
</div>
|
|
<div class="mt-3" v-if="item.content.query_result && item.content.query_result.columns.length">
|
|
<div class="mt-3" v-if="item.content.query_result && item.content.query_result.columns.length">
|
|
- <div>
|
|
|
|
|
|
+ <div class="text-right">
|
|
<v-menu
|
|
<v-menu
|
|
v-model="item.showMenu"
|
|
v-model="item.showMenu"
|
|
:close-on-content-click="false"
|
|
:close-on-content-click="false"
|
|
@@ -85,10 +85,10 @@
|
|
v-bind="attrs"
|
|
v-bind="attrs"
|
|
text
|
|
text
|
|
color="primary"
|
|
color="primary"
|
|
- >我要画图</v-btn>
|
|
|
|
|
|
+ >数据作图</v-btn>
|
|
</template>
|
|
</template>
|
|
<div class="white">
|
|
<div class="white">
|
|
- <v-banner>画图配置</v-banner>
|
|
|
|
|
|
+ <v-banner>作图配置</v-banner>
|
|
<div class="pa-3">
|
|
<div class="pa-3">
|
|
<v-autocomplete
|
|
<v-autocomplete
|
|
v-model="item.model.typeAxis"
|
|
v-model="item.model.typeAxis"
|
|
@@ -119,6 +119,12 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</v-menu>
|
|
</v-menu>
|
|
|
|
+ <v-btn
|
|
|
|
+ text
|
|
|
|
+ color="primary"
|
|
|
|
+ :loading="exportLoading"
|
|
|
|
+ @click="onExport(item.content.query_result)"
|
|
|
|
+ >数据下载</v-btn>
|
|
</div>
|
|
</div>
|
|
<v-card flat outlined height="324">
|
|
<v-card flat outlined height="324">
|
|
<div class="pa-3">
|
|
<div class="pa-3">
|
|
@@ -210,7 +216,7 @@
|
|
<v-icon>mdi-send</v-icon>
|
|
<v-icon>mdi-send</v-icon>
|
|
</v-btn>
|
|
</v-btn>
|
|
</div>
|
|
</div>
|
|
- <div v-if="!react">
|
|
|
|
|
|
+ <!-- <div v-if="!react">
|
|
<v-chip-group
|
|
<v-chip-group
|
|
active-class="primary--text"
|
|
active-class="primary--text"
|
|
column
|
|
column
|
|
@@ -225,7 +231,7 @@
|
|
{{ chip.text }}
|
|
{{ chip.text }}
|
|
</v-chip>
|
|
</v-chip>
|
|
</v-chip-group>
|
|
</v-chip-group>
|
|
- </div>
|
|
|
|
|
|
+ </div> -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -237,6 +243,8 @@ import {
|
|
// getAskThroughReact,
|
|
// getAskThroughReact,
|
|
addFeedback
|
|
addFeedback
|
|
} from '@/api/dataChart'
|
|
} from '@/api/dataChart'
|
|
|
|
+import * as XLSX from 'xlsx'
|
|
|
|
+import { saveAs } from 'file-saver'
|
|
import { mapGetters } from 'vuex'
|
|
import { mapGetters } from 'vuex'
|
|
export default {
|
|
export default {
|
|
name: 'dataChartEditChat',
|
|
name: 'dataChartEditChat',
|
|
@@ -247,11 +255,12 @@ export default {
|
|
},
|
|
},
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
- routingMode: undefined,
|
|
|
|
- chips: [
|
|
|
|
- { text: '聊天模式', value: 'chat_direct' },
|
|
|
|
- { text: '数据库模式', value: 'database_direct' }
|
|
|
|
- ],
|
|
|
|
|
|
+ // routingMode: undefined,
|
|
|
|
+ // chips: [
|
|
|
|
+ // { text: '聊天模式', value: 'chat_direct' },
|
|
|
|
+ // { text: '数据库模式', value: 'database_direct' }
|
|
|
|
+ // ],
|
|
|
|
+ exportLoading: false,
|
|
loading: false,
|
|
loading: false,
|
|
disabled: false,
|
|
disabled: false,
|
|
question: '',
|
|
question: '',
|
|
@@ -303,18 +312,17 @@ export default {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
// 先关闭现有连接
|
|
// 先关闭现有连接
|
|
this.stopSSE()
|
|
this.stopSSE()
|
|
- const query = this.react
|
|
|
|
- ? {
|
|
|
|
- question: encodeURIComponent(ask.question),
|
|
|
|
- user_id: this.userInfo.id,
|
|
|
|
- conversation_id: this.conversationId
|
|
|
|
- }
|
|
|
|
- : {
|
|
|
|
- question: encodeURIComponent(ask.question),
|
|
|
|
- user_id: this.userInfo.id,
|
|
|
|
- routing_mode: this.routingMode,
|
|
|
|
- conversation_id: this.conversationId
|
|
|
|
- }
|
|
|
|
|
|
+ const query = {
|
|
|
|
+ question: encodeURIComponent(ask.question),
|
|
|
|
+ user_id: this.userInfo.id,
|
|
|
|
+ conversation_id: this.conversationId
|
|
|
|
+ }
|
|
|
|
+ // : {
|
|
|
|
+ // question: encodeURIComponent(ask.question),
|
|
|
|
+ // user_id: this.userInfo.id,
|
|
|
|
+ // // routing_mode: this.routingMode,
|
|
|
|
+ // conversation_id: this.conversationId
|
|
|
|
+ // }
|
|
const queryStr = Object.keys(query).reduce((acc, key) => {
|
|
const queryStr = Object.keys(query).reduce((acc, key) => {
|
|
if (query[key] === undefined) {
|
|
if (query[key] === undefined) {
|
|
return acc
|
|
return acc
|
|
@@ -464,26 +472,62 @@ export default {
|
|
this.abortController = null
|
|
this.abortController = null
|
|
}
|
|
}
|
|
this.items.splice(1, this.items.length - 1, ...data.messages.map(e => {
|
|
this.items.splice(1, this.items.length - 1, ...data.messages.map(e => {
|
|
- if (e.role === 'user') {
|
|
|
|
|
|
+ if (e.role === 'assistant' || e.role === 'ai') {
|
|
|
|
+ if (!this.react) {
|
|
|
|
+ e.metadata.response = e.content
|
|
|
|
+ }
|
|
|
|
+
|
|
return {
|
|
return {
|
|
- type: 2,
|
|
|
|
- user: '游客',
|
|
|
|
- content: e.content
|
|
|
|
|
|
+ type: 1,
|
|
|
|
+ content: this.react ? e.content : e.metadata,
|
|
|
|
+ showSnackbar: false,
|
|
|
|
+ dataValidation: false,
|
|
|
|
+ question: e.content, // 记录当前问题
|
|
|
|
+ showMenu: false,
|
|
|
|
+ model: {
|
|
|
|
+ dataAxis: null,
|
|
|
|
+ typeAxis: null
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return {
|
|
return {
|
|
- type: 1,
|
|
|
|
- content: e.metadata,
|
|
|
|
- showSnackbar: false,
|
|
|
|
- dataValidation: false,
|
|
|
|
- question: e.content, // 记录当前问题
|
|
|
|
- showMenu: false,
|
|
|
|
- model: {
|
|
|
|
- dataAxis: null,
|
|
|
|
- typeAxis: null
|
|
|
|
- }
|
|
|
|
|
|
+ type: 2,
|
|
|
|
+ user: '游客',
|
|
|
|
+ content: e.content
|
|
}
|
|
}
|
|
}))
|
|
}))
|
|
|
|
+ },
|
|
|
|
+ onExport ({ columns, rows }) {
|
|
|
|
+ const sheetName = 'Sheet1'
|
|
|
|
+ const fileName = '数据下载'
|
|
|
|
+ this.exportLoading = true
|
|
|
|
+ try {
|
|
|
|
+ // 准备Excel数据
|
|
|
|
+ const excelData = [columns]
|
|
|
|
+
|
|
|
|
+ // 添加数据行
|
|
|
|
+ rows.forEach(item => {
|
|
|
|
+ const row = columns.map(header => item[header])
|
|
|
|
+ excelData.push(row)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // 创建工作簿
|
|
|
|
+ const ws = XLSX.utils.aoa_to_sheet(excelData)
|
|
|
|
+ const wb = XLSX.utils.book_new()
|
|
|
|
+ XLSX.utils.book_append_sheet(wb, ws, sheetName)
|
|
|
|
+
|
|
|
|
+ // 生成Excel文件并下载
|
|
|
|
+ const excelBuffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array' })
|
|
|
|
+ const blob = new Blob([excelBuffer], {
|
|
|
|
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
|
|
+ })
|
|
|
|
+ saveAs(blob, `${fileName}.xlsx`)
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log(error)
|
|
|
|
+ this.$snackbar.error('Excel导出失败')
|
|
|
|
+ } finally {
|
|
|
|
+ this.exportLoading = false
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|