import React, { Component } from "react"; import { qualify_appealOrg } from '../../../../services/bkt/qualify'; import { Input, Cascader, Form } from "antd"; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 }, }; @Form.create() export default class AppealModal extends Component { constructor(props) { super(props); this.state = { options: [] } } componentWillMount() { this._getAppealOrg(); } componentDidMount() { this.props.onGetForm && this.props.onGetForm(this.props.form); } _getAppealOrg = (parentOrgId = '', cb) => { const { personApplyId } = this.props; qualify_appealOrg({ data: { parentOrgId, personApplyId } }).then(res => { if (!parentOrgId) { const options = res.data.map(item => { return { ...item, value: `${item.id} ${item.orgName} ${item.areaCode} ${false}`, label: item.area, isLeaf: false }; }); this.setState({ options }); } cb && cb(res.data); }); } _loadData = selectedOptions => { const targetOption = selectedOptions[selectedOptions.length - 1]; // if(targetOption.isLeaf) { // return; // } targetOption.loading = true; this._getAppealOrg(targetOption.id, children => { targetOption.loading = false; if (children.length > 0) { targetOption.children = children.map(item => { let label = ('' + targetOption.areaCode).slice(4) == '00' ? item.area : item.orgName; const isLeaf = ('' + targetOption.areaCode).slice(4) != '00'; return { ...item, value: `${item.id} ${item.orgName} ${item.areaCode} ${isLeaf}`, label, isLeaf }; }); } else { targetOption.children = ''; } this.setState({ options: [...this.state.options], }); }); } render() { const { getFieldDecorator } = this.props.form; return (
{getFieldDecorator('appealContext', { initialValue: '', rules: [ { required: true, message: '请填写申诉内容' } ] })( )} {getFieldDecorator('appealInfoArr', { initialValue: '', rules: [ { required: true, message: '请选择申诉机构' } ] })( { // console.log(value, selectedOptions); // const values = this.props.form.getFieldsValue(); // console.log(values); // this.props.onChangeValue(values); // }} /> )}
); } }