import React from 'react';
import { Icon, Modal, message, Spin, Input, Select, DatePicker, Button, Radio, Form, Cascader } from 'antd';
import moment from 'moment';
import './userList.less';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import { areaSelect, getProvince } from '../../NewDicProvinceList.js';
import { getAuditState } from '../../tools.js';
import { auditStatusList, certifyStepList } from '../../dataDic.js';
const UserShow = Form.create()(React.createClass({
getInitialState() {
return {
visible: false,
loading: false
};
},
loadData(uid) {
this.props.spinState(true);
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/userCertify/userDetail",
data: {
uid: uid
},
success: function (data) {
let thisData = data.data;
if (!thisData) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
thisData = {};
};
this.setState({
username: thisData.username,
sex: thisData.sex,
id: thisData.id,
birth: thisData.dateOfBirthYear + '-' + thisData.dateOfBirthMonth,
idNumber: thisData.idNumber,
province: thisData.province,
city: thisData.city,
area: thisData.area,
positiveIdUrl: thisData.positiveIdUrl,
oppositeIdUrl: thisData.oppositeIdUrl,
aftUsername: thisData.aftUsername,
contactMobile: thisData.contactMobile,
bankName: thisData.bankName,
bankAccount: thisData.bankAccount,
bankCardNumber: thisData.bankCardNumber,
amountMoney: thisData.amountMoney,
auditStatus: thisData.auditStatus,
process: thisData.process ? String(thisData.process) : undefined,
paymentDateFormattedDate: thisData.paymentDateFormattedDate,
paymentDate: thisData.paymentDate,
expert: thisData.expert,
celebrity: thisData.celebrity,
level: thisData.lvl,
aid: thisData.aid, //业务员ID
mid: thisData.mid //客户经理ID
});
this.props.form.resetFields();
}.bind(this),
}).always(function () {
this.props.spinState(false);
}.bind(this));
},
getAccountManagerList() {
this.props.spinState(true);
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/userCertify/accountManager",
success: function (data) {
let theArr = [];
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
return;
};
for (var item in data.data) {
theArr.push(
{data.data[item]}
)
};
this.setState({
accountManagerOption: theArr,
accountManagerList: data.data
});
}.bind(this),
}).always(function () {
this.props.spinState(false);
}.bind(this));
},
getTechnicianList() {
this.props.spinState(true);
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/userCertify/technician",
success: function (data) {
let theArr = [];
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
return;
};
for (var item in data.data) {
theArr.push(
{data.data[item]}
)
};
this.setState({
technicianOption: theArr,
technicianList: data.data
});
}.bind(this),
}).always(function () {
this.props.spinState(false);
}.bind(this));
},
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/userCertify/updateUserDetail",
data: {
uid: this.props.uid,
id: this.state.id,
auditStatus: values.auditStatus,
level: this.state.level,
aid: values.aid, //指派业务员ID
mid: values.mid, //指派客户经理ID
}
}).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.handleOk();
}.bind(this));
}
});
},
componentWillMount() {
this.loadData(this.props.uid);
this.getAccountManagerList();
this.getTechnicianList();
},
componentWillReceiveProps(nextProps) {
if (!this.props.visible && nextProps.visible) {
this.loadData(nextProps.uid);
};
},
render() {
const { getFieldDecorator } = this.props.form;
const FormItem = Form.Item
const formItemLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 12 },
};
return (
)
}
}));
const UserForm = Form.create()(React.createClass({
getInitialState() {
return {
visible: false,
loading: false,
saveSign: "save"
};
},
loadData(uid) {
this.props.spinState(true);
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/userDetail",
data: {
uid: uid
},
success: function (data) {
let thisData = data.data;
if (!thisData) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
thisData = {};
};
let d = new Date()
if (thisData && thisData.dateOfBirthMonth && thisData.dateOfBirthYear) {
d.setMonth(thisData.dateOfBirthMonth - 1);
d.setYear(parseInt(thisData.dateOfBirthYear));
};
this.setState({
username: thisData.username,
sex: thisData.sex,
id: thisData.id,
birth: d,
idNumber: thisData.idNumber,
address: [thisData.province, thisData.city, thisData.area],
positiveIdUrl: thisData.positiveIdUrl,
oppositeIdUrl: thisData.oppositeIdUrl,
aftUsername: thisData.aftUsername,
contactMobile: thisData.contactMobile,
bankName: thisData.bankName,
bankAccount: thisData.bankAccount,
bankCardNumber: thisData.bankCardNumber,
amountMoney: thisData.amountMoney,
auditStatus: thisData.auditStatus,
process: thisData.process ? String(thisData.process) : undefined,
paymentDateFormattedDate: thisData.paymentDateFormattedDate,
paymentDate: thisData.paymentDate,
level: thisData.level,
expert: thisData.expert,
celebrity: thisData.celebrity,
aid: thisData.aid, //业务员ID
mid: thisData.mid //客户经理ID
});
this.props.form.resetFields();
}.bind(this),
}).always(function () {
this.props.spinState(false);
}.bind(this));
},
handleSubmit(e) {
if (e) {
e.preventDefault();
};
this.props.form.validateFields((err, values) => {
// //金额判断
// if (values.amountMoney && values.amountMoney < 0 && values.amountMoney > 100 && /^\d+(\.\d{2})?$/.test(values.amountMoney)) {
// message.warning('请输入0-100以内的金额');
// return;
// };
if ((this.state.auditStatus == "5" && values.level == "0") || (this.state.auditStatus != "5" && values.level != "0")) {
message.warning('认证状态和用户等级不匹配!');
return;
};
if (!err) {
this.props.spinState(true);
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/updateUserDetail",
data: {
uid: this.props.uid,
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: values.address[0],
city: values.address[1],
area: values.address[2],
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,
level: values.level,
expert: values.expert,
celebrity: values.celebrity,
//aid: values.aid, //指派业务员ID
//mid: values.mid, //指派客户经理ID
saveSign: this.state.saveSign
}
}).done(function (data) {
if (!data.error.length) {
message.success('保存成功!');
} else {
message.warning(data.error[0].message);
}
}.bind(this)).always(function () {
this.setState({
saveSign: "save"
});
this.props.spinState(false);
this.props.handleOk();
}.bind(this));
}
});
},
componentWillMount() {
this.loadData(this.props.uid);
},
componentWillReceiveProps(nextProps) {
if (!this.props.visible && nextProps.visible) {
this.loadData(nextProps.uid);
};
},
render() {
const { getFieldDecorator } = this.props.form;
const { MonthPicker } = DatePicker;
const FormItem = Form.Item
const formItemLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 12 },
};
return (
)
}
}));
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;
},
spinChange(e) {
this.setState({
loading: e
});
},
render() {
if (this.props.data) {
return (
{window.showAuditStatus ?
: }
);
} else {
return
}
},
});
export default PatentDesc;
//
// {getFieldDecorator('amountMoney', {
// initialValue: this.state.amountMoney
// })(
//
// )}
//
//
// {getFieldDecorator('paymentDateFormattedDate', {
// initialValue: this.state.paymentDate ? moment(this.state.paymentDate) : null
// })(
//
// )}
//