index.vue
6.33 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
<template>
<view class="h-page">
<CustomNavBar :title="t('Store Stats')" />
<PageOptions
ref="pageOptionsRef"
:has-today="true"
@change="handleOptionsChange"
:compStyle="{ backgroundColor: '#fff', borderBottom: '1px solid #eee' }"
></PageOptions>
<view class="h-c-container">
<view class="statistic">
<view class="s-item">
<view>{{ t("TaskNotice.alarmCount") }}</view>
<view class="count">{{ alertCount }}</view>
</view>
<view class="s-item">
<view>{{ t("app.inspection.handled") }}</view>
<view class="count">{{ processed }}</view>
</view>
</view>
<view style="margin-top: 28rpx; font-weight: 500">{{
t("TaskNotice.histProcTrend")
}}</view>
<view style="height: 480rpx">
<ChartsNvue v-if="renderFlag === '1'" ref="chartsRef" />
<view
class="p-empty"
v-if="renderFlag === '0'"
style="margin-top: 40rpx"
>
<image
class="p-empty-img"
src="/static/common/empty.png"
mode=""
></image>
<text class="p-empty-text chart-text">{{
t("maintenance.monitor.project.empty.text")
}}</text>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { onReachBottom, onPageScroll, onLoad } from "@dcloudio/uni-app";
import { ref, onMounted, nextTick } from "vue";
import PageOptions from "@/components/PageOptions.vue";
import CustomNavBar from "@/components/CustomNav.nvue";
import ChartsNvue from "@/components/Charts.nvue";
import { getDayStatisticsApi } from "@/api/message.js";
import { getStageObj, rpx2Px, getPageParams } from "@/utils";
import { t } from "@/plugins/index.js";
// #ifdef APP-PLUS || H5
import * as echarts from "echarts";
// #endif
// #ifdef MP-WEIXIN
const echarts = require("../../../../../uni_modules/lime-echart/static/echarts.min");
// #endif
const params = ref({});
const initFlag = ref(false);
const pageOptionsRef = ref(null);
// 是否路由携带参数
const isRouteHaveParam = ref(false);
onLoad((options) => {
// 获取路由参数
console.log(options, "options");
const params = getPageParams(options);
const { date, storeId } = params;
// 如果有日期参数,设置为date类型并传入日期
if (date) {
console.log("onMounted1");
isRouteHaveParam.value = true;
// 使用PageOptions组件的方法直接设置日期类型和日期
console.log("暴露出方法0");
nextTick(() => {
pageOptionsRef.value.setDateTypeAndDate("date", date);
});
}
});
const handleOptionsChange = (e) => {
params.value = e;
// 阻碍默认传7天
const { type } = params.value;
if (type === "last7days" && isRouteHaveParam.value) return;
initPage();
isRouteHaveParam.value = false;
};
const residenceTimeRef = ref(null);
const processed = ref(0);
const alertCount = ref(0);
const initPage = async () => {
try {
const requestParams = {
accountId: getStageObj("account")?.id,
startTime: params.value.startDate,
endTime: params.value.endDate,
mallId: params.value.storeId || "",
};
const res = await getDayStatisticsApi(requestParams);
if (res.code === 200) {
processed.value = res.data?.closeEdSum || 0;
alertCount.value = res.data?.total || 0;
initChart(res.data?.result || []);
}
console.log(res, "res");
} catch (error) {
console.log(error);
}
};
const renderFlag = ref("");
const chartsRef = ref(null);
const initChart = (data) => {
// const data = [{
// date: '09-23',
// closenum: 19,
// unclosenum: 19,
// totalnum: 38
// },{
// date: '09-24',
// closenum: 0,
// unclosenum: 0,
// totalnum: 0
// },{
// date: '09-25',
// closenum: 4,
// unclosenum: 5,
// totalnum: 9
// },{
// date: '09-26',
// closenum: 11,
// unclosenum: 99,
// totalnum: 110
// }]
if (data.length > 0) {
renderFlag.value = "1";
} else {
renderFlag.value = "0";
return false;
}
const val = {
date: [],
total: [],
processed: [],
};
data.forEach((item) => {
val.date.push(item.date);
val.total.push(item.totalnum);
val.processed.push(item.closenum);
});
const option = {
grid: {
containLabel: true,
top: rpx2Px(40),
left: 0,
right: 0,
bottom: rpx2Px(60),
},
legend: {
show: true,
icon: "circle",
itemWidth: rpx2Px(16),
itemHeight: rpx2Px(16),
bottom: 0,
left: "center",
textStyle: {
color: "#4E515E",
},
},
xAxis: {
type: "category",
data: val.date,
boundaryGap: false,
axisTick: {
show: false,
},
axisLabel: {
color: "#656A72",
},
axisLine: {
lineStyle: {
color: "#E1E4EA",
},
},
},
tooltip: {
trigger: "axis",
},
yAxis: {
type: "value",
},
series: [
{
name: t("TaskNotice.alarmCount"),
data: val.total,
type: "line",
showSymbol: false,
smooth: true,
lineStyle: {
color: "#387CF5",
},
itemStyle: {
color: "#387CF5",
},
},
{
name: t("app.inspection.handled"),
data: val.processed,
type: "line",
showSymbol: false,
smooth: true,
lineStyle: {
color: "#FFAB37",
},
itemStyle: {
color: "#FFAB37",
},
},
],
};
nextTick(() => {
chartsRef.value?.initCharts(option);
});
};
</script>
<style lang="scss">
.h-page {
/* #ifdef H5 */
min-height: calc(100vh - 44px);
/* #endif */
/* #ifndef H5 */
min-height: 100vh;
/* #endif */
background-color: #fff;
.h-c-container {
padding: 28rpx 32rpx 0;
.statistic {
display: flex;
gap: 20rpx;
.s-item {
flex: 1;
height: 160rpx;
min-width: 0;
border-radius: 12rpx 12rpx 12rpx 12rpx;
border: 2rpx solid #eef0f3;
padding: 28rpx 0 0 32rpx;
view {
font-family: Inter, Inter;
font-weight: 500;
font-size: 28rpx;
color: #262626;
}
.count {
font-size: 40rpx;
font-weight: 500;
}
}
}
}
}
</style>