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 { progressiveness, innovativeness, ripeness, alternatives, defensive, prospect, supplyAndDemand, rangeOfApplication, imitable, profitability } from './dict.js'; const FormItem = Form.Item; const Option = Select.Option; const formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 10 }, }; const EvaluateStep3 = 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/step3', 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('progressiveness', { rules: [{ required: true, message: '请选择技术的先进性!' }], initialValue: this.stringify(initialData.progressiveness) })( )} {getFieldDecorator('innovativeness', { rules: [{ required: true, message: '请选择技术的创新性!' }], initialValue: this.stringify(initialData.innovativeness) })( )} {getFieldDecorator('ripeness', { rules: [{ required: true, message: '请选择技术的成熟度!' }], initialValue: this.stringify(initialData.ripeness) })( )} {getFieldDecorator('alternatives', { rules: [{ required: true, message: '请选择技术的替代性!' }], initialValue: this.stringify(initialData.alternatives) })( )} {getFieldDecorator('defensive', { rules: [{ required: true, message: '请选择技术的防御力!' }], initialValue: this.stringify(initialData.defensive) })( )} {getFieldDecorator('prospect', { rules: [{ required: true, message: '请选择技术领域发展前景!' }], initialValue: this.stringify(initialData.prospect) })( )} {getFieldDecorator('supplyAndDemand', { rules: [{ required: true, message: '请选择技术的供求关系!' }], initialValue: this.stringify(initialData.supplyAndDemand) })( )} {getFieldDecorator('rangeOfApplication', { rules: [{ required: true, message: '请选择技术的应用范围!' }], initialValue: this.stringify(initialData.rangeOfApplication) })( )} {getFieldDecorator('imitable', { rules: [{ required: true, message: '请选择技术的模仿可能性!' }], initialValue: this.stringify(initialData.imitable) })( )} {getFieldDecorator('profitability', { rules: [{ required: true, message: '请选择技术的独立获利能力!' }], initialValue: this.stringify(initialData.profitability) })( )}
) }, })); export default EvaluateStep3;