import React from 'react';
import {connect, routerRedux} from 'dva';
import {Button, Input, Upload, Icon, Checkbox, Row, Tooltip, List, Modal,Select} from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import XLSX from './xlsx.core.min';
import {router} from "umi";
import permission from "@/models/permission";
import TitleSearch from "@/components/TitleSearch/TitleSearch";


let go = 0;
let deviceData = [];
let checkUser = 1;

class AccountEdit extends React.Component {

  //构造
  constructor(props) {
    super(props);
    this.state = {
      account: '',
      pw: '',
      pw2: '',
      id: '',
      email: '',
      phone: '',
      status: '',
      radio: 2,
      createUser: '',
      userId: '',
      defaultLevel:'',

      permission: [],
      targetKeys: [],
      deviceData: [],
      visible: false,
      visible2: false,
      newEdit: false,
      level: '',
      levelList: [{label: '四级管理员', value: 1},
        {label: '三级管理员', value: 2},
        {label: '二级管理员', value: 3},
        {label: '一级管理员', value: 4},
        {label: '超级管理员', value: 5}
      ],
      leaderList: [{userAccount: '未选择管理员等级'}],
      adList: ["一级管理员", "二级管理员","三级管理员"],

      leader: '',
      deviceList: [],
      addDevice: '',
      flag: 1,

      used: null,
      newAdd: null,
      strList: [],
    }
  }

