wangzhibo
4 天以前 656e2507b9aa388afa4c3346927b1b94ab70a0b2
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
<template>
    <div class="screen-page">
        <el-row :gutter="10" class="kpi-row">
            <el-col :lg="3" :sm="8" :xs="12">
                <kpi-card label="在线分拣员" :value="data.kpis.sorterOnline"
                    :hint="`${data.kpis.sorterOnline} / ${data.kpis.sorterTotal}`" />
            </el-col>
            <el-col :lg="3" :sm="8" :xs="12">
                <kpi-card label="在线车辆" :value="data.kpis.vehicleOnline"
                    :hint="`${data.kpis.vehicleOnline} / ${data.kpis.vehicleTotal}`" />
            </el-col>
            <el-col :lg="3" :sm="8" :xs="12">
                <kpi-card label="在线分拣点" :value="data.kpis.siteOnline"
                    :hint="`${data.kpis.siteOnline} / ${data.kpis.siteTotal},按站点启用`" />
            </el-col>
            <el-col :lg="3" :sm="8" :xs="12">
                <kpi-card label="今日回收订单" :value="data.kpis.todayOrders" :hint="``" />
            </el-col>
            <el-col :lg="4" :sm="8" :xs="12">
                <kpi-card label="今日预约 / 待处理" :value="data.kpis.todayAppointments"
                    :hint="`待处理 ${data.kpis.pendingAppointments}`" />
            </el-col>
            <el-col :lg="4" :sm="8" :xs="12">
                <kpi-card label="异常告警" :value="data.kpis.alerts" alert
                    :hint="`健康异常 ${data.kpis.healthAlerts},不展示隐私体征`" />
            </el-col>
            <el-col :lg="4" :sm="8" :xs="12">
                <kpi-card label="车辆安全事件" :value="safetyCount" hint="超速 / 急刹等,来自车辆日汇总" />
            </el-col>
        </el-row>
 
        <el-row :gutter="10" class="mid-row">
            <el-col :lg="14" :xs="24">
                <panel-card title="订单趋势" sub="现场 / 预约 / 大屏 / 活动,按天对比">
                    <v-chart :option="orderOption" autoresize class="chart" />
                </panel-card>
            </el-col>
            <el-col :lg="10" :xs="24">
                <panel-card title="预约订单漏斗" sub="新增/待审核 → 已确认/已接单 → 已完成">
                    <div class="funnel">
                        <div v-for="(item, index) in data.appointmentFlow" :key="item.name" class="funnel__item">
                            <div class="funnel__name">{{ item.name }}</div>
                            <div class="funnel__bar">
                                <i :style="{ width: funnelWidth(item.value) }" />
                            </div>
                            <div class="funnel__value">{{ item.value }}</div>
                            <span v-if="index < data.appointmentFlow.length - 1" class="funnel__next">→</span>
                        </div>
                    </div>
                    <p class="funnel__tip">预约 → 接单 → 完成</p>
                </panel-card>
            </el-col>
        </el-row>
 
        <el-row :gutter="10">
            <el-col :lg="8" :xs="24">
                <panel-card title="分拣员状态" sub="来自分拣员日表,只汇总状态,不展示体征明细">
                    <div class="status-list">
                        <div v-for="item in data.sorterStatus" :key="item.name" class="status-list__item">
                            <i :style="{ background: item.color }" />
                            <span>{{ item.name }}</span>
                            <strong>{{ item.value }}</strong>
                        </div>
                    </div>
                </panel-card>
            </el-col>
            <el-col :lg="8" :xs="24">
                <panel-card title="车辆运行" sub="公司领导看运力与安全,不进校领导首页">
                    <div class="table table--vehicle">
                        <div class="table__head">
                            <span>车牌</span>
                            <span>里程km</span>
                            <span>怠速分</span>
                            <span>超速</span>
                            <span>状态</span>
                        </div>
                        <div v-for="item in data.vehicles" :key="item.no" class="table__row">
                            <span>{{ item.no }}</span>
                            <span>{{ item.km }}</span>
                            <span>{{ item.idle }}</span>
                            <span>{{ item.overspeed }}</span>
                            <span :class="item.status === '在线' ? 'is-on' : 'is-off'">{{ item.status }}</span>
                        </div>
                    </div>
                </panel-card>
            </el-col>
            <el-col :lg="8" :xs="24">
                <panel-card title="分拣点吞吐" sub="运营维度才下钻到点位">
                    <div class="table table--site">
                        <div class="table__head">
                            <span>收集点</span>
                            <span>今日kg</span>
                            <span>在线</span>
                        </div>
                        <div v-for="item in data.sites" :key="item.name" class="table__row">
                            <span>{{ item.name }}</span>
                            <span>{{ item.weight }}</span>
                            <span :class="item.online ? 'is-on' : 'is-off'">{{ item.online ? '在线' : '离线' }}</span>
                        </div>
                    </div>
                </panel-card>
            </el-col>
        </el-row>
    </div>
