import React from 'react';
import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker, Upload } from 'antd';
import { intellectualGetList, catagoryList } from '../../../../dataDic.js';
import { beforeUploadFile, newDownloadFile, getPreview } from '../../../../tools.js';
import ajax from 'jquery/src/ajax/xhr.js'
import $ from 'jquery/src/ajax';
import moment from 'moment';
const IntellectualDescFrom = Form.create()(React.createClass({
loadData(id, type) {
this.props.spinState(true);
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/intellectualDetail",
data: {
id: id ? id : this.props.data.id,
type: type != undefined && type != null ? type : this.props.data.type
}
}).done((data) => {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
this.state.data = {};
} else { this.state.data = data.data };
}).always(function () {
this.props.spinState(false);
}.bind(this));
},
getInitialState() {
return {
loading: false,
intellectualGetOption: [],
catagoryOption: [],
data: {}
};
},
componentWillMount() {
let _me = this;
intellectualGetList.map(function (item) {
_me.state.intellectualGetOption.push(
{item.key}
)
});
catagoryList.map(function (item) {
_me.state.catagoryOption.push(
{item.key}
)
});
if (this.props.data.id && this.props.data.type != undefined && this.props.data.type != null) {
this.loadData();
};
},
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/intellectual",
data: {
id: this.props.data.id,
uid: this.props.uid,
intellectualPropertyNumber: values.intellectualPropertyNumber,
intellectualPropertyName: values.intellectualPropertyName,
catagory: values.catagory,
obtainWay: values.obtainWay,
sortNumber: values.sortNumber,
authorizationNumber: values.authorizationNumber,
authorizationDateFormattedDate: values.authorizationDate._i || this.state.authorizationDateFormattedDate,
propertyRightUrl: this.state.propertyRightUrl
}
}).done(function (data) {
if (!data.error.length) {
message.success('保存成功!');
} else {
message.warning(data.error[0].message);
}
}.bind(this)).always(function () {
this.props.spinState(false);
this.props.clickOk();
this.props.form.resetFields();
}.bind(this));
}
});
},
componentWillReceiveProps(nextProps) {
if (!this.props.visible && nextProps.visible) {
if (nextProps.data.id && nextProps.data.type != undefined && nextProps.data.type != null) {
this.loadData(nextProps.data.id, nextProps.data.type);
};
this.state.data = {};
this.state.fileList = [];
this.state.propertyRightUrl = undefined;
};
},
render() {
const FormItem = Form.Item;
const { getFieldDecorator } = this.props.form;
const formItemLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 12 },
};
const _me = this;
const theData = this.state.data;
return (
);
},
}));
const intellectualDesc = React.createClass({
getInitialState() {
return {
visible: false,
loading: false
};
},
componentWillReceiveProps(nextProps) {
this.state.visible = nextProps.showDesc
},
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 intellectualDesc;