/*
 * @Note:
 * @Author: 2058827620@qq.com
 * @Date: 2022-04-03 10:53:25
 */

import { incomedayPage } from '@/services/piles';
import React, { useState, useEffect, useRef } from 'react';
import {
  Modal,
  Table
} from 'antd';
import { ActionType, PageContainer, ProTable } from '@ant-design/pro-components';


import { orderList } from '@/services/order';



export default ({ values, modalOpenState, onModalOpenState }) => {

  const [config, setConfig] = useState(null);
  const [items, setItems] = useState(null);
  const actionRef = useRef<ActionType>();

  useEffect(() => {
    if (actionRef.current) {
      actionRef.current.reload();
    }
  }, [values]);

  const columns = [
    {
      title: '用户ID',
      dataIndex: 'userId',
      search: false,
    },
    {
      title: '设备ID',
      dataIndex: 'deviceId',
      search: false,
    },
    {
      title: '分账日期',
      dataIndex: 'incomeDate',
      search: false,
    },
    // {
    //   title: '服务费金额',
    //   dataIndex: 'serviceAmount',
    //   search: false,
    // },
    // {
    //   title: '用户分成金额',
    //   dataIndex: 'userAmount',
    //   search: false,
    // },
    // {
    //   title: '平台分成金额',
    //   dataIndex: 'platformAmount',
    //   search: false,
    // },
    // {
    //   title: '奖金金额',
    //   dataIndex: 'bonusAmount',
    //   search: false,
    // },

    // {
    //   title: '平台分成配置',
    //   dataIndex: 'setConfig',
    //   search: false,
    // },
    {
      title: '创建时间',
      dataIndex: 'createTime',
      search: false,
    },
  ];

  return (
    <>
      <Modal width="800px" title="收益列表" open={modalOpenState} onOk={() => {
        onModalOpenState(false);
      }} onCancel={() => {
        onModalOpenState(false)
      }}>
        <>
          <ProTable
            actionRef={actionRef}
            rowKey="id"
            key="logList"
            search={{
              labelWidth: 120,
            }}
            request={async (params, sorter, filter) => {
              params.deviceNo = values?.deviceNo
              params.orderId = values?.orderId
              params.userId = values?.userId
              let { data } = await incomedayPage(params)
              return {
                data: data?.records || [],
                total: data?.total,
              };
            }}
            columns={columns}
          />
        </>
      </Modal>
    </>
  );
};