userDesc.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. import React from 'react';
  2. import { Icon, Modal, message, Spin, Input, Select, DatePicker, Button, Radio, Form } from 'antd';
  3. import moment from 'moment';
  4. import './userList.less';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. import { addressInit } from '../../tools.js';
  8. import { auditStatusList } from '../../dataDic.js';
  9. const UserForm = Form.create()(React.createClass({
  10. getInitialState() {
  11. return {
  12. visible: false,
  13. loading: false
  14. };
  15. },
  16. loadData() {
  17. this.state.data = [];
  18. this.setState({
  19. loading: true
  20. });
  21. $.ajax({
  22. method: "post",
  23. dataType: "json",
  24. crossDomain: false,
  25. url: globalConfig.context + "/api/admin/userDetail",
  26. data: {
  27. uid: this.props.uid
  28. },
  29. success: function (data) {
  30. if (data.error.length || !data.data) {
  31. message.warning(data.error[0].message);
  32. return;
  33. }
  34. let d = new Date()
  35. if (data.data.dateOfBirthMonth && data.data.dateOfBirthYear) {
  36. d.setMonth(data.data.dateOfBirthMonth - 1);
  37. d.setYear(parseInt(data.data.dateOfBirthYear));
  38. };
  39. addressInit('cmbProvince', 'cmbCity', 'cmbArea',
  40. data.data.province, data.data.city, data.data.area);
  41. this.setState({
  42. username: data.data.username,
  43. sex: data.data.sex,
  44. id:data.data.id,
  45. birth: d,
  46. idNumber: data.data.idNumber,
  47. positiveIdUrl: data.data.positiveIdUrl,
  48. oppositeIdUrl: data.data.oppositeIdUrl,
  49. aftUsername: data.data.aftUsername,
  50. contactMobile: data.data.contactMobile,
  51. bankName: data.data.bankName,
  52. bankAccount: data.data.bankAccount,
  53. bankCardNumber: data.data.bankCardNumber,
  54. amountMoney: data.data.amountMoney,
  55. auditStatus: String(data.data.auditStatus),
  56. process: data.data.process
  57. });
  58. }.bind(this),
  59. }).always(function () {
  60. this.setState({
  61. loading: false
  62. });
  63. }.bind(this));
  64. },
  65. handleSubmit(e) {
  66. e.preventDefault();
  67. this.props.form.validateFields((err, values) => {
  68. //地址值
  69. let cmbP = document.getElementById('cmbProvince').value;
  70. let cmbC = document.getElementById('cmbCity').value;
  71. let cmbA = document.getElementById('cmbArea').value;
  72. if (!err) {
  73. this.setState({
  74. loading: true
  75. });
  76. $.ajax({
  77. method: "POST",
  78. dataType: "json",
  79. crossDomain: false,
  80. url: globalConfig.context + "/api/admin/updateUserDetail",
  81. data: {
  82. id: this.state.id,
  83. username: values.username,
  84. sex: values.sex,
  85. dateOfBirthYear: values.birth ? values.birth._d.getFullYear() : undefined,
  86. dateOfBirthMonth: values.birth ? values.birth._d.getMonth() + 1 : undefined,
  87. idNumber: values.idNumber,
  88. aftUsername: values.aftUsername,
  89. province: cmbP,
  90. city: cmbC,
  91. area: cmbA,
  92. contactMobile: values.contactMobile,
  93. bankName: values.bankName,
  94. bankAccount: values.bankAccount,
  95. bankCardNumber: values.bankCardNumber,
  96. amountMoney: values.amountMoney,
  97. auditStatus: values.auditStatus,
  98. process: values.process
  99. }
  100. }).done(function (data) {
  101. if (!data.error.length) {
  102. message.success('保存成功!');
  103. } else {
  104. message.warning(data.error[0].message);
  105. }
  106. }.bind(this)).always(function () {
  107. this.setState({
  108. visible: false,
  109. });
  110. this.props.closeDesc(false);
  111. }.bind(this));
  112. }
  113. });
  114. },
  115. componentDidMount() {
  116. addressInit('cmbProvince', 'cmbCity', 'cmbArea');
  117. this.loadData();
  118. },
  119. componentWillReceiveProps(){
  120. this.loadData();
  121. },
  122. render() {
  123. const { getFieldDecorator } = this.props.form;
  124. const { MonthPicker } = DatePicker;
  125. const FormItem = Form.Item
  126. const formItemLayout = {
  127. labelCol: { span: 4 },
  128. wrapperCol: { span: 12 },
  129. };
  130. return (
  131. <Form horizontal onSubmit={this.handleSubmit} className="person-form">
  132. <FormItem
  133. {...formItemLayout}
  134. label="用户名"
  135. >
  136. {getFieldDecorator('username', {
  137. initialValue: this.state.username || null
  138. })(
  139. <Input />
  140. )}
  141. </FormItem>
  142. <FormItem
  143. {...formItemLayout}
  144. label="性别"
  145. >
  146. {getFieldDecorator('sex', {
  147. initialValue: this.state.sex || null
  148. })(
  149. <Radio.Group>
  150. <Radio value="男">男</Radio>
  151. <Radio value="女">女</Radio>
  152. </Radio.Group>
  153. )}
  154. </FormItem>
  155. <FormItem
  156. {...formItemLayout}
  157. label="出生日期"
  158. >
  159. {getFieldDecorator('birth', {
  160. initialValue: !this.state.birth ? null : moment(this.state.birth, 'YYYY/MM')
  161. })(
  162. <MonthPicker />
  163. )}
  164. </FormItem>
  165. <FormItem
  166. {...formItemLayout}
  167. label="身份证号"
  168. >
  169. {getFieldDecorator('idNumber', {
  170. initialValue: this.state.username || null
  171. })(
  172. <Input />
  173. )}
  174. </FormItem>
  175. <FormItem
  176. labelCol={{ span: 4 }}
  177. wrapperCol={{ span: 18 }}
  178. label="身份证图片"
  179. >
  180. <div className="idcard-img clearfix">
  181. {this.state.positiveIdUrl ? <div>
  182. <div className="idcard-imgbox">
  183. <img src={globalConfig.context + '/open/writeImage?path=' + this.state.positiveIdUrl} alt="点击查看大图"
  184. onClick={(e) => { window.open(e.target.src) }} />
  185. </div>
  186. </div> : <div>未上传</div>}
  187. {this.state.oppositeIdUrl ? <div>
  188. <div className="idcard-imgbox">
  189. <img src={globalConfig.context + '/open/writeImage?path=' + this.state.oppositeIdUrl} alt="点击查看大图"
  190. onClick={(e) => { window.open(e.target.src) }} />
  191. </div>
  192. </div> : <div>未上传</div>}
  193. </div>
  194. </FormItem>
  195. <FormItem
  196. {...formItemLayout}
  197. label="认证姓名"
  198. >
  199. {getFieldDecorator('aftUsername', {
  200. initialValue: this.state.aftUsername || null
  201. })(
  202. <Input />
  203. )}
  204. </FormItem>
  205. <FormItem
  206. {...formItemLayout}
  207. label="联系电话"
  208. >
  209. {getFieldDecorator('contactMobile', {
  210. initialValue: this.state.contactMobile || null
  211. })(
  212. <Input />
  213. )}
  214. </FormItem>
  215. <FormItem
  216. labelCol={{ span: 4 }}
  217. wrapperCol={{ span: 18 }}
  218. label="所在地"
  219. >
  220. {getFieldDecorator('address')(
  221. <div>
  222. <select id="cmbProvince" name="cmbProvince"></select>
  223. <select id="cmbCity" name="cmbCity"></select>
  224. <select id="cmbArea" name="cmbArea"></select>
  225. </div>
  226. )}
  227. </FormItem>
  228. <FormItem
  229. {...formItemLayout}
  230. label="开户银行"
  231. >
  232. {getFieldDecorator('bankAccount', {
  233. initialValue: this.state.bankAccount || null
  234. })(
  235. <Input />
  236. )}
  237. </FormItem>
  238. <FormItem
  239. {...formItemLayout}
  240. label="银行卡号"
  241. >
  242. {getFieldDecorator('bankCardNumber', {
  243. initialValue: this.state.bankCardNumber || null
  244. })(
  245. <Input />
  246. )}
  247. </FormItem>
  248. <FormItem
  249. {...formItemLayout}
  250. label="打款金额"
  251. >
  252. {getFieldDecorator('amountMoney', {
  253. initialValue: this.state.amountMoney || null
  254. })(
  255. <Input />
  256. )}
  257. </FormItem>
  258. <FormItem
  259. {...formItemLayout}
  260. label="认证状态"
  261. >
  262. {getFieldDecorator('auditStatus', {
  263. initialValue: this.state.auditStatus || null
  264. })(
  265. <Select placeholder="选择认证状态" style={{ width: 200 }}
  266. onChange={(e) => { this.state.auditStatus = e }}>
  267. {
  268. auditStatusList.map(function (item, i) {
  269. return <Select.Option key={i} value={item.value} >{item.key}</Select.Option>
  270. })
  271. }
  272. </Select>
  273. )}
  274. </FormItem>
  275. <FormItem
  276. {...formItemLayout}
  277. label="认证步骤"
  278. >
  279. {getFieldDecorator('process', {
  280. initialValue: this.state.process || null
  281. })(
  282. <Input />
  283. )}
  284. </FormItem>
  285. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  286. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  287. </FormItem>
  288. </Form >
  289. )
  290. }
  291. }));
  292. const PatentDesc = React.createClass({
  293. getInitialState() {
  294. return {
  295. visible: false,
  296. loading: false
  297. };
  298. },
  299. showModal() {
  300. this.setState({
  301. visible: true,
  302. });
  303. },
  304. handleCancel(e) {
  305. this.setState({
  306. visible: false,
  307. });
  308. this.props.closeDesc(false);
  309. },
  310. componentWillReceiveProps(nextProps) {
  311. this.state.visible = nextProps.showDesc;
  312. },
  313. render() {
  314. if (this.props.data) {
  315. return (
  316. <div className="patent-desc">
  317. <Spin spinning={this.state.loading} className='spin-box'>
  318. <Modal title="用户详情" visible={this.state.visible}
  319. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  320. width='800px'
  321. footer={[]}
  322. className="admin-desc-content">
  323. <UserForm uid={this.props.data.id} closeDesc={this.handleCancel} />
  324. </Modal>
  325. </Spin>
  326. </div>
  327. );
  328. } else {
  329. return <div></div>
  330. }
  331. },
  332. });
  333. export default PatentDesc;