//渲染每一个人员item
/**
 * 通过搜索获得地图列表(保安人员)
 */
import React, { Component } from "react";
import { connect } from "dva";
import { Pagination, message, Icon, Modal, Button, Tooltip } from "antd";
// import "../person.less";
const { confirm } = Modal;
@connect((state) => ({
  selectedId: state.command.eventList.selectedId,
  //   tabIndex2: state.command.tabIndex.person.tabIndex2,
}))
export default class EventItem extends Component {
  constructor(props) {
    super(props);
    this.state = {
      data: props.data || [],
      // loadingText: props.data,
    };
  }

  componentDidMount() {}
  componentWillReceiveProps(nextProps) {
    // this.setState({
    //   loadingText: nextProps.loadingText,
    // });
    if (nextProps.data != this.state.data) {
      this.setState({
        data: nextProps.data,
      });
    }
  }
  render() {
    return (
      <div>
        {this.state.data.length > 0 ? (
          this.state.data.map((item, index) => {
            return (
              <div
                key={index}
                className="item"
                onClick={() => {
                  if (item.lnglat) {
                    // if (this.props.selectedId != item.perId) {
                    this.props.dispatch({
                      type: "command/setEventSelectIndex",
                      payload: item.id,
                    });
                  } else {
                    message.warning("该人员暂未定位");
                  }
                }}
              >
                <div
                  className={
                    this.props.selectedId === item.id
                      ? "selected poibox"
                      : "poibox"
                  }
                >
                  {item.name}
                </div>
              </div>
            );
          })
        ) : (
          <div
            style={{ textAlign: "center", fontSize: "14px", color: "#afb0b1" }}
          >
             {this.state.loadingText || "暂无数据"}
          </div>
        )}
      </div>
    );
  }
}
