import React from 'react'; import { Icon, Modal, Button, Form, Upload, message, Input, Spin, Select } from 'antd'; import './comprehensive.less'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; import { getBase64, beforeUpload, companySearch } from '../../../tools.js'; class Avatar extends React.Component { constructor(props) { super(props); this.state = { imageUrl: '' } } componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.state.fileList = []; }; } handleChange(info) { if (!this.props.oid || this.props.oid === "") { message.warning('请先选择公司!'); return; }; if (info.file.status === 'done') { if (!info.file.response.error.length) { message.success(`${info.file.name} 文件上传成功!`); } else { message.warning(info.file.response.error[0].message); return; }; getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl })); this.props.urlData(info.file.response.data); } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); }; this.setState({ fileList: info.fileList.slice(-1) }); } render() { return ( ); } }; const PatentAddFrom = Form.create()(React.createClass({ getCompanyList() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/getUnitNames", success: function (data) { if (data.error.length || !data.data) { return; }; let _me = this; for (var item in data.data) { _me.state.companyOption.push( {data.data[item]} ) }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getSalesmanList() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/salesman", success: function (data) { if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } return; }; let _me = this, theArr = []; for (var item in data.data) { theArr.push( {data.data[item]} ) }; this.setState({ salesmanOption: theArr }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getContactsList(theUid) { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/findAllContacts", data: { uid: theUid || this.state.uid }, success: function (data) { let theOption = []; if (data.error.length || !data.data) { return; }; for (let item in data.data) { let theData = data.data[item]; theOption.push( {theData.name} ); }; this.setState({ contactsOption: theOption }); }.bind(this), }); }, getInitialState() { return { loading: false, companyOption: [] // firstCheck: 0, // secondCheck: 0, // thirdCheck: 0 }; }, componentWillMount() { this.getCompanyList(); this.getSalesmanList(); }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/patent/apply", data: { 'uid': values.companyName, 'contacts': values.contacts, 'firstInventorIdNumber': values.firstInventorID, 'firstInventorName': values.firstInventorName, 'patentDes': values.intro, 'secondInventorName': values.secondInventorName, 'office': values.office, 'thirdInventorName': values.thirdInventorName, 'patentProryStatementUrl': this.state.avatarUrl, 'salesman': values.salesman } }).done(function (data) { if (data.error && !data.error.length) { message.success('保存成功!'); this.props.okClick(); this.props.closeModal(); this.props.form.resetFields(); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); }.bind(this)); } }); }, avatarUrl(e) { this.state.avatarUrl = e; }, render() { const FormItem = Form.Item; const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 18 }, }; const _me = this; return (
{getFieldDecorator('companyName', { rules: [{ required: true, message: '请选择一个公司!' }], initialValue: this.state.companyName || null })( )} {getFieldDecorator('contacts', { rules: [{ required: true, message: '请选择一个联系人!' }], initialValue: this.state.contacts || null })( )} {getFieldDecorator('intro', { initialValue: this.state.intro || null })( )} {getFieldDecorator('office')( )}

第一发明人

{getFieldDecorator('firstInventorName')( )} {getFieldDecorator('firstInventorID')( )}

第二发明人

{getFieldDecorator('secondInventorName')( )}

第三发明人

{getFieldDecorator('thirdInventorName')( )} {getFieldDecorator('avatar')( )}

{ window.open(globalConfig.context + "/api/admin/patent/downloadTemplateFile?sign=patent_prory_statement") }}>模板下载

{getFieldDecorator('salesman', { rules: [{ required: true, message: '请选择一个营销员!' }], initialValue: this.state.salesman || null })( )}
); }, })); const PatentAdd = React.createClass({ getInitialState() { return { visible: false, loading: false }; }, showModal() { this.setState({ visible: true, }); }, handleOk() { this.setState({ visible: false, }); }, handleCancel(e) { this.setState({ visible: false, }); this.props.closeDesc(false); }, spinChange(e) { this.setState({ loading: e }); }, render() { return (
{ this.props.closeDesc(false, true) }} />
); }, }); export default PatentAdd; // 告知专利局是否公布