import React, { PureComponent, useState, useEffect } from 'react'
import { Modal, Row, Col, Table, Pagination, Button } from 'antd'
import EnDash from '../EnDash'
import AuthButton from '@/components/AuthButton';

import Style from './style.less'
import HotBlock from '../HotBlock'
import HouseListInfo from '../HouseListInfo'

export default function UserInfo(props) {
  console.log(props.visible, 'houseINfo');
  const [data, setData] = useState({ list: [], total: 0 })
  const [house, setHouse] = useState(false);
  const columns = [
    {
      title: '销售批次名',
      dataIndex: 'salesBatchName',
      key: 'salesBatchName',
      align: 'center',
    },
    {
      title: '楼盘名称',
      dataIndex: 'buildingName',
      key: 'buildingName',
      align: 'center',
    },
    {
      title: '备注',
      dataIndex: 'remark',
      key: 'remark',
      align: 'center',
    },
    {
      title: '预选开始时间',
      dataIndex: 'preselectionStartTime',
      key: 'preselectionStartTime',
      align: 'center',
      render: (x, row) => <><span>{`${moment(row.preselectionStartTime).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
    },
    {
      title: '预选结束时间',
      dataIndex: 'preselectionEndTime',
      key: 'preselectionEndTime',
      align: 'center',
      render: (x, row) => <><span>{`${moment(row.preselectionEndTime).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
    },
    {
      title: '发布状态',
      dataIndex: 'status',
      key: 'status',
      align: 'center',
      render: status => <><span>{status == 0 ? '否' : '是'}</span></>,
    },
    {
      title: '操作',
      dataIndex: '',
      key: '',
      align: 'center',
      render: (text, record) => (
        <AuthButton name="admin.salesBatch.detail.get" noRight={null}>
          <a style={{ color: '#66B3FF' }} onClick={toAddHouse(record)} >查看详情</a>
        </AuthButton>
      ),
    },
  ];

  return (
    <>
      <Modal footer={null} title="个人信息" visible={props.visible} onCancel={props.onCancel} width={800}>
        <AuthButton noRight={null}>
          <Button type="danger" style={{marginLeft:'663px'}} onClick={() => setHouse(true)}>添加房源</Button>
        </AuthButton>
        <Table dataSource={data.records} columns={columns} pagination={false} rowKey="activityList" />
        <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
          <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current}/>
        </div>
      </Modal>
      <HouseListInfo visible={house} onCancel={() => setHouse(false)}/>
    </>
  );
}
