xiaoyi
2026-10-30 ae3ab0d376959cd8560e45dce24b6a8b1b39d162
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
/** 安全生产模块 - 枚举、选项与通用工具 */
 
// ==================== 枚举定义 ====================
 
/** 特种作业证类型 */
export const CERT_TYPE_OPTIONS = [
  { label: '低压电工证', value: 'LOW_VOLTAGE_ELECTRICIAN' },
  { label: '高压操作证', value: 'HIGH_VOLTAGE_OPERATION' },
  { label: '焊接与热切割作业证', value: 'WELDING' },
  { label: '起重机械作业证', value: 'HOIST' },
  { label: '高处作业证', value: 'HEIGHT_WORK' },
  { label: '有限空间作业证', value: 'LIMITED_SPACE' },
  { label: '叉车作业证', value: 'FORKLIFT' },
  { label: '锅炉作业证', value: 'BOILER' },
  { label: '其他特种作业证', value: 'OTHER' },
];
 
/** 证件状态 */
export const CERT_STATUS_OPTIONS = [
  { label: '有效', value: 'VALID' },
  { label: '即将到期', value: 'EXPIRING' },
  { label: '已过期', value: 'EXPIRED' },
  { label: '已注销', value: 'REVOKED' },
];
 
export const CERT_STATUS_COLOR: Record<string, string> = {
  VALID: 'green',
  EXPIRING: 'orange',
  EXPIRED: 'red',
  REVOKED: 'default',
};
 
/** 巡检点位类型 */
export const POINT_TYPE_OPTIONS = [
  { label: '高压配电室', value: 'HIGH_VOLTAGE_ROOM' },
  { label: '机组区', value: 'UNIT_AREA' },
  { label: '危化品库', value: 'DANGER_CHEMICAL' },
  { label: '消防重点部位', value: 'FIRE_AREA' },
  { label: '生产车间', value: 'WORKSHOP' },
  { label: '其他', value: 'OTHER' },
];
 
/** 巡检周期 */
export const INSPECT_CYCLE_OPTIONS = [
  { label: '每班', value: 'SHIFT' },
  { label: '每日', value: 'DAILY' },
  { label: '每周', value: 'WEEKLY' },
  { label: '每月', value: 'MONTHLY' },
];
 
/** 巡检结果 */
export const INSPECTION_RESULT_OPTIONS = [
  { label: '正常', value: 'NORMAL' },
  { label: '异常', value: 'ABNORMAL' },
];
 
/** 隐患等级 */
export const HAZARD_LEVEL_OPTIONS = [
  { label: '一般隐患', value: 'GENERAL' },
  { label: '重大隐患', value: 'MAJOR' },
];
 
export const HAZARD_LEVEL_COLOR: Record<string, string> = {
  GENERAL: 'blue',
  MAJOR: 'red',
};
 
/** 隐患来源 */
export const HAZARD_SOURCE_OPTIONS = [
  { label: '巡检发现', value: 'INSPECTION' },
  { label: '自查上报', value: 'SELF_CHECK' },
  { label: '员工上报', value: 'REPORT' },
  { label: '外部检查', value: 'EXTERNAL' },
];
 
/** 隐患状态(闭环流转) */
export const HAZARD_STATUS_OPTIONS = [
  { label: '已上报', value: 'REPORTED' },
  { label: '已分派', value: 'ASSIGNED' },
  { label: '整改中', value: 'RECTIFYING' },
  { label: '待复查', value: 'RECHECKING' },
  { label: '复查不通过', value: 'REJECTED' },
  { label: '已闭环', value: 'CLOSED' },
];
 
export const HAZARD_STATUS_COLOR: Record<string, string> = {
  REPORTED: 'default',
  ASSIGNED: 'blue',
  RECTIFYING: 'processing',
  RECHECKING: 'orange',
  REJECTED: 'red',
  CLOSED: 'success',
};
 
/** 作业票类型 */
export const PERMIT_TYPE_OPTIONS = [
  { label: '动火作业', value: 'HOT_WORK' },
  { label: '高压带电作业', value: 'LIVE_HIGH_VOLTAGE' },
  { label: '有限空间作业', value: 'LIMITED_SPACE' },
  { label: '高处作业', value: 'WORK_AT_HEIGHT' },
  { label: '吊装作业', value: 'LIFTING' },
  { label: '临时用电作业', value: 'TEMP_ELECTRIC' },
  { label: '其他作业', value: 'OTHER' },
];
 
/** 作业票状态 */
export const PERMIT_STATUS_OPTIONS = [
  { label: '草稿', value: 'DRAFT' },
  { label: '待审批', value: 'PENDING' },
  { label: '已批准', value: 'APPROVED' },
  { label: '已驳回', value: 'REJECTED' },
  { label: '作业中', value: 'IN_PROGRESS' },
  { label: '已完结', value: 'CLOSED' },
  { label: '已作废', value: 'CANCELLED' },
];
 
