- 新增状态机模型和状态流转的完整 CRUD 功能 - 添加字典编码 OBJECT_STATUS_MODEL_OBJECT_TYPE_DICT_CODE 用于对象类型下拉选择 - 实现状态机列表页、搜索组件、操作对话框和状态流转管理 - 新增 infra API 接口封装和类型定义 - 遵循项目规范:使用 TableSearchFields 搜索组件、BusinessTableActionCell 操作列、统一的状态标签展示 涉及文件: - src/constants/dict.ts: 新增对象类型字典编码 - src/service/api/infra.ts: 新增状态机和状态流转相关 API - src/typings/api/infra.d.ts: 新增状态机相关类型定义 - src/views/infra/state-machine/: 新增状态机管理页面及子组件
39 lines
873 B
TypeScript
39 lines
873 B
TypeScript
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');
|
|
}
|