import React from 'react'; import { Icon, Modal, message, Spin, Input, Select, DatePicker, Button, Radio, Form } from 'antd'; import moment from 'moment'; import './userList.less'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import { addressInit } from '../../tools.js'; import { auditStatusList } from '../../dataDic.js'; const UserForm = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false }; }, loadData() { this.state.data = []; this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/userDetail", data: { uid: this.props.uid }, success: function (data) { if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; return; }; let d = new Date() if (data.data.dateOfBirthMonth && data.data.dateOfBirthYear) { d.setMonth(data.data.dateOfBirthMonth - 1); d.setYear(parseInt(data.data.dateOfBirthYear)); }; addressInit('cmbProvince', 'cmbCity', 'cmbArea', data.data.province, data.data.city, data.data.area); this.setState({ username: data.data.username, sex: data.data.sex, id: data.data.id, birth: d, idNumber: data.data.idNumber, positiveIdUrl: data.data.positiveIdUrl, oppositeIdUrl: data.data.oppositeIdUrl, aftUsername: data.data.aftUsername, contactMobile: data.data.contactMobile, bankName: data.data.bankName, bankAccount: data.data.bankAccount, bankCardNumber: data.data.bankCardNumber, amountMoney: data.data.amountMoney, auditStatus: String(data.data.auditStatus), process: data.data.process, paymentDateFormattedDate: data.data.paymentDateFormattedDate, paymentDate: data.data.paymentDate }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { //地址值 let cmbP = document.getElementById('cmbProvince').value; let cmbC = document.getElementById('cmbCity').value; let cmbA = document.getElementById('cmbArea').value; if (!err) { this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/updateUserDetail", data: { id: this.state.id, username: values.username, sex: values.sex, dateOfBirthYear: values.birth ? values.birth._d.getFullYear() : undefined, dateOfBirthMonth: values.birth ? values.birth._d.getMonth() + 1 : undefined, idNumber: values.idNumber, aftUsername: values.aftUsername, province: cmbP, city: cmbC, area: cmbA, contactMobile: values.contactMobile, bankName: values.bankName, bankAccount: values.bankAccount, bankCardNumber: values.bankCardNumber, amountMoney: values.amountMoney, auditStatus: values.auditStatus, paymentDateFormattedDate: values.paymentDateFormattedDate ? values.paymentDateFormattedDate.format("YYYY-MM-DD") : undefined, process: values.process } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.setState({ visible: false, }); this.props.handleOk(); }.bind(this)); } }); }, componentDidMount() { addressInit('cmbProvince', 'cmbCity', 'cmbArea'); this.loadData(); }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.loadData(); }; }, render() { const { getFieldDecorator } = this.props.form; const { MonthPicker } = DatePicker; const FormItem = Form.Item const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 12 }, }; return (
{getFieldDecorator('username', { initialValue: this.state.username || null })( )} {getFieldDecorator('sex', { initialValue: this.state.sex || null })( )} {getFieldDecorator('birth', { initialValue: !this.state.birth ? null : moment(this.state.birth, 'YYYY/MM') })( )} {getFieldDecorator('idNumber', { initialValue: this.state.idNumber || null })( )}
{this.state.positiveIdUrl ?
)} {getFieldDecorator('contactMobile', { initialValue: this.state.contactMobile || null })( )} {getFieldDecorator('address')(
)}
{getFieldDecorator('bankAccount', { initialValue: this.state.bankAccount || null })( )} {getFieldDecorator('bankCardNumber', { initialValue: this.state.bankCardNumber || null })( )} {getFieldDecorator('amountMoney', { initialValue: this.state.amountMoney || null })( )} {getFieldDecorator('paymentDateFormattedDate', { initialValue: this.state.paymentDate ? moment(this.state.paymentDate) : null })( )} {getFieldDecorator('auditStatus', { initialValue: this.state.auditStatus || null })( )} {getFieldDecorator('process', { initialValue: this.state.process || null })( )} ) } })); const PatentDesc = React.createClass({ getInitialState() { return { visible: false, loading: false }; }, showModal() { this.setState({ visible: true, }); }, handleCancel(e) { this.setState({ visible: false, }); this.props.closeDesc(false); }, handleOk(e) { this.setState({ visible: false, }); this.props.closeDesc(false, true); }, componentWillReceiveProps(nextProps) { this.state.visible = nextProps.showDesc; }, render() { if (this.props.data) { return (
); } else { return
} }, }); export default PatentDesc;