/**
 * @author Lyq
 * 企业管理--监管设置页面
 */
import React from 'react';
import {
    Cascader,
} from 'antd';
// import style from 'styled-components';
import { 
  getSysPoliceList, 
  // saveComRegulatorSet, 
  // getComRegulatorSet 
} from '../../services/api';
export default class Regulator extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.state = {
            regulator: [],
            // info: []
        }
    }

    /******************************生命周期******************************/

    componentWillMount() {
        // this.__getComRegulatorSet()
        this.__getSysPoliceList()

    }
    // //获取已经配置过机构的信息
    // __getComRegulatorSet() {
    //     getComRegulatorSet().then(
    //         res => {
    //             if (res.retType === '0') {
    //                 this.setState({
    //                     info: res.data
    //                 })
    //             }
    //         }
    //     )
    // }
    //获取所有派出所信息
    __getSysPoliceList() {
        getSysPoliceList().then(
            res => {
                const dataStr = JSON.stringify(res.data)
                    .replace(/\"childList\"/g, '"children"')
                    .replace(/\"policeId\"/g, '"value"')
                    .replace(/\"policeName\"/g, '"label"')
                    .replace(/\"children\":\[\],/g, '');
                this.setState({
                    regulator: JSON.parse(dataStr)
                });
            }
        )
    }
    /******************************相关事件******************************/

    render() {
        return (
          <Cascader
            {...this.props}
            options={this.state.regulator}
            placeholder="请选择所属监管机构"
            // changeOnSelect
          />
        );
    }
}