/**
 * 通过搜索获得地图列表(保安人员)
 */
import React, { Component } from "react";
import { connect } from "dva";
import { Pagination, message, Icon, Input, Button, Tooltip } from "antd";
// import "../person.less";
import EventItem from "./EventItem";
@connect((state) => ({
  selectedId: state.command.eventList.selectedId,
  tabIndex2: state.command.tabIndex.event.tabIndex2,
}))
export default class OneEvent extends Component {
  constructor(props) {
    super(props);
    this.state = {
      eventList: [{
        name: '活动事件1',
        lnglat: [106.22445,38.486085],
        describe:'活动事件测试信息',
        id: '1'
      }, {
        name: '活动事件2',
        lnglat: [106.225293,38.485052],
        describe: '活动事件测试信息',
        id: '2'
      }, {
        name: '活动事件3',
        lnglat: [106.222696,38.485312],
        describe: '活动事件测试信息',
        id: '3'
      }],
      tabKey: "1",
      currentKey: null, //主要用于处理tab页面改变，不让重新请求数据
      // searchData: {
      //   pageNumber: 1,
      //   pageSize: 7,
      //   keyWord: null,
      // },
      // personList: [], //人员列表数据
      height: null, //最大高度
      // loadingText: "暂无数据",
    };
  }

  componentDidMount() {
    const height = document.documentElement.clientHeight - 120 - 130 - 40;
    this.setState({ height });
    this.props.dispatch({
      type: "command/fetchEventList",
      payload: {
        list: this.state.eventList,
      },
    });
  }
  componentWillReceiveProps(nextProps) {
    // if (
    //   nextProps.tabIndex2 == this.state.tabKey && //定位当前tab页是自己
    //   nextProps.tabIndex2 !== this.state.currentKey //用于不让数据一直刷新
    // ) {
    //   this.setState({
    //     currentKey: nextProps.tabIndex2,
    //   });
    //   console.log("这里")
    //   // this.getPersonList(this.state.searchData.pageNumber);
    // }
    // if (nextProps.tabIndex2 != this.state.tabKey) {
    //   this.setState({
    //     currentKey: null,
    //   });
    // }
  }

  // getPersonList(pageNumber) {
  //   this.props.dispatch({
  //     type: "command/setEventSelectIndex",
  //     payload: null,
  //   });
  //   this.setState(
  //     {
  //       searchData: {
  //         ...this.state.searchData,
  //         pageNumber,
  //         pageSize: 7,
  //       },
  //       loadingText: "正在加载中...",
  //     },
  //     () => {
  //       getComPerLocationByKeyword({
  //         ...this.state.searchData,
  //       }).then((res) => {
  //         if (res.retType === "0") {
  //           this.setState({
  //             personList: res.data.data,
  //             total: res.data.total,
  //             loadingText: res.data.data.length > 0 ? "加载完成" : "暂无数据",
  //           });
  //           this.props.dispatch({
  //             type: "command/fetchPersonList",
  //             payload: {
  //               list: res.data.data,
  //             },
  //           });
  //         }
  //       });
  //     }
  //   );
  // }

  render() {
    return (
      <div className="data-list">
        <div className="security search-list_command amap_lib_placeSearch">
          <div
            className="list"
            style={{ maxHeight: this.state.height, overflow: "auto" }}
          >
            <EventItem
              data={this.state.eventList}
            />
          </div>
        </div>
      </div>
    );
  }
}
