|
@@ -3,16 +3,16 @@ import { ref } from 'vue';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import { NTabs, NTab } from 'naive-ui';
|
|
|
import { useChatStore } from '@/stores/modules/chatStore';
|
|
|
-import { columns } from './config/index.jsx';
|
|
|
import { BaseTable, ChatWelcome, RecodeSquareCardItem, TheSubMenu, TheChatView } from "@/components";
|
|
|
+import { useInfinite, useRecommend, useFetchStream, useScroll } from '@/composables';
|
|
|
import { ChatBaseCard, ChatAnswer } from '@/components/Chat';
|
|
|
import { CustomModal } from "./components";
|
|
|
+import { columns } from './config';
|
|
|
|
|
|
-import { format } from "@/utils/format";
|
|
|
+import { formatToData } from "@/utils/format";
|
|
|
|
|
|
import { waterApi } from '@/api/water';
|
|
|
|
|
|
-import { useInfinite, useRecommend, useFetchStream, useScroll } from '@/composables';
|
|
|
|
|
|
const { recommendList } = useRecommend({type: 1});
|
|
|
const { scrollRef, scrollToTop, scrollToBottom, scrollToBottomIfAtBottom } = useScroll();
|
|
@@ -68,7 +68,7 @@ const resetConfiguration = () => {
|
|
|
/**
|
|
|
* 报警详情
|
|
|
*/
|
|
|
-const handleOpenContent = async ({ id, category }) => {
|
|
|
+const handleOpenContent = async ({ id, category, reason:title }) => {
|
|
|
|
|
|
if ( id == flowParams.warningId ) return;
|
|
|
|
|
@@ -76,14 +76,14 @@ const handleOpenContent = async ({ id, category }) => {
|
|
|
flowParams.warningId = id;
|
|
|
flowParams.feedback = '';
|
|
|
flowParams.simulate = '{}';
|
|
|
+
|
|
|
answerLoading.value = false;
|
|
|
|
|
|
const { data } = await waterApi.getWaringDetails(id);
|
|
|
- // const res = await waterApi.getWaringForecast(id);
|
|
|
|
|
|
+ const answer = JSON.parse(data.answer);
|
|
|
const showVal = JSON.parse(data.showVal);
|
|
|
const { basic, jsData, csData } = showVal;
|
|
|
- const answer = JSON.parse(data.answer);
|
|
|
|
|
|
cancelFetch();
|
|
|
|
|
@@ -93,72 +93,23 @@ const handleOpenContent = async ({ id, category }) => {
|
|
|
const alertList = [];
|
|
|
|
|
|
answer.map(item => {
|
|
|
-
|
|
|
- const answerObjItem = JSON.parse( item );
|
|
|
-
|
|
|
- // TODO: 后面带需求确定后完善
|
|
|
-
|
|
|
- if ( answerObjItem.biz === "DECISION_REPORT" ) {
|
|
|
- reportList.push(answerObjItem.message);
|
|
|
-
|
|
|
- // const answerContent = answer.map(item => {
|
|
|
- // const itemParse = JSON.parse(item);
|
|
|
- // return itemParse.message;
|
|
|
- // }).join("");
|
|
|
-
|
|
|
- // answerResult.value.push({
|
|
|
- // biz: 'DECISION_REPORT',
|
|
|
- // answer: answerContent,
|
|
|
- // loading: false,
|
|
|
- // delayLoading: false
|
|
|
- // })
|
|
|
- }
|
|
|
-
|
|
|
- if( answerObjItem.biz === "DECISION_ALERT" ) {
|
|
|
- alertList.push(item);
|
|
|
- // const [ parseAnswer ] = answer.map(item => {
|
|
|
- // const result = JSON.parse( item );
|
|
|
- // result.message = Object.keys(result.message).map(key => ({ ...result.message[key], isActive: null }));
|
|
|
- // return result;
|
|
|
- // })
|
|
|
-
|
|
|
- // answerResult.value.push({
|
|
|
- // biz: 'DECISION_ALERT',
|
|
|
- // loading: false,
|
|
|
- // delayLoading: false,
|
|
|
- // isAllSelect: false,
|
|
|
- // list: parseAnswer?.message
|
|
|
- // })
|
|
|
- }
|
|
|
-
|
|
|
- if (answerObjItem.biz === "DECISION_SIMULATE") {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // const usefulkeys = ['on', 'off'];
|
|
|
- // const resultObj = {};
|
|
|
-
|
|
|
- // usefulkeys.forEach(key => {
|
|
|
- // const tempArr = data[key];
|
|
|
-
|
|
|
- // resultObj[key] = tempArr.map(item => {
|
|
|
- // return {
|
|
|
- // ...item,
|
|
|
- // label: SIMULATE_ENUM[item.name],
|
|
|
- // inpVal: Array.isArray( item.value ) ? item.value.join() : item.value,
|
|
|
- // errMsg: ''
|
|
|
- // }
|
|
|
- // })
|
|
|
- // })
|
|
|
+ const answerObjItem = JSON.parse(item);
|
|
|
+ switch(answerObjItem.biz) {
|
|
|
+ case "DECISION_REPORT":
|
|
|
+ reportList.push(answerObjItem.message);
|
|
|
+ break
|
|
|
+ case "DECISION_ALERT":
|
|
|
+ alertList.push(JSON.parse(item));
|
|
|
+ break
|
|
|
+ case "DECISION_SIMULATE":
|
|
|
+ // console.log("实际未返回");
|
|
|
}
|
|
|
-
|
|
|
})
|
|
|
|
|
|
if ( reportList.length ) {
|
|
|
- const answerContent = reportList.join("");
|
|
|
answerResult.value.push({
|
|
|
biz: 'DECISION_REPORT',
|
|
|
- answer: answerContent,
|
|
|
+ answer: reportList.join(""),
|
|
|
loading: false,
|
|
|
delayLoading: false
|
|
|
})
|
|
@@ -166,9 +117,8 @@ const handleOpenContent = async ({ id, category }) => {
|
|
|
|
|
|
if ( alertList.length ) {
|
|
|
const [ parseAnswer ] = alertList.map(item => {
|
|
|
- const result = JSON.parse( item );
|
|
|
- result.message = Object.keys(result.message).map(key => ({ ...result.message[key], isActive: null }));
|
|
|
- return result;
|
|
|
+ item.message = Object.keys(item.message).map(key => ({ ...item.message[key], isActive: null }));
|
|
|
+ return item;
|
|
|
})
|
|
|
answerResult.value.push({
|
|
|
biz: 'DECISION_ALERT',
|
|
@@ -179,25 +129,12 @@ const handleOpenContent = async ({ id, category }) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- const textWhiteList = [
|
|
|
- { label: '报警时间', realKey: '报警时间', value: '', isWarning: false },
|
|
|
- { label: '报警值', realKey: '报警值', value: 'mg/L', isWarning: true },
|
|
|
- { label: '管控值', realKey: '管控值', value: 'mg/L', isWarning: false },
|
|
|
- { label: '标准值', realKey: '标准值', value: 'mg/L', isWarning: false },
|
|
|
- { label: '报警级别', realKey: '告警级别', value: '', isWarning: false },
|
|
|
- { label: '报警次数', realKey: '报警次数', value: '', isWarning: false },
|
|
|
- { label: '数据来源', realKey: '数据来源', value: '', isWarning: false },
|
|
|
- { label: '状态', realKey: '状态', value: '', isWarning: false }
|
|
|
- ]
|
|
|
-
|
|
|
- basic['数据来源'] = '在线仪表';
|
|
|
-
|
|
|
- textDataSources.value = format.textSorting(basic, textWhiteList);
|
|
|
+ basic.title = title;
|
|
|
+ textDataSources.value = formatToData(basic, '报警值');
|
|
|
|
|
|
jsTableData.value = [jsData];
|
|
|
csTableData.value = [csData];
|
|
|
|
|
|
- scrollToTop();
|
|
|
}
|
|
|
|
|
|
const onChangeTabs = warningStatus => {
|
|
@@ -221,17 +158,14 @@ const onRegenerate = async () => {
|
|
|
|
|
|
let tempSimulate = null;
|
|
|
|
|
|
- answerLoading.value = answerResult.value[len -1 ].biz !== 'DECISION_TABLE';
|
|
|
+ answerLoading.value = answerResult.value[len - 1 ].biz !== 'DECISION_TABLE';
|
|
|
|
|
|
const feedback = flowParams.feedback
|
|
|
|
|
|
const params = {
|
|
|
body: JSON.stringify({ ...flowParams, feedback: JSON.stringify(feedback) }),
|
|
|
- errorHandler: () => {
|
|
|
-
|
|
|
- },
|
|
|
+ errorHandler: () => {},
|
|
|
successHandler: data => {
|
|
|
-
|
|
|
const item = JSON.parse(data);
|
|
|
|
|
|
answerLoading.value = false;
|
|
@@ -244,7 +178,6 @@ const onRegenerate = async () => {
|
|
|
|
|
|
if (item.biz === 'DECISION_ALERT') {
|
|
|
const list = Object.keys(item.message).map(key => ({ ...item.message[key], isActive: null }));
|
|
|
-
|
|
|
answerResult.value.push({
|
|
|
biz: 'DECISION_ALERT',
|
|
|
loading: true,
|
|
@@ -256,7 +189,6 @@ const onRegenerate = async () => {
|
|
|
|
|
|
if (item.biz === 'DECISION_SIMULATE') {
|
|
|
const lastAnswerItem = answerResult.value[len - 1];
|
|
|
-
|
|
|
if ( lastAnswerItem.biz === 'DECISION_TABLE' ) {
|
|
|
answerResult.value[len - 1] = {
|
|
|
...lastAnswerItem,
|
|
@@ -283,6 +215,7 @@ const onRegenerate = async () => {
|
|
|
await refetch(params);
|
|
|
|
|
|
const answerItem = answerResult.value[answerResult.value.length - 1];
|
|
|
+
|
|
|
if (answerItem?.biz) {
|
|
|
answerItem.loading = false;
|
|
|
answerItem.delayLoading = false;
|
|
@@ -291,6 +224,7 @@ const onRegenerate = async () => {
|
|
|
scrollToBottom()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (tempSimulate) {
|
|
|
answerResult.value.push(tempSimulate);
|
|
|
}
|
|
@@ -514,5 +448,4 @@ const handleWelcomeRecommend = question => {
|
|
|
:current-data="modalData"
|
|
|
@on-submit="handleSendSimulate"
|
|
|
></CustomModal>
|
|
|
-
|
|
|
</template>
|