Skip to content

Commit 8be62f2

Browse files
committed
refactor: update view select
1 parent 895c101 commit 8be62f2

File tree

4 files changed

+133
-29
lines changed

4 files changed

+133
-29
lines changed

frontend/src/views/dashboard/components/sq-view/index.vue

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ defineProps({
88
})
99
1010
import { ref } from 'vue'
11-
1211
const chartRef = ref(null)
1312
const renderChart = () => {
1413
//@ts-expect-error eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -23,6 +22,14 @@ defineExpose({
2322

2423
<template>
2524
<div class="chart-base-container">
25+
<div class="header-bar">
26+
<div class="title">
27+
{{ viewInfo.chart.title }}
28+
</div>
29+
<div class="buttons-bar">
30+
<div class="chart-select-container"></div>
31+
</div>
32+
</div>
2633
<div style="height: 100%; width: 100%">
2734
<ChartComponent
2835
v-if="viewInfo.id"
@@ -43,5 +50,120 @@ defineExpose({
4350
.chart-base-container {
4451
width: 100%;
4552
height: 100%;
53+
background: #fff;
54+
.header-bar {
55+
height: 32px;
56+
display: flex;
57+
58+
align-items: center;
59+
flex-direction: row;
60+
61+
.tool-btn {
62+
width: 24px;
63+
height: 24px;
64+
65+
font-size: 16px;
66+
font-weight: 400;
67+
line-height: 24px;
68+
border-radius: 6px;
69+
color: rgba(100, 106, 115, 1);
70+
71+
.tool-btn-inner {
72+
display: flex;
73+
flex-direction: row;
74+
align-items: center;
75+
}
76+
77+
&:hover {
78+
background: rgba(31, 35, 41, 0.1);
79+
}
80+
&:active {
81+
background: rgba(31, 35, 41, 0.1);
82+
}
83+
}
84+
85+
.chart-active {
86+
background: rgba(28, 186, 144, 0.1);
87+
color: rgba(28, 186, 144, 1);
88+
border-radius: 6px;
89+
90+
:deep(.ed-select__wrapper) {
91+
background: transparent;
92+
}
93+
:deep(.ed-select__input) {
94+
color: rgba(28, 186, 144, 1);
95+
}
96+
:deep(.ed-select__placeholder) {
97+
color: rgba(28, 186, 144, 1);
98+
}
99+
:deep(.ed-select__caret) {
100+
color: rgba(28, 186, 144, 1);
101+
}
102+
}
103+
104+
.title {
105+
flex: 1;
106+
white-space: nowrap;
107+
overflow: hidden;
108+
text-overflow: ellipsis;
109+
110+
color: rgba(31, 35, 41, 1);
111+
font-weight: 500;
112+
font-size: 16px;
113+
line-height: 24px;
114+
}
115+
116+
.buttons-bar {
117+
display: flex;
118+
flex-direction: row;
119+
align-items: center;
120+
121+
gap: 16px;
122+
123+
.divider {
124+
width: 1px;
125+
height: 16px;
126+
border-left: 1px solid rgba(31, 35, 41, 0.15);
127+
}
128+
}
129+
130+
.chart-select-container {
131+
padding: 3px;
132+
display: flex;
133+
flex-direction: row;
134+
gap: 4px;
135+
border-radius: 6px;
136+
137+
border: 1px solid rgba(217, 220, 223, 1);
138+
139+
.chart-select {
140+
min-width: 40px;
141+
width: 40px;
142+
height: 24px;
143+
144+
:deep(.ed-select__wrapper) {
145+
padding: 4px;
146+
min-height: 24px;
147+
box-shadow: unset;
148+
border-radius: 6px;
149+
150+
&:hover {
151+
background: rgba(31, 35, 41, 0.1);
152+
}
153+
&:active {
154+
background: rgba(31, 35, 41, 0.1);
155+
}
156+
}
157+
:deep(.ed-select__caret) {
158+
font-size: 12px !important;
159+
}
160+
}
161+
}
162+
}
163+
}
164+
165+
.chart-show-area {
166+
width: 100%;
167+
height: calc(100% - 32px);
46168
}
47169
</style>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ const curSelectChange = (value: boolean) => {
3131

3232
<style scoped lang="less">
3333
.chart-selection-container {
34-
width: 33%;
35-
height: 250px;
34+
width: 50%;
35+
height: 320px;
3636
position: relative;
37-
padding: 15px;
37+
padding: 8px;
3838
float: left;
3939
overflow: hidden;
4040
.select-area {

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
</el-aside>
2525
<el-container :loading="loading">
2626
<el-main v-if="!loading" class="chat-record-list">
27-
<el-scrollbar ref="chatListRef">
27+
<el-scrollbar ref="chatListRef" style="padding: 8px">
2828
<chart-selection
2929
v-for="(viewInfo, index) in chartInfoList"
3030
:key="index"
3131
:view-info="viewInfo"
3232
:select-change="(value: boolean) => selectChange(value, viewInfo)"
33-
style="width: 33%"
3433
>
3534
</chart-selection>
3635
</el-scrollbar>
@@ -100,11 +99,8 @@ function adaptorChartInfoList(chatInfo: ChatInfo) {
10099
chartInfoList.value = []
101100
if (chatInfo && chatInfo.records) {
102101
chatInfo.records.forEach((record: any) => {
103-
const recordeInfo = { id: chatInfo.id + '_' + record.id, data: null, chart: {} }
104-
if (record?.data) {
105-
recordeInfo['data'] = JSON.parse(record.data)
106-
}
107-
if (record?.chart) {
102+
if (record?.chart && record.data) {
103+
const recordeInfo = { id: chatInfo.id + '_' + record.id, data: record.data, chart: {} }
108104
const chartBaseInfo = JSON.parse(record.chart)
109105
recordeInfo['chart'] = {
110106
type: chartBaseInfo.type,
@@ -114,8 +110,8 @@ function adaptorChartInfoList(chatInfo: ChatInfo) {
114110
yAxis: chartBaseInfo.axis?.y ? [chartBaseInfo.axis.y] : [],
115111
series: chartBaseInfo.axis?.series ? [chartBaseInfo.axis.series] : [],
116112
}
113+
chartInfoList.value.push(recordeInfo)
117114
}
118-
chartInfoList.value.push(recordeInfo)
119115
})
120116
}
121117
}

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,35 @@ function onClickHistory(chat: Chat) {
2424
emits('chatSelected', chat)
2525
}
2626
27-
// 获取当前日期和本周的开始日期
2827
const now = new Date()
2928
const startOfWeek = new Date(now)
3029
startOfWeek.setDate(now.getDate() - now.getDay() + (now.getDay() === 0 ? -6 : 1)) // 设置为本周一
3130
startOfWeek.setHours(0, 0, 0, 0)
3231
33-
// 格式化日期函数
34-
const formatDate = (dateString: string) => {
35-
const date = new Date(dateString)
36-
return date.toLocaleString()
37-
}
38-
39-
// 过滤和分类数据
4032
const filteredAndGroupedData = computed(() => {
4133
const today: Chat[] = []
4234
const thisWeek: Chat[] = []
4335
const earlier: Chat[] = []
4436
45-
// 先过滤数据
4637
const filteredList = props.chatList.filter(
4738
(chat) =>
4839
!filterText.value ||
4940
(chat.brief && chat.brief.toLowerCase().includes(filterText.value.toLowerCase()))
5041
)
5142
52-
// 然后分类
5343
filteredList.forEach((item) => {
44+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
5445
const itemDate = new Date(item.create_time)
5546
56-
// 检查是否是今天
5747
if (
5848
itemDate.getDate() === now.getDate() &&
5949
itemDate.getMonth() === now.getMonth() &&
6050
itemDate.getFullYear() === now.getFullYear()
6151
) {
6252
today.push(item)
63-
}
64-
// 检查是否是本周但不是今天
65-
else if (itemDate >= startOfWeek && itemDate < now) {
53+
} else if (itemDate >= startOfWeek && itemDate < now) {
6654
thisWeek.push(item)
67-
}
68-
// 更早的数据
69-
else {
55+
} else {
7056
earlier.push(item)
7157
}
7258
})

0 commit comments

Comments
 (0)