user.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. import React from 'react';
  2. import ReactDom from 'react-dom';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import { Form,Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload } from 'antd';
  6. import Newuser from "./newUser.jsx"
  7. import './userMangagement.less'
  8. import {techAuditStatusList, station,post } from '../../../dataDic.js';
  9. const User=Form.create()(React.createClass({
  10. loadData(pageNo) {
  11. this.state.data = [];
  12. this.setState({
  13. loading: true
  14. });
  15. $.ajax({
  16. method: "get",
  17. dataType: "json",
  18. crossDomain: false,
  19. url: globalConfig.context + '/api/admin/supervise/adminLi',
  20. data: {
  21. pageNo: pageNo || 1,
  22. pageSize: this.state.pagination.pageSize,
  23. userName:this.state.userNameSearch,
  24. organization:this.state.organizationSearch,
  25. role:this.state.rolesSearch,
  26. post:this.state.postSearch,
  27. station:this.state.stationSearch,
  28. status:this.state.statusSeach,
  29. signName:this.state.signNameSearch,
  30. mobile:this.state.mobileSearch,
  31. proName:this.state.proNameSearch
  32. },
  33. success: function (data) {
  34. let theArr = [];
  35. if (!data.data || !data.data.list) {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message);
  38. };
  39. } else {
  40. for (let i = 0; i < data.data.list.length; i++) {
  41. let thisdata = data.data.list[i];
  42. theArr.push({
  43. key: i,
  44. id: thisdata.id,
  45. mobile: thisdata.mobile,
  46. name: thisdata.name,
  47. email: thisdata.email,
  48. createTime: thisdata.createTime,
  49. number: thisdata.number,
  50. province: thisdata.province,
  51. position: thisdata.position,
  52. superior: thisdata.superior,
  53. superiorId: thisdata.superiorId,
  54. createTimeFormattedDate: thisdata.createTimeFormattedDate
  55. });
  56. };
  57. this.state.pagination.current = data.data.pageNo?data.data.pageNo:'0';
  58. this.state.pagination.total = data.data.totalCount?data.data.totalCount:'0';
  59. };
  60. this.setState({
  61. dataSource: theArr,
  62. pagination: this.state.pagination
  63. });
  64. }.bind(this),
  65. }).always(function () {
  66. this.setState({
  67. loading: false
  68. });
  69. }.bind(this));
  70. },
  71. getInitialState() {
  72. return {
  73. datauser:{},
  74. searchMore: true,
  75. selectedRowKeys: [],
  76. selectedRows: [],
  77. loading: false,
  78. pagination: {
  79. defaultCurrent: 1,
  80. defaultPageSize: 10,
  81. showQuickJumper: true,
  82. pageSize: 10,
  83. onChange: function (page) {
  84. this.loadData(page);
  85. }.bind(this),
  86. showTotal: function (total) {
  87. return '共' + total + '条数据';
  88. }
  89. },
  90. columns: [
  91. {
  92. title: '用户编号',
  93. dataIndex: 'key',
  94. key: 'key',
  95. }, {
  96. title: '登录用户名',
  97. dataIndex: 'name',
  98. key: 'name',
  99. }, {
  100. title: '角色',
  101. dataIndex: 'email',
  102. key: 'email',
  103. }, {
  104. title: '用户姓名',
  105. dataIndex: 'createTime',
  106. key: 'createTime',
  107. }, {
  108. title: '组织机构',
  109. dataIndex: 'number',
  110. key: 'number',
  111. }, {
  112. title: '职务',
  113. dataIndex: 'auditStatus',
  114. key: 'auditStatus',
  115. },
  116. {
  117. title: '岗位',
  118. dataIndex: 'boutique',
  119. key: 'boutique',
  120. },
  121. {
  122. title: '联系手机',
  123. dataIndex: 'mobile',
  124. key: 'mobile',
  125. },
  126. {
  127. title: '上级主管姓名',
  128. dataIndex: 'province',
  129. key: 'province',
  130. },
  131. {
  132. title: '状态',
  133. dataIndex: 'a',
  134. key: 'a',
  135. }
  136. ],
  137. dataSource: [],
  138. };
  139. },
  140. componentWillMount() {
  141. let organizationArr = [];
  142. techAuditStatusList.map(function (item) {
  143. organizationArr.push(
  144. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  145. )
  146. });
  147. this.state.organizationList = organizationArr;
  148. this.loadData();
  149. },
  150. tableRowClick(record, index) {
  151. this.state.userDetaile=true;
  152. this.state.datauser = record;
  153. this.setState({
  154. showDesc: true
  155. });
  156. },
  157. //锁定
  158. locking() {
  159. let deletedIds = [];
  160. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  161. let rowItem = this.state.selectedRows[idx];
  162. if (rowItem.id) {
  163. deletedIds.push(rowItem.id)
  164. };
  165. };
  166. this.setState({
  167. selectedRowKeys: [],
  168. loading: true
  169. });
  170. $.ajax({
  171. method: "POST",
  172. dataType: "json",
  173. crossDomain: false,
  174. url: globalConfig.context + "/api/admin/achievement/delete",
  175. data: {
  176. ids: deletedIds
  177. }
  178. }).done(function (data) {
  179. if (!data.error.length) {
  180. message.success('锁定成功!');
  181. this.setState({
  182. loading: false,
  183. });
  184. } else {
  185. message.warning(data.error[0].message);
  186. };
  187. this.loadData();
  188. }.bind(this));
  189. },
  190. //激活
  191. activation() {
  192. let deletedIds = [];
  193. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  194. let rowItem = this.state.selectedRows[idx];
  195. if (rowItem.id) {
  196. deletedIds.push(rowItem.id)
  197. };
  198. };
  199. this.setState({
  200. selectedRowKeys: [],
  201. loading: true
  202. });
  203. $.ajax({
  204. method: "POST",
  205. dataType: "json",
  206. crossDomain: false,
  207. url: globalConfig.context + "/api/admin/achievement/delete",
  208. data: {
  209. ids: deletedIds
  210. }
  211. }).done(function (data) {
  212. if (!data.error.length) {
  213. message.success('激活成功!');
  214. this.setState({
  215. loading: false,
  216. });
  217. } else {
  218. message.warning(data.error[0].message);
  219. };
  220. this.loadData();
  221. }.bind(this));
  222. },
  223. //删除
  224. delectRow() {
  225. let deletedIds = [];
  226. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  227. let rowItem = this.state.selectedRows[idx];
  228. if (rowItem.id) {
  229. deletedIds.push(rowItem.id)
  230. };
  231. };
  232. this.setState({
  233. selectedRowKeys: [],
  234. loading: true
  235. });
  236. $.ajax({
  237. method: "POST",
  238. dataType: "json",
  239. crossDomain: false,
  240. url: globalConfig.context + "/api/admin/achievement/delete",
  241. data: {
  242. ids: deletedIds
  243. }
  244. }).done(function (data) {
  245. if (!data.error.length) {
  246. message.success('删除成功!');
  247. this.setState({
  248. loading: false,
  249. });
  250. } else {
  251. message.warning(data.error[0].message);
  252. };
  253. this.loadData();
  254. }.bind(this));
  255. },
  256. addClick() {
  257. this.state.userDetaile=false;
  258. this.setState({
  259. showDesc: true
  260. });
  261. },
  262. closeDesc(e, s) {
  263. this.state.showDesc = e;
  264. if (s) {
  265. this.loadData();
  266. };
  267. },
  268. search() {
  269. this.loadData();
  270. },
  271. reset() {
  272. this.state.userNameSearch='';
  273. this.state.organizationSearch=undefined;
  274. this.state.rolesSearch=undefined;
  275. this.state.postSearch=undefined;
  276. this.state.stationSearch=undefined;
  277. this.state.statusSeach=undefined;
  278. this.state.signNameSearch='';
  279. this.state.mobileSearch='';
  280. this.state.proNameSearch='';
  281. this.loadData();
  282. },
  283. searchSwitch() {
  284. this.setState({
  285. searchMore: !this.state.searchMore
  286. });
  287. },
  288. render() {
  289. const rowSelection = {
  290. selectedRowKeys: this.state.selectedRowKeys,
  291. onChange: (selectedRowKeys, selectedRows) => {
  292. this.setState({
  293. selectedRows: selectedRows.slice(-1),
  294. selectedRowKeys: selectedRowKeys.slice(-1)
  295. });
  296. },
  297. onSelectAll: (selected, selectedRows, changeRows) => {
  298. this.setState({
  299. selectedRowKeys:[]
  300. })
  301. },
  302. };
  303. const hasSelected = this.state.selectedRowKeys.length > 0;
  304. const { RangePicker } = DatePicker;
  305. return (
  306. <div className="user-content" >
  307. <div className="content-title">
  308. <div className="user-search">
  309. <Input placeholder="用户姓名" style={{width:'150px'}}
  310. value={this.state.userNameSearch}
  311. onChange={(e) => { this.setState({ userNameSearch: e.target.value }); }} />
  312. <Select placeholder="组织机构"
  313. style={{ width: 160 }}
  314. value={this.state.organizationSearch}
  315. onChange={(e) => { this.setState({ organizationSearch: e }) }}>
  316. {this.state.organizationList}
  317. </Select>
  318. <Select placeholder="角色"
  319. style={{ width: 160 }}
  320. value={this.state.rolesSearch}
  321. onChange={(e) => { this.setState({ rolesSearch: e }) }}>
  322. {this.state.organizationList}
  323. </Select>
  324. <Button type="primary" onClick={this.search}>搜索</Button>
  325. <Button onClick={this.reset}>重置</Button>
  326. <Button style={{ background: "red", border: "none", color: "#fff" }}
  327. disabled={!hasSelected}
  328. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  329. <Button style={{ background: "#333333", border: "none", color: "#fff" }}
  330. disabled={!hasSelected}
  331. onClick={this.locking}>锁定<Icon type="lock" /></Button>
  332. <Button style={{ background: "green", border: "none", color: "#fff" }}
  333. disabled={!hasSelected}
  334. onClick={this.activation}>激活<Icon type="unlock" /></Button>
  335. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  336. <Button type="primary" className="addButton" onClick={this.addClick} >新增用户<Icon type="user" /></Button>
  337. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  338. <Select placeholder="职务"
  339. style={{ width: 160 }}
  340. value={this.state.postSearch}
  341. onChange={(e) => { this.setState({ postSearch: e }) }}>
  342. {
  343. post.map(function (item) {
  344. return <Select.Option key={item.value} >{item.key}</Select.Option>
  345. })
  346. }
  347. </Select>
  348. <Select placeholder="岗位"
  349. style={{ width: 160 }}
  350. value={this.state.stationSearch}
  351. onChange={(e) => { this.setState({ stationSearch: e }) }}>
  352. {
  353. station.map(function (item) {
  354. return <Select.Option key={item.value} >{item.key}</Select.Option>
  355. })
  356. }
  357. </Select>
  358. <Select placeholder="状态"
  359. style={{ width: 160 }}
  360. value={this.state.statusSeach}
  361. onChange={(e) => { this.setState({ statusSeach: e }) }}>
  362. {this.state.organizationList}
  363. </Select>
  364. <Input placeholder="登录用户名" style={{width:'150px'}}
  365. value={this.state.signNameSearch}
  366. onChange={(e) => { this.setState({ signNameSearch: e.target.value }); }} />
  367. <Input placeholder="联系手机" style={{width:'150px',margin:'0 15px'}}
  368. value={this.state.mobileSearch}
  369. onChange={(e) => { this.setState({ mobileSearch: e.target.value }); }} />
  370. <Input placeholder="上级主管名称" style={{width:'150px'}}
  371. value={this.state.proNameSearch}
  372. onChange={(e) => { this.setState({ proNameSearch: e.target.value }); }} />
  373. </div>
  374. </div>
  375. <div className="patent-table">
  376. <Spin spinning={this.state.loading}>
  377. <Table columns={this.state.columns}
  378. dataSource={this.state.dataSource}
  379. rowSelection={rowSelection}
  380. pagination={this.state.pagination}
  381. onRowClick={this.tableRowClick} />
  382. </Spin>
  383. </div>
  384. <Newuser
  385. userDetaile={this.state.userDetaile}
  386. datauser={this.state.datauser}
  387. showDesc={this.state.showDesc}
  388. closeDesc={this.closeDesc} />
  389. </div >
  390. </div>
  391. );
  392. }
  393. }));
  394. export default User;