|
@@ -1,21 +1,30 @@
|
|
<template>
|
|
<template>
|
|
<div class="intelligentQA">
|
|
<div class="intelligentQA">
|
|
- <div class="aside">历史记录</div>
|
|
|
|
|
|
+ <div class="history">
|
|
|
|
+ <div class="historyTitle">历史记录</div>
|
|
|
|
+ <div class="historyContent">
|
|
|
|
+ <div v-for="item in historyData" :key="item.id" class="historyItem">
|
|
|
|
+ <span style="float: left"> {{ item.question }}</span>
|
|
|
|
+ <i class="el-icon-more historyMore" @click="historyDetail(item.id)"></i>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
<div class="chat">
|
|
<div class="chat">
|
|
<!-- <div class="header">Header</div> -->
|
|
<!-- <div class="header">Header</div> -->
|
|
<div ref="main" class="main">
|
|
<div ref="main" class="main">
|
|
<div class="chatLine">
|
|
<div class="chatLine">
|
|
<div v-for="(item, index) in chatInfo" :key="index">
|
|
<div v-for="(item, index) in chatInfo" :key="index">
|
|
|
|
+ <div class="chatRow chatQ" v-if="item.question">
|
|
|
|
+ <div class="questionContent">{{ item.question }}</div>
|
|
|
|
+ </div>
|
|
<div class="chatRow" v-if="item.answer">
|
|
<div class="chatRow" v-if="item.answer">
|
|
<div class="answerData">
|
|
<div class="answerData">
|
|
<div class="answer">{{ item.answer }}</div>
|
|
<div class="answer">{{ item.answer }}</div>
|
|
<!-- <div class="graph"></div> -->
|
|
<!-- <div class="graph"></div> -->
|
|
<graphECharts v-if="item.graph" :graphData="item.graph" class="charts"></graphECharts>
|
|
<graphECharts v-if="item.graph" :graphData="item.graph" class="charts"></graphECharts>
|
|
|
|
+ <i v-if="item.answer" class="el-icon-more more" @click="handleMore(item)"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div class="chatRow chatQ" v-if="item.question">
|
|
|
|
- <div class="questionContent">{{ item.question }}</div>
|
|
|
|
- </div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -26,12 +35,36 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="statistics">
|
|
|
|
+ <div class="statisticsTitle">统计列表</div>
|
|
|
|
+ </div>
|
|
|
|
+ <el-dialog title="更多" :visible.sync="dialogVisible" width="1300px" :before-close="handleClose">
|
|
|
|
+ <div class="dialogContent">
|
|
|
|
+ <div class="contentLeft">
|
|
|
|
+ <div>
|
|
|
|
+ <div class="moreAnswer">{{ moreData.answer }}</div>
|
|
|
|
+ <graphECharts :graphData="moreData.graph"></graphECharts>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="contentRight">
|
|
|
|
+ <div>
|
|
|
|
+ <div class="source">来源:《{{ moreData.file_name }}{{ moreData.fileName }}》</div>
|
|
|
|
+ <div class="fileContent"></div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <!-- <span slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
|
|
|
+ </span> -->
|
|
|
|
+ </el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import store from '@/store'
|
|
import store from '@/store'
|
|
-import { handlerAsk } from '@/api/als/intelligentQA'
|
|
|
|
|
|
+import { handlerAsk, getQAHistoryList, getQAHistoryDetail } from '@/api/als/intelligentQA'
|
|
import graphECharts from '@/views/als/components/Charts/graph.vue'
|
|
import graphECharts from '@/views/als/components/Charts/graph.vue'
|
|
import axios from 'axios'
|
|
import axios from 'axios'
|
|
|
|
|
|
@@ -40,14 +73,24 @@ export default {
|
|
components: { graphECharts },
|
|
components: { graphECharts },
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ dialogVisible: false,
|
|
chatInfo: [],
|
|
chatInfo: [],
|
|
questionInput: '', //202310150010
|
|
questionInput: '', //202310150010
|
|
currentHeight: 'auto',
|
|
currentHeight: 'auto',
|
|
lastScrollHeight: 0,
|
|
lastScrollHeight: 0,
|
|
- isScrollable: false
|
|
|
|
|
|
+ isScrollable: false,
|
|
|
|
+ moreData: {
|
|
|
|
+ user_id: '',
|
|
|
|
+ answer: '',
|
|
|
|
+ file_name: '',
|
|
|
|
+ ossID: '',
|
|
|
|
+ graph: {}
|
|
|
|
+ },
|
|
|
|
+ historyData: []
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
|
|
+ this.getHistory()
|
|
this.adjustHeight()
|
|
this.adjustHeight()
|
|
},
|
|
},
|
|
watch: {},
|
|
watch: {},
|
|
@@ -69,9 +112,19 @@ export default {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ async getHistory() {
|
|
|
|
+ try {
|
|
|
|
+ const {
|
|
|
|
+ data: { list, total }
|
|
|
|
+ } = await getQAHistoryList()
|
|
|
|
+ this.historyData = list
|
|
|
|
+ // console.log('this.historyData', this.historyData)
|
|
|
|
+ } catch (error) {}
|
|
|
|
+ },
|
|
|
|
+
|
|
handleKeydown(event) {
|
|
handleKeydown(event) {
|
|
if (event.key === 'Enter') {
|
|
if (event.key === 'Enter') {
|
|
- // 检查是否按下了 Ctrl 键
|
|
|
|
if (event.ctrlKey) {
|
|
if (event.ctrlKey) {
|
|
// 按下了 Ctrl+Enter,则插入换行符
|
|
// 按下了 Ctrl+Enter,则插入换行符
|
|
this.questionInput += '\n'
|
|
this.questionInput += '\n'
|
|
@@ -90,10 +143,11 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+
|
|
async sendQuestion() {
|
|
async sendQuestion() {
|
|
const sendInput = {
|
|
const sendInput = {
|
|
question: this.questionInput,
|
|
question: this.questionInput,
|
|
- user_id: String(store.state.user.userInfo.user.userId)
|
|
|
|
|
|
+ userId: String(store.state.user.userInfo.user.userId)
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -105,21 +159,10 @@ export default {
|
|
})
|
|
})
|
|
this.questionInput = ''
|
|
this.questionInput = ''
|
|
const { code, data } = await handlerAsk(sendInput)
|
|
const { code, data } = await handlerAsk(sendInput)
|
|
- if (code == 200) {
|
|
|
|
- let newData = data
|
|
|
|
- const graphData = eval('(' + newData.graph + ')')
|
|
|
|
- newData.graph = graphData
|
|
|
|
- const categories = []
|
|
|
|
- newData.graph.data.forEach((node) => {
|
|
|
|
- const flag = categories.find((item) => {
|
|
|
|
- return item.name === node.category
|
|
|
|
- })
|
|
|
|
- if (!flag) {
|
|
|
|
- categories.push({ name: node.category })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- newData.graph.categories = categories
|
|
|
|
|
|
|
|
|
|
+ if (code == 200) {
|
|
|
|
+ // let newData = JSON.parse(data)
|
|
|
|
+ const newData = this.handleData(JSON.parse(data))
|
|
this.chatInfo.pop()
|
|
this.chatInfo.pop()
|
|
this.chatInfo.push(newData)
|
|
this.chatInfo.push(newData)
|
|
}
|
|
}
|
|
@@ -129,41 +172,68 @@ export default {
|
|
main.scrollTop = main.scrollHeight
|
|
main.scrollTop = main.scrollHeight
|
|
}, 0)
|
|
}, 0)
|
|
} catch (error) {}
|
|
} catch (error) {}
|
|
- // {
|
|
|
|
- // code: 200,
|
|
|
|
- // msg: '',
|
|
|
|
- // data: {
|
|
|
|
- // user_id: 'user',
|
|
|
|
- // answer: '解决办法为:更换电池或遥控器',
|
|
|
|
- // graph: {
|
|
|
|
- // data: [
|
|
|
|
- // { name: '202310150010', category: 'HMC' },
|
|
|
|
- // { name: '电视', category: '成品' },
|
|
|
|
- // { name: '电视遥控器失灵', category: '故障描述' },
|
|
|
|
- // { name: '家用电器', category: '系统' },
|
|
|
|
- // { name: '更换电池或遥控器', category: '维修策略' }
|
|
|
|
- // ],
|
|
|
|
- // links: [
|
|
|
|
- // { source: '202310150010', target: '电视', value: '成品' },
|
|
|
|
- // { source: '202310150010', target: '电视遥控器失灵', value: '故障描述' },
|
|
|
|
- // { source: '202310150010', target: '家用电器', value: '系统' },
|
|
|
|
- // { source: '202310150010', target: '更换电池或遥控器', value: '维修策略' }
|
|
|
|
- // ],
|
|
|
|
- // categories: [{ name: 'HMC' }, { name: '成品' }, { name: '故障描述' }, { name: '维修策略' }, { name: '系统' }]
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ handleData(data) {
|
|
|
|
+ const graphData = eval('(' + data.graph + ')')
|
|
|
|
+ data.graph = graphData
|
|
|
|
+ const categories = []
|
|
|
|
+ data.graph.data.forEach((node) => {
|
|
|
|
+ const flag = categories.find((item) => {
|
|
|
|
+ return item.name === node.category
|
|
|
|
+ })
|
|
|
|
+ if (!flag) {
|
|
|
|
+ categories.push({ name: node.category })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ data.graph.categories = categories
|
|
|
|
+ return data
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ handleMore(data) {
|
|
|
|
+ console.log('data', data)
|
|
|
|
+ this.moreData = data
|
|
|
|
+ this.dialogVisible = true
|
|
|
|
+ },
|
|
|
|
|
|
- // data: [
|
|
|
|
- // { name: '111', category: 'HMC' },
|
|
|
|
- // { name: '更换手机屏幕', category: '维修策略' }
|
|
|
|
- // ],
|
|
|
|
- // links: [{ source: '111', target: '更换手机屏幕', value: '维修策略' }],
|
|
|
|
- // categories: [{ name: 'HMC' }, { name: '维修策略' }]
|
|
|
|
|
|
+ handleClose() {
|
|
|
|
+ this.dialogVisible = false
|
|
},
|
|
},
|
|
- showGraph(graphData) {
|
|
|
|
- const { data, links } = graphData
|
|
|
|
|
|
+
|
|
|
|
+ async historyDetail(id) {
|
|
|
|
+ try {
|
|
|
|
+ const { data } = await getQAHistoryDetail(id)
|
|
|
|
+ const newData = this.handleData(data)
|
|
|
|
+ this.chatInfo = []
|
|
|
|
+ this.chatInfo.push(newData)
|
|
|
|
+ } catch (error) {}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // const { code, data } = {
|
|
|
|
+ // code: 200,
|
|
|
|
+ // msg: '',
|
|
|
|
+ // data: {
|
|
|
|
+ // user_id: 'user',
|
|
|
|
+ // answer: '解决办法为:更换电池或遥控器',
|
|
|
|
+ // file_name: '排故手册',
|
|
|
|
+ // ossID: 2,
|
|
|
|
+ // graph: {
|
|
|
|
+ // data: [
|
|
|
|
+ // { name: '202310150010', category: 'HMC' },
|
|
|
|
+ // { name: '电视', category: '成品' },
|
|
|
|
+ // { name: '电视遥控器失灵', category: '故障描述' },
|
|
|
|
+ // { name: '家用电器', category: '系统' },
|
|
|
|
+ // { name: '更换电池或遥控器', category: '维修策略' }
|
|
|
|
+ // ],
|
|
|
|
+ // links: [
|
|
|
|
+ // { source: '202310150010', target: '电视', value: '成品' },
|
|
|
|
+ // { source: '202310150010', target: '电视遥控器失灵', value: '故障描述' },
|
|
|
|
+ // { source: '202310150010', target: '家用电器', value: '系统' },
|
|
|
|
+ // { source: '202310150010', target: '更换电池或遥控器', value: '维修策略' }
|
|
|
|
+ // ]
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|