import Header from '@/components/Header' import Slot from '@/components/Header/slot' import SvgIcon from '@/components/SvgIcon' import { ContractTree } from '@/types/contract' import consts from '@/utils/consts' import { CaretDownOutlined } from '@ant-design/icons' import { Button, Dropdown, Menu, message, Table } from 'antd' import { ColumnsType } from 'antd/lib/table' import React, { useEffect, useState } from 'react' import { useActivate } from 'react-activation' import { RouteComponentProps } from 'react-router' import { Link } from 'react-router-dom' import { apiContractList } from './api' import styles from './index.module.scss' import './index.scss' const List: React.FC = () => { const [ tree, setTree ] = useState({ bidsectionId: '', children: [], childsTotal: 0, contracts: 0, contractsIncome: '', contractsIncomeProgress: '', contractsPaid: '', contractsPay: '', contractsPayProgress: '', contractsReturned: '', csrf: '', hasFolder: false, id: '', isBid: false, isEnd: false, isfolder: 0, name: '', parentId: '', projectId: '' }) const getTree = async () => { const { data = {}, code = -1 } = await apiContractList() if (code === consts.RET_CODE.SUCCESS) { setTree(data) } } const columns:ColumnsType = [ { title: '名称', dataIndex: 'name', key: 'name', width: '25%', render: (text: string, record: ContractTree) => { if (record.isfolder) { return
{text}
} else { return
{record.isEnd ? '└' : '├'} {text}
} } }, { title: '合同总数', dataIndex: 'contracts', key: 'contracts', width: '12%', align: 'right' }, { title: '收入合同金额', dataIndex: 'contractsIncome', key: 'contractsIncome', width: '18%', align: 'right' }, { title: '回款进度', dataIndex: 'contractsIncomeProgress', key: 'contractsIncomeProgress', width: '12%', align: 'center' }, { title: '支出合同金额', dataIndex: 'contractsPay', key: 'contractsPay', width: '18%', align: 'right' }, { title: '支付进度', dataIndex: 'contractsPayProgress', key: 'contractsPayProgress', width: '12%', align: 'center' } ] const handleMenuClick = ({ key }: any) => { message.info(`Click on item ${key}`) } const menu = ( 展开所有 收起所有 ) useActivate(() => { getTree() }) useEffect(() => { getTree() }, []) return (
columns={columns} dataSource={tree.children} pagination={false} rowKey={record => record.id} indentSize={20} bordered >
) } export default List