| | |
| | | DELETED: { text: '已删除', color: 'red' }, |
| | | }; |
| | | |
| | | /** 兼容后端返回未知或小写枚举,避免直接索引得到 undefined。 */ |
| | | export const getRoleTypeMeta = (roleType?: string) => { |
| | | const key = String(roleType ?? '').toUpperCase() as RoleType; |
| | | return roleTypeMeta[key] ?? { text: roleType || '-', color: 'default' }; |
| | | }; |
| | | |
| | | export const getRoleStatusMeta = (status?: string) => { |
| | | const key = String(status ?? '').toUpperCase() as RoleStatus; |
| | | return statusMeta[key] ?? { text: status || '-', color: 'default' }; |
| | | }; |
| | | |
| | | export const createRoleColumns = (options: { |
| | | onDetail: (record: RoleVO) => void; |
| | | onToggle: (record: RoleVO) => void; |
| | |
| | | DISABLED: { text: '禁用' }, |
| | | DELETED: { text: '已删除' }, |
| | | }, |
| | | render: (_value, record) => ( |
| | | <Tag color={statusMeta[record.status].color} bordered={false}> |
| | | {statusMeta[record.status].text} |
| | | </Tag> |
| | | ), |
| | | render: (_value, record) => { |
| | | const meta = getRoleStatusMeta(record.status); |
| | | return ( |
| | | <Tag color={meta.color} bordered={false}> |
| | | {meta.text} |
| | | </Tag> |
| | | ); |
| | | }, |
| | | }, |
| | | { |
| | | title: '操作', |