export const PERMIT_STATUS_COLOR: Record<string, string> = {
  DRAFT: 'default',
  PENDING: 'orange',
  APPROVED: 'blue',
  REJECTED: 'red',
  IN_PROGRESS: 'processing',
  CLOSED: 'success',
  CANCELLED: 'default',
};
 
/** 风险等级 */
export const RISK_LEVEL_OPTIONS = [
  { label: '低', value: 'LOW' },
  { label: '一般', value: 'NORMAL' },
  { label: '高', value: 'HIGH' },
  { label: '极高', value: 'VERY_HIGH' },
];
 
export const RISK_LEVEL_COLOR: Record<string, string> = {
  LOW: 'green',
  NORMAL: 'blue',
  HIGH: 'orange',
  VERY_HIGH: 'red',
};
 
/** 物资类别 */
export const MATERIAL_CATEGORY_OPTIONS = [
  { label: '电力绝缘用具', value: 'INSULATING' },
  { label: '危化品', value: 'HAZARD_CHEMICAL' },
  { label: '消防物资', value: 'FIRE' },
  { label: '劳保用品', value: 'PPE' },
  { label: '其他', value: 'OTHER' },
];
 
export const MATERIAL_CATEGORY_COLOR: Record<string, string> = {
  INSULATING: 'blue',
  HAZARD_CHEMICAL: 'red',
  FIRE: 'orange',
  PPE: 'green',
  OTHER: 'default',
};
 
/** 培训类型 */
export const TRAINING_TYPE_OPTIONS = [
  { label: '安全培训', value: 'SAFETY' },
  { label: '技能培训', value: 'SKILL' },
  { label: '法规宣贯', value: 'LAW' },
  { label: '应急演练培训', value: 'EMERGENCY' },
  { label: '三级安全教育', value: 'INDUCTION' },
  { label: '其他', value: 'OTHER' },
];
 
/** 演练类型 */
export const DRILL_TYPE_OPTIONS = [
  { label: '消防演练', value: 'FIRE' },
  { label: '应急疏散演练', value: 'EMERGENCY_EVAC' },
  { label: '触电事故演练', value: 'ELECTRIC_ACCIDENT' },
  { label: '危化品泄漏演练', value: 'CHEMICAL_LEAK' },
  { label: '其他演练', value: 'OTHER' },
];
 
/** 事故类型 */
export const ACCIDENT_TYPE_OPTIONS = [
  { label: '触电', value: 'ELECTRIC_SHOCK' },
  { label: '火灾', value: 'FIRE' },
  { label: '高处坠落', value: 'FALL' },
  { label: '物体打击', value: 'OBJECT_STRIKE' },
  { label: '机械伤害', value: 'MECHANICAL' },
  { label: '中毒窒息', value: 'CHEMICAL' },
  { label: '车辆伤害', value: 'VEHICLE' },
  { label: '其他', value: 'OTHER' },
];
 
/** 事故等级 */
export const ACCIDENT_LEVEL_OPTIONS = [
  { label: '轻伤事故', value: 'SLIGHT' },
  { label: '一般事故', value: 'GENERAL' },
  { label: '重伤事故', value: 'SEVERE' },
  { label: '重大事故', value: 'MAJOR' },
];
 
export const ACCIDENT_LEVEL_COLOR: Record<string, string> = {
  SLIGHT: 'default',
  GENERAL: 'blue',
  SEVERE: 'orange',
  MAJOR: 'red',
};
 
/** 事故处理状态 */
export const ACCIDENT_STATUS_OPTIONS = [
  { label: '已登记', value: 'REPORTED' },
  { label: '调查中', value: 'INVESTIGATING' },
  { label: '已处理', value: 'HANDLED' },
  { label: '已结案', value: 'CLOSED' },
];
 
// ==================== 工具函数 ====================
 
/** 从选项数组取 label */
export function optionLabel(
  options: { label: string; value: string }[],
  value?: string,
): string {
  if (!value) return '-';
  return options.find((o) => o.value === value)?.label ?? value;
}
 
/** 逗号串转数组 */
export function splitUrls(urls?: string): string[] {
  if (!urls) return [];
  return urls.split(',').filter(Boolean);
}
 
/** 数组转逗号串 */
export function joinUrls(urls: string[]): string {
  return urls.filter(Boolean).join(',');
}
 
/** 数字格式化,去掉多余的 0 */
export function numberText(value?: number, precision = 3): string {
  if (value === null || value === undefined) return '-';
  return Number(value)
    .toFixed(precision)
    .replace(/\.?0+$/, '');
}
 
/** 判断是否为图片 URL */
export function isImage(url: string): boolean {
  return /\.(jpg|jpeg|png|webp|gif|bmp|heic)$/i.test(url);
}