</template>
 
<script lang="ts" setup>
defineOptions({
    name: 'report-screen-operation'
});
 
import { computed } from 'vue';
import KpiCard from '../../components/kpi-card.vue';
import PanelCard from '../../components/panel-card.vue';
import { useChartTheme, useScreenData } from '../../hooks/use-screen';
 
const { data } = useScreenData();
const { mutedColor, splitColor, tooltip } = useChartTheme();
 
const safetyCount = computed(() => data.value.vehicles.reduce((s, e) => s + e.overspeed, 0));
 
function funnelWidth(value: number) {
    const max = data.value.appointmentFlow[0]?.value || 1;
    return `${Math.max((value / max) * 100, 18)}%`;
}
 
const orderOption = computed(() => {
    const colors = ['#16a34a', '#3b82f6', '#f59e0b', '#a855f7'];
    const keys = ['现场回收', '预约上门', '大屏投递', '活动回收'] as const;
    return {
        grid: { containLabel: true, left: 8, right: 12, top: 36, bottom: 8 },
        legend: { top: 0, textStyle: { color: mutedColor.value } },
        tooltip: { trigger: 'axis', ...tooltip() },
        xAxis: {
            type: 'category',
            data: data.value.ordersByType.axis,
            axisLabel: { color: mutedColor.value },
            axisLine: { show: false },
            axisTick: { show: false }
        },
        yAxis: {
            type: 'value',
            splitLine: { lineStyle: { color: splitColor.value, type: 'dashed' } },
            axisLabel: { color: mutedColor.value },
            axisLine: { show: false },
            axisTick: { show: false }
        },
        series: keys.map((name, i) => ({
            name,
            type: 'bar',
            stack: 'order',
            barWidth: 18,
            data: data.value.ordersByType[name],
            itemStyle: { color: colors[i] }
        }))
    };
});
</script>
 
<style lang="scss" scoped>
.screen-page {
 
    .kpi-row,
    .mid-row {
        margin-bottom: 10px;
    }
 
    .kpi-row {
        :deep(.el-col) {
            margin-bottom: 10px;
        }
    }
 
    .mid-row,
    :deep(.panel-card) {
        min-height: 0;
    }
 
    .mid-row {
        :deep(.panel-card) {
            min-height: 340px;
        }
    }
 
    .chart {
        height: 280px;
        width: 100%;
    }
 
    .funnel {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 18px 16px 0;
 
        &__item {
            display: grid;
            grid-template-columns: 52px 1fr 40px 16px;
            align-items: center;
            gap: 8px;
        }
 
        &__name {
            font-size: 13px;
            color: var(--el-text-color-regular);
        }
 
        &__bar {
            height: 18px;
            border-radius: 99px;
            background: var(--el-fill-color-light);
 
            i {
                display: block;
                height: 100%;
                border-radius: 99px;
                background: var(--el-color-primary);
            }
        }
 
        &__value {
            text-align: right;
            font-weight: 700;
        }
 
        &__next {
            color: var(--el-text-color-secondary);
        }
 
        &__tip {
            margin: 16px;
            font-size: 12px;
            color: var(--el-text-color-secondary);
        }
    }
 
    .status-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 16px;
 
        &__item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 14px;
            border-radius: 10px;
            background: var(--el-fill-color-lighter);
            font-size: 14px;
 
            i {
                width: 10px;
                height: 10px;
                border-radius: 50%;
            }
 
            span {
                flex: 1;
            }
 
            strong {
                font-size: 20px;
            }
        }
    }
 
    .table {
        padding: 8px 12px 16px;
        font-size: 13px;
 
        &--vehicle &__head,
        &--vehicle &__row {
            grid-template-columns: 1.4fr repeat(4, 0.8fr);
        }
 
        &--site &__head,
        &--site &__row {
            grid-template-columns: 1.6fr 0.8fr 0.6fr;
        }
 
        &__head,
        &__row {
            display: grid;
            gap: 8px;
            padding: 10px 4px;
        }
 
        &__head {
            color: var(--el-text-color-secondary);
        }
 
        &__row {
            border-top: 1px solid var(--el-border-color-extra-light);
        }
 
        .is-on {
            color: var(--el-color-success);
        }
 
        .is-off {
            color: var(--el-text-color-secondary);
        }
    }
 
}
</style>