gaoluyang
2026-11-03 2d8b1a28fa5c8b852f0d0078bac4894bfb4abed5
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
import type { DictData } from "../../../api/crm";
 
/** 字典类型常量(与 web 端 @vben/constants DICT_TYPE 保持一致) */
export const DICT = {
  COMMON_STATUS: "common_status",
  MES_PD_PARAM_TYPE: "mes_pd_param_type",
  MES_PD_TEMPLATE_TYPE: "mes_pd_template_type",
  MES_PRO_LINK_TYPE: "mes_pro_link_type",
  MES_TIME_UNIT_TYPE: "mes_time_unit_type",
} as const;
 
/** 自动编码规则(与 web 端 MesAutoCodeRuleCode 一致) */
export const RULE = {
  PRO_PROCESS_CODE: "PRO_PROCESS_CODE",
  PRO_ROUTE_CODE: "PRO_ROUTE_CODE",
} as const;
 
export const STATUS_ENABLE = 0;
export const STATUS_DISABLE = 1;
 
export function dateText(value?: string) {
  return value?.replace("T", " ").slice(0, 16) || "--";
}
 
export function booleanText(value?: boolean) {
  return value ? "是" : "否";
}
 
export function numberText(value?: number | string) {
  return value === undefined || value === null || value === "" ? "--" : String(value);
}
 
export function dictLabel(dicts: DictData[], type: string, value?: number | string, fallback = "--") {
  if (value === undefined || value === null) return fallback;
  return dicts.find(item => item.dictType === type && String(item.value) === String(value))?.label || fallback;
}
 
export function dictOptions(dicts: DictData[], type: string) {
  return dicts
    .filter(item => item.dictType === type && item.status !== 1)
    .sort((a, b) => (a.sort || 0) - (b.sort || 0));
}
 
/** 工序状态(common_status):0 启用 / 1 停用 */
export function statusText(status?: number) {
  return Number(status) === STATUS_DISABLE ? "停用" : "启用";
}
 
/** 底部选择面板的候选项结构 */
export interface SheetOption {
  key: number | string;
  label: string;
  sub?: string;
  extra?: string;
}
 
export function statusClass(status?: number) {
  return Number(status) === STATUS_DISABLE ? "tag-disabled" : "tag-enabled";
}
 
/** 工艺路线颜色圆点样式(甘特图颜色) */
export function colorStyle(color?: string) {
  return color ? `background:${color}` : "background:#d5dde8";
}