import React, { Component, useState, useEffect } from 'react';
import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions } from 'antd';
import BuildSelect from '../../../components/SelectButton/BuildSelect'
import { func } from 'prop-types';
import request from '../../../utils/request';
import apis from '../../../services/apis';
// const { Option } = Select;

const UserBehavior = (props) => {
  const [data, setData] = useState({ records: [] })
  useEffect(() => {
    IntentionUsers()
    // getUserBehaviorProfile(formatDate(props.startDate, props.endDate))

  }, [])
  function IntentionUsers (params) {
    request({
      ...apis.indexEcharts.intentionUsers,
      params: { pageSize: 9999, ...params }
    }).then((data) => {
      setData(data)
    })
  }

  // getIntentionUsers({ commit }, payload) {
  //   return new Promise((resolve, reject) => {
  //     request({
  //       ...apis.indexEcharts.intentionUsers,
  //       params: { pageSize: 9999, ...payload }
  //     }).then((data) => {
  //       resolve(data.records)
  //     }).catch((err) => {
  //       reject(err)
  //     })
  //   })
  // },
  // const dataSource = [
  //   {
  //     key: '1',
  //     name: '胡彦斌',
  //     age: 32,
  //     address: '西湖区湖底公园1号',
  //   },
  //   {
  //     key: '2',
  //     name: '胡彦祖',
  //     age: 42,
  //     address: '西湖区湖底公园1号',
  //   },
  // ];
  
  const columns = [
    {
      title: '用户姓名',
      dataIndex: 'personName',
      key: 'personName',
      width: '25%',
    },
    {
      title: '手机号',
      dataIndex: 'phone',
      key: 'phone',
      width: '25%',
    },
    {
      title: '意向楼盘',
      dataIndex: 'buildingName',
      key: 'buildingName',
      width: '25%',
    },
    {
      title: '意向值',
      dataIndex: 'intention',
      key: 'intention',
      width: '25%',
    },
  ];

  function handleBuildingChange (e) {
    IntentionUsers({ buildingId: e })
  }
  return (
    <>
      <div>
      <p style={{fontSize:'0.12rem',fontWeight:'600'}}>意向客户</p>

        <BuildSelect slot='action' onChange={(e => handleBuildingChange(e))}></BuildSelect>

        <Table rowKey="IntentionalCustomers" dataSource={data.records} columns={columns} style={{marginTop:'15px'}} pagination={false} scroll={{ y: 500 }} />

      </div>

    </>
  )
}

export default UserBehavior;