import Header from '@/components/Header' import Slot from '@/components/Header/slot' import SvgIcon from '@/components/SvgIcon' import { tenderStore } from '@/store/mobx' import { ContractTree } from '@/types/contract' import consts from '@/utils/consts' import { CaretDownOutlined } from '@ant-design/icons' import { useAutoTable, useContractTree, useTableExpand } from '@/utils/common/customHooks' import { Button, Dropdown, Menu, Table } from 'antd' import { ColumnsType } from 'antd/lib/table' import React, { useState, useEffect } from 'react' import { useAliveController } from 'react-activation' import styles from './index.module.scss' import { apiContractList } from '@/utils/common/api' import { formatMoney, handleIntoBidsection } from '@/utils/util' const List: React.FC<{}> = () => { const needSubtractHeight = 34 + 32 const [ y ] = useAutoTable(needSubtractHeight) const { clear } = useAliveController() const [ loading, setLoading ] = useState(false) useEffect(() => { // 清除所有的缓存页面 clear() getTree() }, []) const getTree = async () => { setLoading(true) const { data, code = -1 } = await apiContractList(consts.BIDSECTION_TYPE.CONTRACT) if (code === consts.RET_CODE.SUCCESS) { setTree(data) setLoading(false) } } const [ tree, setTree ] = useContractTree() const [ expandedRowKeys, setRowKeys ] = useTableExpand(tree) const handleLinkClick = (id: string, name: string) => { tenderStore.saveTenderInfo({ bidsectionId: id, name }) handleIntoBidsection("contract", id) } const columns: ColumnsType = [ { title: '名称', dataIndex: 'name', key: 'name', width: '25%', render: (text: string, record: ContractTree) => { if (record.isfolder) { return (
{text}
) } else { return (
{record.isEnd ? '└' : '├'} handleLinkClick(record.bidsectionId, record.name)}> {text}
) } } }, { title: '合同总数', dataIndex: 'contracts', key: 'contracts', width: '12%', align: 'right' }, { title: '收入合同金额', dataIndex: 'contractsIncome', key: 'contractsIncome', width: '18%', align: 'right', // eslint-disable-next-line react/display-name render: (text: number) => {formatMoney(text)} }, { 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) => { if (key === 'expanded') { setRowKeys(true) } else { setRowKeys(false) } } const menu = ( 展开所有 收起所有 ) return (
columns={columns} loading={loading} dataSource={tree.children} pagination={false} rowKey={record => record.id} indentSize={20} scroll={{ y }} expandable={{ expandedRowKeys, onExpand: setRowKeys }} bordered />
) } export default List