import React from 'react'; import { Icon, Form, Button, Input, Select, Spin, Table, message, Modal, Checkbox, Upload } from 'antd'; import { cognizanceStateList } from '../../../dataDic.js'; import { getCognizanceState, beforeUpload, getBase64 } from '../../../tools.js'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; const WebsiteChangeFrom = Form.create()(React.createClass({ loadData(id) { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/techproject/techWebsiteDetail", data: { id: id || this.props.data.id }, success: function (data) { this.state.data = data.data; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getInitialState() { return { loading: false, stateOption: [], introduce: '', projectCheck: 0, subsidy: 0, stateTable: [] }; }, componentWillMount() { let _me = this; cognizanceStateList.map(function (item) { _me.state.stateOption.push( {item.key} ) }); 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/techproject/disposeTechWebsite", data: { id: this.state.data.id, uid: this.state.data.uid, department: values.department, website: values.website, accountNumber: values.accountNumber, password: values.password, } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); this.props.closeModal(); this.props.form.resetFields(); this.state.targetKeys = []; this.state.selectedKeys = []; } else { message.warning(data.error[0].message); }; this.props.spinState(false); }.bind(this)); } }); }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.loadData(nextProps.data.id); }; }, projectEstablishmentCheck(e) { if (e.target.checked == true) { this.state.projectCheck = 1; } else if (e.target.checked == false) { this.state.projectCheck = 0; }; }, subsidyCheck(e) { if (e.target.checked == true) { this.state.subsidy = 1; } else if (e.target.checked == false) { this.state.subsidy = 0; }; }, render() { const FormItem = Form.Item; const { getFieldDecorator } = this.props.form; const theData = this.state.data; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 18 }, }; const _me = this; if (this.state.data) { return (
{theData.unitName} {getFieldDecorator('department', { initialValue: theData.department })( )} {getFieldDecorator('website', { initialValue: theData.website })( )} {getFieldDecorator('accountNumber', { initialValue: theData.accountNumber })( )} {getFieldDecorator('password', { initialValue: theData.password })( )}
); } else { return (
) }; }, })); const WebsiteChange = 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); }, handleCancel(e) { this.setState({ visible: false, }); this.props.closeDesc(false); }, spinChange(e) { this.setState({ loading: e }); }, render() { return (
); } }); export default WebsiteChange;