import React from 'react'; import { Spin, Form, Button, Select, message } from 'antd'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; import { accessMethods, legalStatus, maintenanceStatus, confidentialities, decidabilities, rightLimitations } from './dict.js'; const FormItem = Form.Item; const Option = Select.Option; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 10 } }; const EvaluateStep2 = Form.create({})(React.createClass({ getInitialState() { return { loading: false, initialData: {} }; }, componentWillMount() { this.state.initialData = this.props.data || {}; }, next() { if (this.state.loading) { return; } this.props.form.validateFields((err, values) => { if (!err) { this.setState({ loading: true }) values.id = this.props.id; $.ajax({ url: globalConfig.context + '/api/user/evaluate/step2', method: 'post', data: values }).done(function (res) { if (res.error && res.error.length) { message.error(res.error[0].message) } else { if (this.props.next) { this.props.next(values); } } }.bind(this)).fail(function () { this.setState({ loading: false }) }.bind(this)); } }); }, prev() { if (this.props.prev) { this.props.prev(); } }, stringify(val) { return val && String(val) }, render() { let { loading, initialData } = this.state; const { getFieldDecorator } = this.props.form; return (
{getFieldDecorator('accessMethod', { rules: [{ required: true, message: '请选择技术取得的方式!' }], initialValue: this.stringify(initialData.accessMethod) })( )} {getFieldDecorator('legalStatus', { rules: [{ required: true, message: '请选择法律保护状态!' }], initialValue: this.stringify(initialData.legalStatus) })( )} {getFieldDecorator('patentMaintenance', { rules: [{ required: true, message: '请选择专利维护状态!' }], initialValue: this.stringify(initialData.patentMaintenance) })( )} {getFieldDecorator('confidentiality', { rules: [{ required: true, message: '请选择保密性!' }], initialValue: this.stringify(initialData.confidentiality) })( )} {getFieldDecorator('decidability', { rules: [{ required: true, message: '请选择他人侵权的易判定性!' }], initialValue: this.stringify(initialData.decidability) })( )} {getFieldDecorator('hasRightLimitation', { rules: [{ required: true, message: '请选择是否涉及质押、担保、诉讼等权利限制!' }], initialValue: this.stringify(initialData.hasRightLimitation) })( )}
) }, })); export default EvaluateStep2;