import React from 'react'; import { Input, Modal, Button, message, Select } from 'antd'; import { achievementCategoryList } from '../../dataDic.js'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; const BatchImport = React.createClass({ getInitialState: function () { return { loading: false }; }, showModal() { this.setState({ visible: true, }); }, handleOk(e) { this.setState({ visible: false, }); }, handleCancel(e) { this.setState({ visible: false, }); }, provinceChange(e) { let theArr = []; this.props.provinceList.map((item) => { if (item.id == e) { item.cityList.map((city) => { theArr.push( {city.name} ) }); } }); this.setState({ cityOption: theArr, province: e, city: undefined }); }, cityChange(e) { this.setState({ city: e }); }, //提交 handleSubmit() { let theArr = this.state.inputValue.split(/[\r\n]/g); if (!theArr.length) { return; }; if (theArr.length > 999) { message.warning("数据条数不能多于1000条!"); return; }; let unitName = theArr.join(','); this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/cognizanceRecord/import', data: { unitName: unitName, district: this.state.city || this.state.province, year: this.state.year } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('导入成功!'); this.handleOk(); } else { message.warning(data.error[0].message); }; }.bind(this)); }, reset() { this.setState({ province: undefined, city: undefined, year: undefined, inputValue: undefined }); }, render() { return (
保存, ]} >
地区 年份
公司名称
{ this.setState({ inputValue: e.target.value }); }} />
); } }); export default BatchImport;