Skip to content

Commit 126d20d

Browse files
committed
fix: fix view selection
1 parent ec4e199 commit 126d20d

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

frontend/src/views/dashboard/editor/ChatChartSelection.vue

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import { useI18n } from 'vue-i18n'
6363
import { Chat, chatApi, ChatInfo } from '@/api/chat.ts'
6464
import DashboardChatList from '@/views/dashboard/editor/DashboardChatList.vue'
6565
import ChartSelection from '@/views/dashboard/editor/ChartSelection.vue'
66+
import { concat } from 'lodash-es'
6667
6768
const dialogShow = ref(false)
6869
const { t } = useI18n()
@@ -95,17 +96,55 @@ function selectChange(value: boolean, viewInfo: any) {
9596
}
9697
}
9798
99+
const getData = (record: any) => {
100+
if (record?.predict_record_id !== undefined && record?.predict_record_id !== null) {
101+
let _list = []
102+
if (record?.predict_data && typeof record?.predict_data === 'string') {
103+
if (
104+
record?.predict_data.length > 0 &&
105+
record?.predict_data.trim().startsWith('[') &&
106+
record?.predict_data.trim().endsWith(']')
107+
) {
108+
try {
109+
_list = JSON.parse(record?.predict_data)
110+
} catch (e) {
111+
console.error(e)
112+
}
113+
}
114+
} else {
115+
if (record?.predict_data.length > 0) {
116+
_list = record?.predict_data
117+
}
118+
}
119+
120+
if (_list.length == 0) {
121+
return _list
122+
}
123+
124+
if (record.data && record.data.length > 0) {
125+
return concat(record.data, _list)
126+
}
127+
128+
return _list
129+
} else {
130+
return record.data
131+
}
132+
}
133+
98134
function adaptorChartInfoList(chatInfo: ChatInfo) {
99135
chartInfoList.value = []
100136
if (chatInfo && chatInfo.records) {
101137
chatInfo.records.forEach((record: any) => {
138+
const data = getData(record)
102139
if (
103-
(record?.analysis_record_id === undefined || record?.analysis_record_id === null) &&
104-
(record?.predict_record_id === undefined || record?.predict_record_id === null) &&
105-
record?.chart &&
106-
record.data
140+
((record?.analysis_record_id === undefined || record?.analysis_record_id === null) &&
141+
(record?.predict_record_id === undefined || record?.predict_record_id === null) &&
142+
(record?.sql || record?.chart)) ||
143+
(record?.predict_record_id !== undefined &&
144+
record?.predict_record_id !== null &&
145+
data.length > 0)
107146
) {
108-
const recordeInfo = { id: chatInfo.id + '_' + record.id, data: record.data, chart: {} }
147+
const recordeInfo = { id: chatInfo.id + '_' + record.id, data: data, chart: {} }
109148
const chartBaseInfo = JSON.parse(record.chart)
110149
recordeInfo['chart'] = {
111150
type: chartBaseInfo.type,

0 commit comments

Comments
 (0)