userList.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import './userList.less';
  7. import UserDesc from './userDesc.jsx';
  8. import { auditStatusList } from '../../dataDic.js';
  9. const OrgAdd = React.createClass({
  10. getInitialState() {
  11. return {
  12. visible: false,
  13. loading: false
  14. };
  15. },
  16. showModal() {
  17. this.state.mobile;
  18. this.setState({
  19. visible: true,
  20. });
  21. },
  22. handleCancel(e) {
  23. this.setState({
  24. visible: false,
  25. });
  26. },
  27. handleOk() {
  28. this.setState({
  29. loading: true
  30. });
  31. $.ajax({
  32. method: "post",
  33. dataType: "json",
  34. crossDomain: false,
  35. url: globalConfig.context + "/api/admin/addNewUser",
  36. data: {
  37. mobile: this.state.mobile,
  38. type: 0
  39. }
  40. }).done(function (data) {
  41. this.setState({
  42. loading: false
  43. });
  44. if (!data.error.length) {
  45. message.success('新增成功!');
  46. this.setState({
  47. visible: false,
  48. });
  49. this.props.closeDesc(false, true);
  50. } else {
  51. message.warning(data.error[0].message);
  52. };
  53. }.bind(this));
  54. },
  55. render() {
  56. return (
  57. <div className="patent-desc" style={{ float: 'right', marginRight: '20px' }}>
  58. <Button type="primary" onClick={this.showModal}>添加用户</Button>
  59. <Modal title="新增个人用户" visible={this.state.visible}
  60. onCancel={this.handleCancel}
  61. width='350px'
  62. footer={[
  63. <Button key="submit" type="primary" loading={this.state.loading} onClick={this.handleOk}>提交</Button>,
  64. <Button key="back" onClick={this.handleCancel}>返回</Button>
  65. ]}
  66. className="admin-desc-content">
  67. <div className='orgAdd-input'>
  68. <span>用户手机号码:</span>
  69. <Input
  70. value={this.state.mobile}
  71. onChange={(e) => { this.setState({ mobile: e.target.value }); }} />
  72. </div>
  73. </Modal>
  74. </div>
  75. );
  76. }
  77. });
  78. const UserList = React.createClass({
  79. loadData(pageNo) {
  80. this.state.data = [];
  81. this.setState({
  82. loading: true
  83. });
  84. $.ajax({
  85. method: "post",
  86. dataType: "json",
  87. crossDomain: false,
  88. url: globalConfig.context + "/api/admin/userList",
  89. data: {
  90. pageNo: pageNo || 1,
  91. pageSize: this.state.pagination.pageSize,
  92. mobile: this.state.searchLoginId, //登录名
  93. email: this.state.searchEmail,
  94. createTime: this.state.searchTime,
  95. number: this.state.searchAftId, //阿凡提号
  96. aftUsername: this.state.searchAftUsername,
  97. auditStatus: this.state.searchAuditStatus
  98. },
  99. success: function (data) {
  100. if (data.error.length || !data.data || !data.data.list) {
  101. message.warning(data.error[0].message);
  102. return;
  103. }
  104. for (let i = 0; i < data.data.list.length; i++) {
  105. let thisdata = data.data.list[i];
  106. this.state.data.push({
  107. key: i,
  108. id: thisdata.id,
  109. mobile: thisdata.mobile,
  110. email: thisdata.email,
  111. createTime: thisdata.createTime,
  112. aftUsername: thisdata.aftUsername,
  113. number: thisdata.number,
  114. auditStatus: thisdata.auditStatus,
  115. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  116. adminName: thisdata.adminName
  117. });
  118. };
  119. this.state.pagination.current = data.data.pageNo;
  120. this.state.pagination.total = data.data.totalCount;
  121. this.setState({
  122. dataSource: this.state.data,
  123. pagination: this.state.pagination
  124. });
  125. }.bind(this),
  126. }).always(function () {
  127. this.setState({
  128. loading: false
  129. });
  130. }.bind(this));
  131. },
  132. getInitialState() {
  133. return {
  134. searchMore: true,
  135. data: [],
  136. loading: false,
  137. pagination: {
  138. defaultCurrent: 1,
  139. defaultPageSize: 10,
  140. showQuickJumper: true,
  141. pageSize: 10,
  142. onChange: function (page) {
  143. this.loadData(page);
  144. }.bind(this),
  145. showTotal: function (total) {
  146. return '共' + total + '条数据';
  147. }
  148. },
  149. columns: [
  150. {
  151. title: '阿凡提号',
  152. dataIndex: 'number',
  153. key: 'number',
  154. }, {
  155. title: '登录名',
  156. dataIndex: 'mobile',
  157. key: 'mobile',
  158. }, {
  159. title: '认证状态',
  160. dataIndex: 'auditStatus',
  161. key: 'auditStatus',
  162. render: text => {
  163. switch (String(text)) {
  164. case "0":
  165. return "未提交审核";
  166. case "1":
  167. return "提交审核";
  168. case "2":
  169. return "审核未打款";
  170. case "3":
  171. return "审核已打款";
  172. case "4":
  173. return "认证未通过";
  174. case "5":
  175. return "已认证";
  176. }
  177. },
  178. }, {
  179. title: '注册时间',
  180. dataIndex: 'createTimeFormattedDate',
  181. key: 'createTimeFormattedDate',
  182. }, {
  183. title: '认证名称',
  184. dataIndex: 'aftUsername',
  185. key: 'aftUsername',
  186. }, {
  187. title: '联系方式',
  188. dataIndex: 'email',
  189. key: 'email',
  190. }, {
  191. title: '业务员',
  192. dataIndex: 'adminName',
  193. key: 'adminName',
  194. }
  195. ],
  196. dataSource: [],
  197. searchTime: [,]
  198. };
  199. },
  200. componentWillMount() {
  201. this.loadData();
  202. },
  203. tableRowClick(record, index) {
  204. this.state.RowData = record;
  205. this.setState({
  206. showDesc: true
  207. });
  208. },
  209. closeDesc(e, s) {
  210. this.state.showDesc = e;
  211. if (s) {
  212. this.loadData();
  213. };
  214. },
  215. search() {
  216. this.loadData();
  217. },
  218. reset() {
  219. this.state.searchAftId = "";
  220. this.state.searchLoginId = "";
  221. this.state.searchAuditStatus = "";
  222. this.state.searchAftUsername = "";
  223. this.state.searchEmail = "";
  224. this.state.searchTime = [,];
  225. this.loadData();
  226. },
  227. searchSwitch() {
  228. this.setState({
  229. searchMore: !this.state.searchMore
  230. });
  231. },
  232. searchcreateTime(date, dateString) {
  233. this.state.createTime = dateString;
  234. },
  235. render() {
  236. const { RangePicker } = DatePicker;
  237. return (
  238. <div className="user-content" >
  239. <div className="content-title">
  240. <span>个人用户管理</span>
  241. <OrgAdd closeDesc={this.closeDesc} />
  242. </div>
  243. <div className="user-search">
  244. <Input placeholder="阿凡提号" value={this.state.searchAftId}
  245. onChange={(e) => { this.setState({ searchAftId: e.target.value }); }} />
  246. <Input placeholder="登录号" value={this.state.searchLoginId}
  247. onChange={(e) => { this.setState({ searchLoginId: e.target.value }); }} />
  248. <Select placeholder="选择认证状态" style={{ width: 140 }}
  249. value={this.state.searchAuditStatus}
  250. onChange={(e) => { this.setState({ searchAuditStatus: e }) }}>
  251. {
  252. auditStatusList.map(function (item, i) {
  253. return <Select.Option key={i} value={item.value} >{item.key}</Select.Option>
  254. })
  255. }
  256. </Select>
  257. <Input placeholder="认证名称" value={this.state.searchAftUsername}
  258. onChange={(e) => { this.setState({ searchAftUsername: e.target.value }); }} />
  259. <Input placeholder="联系方式" value={this.state.searchEmail}
  260. onChange={(e) => { this.setState({ searchEmail: e.target.value }); }} />
  261. <Button type="primary" onClick={this.search}>搜索</Button>
  262. <Button onClick={this.reset}>重置</Button>
  263. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  264. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  265. <p>
  266. <span>注册时间:</span>
  267. <RangePicker value={[moment(this.state.searchTime[0]), moment(this.state.searchTime[1])]}
  268. onChange={(data, dataString) => { this.setState({ searchTime: dataString }); }} />
  269. </p>
  270. </div>
  271. </div>
  272. <div className="patent-table">
  273. <Spin spinning={this.state.loading}>
  274. <Table columns={this.state.columns}
  275. dataSource={this.state.dataSource}
  276. pagination={this.state.pagination}
  277. onRowClick={this.tableRowClick} />
  278. </Spin>
  279. </div>
  280. <UserDesc data={this.state.RowData} showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  281. </div >
  282. );
  283. }
  284. });
  285. export default UserList;