import React, { useState, useEffect } from 'react';
import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, notification } from 'antd';
import moment from 'moment';
import request from '../../../utils/request';
import apis from '../../../services/apis';
import { router } from 'umi';

import OverView from './compenents/OverView'
import Content from './compenents/Content'
import Prompt from 'umi/prompt';


const { Option } = Select
const { TabPane } = Tabs;

const formItemLayout = {
  labelCol: {
    xs: { span: 24 },
    sm: { span: 2 },
  },
  wrapperCol: {
    xs: { span: 24 },
    sm: { span: 16 },
  },
};

function openNotificationWithIcon(type, message) {
  notification[type]({
    message,
    description:
      '',
  });
}

function EditHouse(props) {
  const [tab, setTab] = useState(JSON.parse(localStorage.getItem("tabState"))||'overView')
  //   () => {
  //   if (localStorage.getItem("liveActivePageParams")) {
  //     props.form.setFieldsValue(JSON.parse(localStorage.getItem("liveActivePageParams")));
  //     // const { getFieldDecorator } = JSON.parse(localStorage.getItem("pageParams"))

  //     getList(JSON.parse(localStorage.getItem("liveActivePageParams")))
  //   } else {
  //     localStorage.setItem("liveActivePageParams", JSON.stringify({ pageNum: 1, pageSize: 10 }));
  //     getList({ pageNum: 1, pageSize: 10 });
  //   }
  // })
  const [contentDesc, setContentDesc] = useState(true)
  const companyId = props.location.query.id;
  function tabsCallback(e) {
    localStorage.setItem("tabState", JSON.stringify(e));
    setTab(e)
  }

  // building 回调
  function buildingOnSuccess(e) {
    setBuildingData(e)
  }

  return (
    <>

      <Tabs type="card" value={tab} defaultActiveKey={tab} buttonStyle="solid" onChange={e => tabsCallback(e)}>
        <TabPane tab="统计总况" key="overView" ></TabPane>
        <TabPane tab="统计内容" key="content" ></TabPane>
      </Tabs>
      <div style={{ marginTop: '20px' }}>
        {(tab === 'overView' && <OverView />)}
        {(tab === 'content' && <Content />)}
        {(tab === 'desc' && <Icon type="question-circle" theme="filled" style={{ fontSize: '25px', color: '#F00', marginLeft: '30px' }} />)}

      </div>
      <Prompt message={location =>
        location.pathname.startsWith("/statistical/activity")
          ? true
          : localStorage.removeItem("tabState")} />
    </>
  )
}

const WrappedEditHouseForm = Form.create({ name: 'editHouse' })(EditHouse);

export default WrappedEditHouseForm
