orgList.jsx 11 KB

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