import React, { useEffect, useState } from 'react'; import { Badge, ProTable, Tooltip, Utils, Progress } from 'knowdesign'; import { formatAssignSize, runningStatusEnum } from './config'; const columns: any = [ { title: 'Partition', dataIndex: 'partitionId', key: 'partitionId', render: (t: any, r: any) => { // return runningStatusEnum[r?.status]; return ( {t} ); }, }, { title: '源BrokerID', dataIndex: 'sourceBrokerIds', key: 'sourceBrokerIds', render: (t: any, r: any) => { return t && t.length > 0 ? t.join('、') : '-'; }, }, { title: '目标BrokerID', dataIndex: 'desBrokerIds', key: 'desBrokerIds', render(t: any, r: any) { return t && t.length > 0 ? t.join('、') : '-'; }, }, // { // title: '需迁移MessageSize(MB)', // dataIndex: 'totalSize', // key: 'totalSize', // render(t: any, r: any) { // return t || t === 0 ? formatAssignSize(t, 'MB') : '-'; // }, // }, // { // title: '已完成MessageSize (MB)', // dataIndex: 'movedSize', // key: 'movedSize', // render(t: any, r: any) { // return t || t === 0 ? formatAssignSize(t, 'MB') : '-'; // }, // }, { title: 'MessageSize迁移进度(MB)', dataIndex: 'movedSize', key: 'movedSize', render(t: any, r: any) { const movedSize = r.movedSize ? Number(Utils.formatAssignSize(t, 'MB')) : 0; const totalSize = r.totalSize ? Number(Utils.formatAssignSize(t, 'MB')) : 0; return (
0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0) + '%'}> 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0} strokeColor="#556EE6" trailColor="#ECECF1" showInfo={false} /> {movedSize + '/' + totalSize}
); }, }, // { // title: '状态', // key: 'status', // width: 100, // render: (t: any, r: any) => { // return ( // // // {runningStatusEnum[r?.status]} // // ); // }, // }, // { // title: 'BytesIn(MB/s)', // dataIndex: 'byteIn', // key: 'byteIn', // render(t: any, r: any) { // return t ? t : '-'; // }, // }, // { // title: '同步速率(MB/s)', // dataIndex: 'byteMove', // key: 'byteMove', // render(t: any, r: any) { // return t ? t : '-'; // }, // }, { title: '预计剩余时长', dataIndex: 'remainTime', key: 'remainTime', render(t: any, r: any) { return t ? Utils.transUnitTime(t) : t === 0 ? t : '-'; }, }, ]; export const ExpandedRow: any = ({ record, data, loading }: any) => { const [pagination, setPagination] = useState({ current: 1, pageSize: 5, // total: data[record.key]?.length, simple: true, hideOnSinglePage: false, }); const [status, setStatus] = useState({ total: 0, success: 0, doing: 0, fail: 0, }); const onTableChange = (pagination: any, filters: any) => { setPagination(pagination); }; const calcStatus = () => { const success = data[record.key]?.filter((item: any) => runningStatusEnum[item.status] === 'Success').length || 0; const doing = data[record.key]?.filter((item: any) => runningStatusEnum[item.status] === 'Doing').length || 0; const fail = data[record.key]?.filter((item: any) => runningStatusEnum[item.status] === 'Fail').length || 0; const total = data[record.key]?.length || 0; setStatus({ total, success, doing, fail }); }; useEffect(() => { calcStatus(); }, [data[record.key]]); return (
执行情况: Partition总数 {(status?.success || 0) + (status?.doing || 0) + (status?.fail || 0)} Success {status?.success || 0} Fail {status?.fail || 0} Doing {status?.doing || 0} {/* */}
); };