orgList.jsx 11 KB

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