  /*-----------------   方法集  ------------------*/
  //显示信息
  info() {
    let _this = this;
    const { used, newAdd, strList} = this.state;
    const strSelect = strList.map((item, index) => (
      <p>{item}</p>
    ));
    Modal.info({
      title: '批量导入结果',
      content: (
        <div>
          <p>绑定<span style={{color:"lightgreen",fontSize:24}}>{newAdd}</span>台设备，
            以下<span style={{color:"red",fontSize:24}}>{used}</span>台设备已被占用</p>
          {strSelect}
        </div>
      ),
      onOk() {
        _this.back();
      },
    });
  }
  //检测是否存在相同用户
  checkUser = () => {
    checkUser = 1;
    if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
      alert("未输入账号名称！");
      checkUser = 0;
      return;
    }
    this.props.dispatch({
      type: 'accountModel/checkAccountByName',
      payload: {
        username: this.state.account,
      },
      callback: (res) => {
        if (res) {
          if (res.error_code == "0000") {
            checkUser = 0;
            alert(res.error_msg);
          }  else if(res.error_code == "0008"){
            alert(res.error_msg);
            window.location.href = '/';
            router.replace('/');
          } else {
            checkUser = 1;
          }
        }
      }
    });
  };
  //跳转到账户页面
  back = () => {
    this.props.dispatch(routerRedux.push({
      pathname: '/AccountManagement/account',
    }))
  };
  //获取所有上级
  getAllLeader = (level) => {
    const params = {
      userLevel: level,
    };
    this.props.dispatch({
      type: 'accountModel/getAllLeader',
      payload: params,
      callback: (res) => {
        if (res) {
          this.setState({
            leaderList: res,
          })
        }
      }
    });
  };
  //两次密码校对
  checkPw = () => {
    if (this.state.pw == null || this.state.pw == undefined || this.state.pw.trim() == '') {
      alert("未输入密码！");
      go = 0;
    } else if (this.state.pw2 == null || this.state.pw2 == undefined || this.state.pw2.trim() == '') {
      alert("未输入确认密码！");
      go = 0;
    } else if (this.state.pw != this.state.pw2) {
      go = 0;
      alert("两次输入的密码不同!");
    } else {
      go = 1;
      this.onSubmit();
    }
  };
  //批量导入设备
  importUserDeviceListExcel = (id) => {
    if (this.state.deviceList != undefined && this.state.deviceList != null && this.state.deviceList != '') {
      this.props.dispatch({
        type: 'deviceModel/importUserDeviceListExcel',
        payload: {
          jsonArr: this.state.deviceList,
          userID: id,
        },
        callback: (res) => {
          if (res) {
            this.setState({
              used: res.data.used,
              newAdd: res.data.integer,
              strList: res.data.strList,
            },() => {
              this.info();
            });
          }
        }
      });
    }else{
      this.back();
    }
  };
  //获取用户拥有的设备
  getUserDevice = (userID) => {
    const params = {
      userID: userID,
    };
    this.props.dispatch({
      type: 'deviceModel/getTargetKeys',
      payload: params,
      callback: (res) => {
        if (res) {
          this.setState({
            targetKeys: res
          });
        }
      }
    });
  };
  //获取操作员拥有的设备
  getDevice = () => {
    const params = {
      userID: this.props.currentUser.userid,
    };
    this.props.dispatch({
      type: 'deviceModel/getUserDevice',
      payload: params,
      callback: (res) => {
        deviceData = [];
        if (res) {
          for (let i = 0; i < res.total; i++) {
            if (res.rows[i].deviceSerialNumber != '' && res.rows[i].deviceSerialNumber != null) {
              deviceData.push({
                key: res.rows[i].deviceID,
                title: res.rows[i].deviceSerialNumber,
              });
            }
          }
        }
      }
    });
  };
  //保存权限信息
  savePermission = (id) => {
    const nowUser = this.props.currentUser;
    this.props.dispatch({
      type: 'permissionModel/saveAccountPermission',
      payload: {
        userName: this.state.account,
        userPassword: this.state.pw,
        permissionArray: this.state.permission,
      },
      callback: (res) => {
        if(res){
          console.log(res);
          if(id == nowUser.userid){
            this.props.currentUser.permission = this.state.permission;
          }
          alert(res.error_msg);
        }
      }
    });
  };
  //获取权限信息
  getPermission = (userID) => {
    const params1 = this.props.location.query;

    const params = {
      userID: params1.tosUserName,
    };
    this.props.dispatch({
      type: 'permissionModel/getAccountPermission',
      payload: params,
      callback: (res) => {
        if (res) {
          this.setState({
            permission: res,
          })
        }
      }
    });
  };
  //绑定单个设备
  addToDeviceList() {
    const oldDeviceList = this.state.deviceList;
    if (!oldDeviceList.includes(this.state.addDevice) && this.state.addDevice != '' && this.state.addDevice != null && this.state.addDevice != undefined) {
      oldDeviceList.push(this.state.addDevice);
    }
    this.setState({
      deviceList: oldDeviceList
    })
  }
  //SN变更
  addDeviceChange(e) {
    this.setState({
      addDevice: e.target.value,
    });
  }
  //用户名变更
  accountChange = (e) => {
    this.setState({account: e.target.value});
  };

  adChange = (e) => {
    this.setState({level: e == undefined?undefined:e+1});
  };

  //密码变更
  pwChange = (e) => {
    this.setState({pw: e.target.value});
  };
  //确认密码变更
  pwChange2 = (e) => {
    this.setState({pw2: e.target.value});
  };
  //联系电话变更
  phoneChange = (e) => {
    this.setState({phone: e.target.value});
  };
  //联系邮箱变更
  emailChange = (e) => {
    this.setState({email: e.target.value});
  };
  //提交前验证
  onGo = () => {
    if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
      alert("未输入账号名称！");
      checkUser = 0;
      return;
    }
    this.props.dispatch({
      type: 'accountModel/checkAccountByName',
      payload: {
        username: this.state.account,
      },
      callback: (res) => {
        if (res) {
          console.log(res);
          if (res.error_code == "0000") {
            checkUser = 0;
            alert(res.error_msg);
          } else if(res.error_code == "0008"){
            alert(res.error_msg);
            window.location.href = '/';
            router.replace('/');
          } else {
            this.checkPw();
          }
        }
      }
    });
  };
  //提交
  onSubmit = () => {
    if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
      alert("未输入账号名称！");
      checkUser = 0;
      return;
    }
    this.props.dispatch({
      type: 'accountModel/checkAccountByName',//请求一次，通过用户名查表
      payload: {
        username: this.state.account,
      },
      callback: (res) => {
        if (res) {
          console.log(res);
          if (res.error_code == "0000") {
            // if(this.state.newEdit==true){
            //   checkUser = 0;
            //   alert(res.error_msg);
            // }else {
              let oneself = 0;
              if(this.state.id!=null&&(this.state.id == this.props.currentUser.userid)){
                oneself = 1;
              }
              const params = {
            /*    userAccount: this.state.account,
                userID: this.state.id ? this.state.id : null,
                userPhone: this.state.phone,

                userPassword: this.state.newEdit == true ? this.state.pw : null,
                userEmail: this.state.email,
                createUser: this.state.createUser != undefined ? this.state.createUser : this.state.userId,
                userLevel: this.state.level,*/
                userLeader: this.state.leader,
                oneself: oneself,

                tosUserName:this.state.account,
                id:this.state.id ? this.state.id : null,
                tosUserPhone:this.state.phone,
                userStatus: this.state.status ? this.state.status : 1,
                tosUserPwd:this.state.newEdit == true ? this.state.pw : null,
                tosUserEmail:this.state.email,
                tosuserLevel:this.state.level,
                tosUserToCompany:this.state.createUser != undefined ? this.state.createUser : this.state.userId,
                tosUserServiceCell:this.state.leader,
              };
              this.props.dispatch({
                type: 'accountModel/saveAccount',// 第二次请求，查不到用户的时候，保存新的用户
                payload: params,
                callback: (res) => {
                  console.log(res);
                  if (res.error_code == "0000") {
                    // alert(res.error_msg);
                    console.log("data",res.data);
                    // this.importUserDeviceListExcel(res.data.userID);
                    this.savePermission(res.data.userID);// 第三次请求，插入权限表格
                  } else if (res.error_code == "0001") {
                    alert(res.error_msg);
                  }  else if (res.error_code == "0002") {
                    alert(res.error_msg);
                  }  else if(res.error_code == "0008"){
                    alert(res.error_msg);
                    window.location.href = '/';
                    router.replace('/');
                  } else {
                    alert("提交失败！");
                  }
                }
              });
            // }
          } else if(res.error_code == "0008"){
            alert(res.error_msg);
            window.location.href = '/';
            router.replace('/');
          } else {
            checkUser = 1;
            let oneself = 0;
            if(this.state.id!=null&&(this.state.id == this.props.currentUser.userid)){
              oneself = 1;
            }
            const params = {

              tosUserName:this.state.account,
              id:this.state.id ? this.state.id : null,
              tosUserPhone:this.state.phone,
              userStatus: this.state.status ? this.state.status : 1,
              tosUserPwd:this.state.newEdit == true ? this.state.pw : null,
              tosUserEmail:this.state.email,
              tosuserLevel:this.state.level,
              tosUserToCompany:this.state.createUser != undefined ? this.state.createUser : this.state.userId,
              tosUserServiceCell:this.state.leader,
              userLevel: this.state.level,
              userLeader: this.state.leader,
              oneself: oneself,

            /*  userAccount: this.state.account,
              userID: this.state.id ? this.state.id : null,
              userPhone: this.state.phone,
              userStatus: this.state.status ? this.state.status : 1,
              userPassword: this.state.newEdit == true ? this.state.pw : null,
              userEmail: this.state.email,
              createUser: this.state.createUser != undefined ? this.state.createUser : this.state.userId,
              userLevel: this.state.level,
              userLeader: this.state.leader,
              oneself: oneself,*/
            };
            this.props.dispatch({
              type: 'accountModel/saveAccount',
              payload: params,
              callback: (res) => {
                console.log(res);
                if (res.error_code == "0000") {
                  alert(res.error_msg);
                  console.log("data",res.data);
                  this.importUserDeviceListExcel(res.data.userID);
                  this.savePermission(res.data.userID);  //第三次请求，RPC保存权限表格
                } else if (res.error_code == "0001") {
                  alert(res.error_msg);
                }  else if (res.error_code == "0002") {
                  alert(res.error_msg);
                }  else if(res.error_code == "0008"){
                  alert(res.error_msg);
                  window.location.href = '/';
                  router.replace('/');
                } else {
                  alert("提交失败！");
                }
              }
            });
          }
        }
      }
    });
  };
  //初始化
  componentDidMount() {
    this.getDevice();
    const nowUser = this.props.currentUser.userid;
    if (this.props.location.query != null) {
      const params = this.props.location.query;
      if (params.userID == null || params.userID == '' || params.userID == undefined) {
        this.setState({
          newEdit: true
        })
      }
      this.setState({
        level:params.tosuserLevel,
        account: params.tosUserName,
        pw: params.userPassword,
        id: params.id,
        email: params.tosUserEmail,
        phone: params.tosUserPhone,
        status: params.deleted,
       /* level: params.userLevel,
        account: params.userAccount,
        pw: params.userPassword,
        id: params.userID,
        email: params.userEmail,
        phone: params.userPhone,
        status: params.userStatus,*/
        userId: nowUser,
        createUser: params.createUser,
        leader: params.userLeader ? params.userLeader.toString() : params.userLeader,
      },() => {
        if(this.props.currentUser.userid==this.state.id){
          this.setState({
            flag: 0,
          })
        }
        this.setState({
          flag: 1,
        })
      });
      if (params.id != '' && params.id != null) {
        this.getPermission(params.account);
        this.getUserDevice(params.account);
      }
      if (params.userLevel != '' && params.userLevel != null) {
        this.getAllLeader(params.userLevel);
      }
    }
  }
  //多选框
  onChange(checkedValues) {
    this.setState({
      permission: checkedValues,
    });
  }

  /*--------------------------------------*/
  columns = [
    {
      title: '设备串号',
      dataIndex: 'deviceName',
      key: 'deviceName',
    },
  ];

