Files
cn-rdms-web/src/views/infra/state-machine/shared.ts

39 lines
873 B
TypeScript
Raw Normal View History

import dayjs from 'dayjs';
export const statusOptions: Array<{ label: string; value: Api.Infra.CommonStatus }> = [
{ label: '启用', value: 0 },
{ label: '停用', value: 1 }
];
export function getStatusLabel(value?: Api.Infra.CommonStatus | null) {
if (value === 0) {
return '启用';
}
if (value === 1) {
return '停用';
}
return '--';
}
export function getStatusTagType(value?: Api.Infra.CommonStatus | null): UI.ThemeColor {
return value === 0 ? 'success' : 'warning';
}
export function getBooleanLabel(value?: boolean | null) {
return value ? '是' : '否';
}
export function getBooleanTagType(value?: boolean | null): UI.ThemeColor {
return value ? 'success' : 'info';
}
export function formatDateTime(value?: string | number | null) {
if (!value) {
return '--';
}
return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
}