111 lines
4.1 KiB
TypeScript

import {
BadgeCheck,
BriefcaseBusiness,
Clock3,
PackagePlus,
TriangleAlert,
UsersRound,
type LucideIcon,
} from 'lucide-react'
export type CoreMetricKey =
| 'ongoing-projects'
| 'monthly-launches'
| 'on-time-delivery'
| 'first-pass-rate'
| 'team-workload'
| 'risks'
export type CoreMetric = {
key: CoreMetricKey
label: string
exampleValue: string
exampleNumericValue?: number
description: string
icon: LucideIcon
detailDescription: string
plannedFields: string[]
}
export const CORE_METRICS: CoreMetric[] = [
{
key: 'ongoing-projects',
label: '进行中项目',
exampleValue: '42',
description: '2026 年 4 月 1 日起发起且当前未完结的钉钉流程总量。',
icon: BriefcaseBusiness,
detailDescription: '展示 2026 年 4 月 1 日起发起、当前仍在流转中的钉钉审批流程,并按最近更新时间排序。',
plannedFields: ['流程名称', '当前状态', '发起部门', '待办任务', '发起时间', '最近更新'],
},
{
key: 'monthly-launches',
label: '本月上新',
exampleValue: '18/24',
description: '本月已完结的新品美术设计流程与当前进行中新品美术设计流程的对照。',
icon: PackagePlus,
detailDescription: '可按月份或自定义日期范围查看 2026 年 4 月 1 日起发起的新品美术设计流程;已完结按所选范围统计,进行中沿用当前流程快照。',
plannedFields: ['流程编码', '品牌', '发起人', '所在部门', '当前节点', '业务时间'],
},
{
key: 'on-time-delivery',
label: '按时交付',
exampleValue: '94.6%',
exampleNumericValue: 94.6,
description: '所选期间按时完成流程(含超时免扣)占审核节点完成流程的比例,待计算流程不计入分母。',
icon: Clock3,
detailDescription: '按月份或自定义日期范围查看审核节点完成流程的标准时效、实际用时与判定;超时免扣流程视为按时完成,待计算流程不计入分母,内容视频沿用排队顺延规则。',
plannedFields: ['流程', '发起人', '计时节点', '标准时效', '实际用时', '判定结果'],
},
{
key: 'first-pass-rate',
label: '首轮通过',
exampleValue: '82.3%',
description: 'V1版审核通过作品数占所有已通过作品数的比例。',
icon: BadgeCheck,
detailDescription: '查看作品过稿中每个作品的 V1 审核结果,以及首轮通过率的真实统计口径。',
plannedFields: ['交付内容', '评审人', '首轮结果', '修改轮次', '评审时间'],
},
{
key: 'team-workload',
label: '团队负荷',
exampleValue: '—',
description: '品牌中心在职人员(排除商品企划部和指定管理人员)的进行中流程负荷平均值;每个进行中流程计 50%,空闲人员按 0% 计入。',
icon: UsersRound,
detailDescription: '按部门展开品牌中心人员的进行中流程数量、当前节点与负荷;不统计商品企划部,同一人员同一流程只计一次,数据每小时增量同步。',
plannedFields: ['部门', '人员', '进行中流程数', '当前节点', '负荷率', '状态'],
},
{
key: 'risks',
label: '风险',
exampleValue: '4项',
description: '当前需要重点跟进的风险事项数量。',
icon: TriangleAlert,
detailDescription: '用于集中查看风险事项、责任人、截止时间与处理进度。',
plannedFields: ['风险事项', '风险等级', '负责人', '截止时间', '处理状态'],
},
]
export function getCoreMetric(key: string): CoreMetric | null {
return CORE_METRICS.find((metric) => metric.key === key) || null
}
export function getCoreMetricHref(key: CoreMetricKey): string {
return `/workspaces/dashboard/core-metrics/${key}`
}
export function getCoreMetricParams() {
return CORE_METRICS.map((metric) => ({
section: 'dashboard',
item: 'core-metrics',
metric: metric.key,
}))
}
export type OnTimeDeliveryBand = 'green' | 'yellow' | 'red'
export function getOnTimeDeliveryBand(rate: number): OnTimeDeliveryBand {
if (rate > 95) return 'green'
if (rate >= 90) return 'yellow'
return 'red'
}