import React from 'react';
import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker } from 'antd';
import './comprehensive.less';
import { patentGetList, patentTypeList } from '../../../dataDic.js';
import { companySearch } from '../../../tools.js';
import ajax from 'jquery/src/ajax/xhr.js'
import $ from 'jquery/src/ajax';
const PatentAddFrom = Form.create()(React.createClass({
getInitialState() {
return {
loading: false,
patentGetOption: [],
patentTypeOption: [],
companyOption: []
};
},
getCompanyList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/user/patent/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));
},
componentWillMount() {
let _me = this;
patentGetList.map(function (item) {
_me.state.patentGetOption.push(
{item.key}
)
});
patentTypeList.map(function (item) {
_me.state.patentTypeOption.push(
{item.key}
)
});
this.getCompanyList();
},
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/user/patent/managerInputPatent",
data: {
"uid": this.state.companyId,
"patentNumber": values.patentNumber,
"patentName": values.patentName,
"patentCatagory": this.state.patentCatagory,
"obtailWay": this.state.obtailWay,
"sortNumber": values.sortNumber,
"authorizationNumber": values.authorizationNumber,
"authorizationDate": this.state.authorizationDate
}
}).done(function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
message.success('保存成功!');
this.props.clickOk();
this.props.form.resetFields();
};
}.bind(this)).always(function () {
this.props.spinState(false);
}.bind(this));
}
});
},
checkIdcardnum(rule, value, callback) {
if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
callback('请输入正确的身份证号!');
} else {
callback();
}
},
render() {
const FormItem = Form.Item;
const { getFieldDecorator } = this.props.form;
const formItemLayout = {
labelCol: { span: 3 },
wrapperCol: { span: 12 },
};
const _me = this;
return (
);
},
}));
const PatentAdd = React.createClass({
getInitialState() {
return {
visible: false,
loading: false
};
},
showModal() {
this.setState({
visible: true,
});
},
handleOk() {
this.setState({
visible: false,
});
this.props.closeDesc(false, true);
},
handleCancel(e) {
this.setState({
visible: false,
});
this.props.closeDesc(false);
},
spinChange(e) {
this.setState({
loading: e
});
},
render() {
return (
);
},
});
export default PatentAdd;