import { Space, Tag, Typography } from 'antd';
import { StatusEnum } from '../enum';
import { SENSITIVE_LEVEL_ENUM, SENSITIVE_LEVEL_COLOR } from '../constant';
import { TagsOutlined, ReadOutlined } from '@ant-design/icons';
import { history } from 'umi';
import { ISemantic } from '../data';
import { isString } from 'lodash';
import dayjs from 'dayjs';
import { isArrayOfValues } from '@/utils/utils';
import styles from './style.less';
import IndicatorStar, { StarType } from '../components/IndicatorStar';
const { Text, Paragraph } = Typography;
export const ColumnsConfig: any = (params?: {
indicatorInfo?: {
url?: string;
starType?: StarType;
};
}) => {
return {
description: {
render: (_, record: ISemantic.IMetricItem) => {
const { description } = record;
return (
{description}
);
},
},
dimensionInfo: {
render: (_, record: ISemantic.IDimensionItem) => {
const { name, alias, bizName } = record;
return (
<>
{name}
{bizName}
{alias && (
{alias && (
别名:
{isString(alias) &&
alias.split(',').map((aliasName: string) => {
return (
{aliasName}
);
})}
)}
)}
>
);
},
},
indicatorInfo: {
render: (_, record: ISemantic.IMetricItem) => {
const { name, alias, bizName, classifications, id, isCollect } = record;
let url = `/metric/detail/`;
let starType: StarType = 'metric';
if (params) {
if (params?.indicatorInfo?.url) {
url = params.indicatorInfo.url;
}
if (params?.indicatorInfo?.starType) {
starType = params.indicatorInfo.starType;
}
}
return (
<>
{bizName}
{(alias || isArrayOfValues(classifications)) && (
{alias && (
别名:
{isString(alias) &&
alias.split(',').map((aliasName: string) => {
return (
{aliasName}
);
})}
)}
{isArrayOfValues(classifications) && (
分类:
{classifications.map((tag: string) => {
return (
{tag}
);
})}
)}
{/*
:
{id}
:
{createdBy}
*/}
)}
>
);
},
},
sensitiveLevel: {
render: (_, record: ISemantic.IMetricItem) => {
const { sensitiveLevel } = record;
return SENSITIVE_LEVEL_COLOR[sensitiveLevel] ? (
{SENSITIVE_LEVEL_ENUM[sensitiveLevel]}
) : (
未知
);
},
},
state: {
render: (status) => {
let tagProps: { color: string; label: string; style?: any } = {
color: 'default',
label: '未知',
style: {},
};
switch (status) {
case StatusEnum.ONLINE:
tagProps = {
// color: 'processing',
color: 'geekblue',
label: '已启用',
};
break;
case StatusEnum.OFFLINE:
tagProps = {
color: 'default',
label: '未启用',
style: {
color: 'rgb(95, 116, 141)',
fontWeight: 400,
},
};
break;
case StatusEnum.INITIALIZED:
tagProps = {
color: 'processing',
label: '初始化',
};
break;
case StatusEnum.DELETED:
tagProps = {
color: 'default',
label: '已删除',
};
break;
case StatusEnum.UNAVAILABLE:
tagProps = {
color: 'default',
label: '不可用',
};
break;
default:
break;
}
return (
{tagProps.label}
);
},
},
createInfo: {
dataIndex: 'updatedAt',
title: '创建信息',
tooltip: '创建人/更新时间',
width: 180,
search: false,
render: (value: any, record: ISemantic.IMetricItem) => {
return (
{record.createdBy}
{value && value !== '-' ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'}
);
},
},
};
};