orgList.jsx 11 KB

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