import React, { useState, useEffect } from 'react'; import { Utils, Drawer, Button, ProTable, Space, Divider, AppContainer } from 'knowdesign'; import { CloseOutlined } from '@ant-design/icons'; import moment from 'moment'; import api from '../../api'; import { defaultPagination } from './index'; import PlanDrawer from './PlanDrawer'; import { timeFormat } from '../../constants/common'; interface PropsType extends React.HTMLAttributes { onClose: () => void; visible: boolean; } const HistoryDrawer: React.FC = ({ onClose, visible }) => { const [global] = AppContainer.useGlobalValue(); const [loading, setLoading] = useState(true); const [pagination, setPagination] = useState(defaultPagination); const [data, setData] = useState([]); const [planDetailData, setPlanDetailData] = useState({}); const [planVisible, setPlanVisible] = useState(false); useEffect(() => { getList(); }, []); const columns = () => [ { title: '执行时间', dataIndex: 'begin', key: 'begin', render: (t: number) => (t ? moment(t).format(timeFormat) : '-'), }, { title: '结束时间', dataIndex: 'end', key: 'end', render: (t: number) => (t ? moment(t).format(timeFormat) : '-'), }, // { // title: 'CPU均衡率', // dataIndex: 'cpu', // render: (text: any, row: any) => { // return `${row?.sub?.cpu?.successNu} (已均衡) / ${row?.sub?.cpu?.failedNu} (未均衡)` // } // }, { title: ( Disk{'(已均衡丨未均衡)'} ), dataIndex: 'disk', render: (text: any, row: any) => { // return `${row?.sub?.disk?.successNu} 丨 ${row?.sub?.disk?.failedNu}`; return (
{row?.sub?.disk?.successNu} {row?.sub?.disk?.failedNu}
); }, }, { title: ( BytesIn{'(已均衡丨未均衡)'} ), dataIndex: 'bytesIn', render: (text: any, row: any) => { // return `${row?.sub?.bytesIn?.successNu} 丨 ${row?.sub?.bytesIn?.failedNu}`; return (
{row?.sub?.bytesIn?.successNu} {row?.sub?.bytesIn?.failedNu}
); }, }, { title: ( BytesOut{'(已均衡丨未均衡)'} ), dataIndex: 'bytesOut', render: (text: any, row: any) => { // return `${row?.sub?.bytesOut?.successNu} 丨 ${row?.sub?.bytesOut?.failedNu}`; return (
{row?.sub?.bytesOut?.successNu} {row?.sub?.bytesOut?.failedNu}
); }, }, { title: '操作', width: 150, fixed: 'right', render: (text: any, row: any) => { return ( ); }, }, ]; const getList = (query = {}) => { const queryParams = { pageNo: pagination.current, pageSize: pagination.pageSize, ...query, }; setLoading(true); Utils.request(api.getBalanceHistory(global?.clusterInfo?.id), { method: 'POST', data: queryParams, }).then( (res: any) => { const { pageNo, pageSize, pages, total } = res.pagination; setPagination({ ...pagination, current: pageNo, pageSize, total, }); const dataDe = res?.bizData || []; const dataHandle = dataDe.map((item: any) => { return { ...item, }; }); setData(dataHandle); setLoading(false); }, () => setLoading(false) ); }; const CheckDetail = (jobId: any) => { Utils.request(api.getBalancePlan(global?.clusterInfo?.id, jobId), { method: 'GET', }).then((res: any) => { const dataDe = res || {}; setPlanDetailData(dataDe); setPlanVisible(true); }); }; const onTableChange = (curPagination: any) => { getList({ pageNo: curPagination.current, pageSize: curPagination.pageSize }); }; return ( <> setPlanVisible(false)} detailData={planDetailData} isPrevew={false} />