//渲染
  render() {
    const {
      adList,defaultLevel,level,  phone, email, permission, account, newEdit, deviceList, pw, pw2, flag
    } = this.state;
    const adSelect = adList.map((item, index) => (
      <Select.Option value={index}>{item}</Select.Option>
    ));
    const uploadprops = {
      accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
      name: 'file',
      headers: {
        authorization: 'authorization-text',
      },
      showUploadList: false,
      beforeUpload: (file, fileList) => {
        const rABS = true;
        const f = fileList[0];
        const reader = new FileReader();
        reader.onload = e => {
          let dataResult = e.target.result;
          if (!rABS) dataResult = new Uint8Array(dataResult);
          const workbook = XLSX.read(dataResult, {
            type: rABS ? 'binary' : 'array',
          });
          const firstWorksheet = workbook.Sheets[workbook.SheetNames[0]];
          const jsonArr = XLSX.utils.sheet_to_json(firstWorksheet, {header: 1});
          const oldDeviceList = this.state.deviceList;
          for (let i = 0; i < jsonArr.length; i++) {
            //去重
            if (!oldDeviceList.includes(jsonArr[i][0]) && jsonArr[i][0] != '' && jsonArr[i][0] != null && jsonArr[i][0] != undefined) {
              oldDeviceList.push(jsonArr[i][0]);
            }
          }
          this.setState({
            deviceList: oldDeviceList
          })
        };
        if (rABS) reader.readAsBinaryString(f);
        else reader.readAsArrayBuffer(f);
        return false;
      },
    };
    const CallBackTitleSearch = (comment: any)=>{
      console.log(comment)
    }
    return (
      <div className={styles.body}>
        <div style={{marginTop: 48}}>
          <div className={styles.detailsBox}>
            <div>
              <span className={styles.detailsContent}>账号</span>
              {newEdit != true ?
              <Input className={styles.input}
                     value={account}
                     onChange={(e) => this.accountChange(e)}
                     disabled
                     placeholder="请输入账号名"/>:''}
              {newEdit == true ?
                <Input className={styles.input}
                       value={account}
                       onChange={(e) => this.accountChange(e)}
                       placeholder="请输入账号名"/>:''}
            </div>
            <div>
              {newEdit == true ?
                <span className={styles.detailsContent}>密码</span> : ''}
              {newEdit == true ?
                <div style={{display: "inline-block"}}>
                  <Input.Password className={styles.input}
                                  onChange={(e) => this.pwChange(e)}
                                  value={pw}
                                  placeholder="请输入密码"/>
                  <Input.Password className={styles.input}
                                  onChange={(e) => this.pwChange2(e)}
                                  value={pw2}
                                  placeholder="请再次输入密码"/>
                </div>
                : ''}
            </div>
            <div>
              <span className={styles.detailsContent}>联系方式</span>
              <Input className={styles.input} value={phone} onChange={(e) => this.phoneChange(e)}
                     placeholder="请输入联系电话"/>
              <Input className={styles.input} value={email} onChange={(e) => this.emailChange(e)}
                     placeholder="请输入联系邮箱"/>
            </div>


            {newEdit != true ?
              <div>
                <span className={styles.detailsContent}>用户等级:</span>
                <Select className={styles.input} disabled placeholder="用户等级" value={defaultLevel} onChange={(e) => this.adChange(e)}
                        allowClear={true}>{adSelect}</Select>
              </div>:''}

            {newEdit == true ?
              <div>
                <span className={styles.detailsContent}>用户等级:</span>
                <Select className={styles.input}  placeholder="用户等级" value={level} onChange={(e) => this.adChange(e)}
                        allowClear={true}>{adSelect}</Select>
              </div>:''}

            <TitleSearch
              listkey={["providerName"]}
              list={["Service Provider"]}
              community={"serviceCommunityList"}
              onSubmit={CallBackTitleSearch} />



            <div>
              <div style={{marginTop:20}}>
                {/*<span className={styles.detailsContent}*/}
                {/*      style={{position: "relative", marginTop:20,bottom: 250}}>权限配置</span>*/}
                {flag == 0?
                  <div style={{display: "inline-block"}}>
                    <Checkbox.Group style={{width: '100%'}}
                                    onChange={(e) => this.onChange(e)}
                                    value={permission}>
                      <Row>
                        {/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>我的设备</span>*/}
                        <Checkbox value="1" disabled>数据中心</Checkbox>
                        <Checkbox value="2" disabled>查看life用户</Checkbox>
                        <Checkbox value="3" disabled>编辑life用户</Checkbox>
                        <Checkbox value="4" disabled>添加业主档案</Checkbox>
                      </Row>
                      <Row>
                        {/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>广告推送</span>*/}
                        <Checkbox value="5" disabled>注销业主档案</Checkbox>
                        <Checkbox value="6" disabled>查看服务商</Checkbox>
                        <Checkbox value="7" disabled>编辑服务商</Checkbox>
                        <Checkbox value="8" disabled>添加服务商</Checkbox>
                      </Row>
                      <Row>
                        {/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>警报提醒</span>*/}
                        <div style={{margin: "5px 0px 5px 0px"}}>
                          <Checkbox value="9" disabled>注销服务商</Checkbox>
                          <Checkbox value="10" disabled>查看物业费记录</Checkbox>
                          <Checkbox value="11" disabled>添加物业费记录</Checkbox>
                          <Checkbox value="12" disabled>查看物业服务</Checkbox>
                        </div>
                        <div style={{margin: "5px 0px 5px 0px"}}>
                          <Checkbox value="13" disabled>编辑物业服务</Checkbox>
                          <Checkbox value="14" disabled>注销物业服务</Checkbox>
                          <Checkbox value="15" disabled>查看订单</Checkbox>
                          <Checkbox value="16" disabled>编辑订单</Checkbox>
                        </div>
                      </Row>
                      <Row>
                        {/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>创建后台账号</span>*/}

                        <Checkbox value="17" disabled>查看合同</Checkbox>
                        <Checkbox value="18" disabled>编辑合同</Checkbox>
                        <Checkbox value="19" disabled>添加合同</Checkbox>
                        <Checkbox value="20" disabled>查看小区</Checkbox>
                      </Row>
                      <Row>
                        {/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}

                        <Checkbox value="21" disabled>编辑小区</Checkbox>
                        <Checkbox value="22" disabled>添加小区</Checkbox>
                        <Checkbox value="23" disabled>查看公告</Checkbox>
                        <Checkbox value="24" disabled>编辑公告</Checkbox>
                      </Row>
                      <Row>
                        {/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}

                        <Checkbox value="25" disabled>添加公告</Checkbox>
                        <Checkbox value="26" disabled>查看访客记录</Checkbox>
                        <Checkbox value="27" disabled>查看预定服务</Checkbox>
                        <Checkbox value="28" disabled>编辑预定服务</Checkbox>
                      </Row>
                      <Row>
                        {/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}

                        <Checkbox value="29" disabled>添加预定服务</Checkbox>
                        <Checkbox value="30" disabled>查看后台账号</Checkbox>
                        <Checkbox value="31" disabled>配置后台账号</Checkbox>
                      </Row>
                    </Checkbox.Group>
                  </div>:''}
                {flag == 1?
                <div style={{display: "inline-block"}}>
                  <Checkbox.Group style={{width: '100%'}}
                                  onChange={(e) => this.onChange(e)}
                                  value={permission}>
                    <Row>
                      <span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
                      <Checkbox value="1" >数据中心</Checkbox>
                      <Checkbox value="2" >查看life用户</Checkbox>
                      <Checkbox value="3" >编辑life用户</Checkbox>
                      <Checkbox value="4" >添加业主档案</Checkbox>
                    </Row>
                    <Row>
                      <span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
                      <Checkbox value="5" >注销业主档案</Checkbox>
                      <Checkbox value="6" >查看服务商</Checkbox>
                      <Checkbox value="7" >编辑服务商</Checkbox>
                      <Checkbox value="8" >添加服务商</Checkbox>
                    </Row>
                    <Row>
                      <span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
                      <div style={{margin: "5px 0px 5px 0px"}}>
                        <Checkbox value="9" >注销服务商</Checkbox>
                        <Checkbox value="10" >查看物业费记录</Checkbox>
                        <Checkbox value="11" >添加物业费记录</Checkbox>
                        <Checkbox value="12" >查看物业服务</Checkbox>
                      </div>
                      <div style={{margin: "5px 0px 5px 0px"}}>
                        <Checkbox value="13" >编辑物业服务</Checkbox>
                        <Checkbox value="14" >注销物业服务</Checkbox>
                        <Checkbox value="15" >查看订单</Checkbox>
                        <Checkbox value="16" >编辑订单</Checkbox>
                      </div>
                    </Row>
                    <Row>
                      <span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>

                      <Checkbox value="17" >查看合同</Checkbox>
                      <Checkbox value="18" >编辑合同</Checkbox>
                      <Checkbox value="19" >添加合同</Checkbox>
                      <Checkbox value="20" >查看小区</Checkbox>
                    </Row>
                    <Row>
                      <span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>

                      <Checkbox value="21" >编辑小区</Checkbox>
                      <Checkbox value="22" >添加小区</Checkbox>
                      <Checkbox value="23" >查看公告</Checkbox>
                      <Checkbox value="24" >编辑公告</Checkbox>
                    </Row>
                    <Row>
                      <span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>


                      <Checkbox value="25" >添加公告</Checkbox>
                      <Checkbox value="26" >查看访客记录</Checkbox>
                      <Checkbox value="27" >查看预定服务</Checkbox>
                      <Checkbox value="28" >编辑预定服务</Checkbox>
                    </Row>
                    <Row>
                      <span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>


                      <Checkbox value="29" >添加预定服务</Checkbox>
                      <Checkbox value="30" >查看后台账号</Checkbox>
                      <Checkbox value="31" >配置后台账号</Checkbox>
                    </Row>

                  </Checkbox.Group>
                </div>:''}
              </div>
            </div>
          {/*  <div>
              <span className={styles.detailsContent}>绑定设备</span>
              <div style={{position: "relative", left: 110, bottom: 50}}>
                <Input
                  className={styles.input}
                  onChange={(e) => this.addDeviceChange(e)}
                  placeholder="请输入设备串号"/>
                <Button className={styles.button1}
                        onClick={() => this.addToDeviceList()}>添加</Button>
                <Upload {...uploadprops}>
                  <Tooltip title="">
                    <Button className={styles.button1}
                            style={{margin: 5, width: 120}}>
                      <Icon type="upload"/>批量导入
                    </Button>
                  </Tooltip>
                </Upload>
                <br/>
                <List
                  style={{width: 240}}
                  size="small"
                  header={<div>设备串号</div>}
                  bordered
                  dataSource={deviceList}
                  renderItem={item => <List.Item>{item}</List.Item>}
                />
              </div>
            </div>*/}
            <div>
              {newEdit == false ?
                <Button className={styles.button1}
                        onClick={() => this.onSubmit()}>提交</Button> : ''}
              {newEdit == true ?
                <Button className={styles.button1}
                        // onClick={() => this.onGo()}>提交</Button> : ''}
                        onClick={() => this.onSubmit()}>提交</Button> : ''}
              <Button className={styles.button1} onClick={() => this.back()}>返回</Button>
            </div>
          </div>
        </div>
      </div>
    );
  }
}

export default connect(({user}: ConnectState) => ({
  currentUser: user.currentUser,
}))(AccountEdit);
