index.tsx 2.52 KB
import { RESPONSE_CODE } from '@/constants/enum';
import { postProcureBillPage } from '@/services';
import { DownOutlined } from '@ant-design/icons';
import { ProTable } from '@ant-design/pro-components';
import { Button } from 'antd';

export default () => {
  const columns = [
    {
      title: '创建时间',
      dataIndex: 'createTime',
      ellipsis: true,
      width: 180,
      hideInSearch: true,
    },
    {
      title: '创建人',
      dataIndex: 'createByName',
      ellipsis: true,
      width: 180,
      hideInSearch: true,
    },
    {
      title: '总金额',
      dataIndex: 'totalAmount',
      ellipsis: true,
      width: 180,
      hideInSearch: true,
    },
    {
      title: '审核状态',
      dataIndex: 'auditStatusText',
      ellipsis: true,
      width: 180,
      hideInSearch: true,
    },
    {
      title: '审核备注',
      dataIndex: 'auditNotes',
      ellipsis: true,
      width: 180,
      hideInSearch: true,
    },
    {
      title: '备注',
      dataIndex: 'notes',
      ellipsis: true,
      width: 180,
      hideInSearch: true,
    },
  ];

  return (
    <ProTable
      columns={columns}
      request={async (params) => {
        const res = await postProcureBillPage({
          data: {
            ...params,
          },
        });
        if (res.result === RESPONSE_CODE.SUCCESS) {
          return {
            data: res?.data?.data,
            total: res?.data?.total || 0,
          };
        }
        return {
          data: [],
          success: false,
        };
      }}
      rowKey="id"
      pagination={{
        showQuickJumper: true,
      }}
      expandable={{
        expandedRowRender: (record) => (
          <ProTable
            columns={[
              { title: '商品名称', dataIndex: 'totalPrice', key: 'totalPrice' },
              { title: '数量', dataIndex: 'number', key: 'number' },
              { title: '备注', dataIndex: 'notes', key: 'notes' },
            ]}
            headerTitle={false}
            search={false}
            options={false}
            dataSource={record.procureBillDetailList}
            pagination={false}
          />
        ),
      }}
      search={false}
      dateFormatter="string"
      headerTitle="嵌套表格"
      options={false}
      toolBarRender={() => [
        <Button key="show">查看日志</Button>,
        <Button key="out">
          导出数据
          <DownOutlined />
        </Button>,
        <Button key="primary" type="primary">
          创建应用
        </Button>,
      ]}
    />
  );
};