index.tsx 1.98 KB
import React from "react";
import { Card, Table } from "antd";
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import { createStore } from "@/hooks/moz";
import store from "./useStore";
import Filter from "./components/Filter";
import { CompanyRelationListVO } from "@/pages/finance/CompanyRelationAuth/api";

const { Column } = Table;

export const { Provider, useStore } = createStore(store);

function CompanyRelationAuth() {
  const {
    selected,
    loading,
    setSelectedRelation,
  } = useStore();

  const rowSelection = {
    onChange: (selectedRowKeys: React.Key[], selectedRows: CompanyRelationListVO[]) => {
      console.log(`selectedRowKeys: ${selectedRowKeys}`, "selectedRows: ", selectedRows);
      setSelectedRelation([...selectedRows]);
    },
    getCheckboxProps: (record: CompanyRelationListVO) => ({
      name: String(record.compId),
    }),
  };

  return (
    <PageHeaderWrapper title="往来单位关系设置">
      <Card>
        <Filter />
        <Table
          rowKey="compId"
          dataSource={selected}
          pagination={false}
          loading={loading}
          rowSelection={{
            type: "checkbox",
            ...rowSelection,
          }}
        >
          <Column title="单位名称" dataIndex="compName" />
          <Column title="简称" dataIndex="compShortName" />
          <Column title="类型" dataIndex="compTypeName" />
          <Column title="发票要求" dataIndex="beforeReimburse" render={(before) => `支付${before ? "前" : "后"}`} />
          <Column title="发票金额要求比例" dataIndex="billAmountRatio" render={(ratio) => `${ratio}%`} />
          <Column title="支持结算方式" dataIndex="settleMethodNames" render={(way) => way || "--"} />
          <Column title="对账周期" dataIndex="accountCheckPeriod" render={(date) => (date ? `${date}日` : "--")} />
        </Table>
      </Card>
    </PageHeaderWrapper>
  );
}

export default () => (
  <Provider>
    <CompanyRelationAuth />
  </Provider>
);