- 首页改成深色实时看板:今日/昨日维度、每 30 秒静默刷新(后台标签页跳过)、 切维度/切回前台立刻刷;工作台榜按「占比」出条并同时给条数与百分比; 支持原生全屏,`AppLayout :immersive` 隐藏左侧菜单与顶栏占满整屏 - 待支付订单 2 小时自动失效(`config.pay.orderTtl` / `PAY_ORDER_TTL`,默认 7200 秒): 定时任务 `app/schedule/subject_order_expire.js` 每分钟扫一次, 详情/列表/平台订单列表读到超时订单就地关单,支付回调入口再兜一层; 超时后的渠道回调与手工确认一律 409;`present()` 下发 `payExpireAt / expired / pending`, 前端展示支付截止时间、超时后停止轮询、平台端隐藏「确认订单」按钮 - 文档同步:根 README 与 backend/README(订单 TTL、看板刷新策略、全屏降级) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
183 lines
4.7 KiB
Vue
183 lines
4.7 KiB
Vue
<script setup lang="ts">
|
||
/**
|
||
* 首页「每个工作台打包数量」横向进度条(纯 CSS)
|
||
*
|
||
* 条长 = **该工作台打包数 / 该时间段总扫码数**(占比),不是相对最大值 —— 一眼就能看出
|
||
* 「这个工作台占了本期多少」。右侧同时给「条数 + 百分比」。
|
||
*
|
||
* 工作台名称就是名称(不再显示 `WS-xxxxx` 这种内部编码,编码只放在 hover 提示里)。
|
||
*/
|
||
import { computed } from 'vue';
|
||
import type { WorkstationPackStat } from '@/api/types';
|
||
|
||
interface Row {
|
||
key: string;
|
||
label: string;
|
||
/** 内部编码(只用于 hover 提示,不占版位) */
|
||
code?: string;
|
||
count: number;
|
||
percent: number;
|
||
deleted?: boolean;
|
||
muted?: boolean;
|
||
}
|
||
|
||
const props = withDefaults(defineProps<{
|
||
items: WorkstationPackStat[];
|
||
/** 区间内没有关联工作台的扫码数 */
|
||
unassigned?: number;
|
||
/** 该时间段的扫码总数(占比的分母);不传就用各项之和 */
|
||
total?: number;
|
||
/** 最多显示几个工作台,其余合并成「其他」 */
|
||
limit?: number;
|
||
}>(), { unassigned: 0, total: 0, limit: 8 });
|
||
|
||
/** 占比的分母:优先用后端给的时间段总数,没给就用各项之和 */
|
||
const denominator = computed(() => {
|
||
const sum = props.items.reduce((acc, item) => acc + Math.max(Number(item.count) || 0, 0), 0)
|
||
+ Math.max(Number(props.unassigned) || 0, 0);
|
||
const total = Number(props.total);
|
||
return Math.max(Number.isFinite(total) && total > 0 ? total : 0, sum, 1);
|
||
});
|
||
|
||
const rows = computed<Row[]>(() => {
|
||
const toRow = (base: Omit<Row, 'percent'>): Row => ({
|
||
...base,
|
||
percent: Math.round((Math.max(base.count, 0) / denominator.value) * 1000) / 10,
|
||
});
|
||
|
||
const list: Row[] = props.items.slice(0, props.limit).map(item => toRow({
|
||
key: `ws-${item.id}`,
|
||
label: item.name || item.code,
|
||
code: item.code,
|
||
count: Math.max(Number(item.count) || 0, 0),
|
||
deleted: item.deleted,
|
||
}));
|
||
|
||
const rest = props.items.slice(props.limit);
|
||
if (rest.length) {
|
||
list.push(toRow({
|
||
key: 'rest',
|
||
label: `其他 ${rest.length} 个工作台`,
|
||
count: rest.reduce((sum, item) => sum + (Number(item.count) || 0), 0),
|
||
muted: true,
|
||
}));
|
||
}
|
||
if (props.unassigned > 0) {
|
||
list.push(toRow({ key: 'unassigned', label: '未关联工作台', count: props.unassigned, muted: true }));
|
||
}
|
||
return list;
|
||
});
|
||
|
||
/** 条长按占比算;非 0 的至少给 2% 让条能看见 */
|
||
function barWidth(percent: number): string {
|
||
if (percent <= 0) return '0';
|
||
return `${Math.max(percent, 2)}%`;
|
||
}
|
||
|
||
/** 百分比展示:很小但有数据时别显示成 0.0% */
|
||
function percentText(percent: number, count: number): string {
|
||
if (count <= 0) return '0%';
|
||
if (percent > 0 && percent < 0.1) return '<0.1%';
|
||
return `${percent.toFixed(percent >= 10 ? 0 : 1)}%`;
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<ul class="rank">
|
||
<li v-for="row in rows" :key="row.key" class="row" :title="row.code ? `${row.label}(${row.code})` : row.label">
|
||
<span class="label">
|
||
<span class="name">{{ row.label }}</span>
|
||
<span v-if="row.deleted" class="tag">已删除</span>
|
||
</span>
|
||
<span class="track">
|
||
<span class="fill" :class="{ muted: row.muted }" :style="{ width: barWidth(row.percent) }" />
|
||
</span>
|
||
<span class="value">
|
||
<b class="count">{{ row.count }}</b>
|
||
<span class="percent">{{ percentText(row.percent, row.count) }}</span>
|
||
</span>
|
||
</li>
|
||
</ul>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.rank {
|
||
list-style: none;
|
||
margin: 0;
|
||
padding: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
}
|
||
|
||
/* 名称列给足宽度(名称优先显示完整),进度条自适应,右侧固定放「条数 + 占比」 */
|
||
.row {
|
||
display: grid;
|
||
grid-template-columns: minmax(96px, 200px) 1fr 84px;
|
||
align-items: center;
|
||
gap: 10px;
|
||
}
|
||
|
||
.label {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
min-width: 0;
|
||
font-size: 13px;
|
||
}
|
||
|
||
.name {
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.tag {
|
||
flex: none;
|
||
font-size: 10px;
|
||
color: var(--danger);
|
||
background: #fef2f2;
|
||
border: 1px solid #fecaca;
|
||
border-radius: 4px;
|
||
padding: 0 4px;
|
||
}
|
||
|
||
.track {
|
||
height: 10px;
|
||
border-radius: 999px;
|
||
background: #eef1f6;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.fill {
|
||
display: block;
|
||
height: 100%;
|
||
border-radius: 999px;
|
||
background: linear-gradient(to right, var(--brand), #60a5fa);
|
||
transition: width 0.3s ease;
|
||
}
|
||
|
||
.fill.muted {
|
||
background: #c7ccd6;
|
||
}
|
||
|
||
.value {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: flex-end;
|
||
gap: 6px;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.count {
|
||
font-size: 13px;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.percent {
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
</style>
|