import type { ActionType, ProColumns } from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table'; import { message, Button, Space, Popconfirm, Input } from 'antd'; import React, { useRef, useState } from 'react'; import type { Dispatch } from 'umi'; import { connect } from 'umi'; import type { StateType } from '../../model'; import { getCommonDimensionList, deleteCommonDimension } from '../../service'; import CommonDimensionInfoModal from './CommonDimensionInfoModal'; import { ISemantic } from '../../data'; import moment from 'moment'; import styles from '../style.less'; type Props = { dispatch: Dispatch; domainManger: StateType; }; const CommonDimensionTable: React.FC = ({ domainManger, dispatch }) => { const { selectDomainId: domainId, dimensionList } = domainManger; const [createModalVisible, setCreateModalVisible] = useState(false); const [dimensionItem, setDimensionItem] = useState(); const [loading, setLoading] = useState(false); const actionRef = useRef(); const queryDimensionList = async () => { setLoading(true); const { code, data, msg } = await getCommonDimensionList(domainId); setLoading(false); let resData: any = {}; if (code === 200) { resData = { data: data || [], success: true, }; } else { message.error(msg); resData = { data: [], total: 0, success: false, }; } return resData; }; const columns: ProColumns[] = [ { dataIndex: 'id', title: 'ID', width: 80, order: 100, search: false, }, { dataIndex: 'key', title: '维度搜索', hideInTable: true, renderFormItem: () => , }, { dataIndex: 'name', title: '维度名称', search: false, }, { dataIndex: 'bizName', title: '字段名称', search: false, // order: 9, }, { dataIndex: 'createdBy', title: '创建人', width: 100, search: false, }, { dataIndex: 'description', title: '描述', search: false, }, { dataIndex: 'updatedAt', title: '更新时间', width: 180, search: false, render: (value: any) => { return value && value !== '-' ? moment(value).format('YYYY-MM-DD HH:mm:ss') : '-'; }, }, { title: '操作', dataIndex: 'x', valueType: 'option', width: 200, render: (_, record) => { return ( { const { code, msg } = await deleteCommonDimension(record.id); if (code === 200) { setDimensionItem(undefined); actionRef.current?.reload(); } else { message.error(msg); } }} > ); }, }, ]; return ( <> { return false; }} size="small" options={{ reload: false, density: false, fullScreen: false }} toolBarRender={() => [ , ]} /> {createModalVisible && ( { setCreateModalVisible(false); actionRef?.current?.reload(); return; }} onCancel={() => { setCreateModalVisible(false); }} /> )} ); }; export default connect(({ domainManger }: { domainManger: StateType }) => ({ domainManger, }))(CommonDimensionTable);