|
@@ -5,6 +5,7 @@ import { BaseButton, RecodeCardItem, TheSubMenu, TheChatView, ChatWelcome, SvgIc
|
|
import { ChatAsk, ChatAnswer } from '@/components/Chat';
|
|
import { ChatAsk, ChatAnswer } from '@/components/Chat';
|
|
import { orderApi } from "@/api/order";
|
|
import { orderApi } from "@/api/order";
|
|
import { chatApi } from '@/api/chat';
|
|
import { chatApi } from '@/api/chat';
|
|
|
|
+import { formatEchart } from '@/utils/format';
|
|
import { getAreaOptions, getOrderAreaOptions } from './config/echartOptions'
|
|
import { getAreaOptions, getOrderAreaOptions } from './config/echartOptions'
|
|
import * as echarts from 'echarts';
|
|
import * as echarts from 'echarts';
|
|
import dayjs from 'dayjs';
|
|
import dayjs from 'dayjs';
|
|
@@ -31,7 +32,7 @@ for (let i = 0; i < 2; i++) {
|
|
const columns = ref(arr)
|
|
const columns = ref(arr)
|
|
|
|
|
|
const tableData = ref([{ no0: 1, no1: 2 }]);
|
|
const tableData = ref([{ no0: 1, no1: 2 }]);
|
|
-
|
|
|
|
|
|
+const pageDataSource = ref({});
|
|
|
|
|
|
let chart = null;
|
|
let chart = null;
|
|
let controller = new AbortController();
|
|
let controller = new AbortController();
|
|
@@ -167,73 +168,68 @@ const onRegenerate = async ({ question, params1 }) => {
|
|
// 提交问题
|
|
// 提交问题
|
|
const handleSubmit = async (question, params) => {
|
|
const handleSubmit = async (question, params) => {
|
|
|
|
|
|
- // if (unref(isExistInHistory)) {
|
|
|
|
- // const { data: sessionId } = await chatApi.getChatSessionTag();
|
|
|
|
- // currenSessionId.value = sessionId;
|
|
|
|
- // }
|
|
|
|
|
|
+ if (unref(isExistInHistory)) {
|
|
|
|
+ const { data: sessionId } = await chatApi.getChatSessionTag();
|
|
|
|
+ currenSessionId.value = sessionId;
|
|
|
|
+ }
|
|
|
|
|
|
isLoading.value = true;
|
|
isLoading.value = true;
|
|
- let option = {}
|
|
|
|
|
|
+
|
|
|
|
+ const option = {
|
|
|
|
+ sessionId: unref(currenSessionId),
|
|
|
|
+ showVal: question,
|
|
|
|
+ answer: '',
|
|
|
|
+ loading: true,
|
|
|
|
+ delayLoading: true,
|
|
|
|
+ echartWithTableData: []
|
|
|
|
+ }
|
|
|
|
|
|
const isChart = tabActive.value == 'customDaily';
|
|
const isChart = tabActive.value == 'customDaily';
|
|
|
|
|
|
if (isChart) {
|
|
if (isChart) {
|
|
- // const data = await createLineEchart(params);
|
|
|
|
-
|
|
|
|
- function getRandomInt(min, max) {
|
|
|
|
- min = Math.ceil(min);
|
|
|
|
- max = Math.floor(max);
|
|
|
|
- return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
|
|
|
|
+ const { data } = await orderApi.postOrderChart(params);
|
|
|
|
+ const titleEnum = {
|
|
|
|
+ jsGroup: '进水指标',
|
|
|
|
+ csGroup: '出水指标',
|
|
|
|
+ hyGroup: '化验指标'
|
|
}
|
|
}
|
|
- const xAxisData = []
|
|
|
|
- const seriesList = []
|
|
|
|
-
|
|
|
|
- for (let i = 0; i < 30; i++) {
|
|
|
|
- xAxisData.push('06-' + (i + 1));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (let i = 0; i < 2; i++) {
|
|
|
|
- seriesList[i] = [];
|
|
|
|
- for (let j = 0; j < 30; j++) {
|
|
|
|
- seriesList[i].push(getRandomInt(1, 6))
|
|
|
|
|
|
+ const reuslt = Object.entries(data).map(([key, value]) => {
|
|
|
|
+ if ( value.length ) {
|
|
|
|
+ const [ xAxisData, yAxisData ] = formatEchart(value);
|
|
|
|
+ return {
|
|
|
|
+ id: key,
|
|
|
|
+ title: titleEnum[key],
|
|
|
|
+ xAxisData,
|
|
|
|
+ yAxisData
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- option = getOrderAreaOptions({
|
|
|
|
- xAxisData,
|
|
|
|
- seriesList
|
|
|
|
- });
|
|
|
|
|
|
+ }).filter(Boolean);
|
|
|
|
|
|
|
|
+ option.echartWithTableData = reuslt;
|
|
}
|
|
}
|
|
|
|
|
|
- addChat({
|
|
|
|
- sessionId: unref(currenSessionId),
|
|
|
|
- showVal: question,
|
|
|
|
- answer: '',
|
|
|
|
- loading: true,
|
|
|
|
- delayLoading: true,
|
|
|
|
- isChart: true
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- console.log( chatDataSource.value );
|
|
|
|
|
|
+ addChat(option);
|
|
|
|
|
|
scrollToBottom();
|
|
scrollToBottom();
|
|
|
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
- updateChat({
|
|
|
|
- sessionId: unref(currenSessionId),
|
|
|
|
- showVal: question,
|
|
|
|
- answer: '',
|
|
|
|
- loading: true,
|
|
|
|
- delayLoading: false,
|
|
|
|
- isChart: true
|
|
|
|
|
|
+
|
|
|
|
+ option.echartWithTableData.forEach(({ id, xAxisData, yAxisData }) => {
|
|
|
|
+ const dom = document.getElementById(id);
|
|
|
|
+ const chart = echarts.init(dom, null, { width: 680, height: 300 });
|
|
|
|
+ const option = getOrderAreaOptions({ xAxisData, yAxisData });
|
|
|
|
+ chart.setOption(option);
|
|
|
|
+ updateChat({
|
|
|
|
+ ...chatDataSource.value[0],
|
|
|
|
+ delayLoading: false
|
|
|
|
+ })
|
|
})
|
|
})
|
|
- if(!chart) {
|
|
|
|
- const dom = document.getElementById('chartContainer')
|
|
|
|
- console.log( echartRef.value );
|
|
|
|
- chart = echarts.init(dom, {width: 680, height: 300});
|
|
|
|
- }
|
|
|
|
- chart.setOption(option);
|
|
|
|
|
|
+
|
|
|
|
+ // if(!chart) {
|
|
|
|
+ // const dom = document.getElementById('chartContainer')
|
|
|
|
+ // chart = echarts.init(dom, null, { width: 680, height: 300 });
|
|
|
|
+ // }
|
|
|
|
+
|
|
// chart.resize();
|
|
// chart.resize();
|
|
// onRegenerate({ question }), 2 * 1000
|
|
// onRegenerate({ question }), 2 * 1000
|
|
}, 2 * 1000);
|
|
}, 2 * 1000);
|
|
@@ -241,36 +237,37 @@ const handleSubmit = async (question, params) => {
|
|
|
|
|
|
// 处理推荐问题
|
|
// 处理推荐问题
|
|
const handleCreateOrder = async () => {
|
|
const handleCreateOrder = async () => {
|
|
- // const { timeBegin, timeEnd, whichWay, checkGroup } = unref(workOrderParams);
|
|
|
|
- // const startDateTime = dayjs(timeBegin);
|
|
|
|
- // const endDateTime = dayjs(timeEnd);
|
|
|
|
- // const params = {
|
|
|
|
- // timeBegin,
|
|
|
|
- // timeEnd,
|
|
|
|
- // whichWay
|
|
|
|
- // };
|
|
|
|
|
|
+ const { timeBegin, timeEnd, whichWay, checkGroup } = unref(workOrderParams);
|
|
|
|
+ const startDateTime = dayjs(timeBegin);
|
|
|
|
+ const endDateTime = dayjs(timeEnd);
|
|
|
|
+ const params = {
|
|
|
|
+ timeBegin,
|
|
|
|
+ timeEnd,
|
|
|
|
+ whichWay
|
|
|
|
+ };
|
|
|
|
|
|
let question = `请生成${reportDate.value}智慧工单分析报告`;
|
|
let question = `请生成${reportDate.value}智慧工单分析报告`;
|
|
|
|
|
|
if (tabActive.value === 'customDaily') {
|
|
if (tabActive.value === 'customDaily') {
|
|
- // const thirtyDaysBeforeEndTime = endDateTime.subtract(30, 'day');
|
|
|
|
- // const isStartAfterThirtyDaysBeforeEnd = startDateTime.isSameOrAfter(thirtyDaysBeforeEndTime);
|
|
|
|
|
|
+ const thirtyDaysBeforeEndTime = endDateTime.subtract(31, 'day');
|
|
|
|
+ const isStartAfterThirtyDaysBeforeEnd = startDateTime.isAfter(thirtyDaysBeforeEndTime);
|
|
|
|
+
|
|
|
|
+ if (!timeBegin) return message.warning('请选择开始日期');
|
|
|
|
+ if (!timeEnd) return message.warning('请选择结束日期');
|
|
|
|
+ if (!isStartAfterThirtyDaysBeforeEnd) return message.warning('只可生成一个月区间的工单报告');
|
|
|
|
+ if (!checkGroup.length) return message.warning('请至少选择一项指标项');
|
|
|
|
|
|
- // if (!timeBegin) return message.warning('请选择开始日期');
|
|
|
|
- // if (!timeEnd) return message.warning('请选择结束日期');
|
|
|
|
- // if (!isStartAfterThirtyDaysBeforeEnd) return message.warning('只可生成一个月区间的工单报告');
|
|
|
|
- // if (!checkGroup.length) return message.warning('请至少选择一项指标项');
|
|
|
|
|
|
+ checkGroup.forEach(key => params[key] = true);
|
|
|
|
|
|
- // checkGroup.forEach(key => params[key] = true);
|
|
|
|
- // // [checkGroup, csCheckGroup, hyCheckGroup].flat().forEach(key => params[key] = true);
|
|
|
|
|
|
+ question = `请成生${startDateTime.format("MM月DD日")}-${endDateTime.format("MM月DD日")}的在线仪表的日报工单`
|
|
|
|
|
|
- // question = `请成生${startDateTime.format("MM月DD日")}-${endDateTime.format("MM月DD日")}的在线仪表的日报工单`
|
|
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ if (!reportDate.value) return message.warning('请选择时间');
|
|
|
|
|
|
- // } else {
|
|
|
|
- // if (!reportDate.value) return message.warning('请选择时间');
|
|
|
|
}
|
|
}
|
|
- handleSubmit(question)
|
|
|
|
- // handleSubmit(question, params);
|
|
|
|
|
|
+
|
|
|
|
+ handleSubmit(question, params)
|
|
}
|
|
}
|
|
|
|
|
|
// 创建echart
|
|
// 创建echart
|
|
@@ -308,6 +305,12 @@ const dateEndDisabled = (timestamp) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+onMounted(() => {
|
|
|
|
+ // const dom = document.getElementById('chartContainer')
|
|
|
|
+ // console.log( echartRef.value );
|
|
|
|
+ // chart = echarts.init(dom);
|
|
|
|
+})
|
|
|
|
+
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
controller.abort();
|
|
controller.abort();
|
|
})
|
|
})
|
|
@@ -337,11 +340,15 @@ onUnmounted(() => {
|
|
'基于大语言模型的智能工单分析助手,可以为您实现数据分析及数据解读',
|
|
'基于大语言模型的智能工单分析助手,可以为您实现数据分析及数据解读',
|
|
'选择日期并为您生成日报分析'
|
|
'选择日期并为您生成日报分析'
|
|
]" v-if="!chatDataSource.length" />
|
|
]" v-if="!chatDataSource.length" />
|
|
-
|
|
|
|
|
|
+ <!-- :loading="item.loading" :delay-loading="item.delayLoading" -->
|
|
|
|
+ <!-- <ChatAnswer content="11111111111"> -->
|
|
|
|
+ <!-- v-show="item.isChart && !item.delayLoading" -->
|
|
|
|
+
|
|
|
|
+ <!-- </ChatAnswer> -->
|
|
|
|
|
|
|
|
|
|
<div class="conversation-item" v-show="chatDataSource.length">
|
|
<div class="conversation-item" v-show="chatDataSource.length">
|
|
- <div v-for="item in chatDataSource" :key="item.id">
|
|
|
|
|
|
+ <div v-for="item in chatDataSource" :key="item.sessionId">
|
|
<ChatAsk :content="item.showVal" :sessionId="item.sessionId"></ChatAsk>
|
|
<ChatAsk :content="item.showVal" :sessionId="item.sessionId"></ChatAsk>
|
|
<ChatAnswer
|
|
<ChatAnswer
|
|
:id="item.id"
|
|
:id="item.id"
|
|
@@ -350,29 +357,18 @@ onUnmounted(() => {
|
|
:delay-loading="item.delayLoading"
|
|
:delay-loading="item.delayLoading"
|
|
:isSatisfied="item.isSatisfied"
|
|
:isSatisfied="item.isSatisfied"
|
|
@on-click-icon="params => updateById(params)"
|
|
@on-click-icon="params => updateById(params)"
|
|
- v-if="!item.isChart"
|
|
|
|
- ></ChatAnswer>
|
|
|
|
- <ChatAnswer content="11111111111" :loading="item.loading" :delay-loading="item.delayLoading" >
|
|
|
|
- <div v-show="item.isChart && !item.delayLoading">
|
|
|
|
- <div class="echart-warpper" >
|
|
|
|
- <span class="#1A2029 font-bold">进水指标</span>
|
|
|
|
-
|
|
|
|
- <!-- <ul class="flex justify-end w-[600px] text-center text-[12px] text-[#666] leading-[18px] space-x-[10px]">
|
|
|
|
- <li class="">
|
|
|
|
- <span class="inline-block w-[10px] h-[2px] mb-[2px] mr-[4px] bg-[#2185da]"></span>
|
|
|
|
- <span>过去</span>
|
|
|
|
- </li>
|
|
|
|
- <li class="">
|
|
|
|
- <span class="inline-block w-[10px] h-[2px] mb-[2px] mr-[4px] bg-[#2ee055]"></span>
|
|
|
|
- <span>未来</span>
|
|
|
|
- </li>
|
|
|
|
- </ul> -->
|
|
|
|
- <div id="chartContainer" class="w-[680px] h-[300px]" ref="echartRef" style="width: 680px; height: 300px;"></div>
|
|
|
|
- </div>
|
|
|
|
- <div class="w-[700px]">
|
|
|
|
- <NDataTable :bordered="true" :single-line="false" single-column :columns="columns" :data="tableData"
|
|
|
|
- scroll="{ x: true }" size="small"></NDataTable>
|
|
|
|
- </div>
|
|
|
|
|
|
+ >
|
|
|
|
+ <div v-show="!item.delayLoading">
|
|
|
|
+ <div v-for="(item, index) in item.echartWithTableData" :key="index">
|
|
|
|
+ <div class="echart-warpper" >
|
|
|
|
+ <span class="mb-[10px] #1A2029 font-bold">{{ item.title }}</span>
|
|
|
|
+ <div :id="item.id" class="w-[680px] h-[300px]" style="width: 680px; height: 300px;"></div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="w-[700px]">
|
|
|
|
+ <NDataTable :bordered="true" :single-line="false" single-column :columns="columns" :data="tableData"
|
|
|
|
+ scroll="{ x: true }" size="small"></NDataTable>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</ChatAnswer>
|
|
</ChatAnswer>
|
|
</div>
|
|
</div>
|
|
@@ -547,7 +543,7 @@ onUnmounted(() => {
|
|
justify-content: center;
|
|
justify-content: center;
|
|
flex-flow: column;
|
|
flex-flow: column;
|
|
width: 100%;
|
|
width: 100%;
|
|
- padding: 20px 0 30px 0;
|
|
|
|
|
|
+ padding: 20px 0;
|
|
border-radius: 8px;
|
|
border-radius: 8px;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|