|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="content">
|
|
|
- <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick" class="fullHeigh">
|
|
|
+ <el-tabs type="border-card" v-model="activeName" class="fullHeigh">
|
|
|
<!-- <el-tab-pane label="数据读取" name="first">
|
|
|
<PrivateChartEditParamsData ref="data" @change="onRender"></PrivateChartEditParamsData>
|
|
|
</el-tab-pane>
|
|
@@ -8,7 +8,7 @@
|
|
|
<PrivateChartEditParamsConfig ref="config" @change="onChangeConfig"></PrivateChartEditParamsConfig>
|
|
|
</el-tab-pane> -->
|
|
|
<el-tab-pane label="AI取数" name="third">
|
|
|
- <div class="box fullHeigh">
|
|
|
+ <div class="box fullHeigh" v-loading="loading">
|
|
|
<div class="box-msg" ref="container">
|
|
|
<div v-for="(item, i) in items" :key="i" :class="{ active: item.type === 1 }" class="box-msg-items d-flex mb-3">
|
|
|
<div class="box-msg-items-header py-3" :class="item.type === 1 ? 'ml-3' : 'mr-3'">
|
|
@@ -20,8 +20,18 @@
|
|
|
</el-image>
|
|
|
</div>
|
|
|
<div class="box-msg-items-item">
|
|
|
- <div class="box-msg-items-item-title">
|
|
|
- {{ item.type === 1 ? '我' : '图表助手' }}
|
|
|
+ <div class="box-msg-items-item-title d-flex align-center">
|
|
|
+ <div class="font-w">{{ item.type === 1 ? '我' : '图表助手' }}</div>
|
|
|
+ <div v-if="item.type === 2 && item.content.sql" class="ml-3">
|
|
|
+ <el-tag
|
|
|
+ @click="item.showSql = !item.showSql"
|
|
|
+ type="info"
|
|
|
+ size="mini"
|
|
|
+ style="cursor: pointer;"
|
|
|
+ >
|
|
|
+ {{ item.showSql ? '隐藏SQL' : '显示SQL' }}
|
|
|
+ </el-tag>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<!-- <div v-if="item.type === 1" class="box-msg-items-item-content">
|
|
|
{{ item.content }}
|
|
@@ -36,17 +46,13 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
- <div>
|
|
|
- {{ item.content.sql }}
|
|
|
+ <div class="py-3">
|
|
|
+ {{ item.content.summary }}
|
|
|
</div>
|
|
|
+ <m-card v-if="item.showSql" shadow="never" :body-style="{ background: '#f5f5f5', color: '#777' }">
|
|
|
+ {{ item.content.sql }}
|
|
|
+ </m-card>
|
|
|
<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"
|
|
@@ -58,6 +64,18 @@
|
|
|
</div>
|
|
|
<m-button type="primary" text slot="reference">我要作图</m-button>
|
|
|
</el-popover>
|
|
|
+ <m-table
|
|
|
+ clearHeader
|
|
|
+ size="small"
|
|
|
+ shadow="never"
|
|
|
+ :headers="item.content.columns"
|
|
|
+ :items="item.content.rows"
|
|
|
+ ></m-table>
|
|
|
+ <div v-if="!item.dataValidation" class="mt-3">
|
|
|
+ 您认为结果是否正确
|
|
|
+ <m-button class="ml-3" size="mini" type="success" icon="mdi mdi-thumb-up" circle @click="onAddTrain(item, true)"></m-button>
|
|
|
+ <m-button size="mini" type="info" icon="mdi mdi-thumb-down" circle @click="onAddTrain(item, true)"></m-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
</div>
|
|
@@ -76,20 +94,16 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-// 数据模块
|
|
|
-// import PrivateChartEditParamsData from './privateChartEditParamsData.vue'
|
|
|
-// import PrivateChartEditParamsConfig from './privateChartEditParamsConfig.vue'
|
|
|
import {
|
|
|
- getAsk
|
|
|
+ getAsk,
|
|
|
+ submitTrainingCorrect,
|
|
|
+ submitTrainingError
|
|
|
} from '@/api/dataOps'
|
|
|
export default {
|
|
|
name: 'privateChartEditParams',
|
|
|
- // components: {
|
|
|
- // PrivateChartEditParamsConfig,
|
|
|
- // PrivateChartEditParamsData
|
|
|
- // },
|
|
|
data () {
|
|
|
return {
|
|
|
+ loading: false,
|
|
|
activeName: 'third',
|
|
|
isAlready: true,
|
|
|
inputTxt: '',
|
|
@@ -125,17 +139,22 @@ export default {
|
|
|
]
|
|
|
},
|
|
|
async onSubmit () {
|
|
|
- if (!this.inputTxt || !this.isAlready) {
|
|
|
+ const content = this.inputTxt
|
|
|
+ if (!content || !this.isAlready) {
|
|
|
return
|
|
|
}
|
|
|
+ this.inputTxt = ''
|
|
|
this.isAlready = false
|
|
|
this.items.push({
|
|
|
type: 1,
|
|
|
- content: this.inputTxt
|
|
|
+ content
|
|
|
})
|
|
|
const ask = {
|
|
|
type: 2,
|
|
|
content: {},
|
|
|
+ question: content,
|
|
|
+ showSql: false,
|
|
|
+ dataValidation: false,
|
|
|
model: {
|
|
|
dataAxis: null,
|
|
|
typeAxis: null
|
|
@@ -144,7 +163,7 @@ export default {
|
|
|
this.items.push(ask)
|
|
|
try {
|
|
|
const { data } = await getAsk({
|
|
|
- question: this.inputTxt
|
|
|
+ question: content
|
|
|
})
|
|
|
const { columns, ...obj } = data
|
|
|
ask.content = {
|
|
@@ -160,7 +179,6 @@ export default {
|
|
|
ask.content = error
|
|
|
// this.$message.error(error)
|
|
|
} finally {
|
|
|
- this.inputTxt = null
|
|
|
this.isAlready = true
|
|
|
}
|
|
|
},
|
|
@@ -177,10 +195,23 @@ export default {
|
|
|
type: typeAxis ? content.rows.map(e => e[typeAxis]) : [],
|
|
|
data: dataAxis ? dataAxis.map(e => content.rows.map(r => r[e])) : []
|
|
|
}
|
|
|
- console.log(111, data)
|
|
|
this.$emit('render', data)
|
|
|
},
|
|
|
- handleClick () {}
|
|
|
+ async onAddTrain (item, bool) {
|
|
|
+ this.loading = true
|
|
|
+ const subApi = bool ? submitTrainingCorrect : submitTrainingError
|
|
|
+ try {
|
|
|
+ await subApi({
|
|
|
+ question: item.question,
|
|
|
+ sql: item.content.sql
|
|
|
+ })
|
|
|
+ item.dataValidation = true
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -193,6 +224,10 @@ export default {
|
|
|
.fullHeigh {
|
|
|
height: 100%;
|
|
|
}
|
|
|
+.font-w {
|
|
|
+ font-weight: bold;
|
|
|
+ color: $theme-color;
|
|
|
+}
|
|
|
.box {
|
|
|
overflow: hidden;
|
|
|
$height: 60px;
|
|
@@ -227,8 +262,7 @@ export default {
|
|
|
flex: 1;
|
|
|
&-title {
|
|
|
font-size: 14px;
|
|
|
- font-weight: bold;
|
|
|
- color: $theme-color;
|
|
|
+ // font-weight: bold;
|
|
|
}
|
|
|
&-content {
|
|
|
font-size: 14px;
|