index.vue
8.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<template>
<view class="home-page">
<!-- 用户信息栏 -->
<view class="user-info-bar">
<view class="user-info">
<image class="avatar" src="../../static/imgs/default-avatar.png" mode="widthFix"></image>
<view class="user-text">
<view class="username">林晓明</view>
<view class="login-time">上次登录1天前</view>
</view>
</view>
<view class="msg-icon">
<u-icon name="message" color="#fff" size="32rpx" />
<view class="msg-badge">5</view>
</view>
</view>
<!-- 任务完成情况卡片 -->
<view class="task-card">
<view class="card-title">任务完成情况</view>
<view class="card-header">
<view class="unit">单位: 个</view>
<!-- ✅ 核心修改:日期范围改为可点击的选择器 -->
<view class="date-range" @click="openDatePicker">
<!-- {{ dateText }}-->
<neo-datetime-pro
v-model="dateRange"
type="daterange"
placeholder="请选择日期范围"
/>
</view>
</view>
<!-- 折线图 -->
<view class="chart-wrap">
<!-- <u-line-chart-->
<!-- :chart-data="chartData"-->
<!-- :x-axis="xAxis"-->
<!-- :y-axis="yAxis"-->
<!-- :legend="legend"-->
<!-- height="300rpx"-->
<!-- ></u-line-chart>-->
</view>
</view>
<!-- 待办/已办切换栏 -->
<view class="tab-bar">
<view
class="tab-item"
:class="{ active: currentTab === 'todo' }"
@click="currentTab = 'todo'"
>
待办事项(5)
<view class="tab-active-line" v-if="currentTab === 'todo'"></view>
</view>
<view
class="tab-item"
:class="{ active: currentTab === 'done' }"
@click="currentTab = 'done'"
>
已办事项(89)
<view class="tab-active-line" v-if="currentTab === 'done'"></view>
</view>
</view>
<!-- 事项列表 -->
<view class="task-list">
<view class="task-item" v-for="(item, index) in currentTaskList" :key="index">
<view class="task-name">事项名称: {{ item.name }}{{ item.name }}{{ item.name }}{{ item.name }}{{ item.name }}{{ item.name }}</view>
<view class="task-desc">
<view>紧急程度: {{ item.urgency }}</view>
<view class="task-time">{{ item.time }}</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive, watch } from 'vue';
// 折线图数据
const chartData = reactive([
{
name: '已完成任务数',
data: [5, 35, 55, 40, 65, 50, 70],
color: '#4CAF50'
},
{
name: '待完成总任务数',
data: [5, 70, 75, 70, 75, 75, 90],
color: '#E53935'
}
]);
const xAxis = reactive(['12.28', '12.29', '12.30', '12.31', '01.01', '01.02', '01.03']);
const yAxis = reactive([0, 25, 50, 75, 100]);
const legend = reactive(['已完成任务数', '待完成总任务数']);
// 标签切换
const currentTab = ref('todo');
const dateRange=ref( [])
// ✅ 核心新增:时间选择器相关数据
const showDatePicker = ref(false);
// 默认显示的时间文本
const dateText = ref('2025/12/28—2026/01/04');
// 选中的开始/结束时间
const selectStartDate = ref('');
const selectEndDate = ref('');
// 打开时间选择器
const openDatePicker = () => {
showDatePicker.value = true;
};
// 确认选择时间
const confirmDate = (e) => {
// 格式化选中的时间
selectStartDate.value = formatDate(e.value[0]);
selectEndDate.value = formatDate(e.value[1]);
dateText.value = `${selectStartDate.value}—${selectEndDate.value}`;
showDatePicker.value = false;
// 这里可以加:时间改变后重新请求图表数据的逻辑
// getChartData(selectStartDate.value, selectEndDate.value)
};
// 时间格式化函数:YYYY/MM/DD 格式
const formatDate = (dateVal) => {
const year = dateVal.getFullYear();
const month = (dateVal.getMonth() + 1).toString().padStart(2, '0');
const day = dateVal.getDate().toString().padStart(2, '0');
return `${year}/${month}/${day}`;
};
// 待办事项数据
const todoList = reactive([
{
name: '绿地卫生验收',
urgency: '特急',
time: '2025-12-31 15:45:23'
},
{
name: '阜成门内大街年度计划巡检',
urgency: '--',
time: '2025-12-31 09:02:00'
},
{
name: '金融街年度计划巡检',
urgency: '--',
time: '2025-12-31 09:02:00'
},
{
name: '金融街年度计划巡检',
urgency: '--',
time: '2025-12-31 09:02:00'
},
{
name: '示例事项',
urgency: '一般',
time: '2026-01-04 10:00:00'
}
]);
// 已办事项数据(示例)
const doneList = reactive([
{
name: '道路清洁验收',
urgency: '普通',
time: '2025-12-30 14:20:00'
}
]);
// 当前显示的事项列表
const currentTaskList = ref(todoList);
// 监听标签切换
watch(currentTab, (newVal) => {
currentTaskList.value = newVal === 'todo' ? todoList : doneList;
});
</script>
<style scoped lang="scss">
.home-page {
background-color: #f5f7fa;
min-height: 100vh;
}
/* 用户信息栏 */
.user-info-bar {
background-color: #1677ff;
padding: 180rpx 30rpx 120rpx;
display: flex;
justify-content: space-between;
align-items: center;
color: #fff;
z-index: 1;
position: relative;
.user-info {
display: flex;
align-items: center;
.avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
margin-right: 20rpx;
}
.username {
font-size: 32rpx;
font-weight: 500;
}
.login-time {
font-size: 24rpx;
opacity: 0.8;
}
}
.msg-icon {
position: relative;
.msg-badge {
position: absolute;
top: -10rpx;
right: -10rpx;
background-color: #ff3d00;
color: #fff;
font-size: 20rpx;
width: 28rpx;
height: 28rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
}
}
/* 任务完成情况卡片 */
.task-card {
background-color: #fff;
margin: 0 30rpx;
margin-top: -60rpx;
border-radius: 16rpx 16rpx 0 0;
padding: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
position: relative;
z-index: 2;
.card-title {
font-size: 30rpx;
font-weight: 600;
margin-bottom: 15rpx;
}
.card-header {
display: flex;
justify-content: space-between;
font-size: 24rpx;
color: #999;
margin-bottom: 10rpx;
align-items: center;
}
// ✅ 日期选择器样式
.date-range {
display: flex;
align-items: center;
gap: 6rpx;
padding: 4rpx 8rpx;
border-radius: 6rpx;
&:active {
background-color: #f5f5f5;
}
}
.date-icon {
margin-top: 2rpx;
}
.chart-wrap {
width: 100%;
height: 300rpx;
}
}
/* 待办/已办切换栏 */
.tab-bar {
display: flex;
background-color: #fff;
margin: 0 30rpx;
border-radius: 0;
overflow: hidden;
.tab-item {
flex: 1;
text-align: center;
padding: 20rpx 0;
font-size: 28rpx;
color: #666;
position: relative;
&.active {
color: #1677ff;
font-weight: 500;
}
.tab-active-line {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 4rpx;
background-color: #1677ff;
}
}
}
/* 事项列表 */
.task-list {
background-color: #fff;
margin: 0 30rpx ;
border-radius: 0 0 16rpx 16rpx;
padding: 10rpx 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
.task-item {
padding: 20rpx 0;
border-bottom: 1px solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.task-name {
font-size: 28rpx;
color: #333;
margin-bottom: 10rpx;
// ✅ 修复超长文字溢出:单行显示+超出省略
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.task-desc {
display: flex;
justify-content: space-between;
font-size: 24rpx;
color: #666;
.task-time {
color: #999;
}
}
}
}
</style>