userList.jsx 11 KB

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