userDesc.jsx 13 KB

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