|
@@ -1,11 +1,12 @@
|
|
|
<script setup>
|
|
|
-import { ref, unref, computed, onMounted, onUnmounted, nextTick } from 'vue';
|
|
|
+import { ref, unref, computed, onMounted, onUnmounted, h } from 'vue';
|
|
|
import { useMessage, NDatePicker, NTabs, NTab, NRadioGroup, NRadio, NCheckboxGroup, NCheckbox, NDataTable } from 'naive-ui';
|
|
|
import { BaseButton, RecodeCardItem, TheSubMenu, TheChatView, ChatWelcome, SvgIcon } from '@/components';
|
|
|
import { ChatAsk, ChatAnswer } from '@/components/Chat';
|
|
|
import { orderApi } from "@/api/order";
|
|
|
import { chatApi } from '@/api/chat';
|
|
|
-import { formatEchart } from '@/utils/format';
|
|
|
+import { formatEchart, isNumberComprehensive } from '@/utils/format';
|
|
|
+import { ORDER_OPTION_ENUM } from './config/enum';
|
|
|
import { getAreaOptions, getOrderAreaOptions } from './config/echartOptions'
|
|
|
import * as echarts from 'echarts';
|
|
|
import dayjs from 'dayjs';
|
|
@@ -196,16 +197,36 @@ const handleSubmit = async (question, params) => {
|
|
|
const reuslt = Object.entries(data).map(([key, value]) => {
|
|
|
if ( value.length ) {
|
|
|
const [ xAxisData, yAxisData ] = formatEchart(value);
|
|
|
+ const [ item ] = value;
|
|
|
+ const columns = Object.keys(item).map(k => ({
|
|
|
+ title: ORDER_OPTION_ENUM[k],
|
|
|
+ key: k,
|
|
|
+ width: '150px',
|
|
|
+ align: 'center',
|
|
|
+ }))
|
|
|
+ const data = value.map(item => {
|
|
|
+ Object.entries(item).forEach(([k, v]) => {
|
|
|
+ console.log(k, isNumberComprehensive(v));
|
|
|
+ if (isNumberComprehensive(v)) {
|
|
|
+ item[k] = v ? Number(v.toFixed(2)) : 0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return item;
|
|
|
+ })
|
|
|
return {
|
|
|
id: key,
|
|
|
title: titleEnum[key],
|
|
|
xAxisData,
|
|
|
- yAxisData
|
|
|
+ yAxisData,
|
|
|
+ columns,
|
|
|
+ data
|
|
|
}
|
|
|
}
|
|
|
}).filter(Boolean);
|
|
|
|
|
|
option.echartWithTableData = reuslt;
|
|
|
+
|
|
|
+ console.log( option );
|
|
|
}
|
|
|
|
|
|
addChat(option);
|
|
@@ -219,10 +240,6 @@ const handleSubmit = async (question, params) => {
|
|
|
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) {
|
|
@@ -230,7 +247,6 @@ const handleSubmit = async (question, params) => {
|
|
|
// chart = echarts.init(dom, null, { width: 680, height: 300 });
|
|
|
// }
|
|
|
|
|
|
- // chart.resize();
|
|
|
// onRegenerate({ question }), 2 * 1000
|
|
|
}, 2 * 1000);
|
|
|
}
|
|
@@ -365,8 +381,19 @@ onUnmounted(() => {
|
|
|
<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>
|
|
|
+ <NDataTable
|
|
|
+ :max-height="250"
|
|
|
+ bordered
|
|
|
+ :single-line="false"
|
|
|
+ :columns="item.columns"
|
|
|
+ :data="item.data"
|
|
|
+ scroll="{ x: true }"
|
|
|
+ size="small"
|
|
|
+ >
|
|
|
+ <template #empty>
|
|
|
+ <span class="leading-[32px]">暂无数据</span>
|
|
|
+ </template>
|
|
|
+ </NDataTable>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|