userDesc.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. import React from 'react';
  2. import { Icon, Modal, message, Spin, Input, Select, DatePicker, Button, Radio, Form, Cascader } 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 { provinceSelect } from '../../tools.js';
  8. import { auditStatusList, certifyStepList } from '../../dataDic.js';
  9. const UserForm = Form.create()(React.createClass({
  10. getInitialState() {
  11. return {
  12. visible: false,
  13. loading: false
  14. };
  15. },
  16. loadData(uid) {
  17. this.setState({
  18. loading: true
  19. });
  20. $.ajax({
  21. method: window.showAuditStatus ? "get" : "post",
  22. dataType: "json",
  23. crossDomain: false,
  24. url: window.showAuditStatus ? globalConfig.context + "/api/admin/userCertify/userDetail" : globalConfig.context + "/api/admin/userDetail",
  25. data: {
  26. uid: uid
  27. },
  28. success: function (data) {
  29. let thisData = data.data;
  30. if (!thisData) {
  31. if (data.error && data.error.length) {
  32. message.warning(data.error[0].message);
  33. };
  34. thisData = {};
  35. };
  36. let d = new Date()
  37. if (thisData && thisData.dateOfBirthMonth && thisData.dateOfBirthYear) {
  38. d.setMonth(thisData.dateOfBirthMonth - 1);
  39. d.setYear(parseInt(thisData.dateOfBirthYear));
  40. };
  41. this.setState({
  42. username: thisData.username,
  43. sex: thisData.sex,
  44. id: thisData.id,
  45. birth: d,
  46. idNumber: thisData.idNumber,
  47. address: [thisData.province, thisData.city, thisData.area],
  48. positiveIdUrl: thisData.positiveIdUrl,
  49. oppositeIdUrl: thisData.oppositeIdUrl,
  50. aftUsername: thisData.aftUsername,
  51. contactMobile: thisData.contactMobile,
  52. bankName: thisData.bankName,
  53. bankAccount: thisData.bankAccount,
  54. bankCardNumber: thisData.bankCardNumber,
  55. amountMoney: thisData.amountMoney,
  56. auditStatus: thisData.auditStatus,
  57. process: thisData.process ? String(thisData.process) : undefined,
  58. paymentDateFormattedDate: thisData.paymentDateFormattedDate,
  59. paymentDate: thisData.paymentDate,
  60. aid: thisData.aid, //业务员ID
  61. mid: thisData.mid //客户经理ID
  62. });
  63. this.props.form.resetFields();
  64. }.bind(this),
  65. }).always(function () {
  66. this.setState({
  67. loading: false
  68. });
  69. }.bind(this));
  70. },
  71. getAccountManagerList() {
  72. this.setState({
  73. loading: true
  74. });
  75. $.ajax({
  76. method: "get",
  77. dataType: "json",
  78. crossDomain: false,
  79. url: globalConfig.context + "/api/admin/userCertify/accountManager",
  80. success: function (data) {
  81. let theArr = [];
  82. if (!data.data) {
  83. if (data.error && data.error.length) {
  84. message.warning(data.error[0].message);
  85. };
  86. return;
  87. };
  88. for (var item in data.data) {
  89. theArr.push(
  90. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  91. )
  92. };
  93. this.setState({
  94. accountManagerOption: theArr,
  95. accountManagerList: data.data
  96. });
  97. }.bind(this),
  98. }).always(function () {
  99. this.setState({
  100. loading: false
  101. });
  102. }.bind(this));
  103. },
  104. getTechnicianList() {
  105. this.setState({
  106. loading: true
  107. });
  108. $.ajax({
  109. method: "get",
  110. dataType: "json",
  111. crossDomain: false,
  112. url: globalConfig.context + "/api/admin/userCertify/technician",
  113. success: function (data) {
  114. let theArr = [];
  115. if (!data.data) {
  116. if (data.error && data.error.length) {
  117. message.warning(data.error[0].message);
  118. };
  119. return;
  120. };
  121. for (var item in data.data) {
  122. theArr.push(
  123. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  124. )
  125. };
  126. this.setState({
  127. technicianOption: theArr,
  128. technicianList: data.data
  129. });
  130. }.bind(this),
  131. }).always(function () {
  132. this.setState({
  133. loading: false
  134. });
  135. }.bind(this));
  136. },
  137. handleSubmit(e) {
  138. e.preventDefault();
  139. this.props.form.validateFields((err, values) => {
  140. //金额判断
  141. if (values.amountMoney && values.amountMoney < 0 && values.amountMoney > 100 && /^\d+(\.\d{2})?$/.test(values.amountMoney)) {
  142. message.warning('请输入0-100以内的金额');
  143. return;
  144. };
  145. if (!err) {
  146. this.setState({
  147. loading: true
  148. });
  149. $.ajax({
  150. method: "POST",
  151. dataType: "json",
  152. crossDomain: false,
  153. url: window.showAuditStatus ? globalConfig.context + "/api/admin/userCertify/updateUserDetail" : globalConfig.context + "/api/admin/updateUserDetail",
  154. data: {
  155. uid: this.props.uid,
  156. id: this.state.id,
  157. username: values.username,
  158. sex: values.sex,
  159. dateOfBirthYear: values.birth ? values.birth._d.getFullYear() : undefined,
  160. dateOfBirthMonth: values.birth ? values.birth._d.getMonth() + 1 : undefined,
  161. idNumber: values.idNumber,
  162. aftUsername: values.aftUsername,
  163. province: values.address[0],
  164. city: values.address[1],
  165. area: values.address[2],
  166. contactMobile: values.contactMobile,
  167. bankName: values.bankName,
  168. bankAccount: values.bankAccount,
  169. bankCardNumber: values.bankCardNumber,
  170. amountMoney: values.amountMoney,
  171. auditStatus: values.auditStatus,
  172. paymentDateFormattedDate: values.paymentDateFormattedDate ? values.paymentDateFormattedDate.format("YYYY-MM-DD") : undefined,
  173. aid: values.aid, //指派业务员ID
  174. mid: values.mid //指派客户经理ID
  175. }
  176. }).done(function (data) {
  177. if (!data.error.length) {
  178. message.success('保存成功!');
  179. } else {
  180. message.warning(data.error[0].message);
  181. }
  182. }.bind(this)).always(function () {
  183. this.setState({
  184. visible: false,
  185. });
  186. this.props.handleOk();
  187. }.bind(this));
  188. }
  189. });
  190. },
  191. componentWillMount() {
  192. this.loadData(this.props.uid);
  193. if (window.showAuditStatus) {
  194. this.getAccountManagerList();
  195. this.getTechnicianList();
  196. };
  197. },
  198. componentWillReceiveProps(nextProps) {
  199. if (!this.props.visible && nextProps.visible) {
  200. this.state.uid = undefined;
  201. this.state.mid = undefined;
  202. this.loadData(nextProps.uid);
  203. };
  204. },
  205. render() {
  206. const { getFieldDecorator } = this.props.form;
  207. const { MonthPicker } = DatePicker;
  208. const FormItem = Form.Item
  209. const formItemLayout = {
  210. labelCol: { span: 6 },
  211. wrapperCol: { span: 12 },
  212. };
  213. return (
  214. <Form horizontal onSubmit={this.handleSubmit} className="person-form">
  215. <FormItem
  216. {...formItemLayout}
  217. label="用户名"
  218. >
  219. {getFieldDecorator('username', {
  220. initialValue: this.state.username
  221. })(
  222. <Input />
  223. )}
  224. </FormItem>
  225. <FormItem
  226. {...formItemLayout}
  227. label="性别"
  228. >
  229. {getFieldDecorator('sex', {
  230. initialValue: this.state.sex
  231. })(
  232. <Radio.Group>
  233. <Radio value="男">男</Radio>
  234. <Radio value="女">女</Radio>
  235. </Radio.Group>
  236. )}
  237. </FormItem>
  238. <FormItem
  239. {...formItemLayout}
  240. label="出生日期"
  241. >
  242. {getFieldDecorator('birth', {
  243. initialValue: !this.state.birth ? null : moment(this.state.birth, 'YYYY/MM')
  244. })(
  245. <MonthPicker />
  246. )}
  247. </FormItem>
  248. <FormItem
  249. {...formItemLayout}
  250. label="身份证号"
  251. >
  252. {getFieldDecorator('idNumber', {
  253. initialValue: this.state.idNumber
  254. })(
  255. <Input />
  256. )}
  257. </FormItem>
  258. <FormItem
  259. labelCol={{ span: 6 }}
  260. wrapperCol={{ span: 18 }}
  261. label="身份证图片"
  262. >
  263. <div className="idcard-img clearfix">
  264. {this.state.positiveIdUrl ? <div>
  265. <div className="idcard-imgbox">
  266. <img src={globalConfig.context + '/open/writeImage?path=' + this.state.positiveIdUrl} alt="点击查看大图"
  267. onClick={(e) => { window.open(e.target.src) }} />
  268. </div>
  269. </div> : <div><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传</div>}
  270. {this.state.oppositeIdUrl ? <div>
  271. <div className="idcard-imgbox">
  272. <img src={globalConfig.context + '/open/writeImage?path=' + this.state.oppositeIdUrl} alt="点击查看大图"
  273. onClick={(e) => { window.open(e.target.src) }} />
  274. </div>
  275. </div> : <div><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传</div>}
  276. </div>
  277. </FormItem>
  278. <FormItem
  279. {...formItemLayout}
  280. label="认证姓名"
  281. >
  282. {getFieldDecorator('aftUsername', {
  283. initialValue: this.state.aftUsername
  284. })(
  285. <Input />
  286. )}
  287. </FormItem>
  288. <FormItem
  289. {...formItemLayout}
  290. label="联系电话"
  291. >
  292. {getFieldDecorator('contactMobile', {
  293. initialValue: this.state.contactMobile
  294. })(
  295. <Input />
  296. )}
  297. </FormItem>
  298. <FormItem
  299. {...formItemLayout}
  300. label="所在地"
  301. >
  302. {getFieldDecorator('address', {
  303. initialValue: this.state.address
  304. })(
  305. <Cascader options={provinceSelect()} placeholder="请选择地址" />
  306. )}
  307. </FormItem>
  308. <FormItem
  309. {...formItemLayout}
  310. label="开户银行"
  311. >
  312. {getFieldDecorator('bankAccount', {
  313. initialValue: this.state.bankAccount
  314. })(
  315. <Input />
  316. )}
  317. </FormItem>
  318. <FormItem
  319. {...formItemLayout}
  320. label="银行卡号"
  321. >
  322. {getFieldDecorator('bankCardNumber', {
  323. initialValue: this.state.bankCardNumber
  324. })(
  325. <Input />
  326. )}
  327. </FormItem>
  328. <div style={{ display: window.showAuditStatus ? 'none' : 'none' }}>
  329. <FormItem
  330. {...formItemLayout}
  331. label="认证状态"
  332. >
  333. <span>
  334. {(() => {
  335. let _me = this, theStatus;
  336. auditStatusList.map(function (item) {
  337. if (_me.state.auditStatus == item.value) {
  338. theStatus = item.key;
  339. };
  340. });
  341. return theStatus;
  342. })()}
  343. </span>
  344. </FormItem>
  345. <FormItem
  346. {...formItemLayout}
  347. label="业务员"
  348. >
  349. <span>{this.state.technicianList ? this.state.technicianList[this.state.aid] : ''}</span>
  350. </FormItem>
  351. <FormItem
  352. {...formItemLayout}
  353. label="客户经理"
  354. >
  355. <span>{this.state.accountManagerList ? this.state.accountManagerList[this.state.mid] : ''}</span>
  356. </FormItem>
  357. </div>
  358. <div style={{ display: window.showAuditStatus ? 'block' : 'none' }}>
  359. <FormItem
  360. {...formItemLayout}
  361. label="认证状态"
  362. >
  363. {getFieldDecorator('auditStatus', {
  364. initialValue: this.state.auditStatus
  365. })(
  366. <Select placeholder="选择要修改的认证状态" style={{ width: 200 }}
  367. onChange={(e) => { this.state.auditStatus = e }}>
  368. {
  369. auditStatusList.map(function (item, i) {
  370. return <Select.Option key={i} value={item.value} >{item.key}</Select.Option>
  371. })
  372. }
  373. </Select>
  374. )}
  375. </FormItem>
  376. <FormItem
  377. {...formItemLayout}
  378. label="业务员"
  379. >
  380. {getFieldDecorator('aid', {
  381. initialValue: this.state.aid
  382. })(
  383. <Select placeholder="选择一个业务员" style={{ width: 200 }}>
  384. {this.state.technicianOption}
  385. </Select>
  386. )}
  387. </FormItem>
  388. <FormItem
  389. {...formItemLayout}
  390. label="客户经理"
  391. >
  392. {getFieldDecorator('mid', {
  393. initialValue: this.state.mid
  394. })(
  395. <Select placeholder="选择一个客户经理" style={{ width: 200 }}>
  396. {this.state.accountManagerOption}
  397. </Select>
  398. )}
  399. </FormItem>
  400. </div>
  401. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  402. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  403. </FormItem>
  404. </Form >
  405. )
  406. }
  407. }));
  408. const PatentDesc = React.createClass({
  409. getInitialState() {
  410. return {
  411. visible: false,
  412. loading: false
  413. };
  414. },
  415. showModal() {
  416. this.setState({
  417. visible: true,
  418. });
  419. },
  420. handleCancel(e) {
  421. this.setState({
  422. visible: false,
  423. });
  424. this.props.closeDesc(false);
  425. },
  426. handleOk(e) {
  427. this.setState({
  428. visible: false,
  429. });
  430. this.props.closeDesc(false, true);
  431. },
  432. componentWillReceiveProps(nextProps) {
  433. this.state.visible = nextProps.showDesc;
  434. },
  435. render() {
  436. if (this.props.data) {
  437. return (
  438. <div className="patent-desc">
  439. <Spin spinning={this.state.loading} className='spin-box'>
  440. <Modal title="用户详情" visible={this.state.visible}
  441. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  442. width='600px'
  443. footer=''
  444. className="admin-desc-content">
  445. <UserForm
  446. uid={this.props.data.id}
  447. closeDesc={this.handleCancel}
  448. visible={this.state.visible}
  449. handleOk={this.handleOk} />
  450. </Modal>
  451. </Spin>
  452. </div>
  453. );
  454. } else {
  455. return <div></div>
  456. }
  457. },
  458. });
  459. export default PatentDesc;
  460. // <FormItem
  461. // {...formItemLayout}
  462. // label="打款金额"
  463. // >
  464. // {getFieldDecorator('amountMoney', {
  465. // initialValue: this.state.amountMoney
  466. // })(
  467. // <Input />
  468. // )}
  469. // </FormItem>
  470. // <FormItem
  471. // {...formItemLayout}
  472. // label="打款日期"
  473. // >
  474. // {getFieldDecorator('paymentDateFormattedDate', {
  475. // initialValue: this.state.paymentDate ? moment(this.state.paymentDate) : null
  476. // })(
  477. // <DatePicker />
  478. // )}
  479. // </FormItem>