import React, { useState, useEffect } from 'react';
import { Input ,Tabs,Table,Space, Button} from 'antd';
const { TabPane } = Tabs;

import {connect} from 'umi';

import { objectColumns } from '@/utils/string';

// cdkCode: 998974
// cdkStatus: "0"
// count: 0
// createTime: "Sep 7, 2020 6:12:35 PM"
// deleted: 0
// enable: 0
// extend: ""
// id: "8f8b49308c0b4fb4a0e6b9d6af0aaa1e"
// inviterAddress: "TANGDE2#01#01#01"
// inviterId: "2597108b72f64a5da34892c14f0e6a57"
// inviterName: "啊啊啊"
// inviterPhone: "2536727886@qq.com"
// linkStatus: 1
// numberPlate: "粤A465123"
// securityGuardCommunity: "unkown"
// securityGuardName: "unkown"
// securityGuardPhone: "unkown"
// status: 1
// updateTime: "Sep 7, 2020 6:13:06 PM"
// visitorsName: "销赃"
// visitorsPhone: "18535669865"


const columns = objectColumns( [
  ["User Name", "inviterName"],
  ["Visitor", "visitorsName"],
  ["Security Guard", "securityGuardName"],
  ["Number Plate", "numberPlate"],
  ["time", "updateTime"],
  ["community", "visitorCommunity"],
  ["unit", "inviterAddress"]
  // ["Actions",null, (text: any, record: any) => (<Space size="middle"> <a>Detail</a></Space>)],
])

import TitleSearch from '@/components/TitleSearch/TitleSearch'
import { RA } from '@/utils/method';
const module="VisitorRecord"
const VisitorRecord = (props:any) => {

  const { dispatch, Data } = props;
  const TosVisitorRecordGet = (values: any) => { dispatch({ type: 'tosVisitorRecord/get', playload: values }) };

  useEffect(() => {
    RA(26,{inviterAddress: "", visitorCommunity: ""},module,dispatch)
  }, [])

  const CallBackTitleSearch = (values:any) => {
    console.log(values)

   // visitorCommunity
    TosVisitorRecordGet({
      visitorCommunity: values.inviterAddress,
    })

  }
  const pagination={defaultCurrent:1,total: Data!=null?Data.length:0}
  return (
    <div style={{ width: "100%", minWidth: 1020, padding: 34, backgroundColor: "#ffffff" }}>
      <TitleSearch listkey={['inviterAddress']}
                   list={['Community Name']}
                   community={"serviceCommunityList"}
                   onSubmit={CallBackTitleSearch}/>
      {Data!=null?
      <Table
        loading={false}
        rowKey="id"
        style={{ marginTop: 16 }}
        dataSource={Data.rows}
        columns={columns}
        pagination={pagination}
        // pagination={{ current: 1, total: Data.total}}
      />:null}
    </div>
  );
};

function map(state:any) {
  const { Data} = state[module]
  return { Data}
}
export default connect(map)(VisitorRecord);
// 备注
// 列表缺少访客时间
// 搜索缺少到达时间、访客姓名
