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
import type { DictData } from "../../../api/crm";
 
export const DICT = {
  COMMON_STATUS: "common_status",
  MES_MD_ITEM_OR_PRODUCT: "mes_md_item_or_product",
};
 
export const RULE = {
  MD_ITEM_CODE: "MD_ITEM_CODE",
  MD_WORKSHOP_CODE: "MD_WORKSHOP_CODE",
  MD_WORKSTATION_CODE: "MD_WORKSTATION_CODE",
};
 
export function dateText(value?: string | Date) {
  if (!value) return "--";
  return String(value).replace("T", " ").slice(0, 16);
}
 
export function boolText(value?: boolean) {
  return value ? "是" : "否";
}
 
export function dictLabel(dicts: DictData[], type: string, value?: string | number | boolean, fallback = "--") {
  const hit = dicts.find(item => item.dictType === type && String(item.value) === String(value));
  return hit?.label || fallback;
}
 
export function dictOptions(dicts: DictData[], type: string) {
  return dicts.filter(item => item.dictType === type);
}
 
export function statusText(status?: number) {
  return Number(status) === 0 ? "开启" : Number(status) === 1 ? "关闭" : "--";
}
 
export function statusClass(status?: number) {
  return Number(status) === 0 ? "tag-enabled" : "tag-disabled";
}
 
export function num(value?: string | number) {
  if (value === "" || value === undefined || value === null) return undefined;
  const numberValue = Number(value);
  return Number.isNaN(numberValue) ? undefined : numberValue;
}