user.jsx 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  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, AutoComplete, Spin, Table, Switch, message, DatePicker, Modal, Upload, Popconfirm, Tabs } from 'antd';
  6. import Newuser from "./newUser.jsx"
  7. import './userMangagement.less'
  8. import { techAuditStatusList, station, post } from '../../../dataDic.js';
  9. import { getPost, getStation } from '../../../tools.js';
  10. import { ChooseList } from "../../order/orderNew/chooseList";
  11. const { TabPane } = Tabs
  12. const User = Form.create()(React.createClass({
  13. loadData(pageNo) {
  14. this.state.data = [];
  15. this.setState({
  16. userDetaile: false,
  17. loading: true,
  18. page: pageNo
  19. });
  20. var admin = window.adminData.isSuperAdmin || '';
  21. var departmentId = window.adminData.departmentId || '';
  22. $.ajax({
  23. method: "get",
  24. dataType: "json",
  25. crossDomain: false,
  26. url: globalConfig.context + '/api/admin/superviser/adminList',
  27. data: {
  28. pageNo: pageNo || 1,
  29. pageSize: this.state.pagination.pageSize,
  30. name: this.state.userNameSearch,
  31. departmentId: admin ? this.state.organizationSearch : departmentId,
  32. rid: this.state.rolesSearch,
  33. duty: this.state.postSearch,
  34. position: this.state.stationSearch,
  35. status: this.state.statusSeach,
  36. mobile: this.state.signNameSearch,
  37. superiorId: this.state.theTypes
  38. },
  39. success: function (data) {
  40. let theArr = [];
  41. if (!data.data || !data.data.list) {
  42. if (data.error && data.error.length) {
  43. message.warning(data.error[0].message);
  44. };
  45. } else {
  46. for (let i = 0; i < data.data.list.length; i++) {
  47. let thisdata = data.data.list[i];
  48. theArr.push({
  49. key: i,
  50. id: thisdata.id,
  51. mobile: thisdata.mobile,
  52. name: thisdata.name,
  53. email: thisdata.email,
  54. createTime: thisdata.createTime,
  55. province: thisdata.province,
  56. position: thisdata.position,
  57. superior: thisdata.superior, //上级名称
  58. superiorId: thisdata.superiorId, //上级Id
  59. duty: thisdata.duty, //职务
  60. status: thisdata.status,
  61. userNo: thisdata.userNo,
  62. departmentName: thisdata.departmentName, //部门名称
  63. departmentId: thisdata.departmentId, //部门id
  64. roles: thisdata.roles.join(','),
  65. rolesId: thisdata.rolesId,
  66. lastLoginTime: thisdata.lastLoginTime,
  67. });
  68. };
  69. this.state.pagination.current = data.data.pageNo ? data.data.pageNo : '0';
  70. this.state.pagination.total = data.data.totalCount ? data.data.totalCount : '0';
  71. };
  72. if (!data.data.list.length) {
  73. this.state.pagination.current = 0
  74. this.state.pagination.total = 0
  75. }
  76. this.setState({
  77. dataSource: theArr,
  78. pagination: this.state.pagination,
  79. selectedRowKeys: []
  80. });
  81. }.bind(this),
  82. }).always(function () {
  83. this.setState({
  84. loading: false
  85. });
  86. }.bind(this));
  87. },
  88. loadDatas(pageNo) {
  89. this.state.data = [];
  90. this.setState({
  91. userDetaile: false,
  92. loading: true,
  93. });
  94. var admin = window.adminData.isSuperAdmin || '';
  95. var departmentId = window.adminData.departmentId || '';
  96. $.ajax({
  97. method: "get",
  98. dataType: "json",
  99. crossDomain: false,
  100. url: globalConfig.context + '/api/admin/superviser/adminList',
  101. data: {
  102. pageNo: pageNo || 1,
  103. pageSize: this.state.paginations.pageSize,
  104. name: this.state.userNameSearchs,
  105. status: "正常"
  106. // departmentId: admin?this.state.organizationSearch:departmentId,
  107. // rid: this.state.rolesSearch,
  108. // duty: this.state.postSearch,
  109. // position: this.state.stationSearch,
  110. // status: this.state.statusSeach,
  111. // mobile: this.state.signNameSearch,
  112. // superiorId: this.state.theTypes
  113. },
  114. success: function (data) {
  115. let theArr = [];
  116. if (!data.data || !data.data.list) {
  117. if (data.error && data.error.length) {
  118. message.warning(data.error[0].message);
  119. };
  120. } else {
  121. for (let i = 0; i < data.data.list.length; i++) {
  122. let thisdata = data.data.list[i];
  123. theArr.push({
  124. key: i,
  125. id: thisdata.id,
  126. mobile: thisdata.mobile,
  127. name: thisdata.name,
  128. email: thisdata.email,
  129. createTime: thisdata.createTime,
  130. province: thisdata.province,
  131. position: thisdata.position,
  132. superior: thisdata.superior, //上级名称
  133. superiorId: thisdata.superiorId, //上级Id
  134. duty: thisdata.duty, //职务
  135. status: thisdata.status,
  136. userNo: thisdata.userNo,
  137. departmentName: thisdata.departmentName, //部门名称
  138. departmentId: thisdata.departmentId, //部门id
  139. roles: thisdata.roles.join(','),
  140. rolesId: thisdata.rolesId
  141. });
  142. };
  143. this.state.paginations.current = data.data.pageNo ? data.data.pageNo : '0';
  144. this.state.paginations.total = data.data.totalCount ? data.data.totalCount : '0';
  145. };
  146. if (!data.data.list.length) {
  147. this.state.paginations.current = 0
  148. this.state.paginations.total = 0
  149. }
  150. this.setState({
  151. dataSourceData: theArr,
  152. paginations: this.state.paginations,
  153. });
  154. }.bind(this),
  155. }).always(function () {
  156. this.setState({
  157. loading: false
  158. });
  159. }.bind(this));
  160. },
  161. getInitialState() {
  162. return {
  163. datauser: {},
  164. searchMore: true,
  165. selectedRowKeys: [],
  166. selectedRows: [],
  167. userDetaile: false,
  168. departmentArr: [],
  169. loading: false,
  170. roleArr: [],
  171. pagination: {
  172. defaultCurrent: 1,
  173. defaultPageSize: 10,
  174. showQuickJumper: true,
  175. pageSize: 10,
  176. onChange: function (page) {
  177. this.loadData(page);
  178. }.bind(this),
  179. showTotal: function (total) {
  180. return '共' + total + '条数据';
  181. }
  182. },
  183. paginations: {
  184. defaultCurrent: 1,
  185. defaultPageSize: 10,
  186. showQuickJumper: true,
  187. pageSize: 10,
  188. onChange: function (page) {
  189. this.loadDatas(page);
  190. }.bind(this),
  191. showTotal: function (total) {
  192. return '共' + total + '条数据';
  193. }
  194. },
  195. columns: [{
  196. title: '用户编号',
  197. dataIndex: 'userNo',
  198. key: 'userNo',
  199. }, {
  200. title: '登录用户名',
  201. dataIndex: 'mobile',
  202. key: 'mobile',
  203. }, {
  204. title: '角色',
  205. dataIndex: 'roles',
  206. key: 'roles',
  207. }, {
  208. title: '用户姓名',
  209. dataIndex: 'name',
  210. key: 'name',
  211. }, {
  212. title: '部门',
  213. dataIndex: 'departmentName',
  214. key: 'departmentName',
  215. }, {
  216. title: '职务',
  217. dataIndex: 'duty',
  218. key: 'duty',
  219. render: text => { return getPost(text) }
  220. },
  221. {
  222. title: '岗位',
  223. dataIndex: 'position',
  224. key: 'position',
  225. render: text => { return getStation(text) }
  226. },
  227. {
  228. title: '上级主管姓名',
  229. dataIndex: 'superior',
  230. key: 'superior',
  231. },
  232. {
  233. title: '状态',
  234. dataIndex: 'status',
  235. key: 'status',
  236. render: (text) =>
  237. <span style={{ color: ["green", "red"][text] }}>
  238. {text == 0
  239. ? "正常" : text == 1
  240. ? "停用" : "-"}
  241. </span>
  242. },
  243. {
  244. title: '最后登录时间',
  245. dataIndex: 'lastLoginTime',
  246. key: 'lastLoginTime',
  247. }
  248. ],
  249. column: [{
  250. title: '用户编号',
  251. dataIndex: 'userNo',
  252. key: 'userNo',
  253. }, {
  254. title: '登录用户名',
  255. dataIndex: 'mobile',
  256. key: 'mobile',
  257. }, {
  258. title: '角色',
  259. dataIndex: 'roles',
  260. key: 'roles',
  261. }, {
  262. title: '用户姓名',
  263. dataIndex: 'name',
  264. key: 'name',
  265. }, {
  266. title: '转交',
  267. dataIndex: 'ee',
  268. key: 'ee',
  269. render: (text, record, index) => {
  270. return <div>
  271. <Popconfirm title={'请确认转交【' + record.name + '】'} onConfirm={(e) => { this.examineOK(record) }} okText="确认" cancelText="取消">
  272. <Button style={{ marginRight: '5px' }} onClick={(e) => { e.stopPropagation() }} type="primary">转交</Button>
  273. </Popconfirm>
  274. </div>
  275. }
  276. },
  277. ],
  278. dataSourceData: [],
  279. };
  280. },
  281. //点击离职一键转交
  282. resources() {
  283. this.loadDatas();
  284. let deletedIds;
  285. let rowItem;
  286. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  287. rowItem = this.state.selectedRows[idx];
  288. // console.log(rowItem.id);
  289. if (rowItem.id) {
  290. deletedIds = rowItem.id;
  291. };
  292. };
  293. this.setState({
  294. visible: true,
  295. aid: deletedIds
  296. });
  297. },
  298. //关闭离职一键转交
  299. handleCancel() {
  300. this.setState({
  301. visible: false,
  302. selectedRowKeys: []
  303. }, () => {
  304. this.loadData(this.state.page);
  305. });
  306. },
  307. //一键离职
  308. examineOK(record) {
  309. // console.log(record);
  310. this.setState({
  311. loading: true
  312. });
  313. $.ajax({
  314. method: "POST",
  315. dataType: "json",
  316. crossDomain: false,
  317. url: globalConfig.context + "/api/admin/role/dimission",
  318. data: {
  319. aid: this.state.aid,
  320. transferId: record.id,
  321. }
  322. }).done(function (data) {
  323. if (!data.error.length) {
  324. message.success('转交成功!');
  325. this.handleCancel()
  326. } else {
  327. message.warning(data.error[0].message);
  328. };
  329. this.setState({
  330. loading: false,
  331. visible2: false
  332. });
  333. }.bind(this));
  334. },
  335. componentWillMount() {
  336. this.loadData();
  337. this.departmentList();
  338. this.rolesList();
  339. this.getList();
  340. },
  341. tableRowClick(record, index) {
  342. this.rolesArrS(record)
  343. },
  344. //新建获取id
  345. addIdS() {
  346. $.ajax({
  347. method: "get",
  348. dataType: "json",
  349. crossDomain: false,
  350. url: globalConfig.context + '/api/admin/superviser/newId',
  351. data: {},
  352. success: function (data) {
  353. this.setState({
  354. addId: data.data
  355. });
  356. }.bind(this),
  357. }).always(function () {
  358. this.setState({
  359. loading: false
  360. });
  361. }.bind(this));
  362. },
  363. //部门
  364. departmentList() {
  365. this.setState({
  366. loading: true
  367. });
  368. $.ajax({
  369. method: "get",
  370. dataType: "json",
  371. crossDomain: false,
  372. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  373. data: {
  374. },
  375. success: function (data) {
  376. let thedata = data.data;
  377. let theArr = [];
  378. if (!thedata) {
  379. if (data.error && data.error.length) {
  380. message.warning(data.error[0].message);
  381. };
  382. thedata = {};
  383. } else {
  384. thedata.map(function (item, index) {
  385. theArr.push({
  386. key: index,
  387. name: item.name,
  388. id: item.id,
  389. depNo: item.depNo
  390. })
  391. })
  392. }
  393. this.setState({
  394. departmentArr: theArr,
  395. })
  396. }.bind(this),
  397. }).always(function () {
  398. this.setState({
  399. loading: false
  400. });
  401. }.bind(this));
  402. },
  403. //修改时获取角色数组
  404. rolesArrS(e) {
  405. $.ajax({
  406. method: "get",
  407. dataType: "json",
  408. crossDomain: false,
  409. url: globalConfig.context + "/api/admin/role",
  410. data: {
  411. uid: e.id
  412. },
  413. success: function (data) {
  414. let thedata = data.data;
  415. let theArr = [];
  416. let theId = []
  417. if (!thedata) {
  418. if (data.error && data.error.length) {
  419. message.warning(data.error[0].message);
  420. };
  421. thedata = {};
  422. } else {
  423. }
  424. this.setState({
  425. role: thedata,
  426. userDetaile: true,
  427. showDesc: true,
  428. datauser: e
  429. })
  430. }.bind(this),
  431. }).always(function () {
  432. }.bind(this));
  433. },
  434. //角色
  435. rolesList() {
  436. this.setState({
  437. loading: true
  438. });
  439. $.ajax({
  440. method: "get",
  441. dataType: "json",
  442. crossDomain: false,
  443. url: globalConfig.context + "/api/roles",
  444. data: {
  445. },
  446. success: function (data) {
  447. let thedata = data.data;
  448. let theArr = [];
  449. if (!thedata) {
  450. if (data.error && data.error.length) {
  451. message.warning(data.error[0].message);
  452. };
  453. thedata = {};
  454. } else {
  455. thedata.map(function (item, index) {
  456. theArr.push({
  457. key: index,
  458. roleName: item.roleName,
  459. id: item.id,
  460. })
  461. })
  462. }
  463. this.setState({
  464. roleArr: theArr,
  465. })
  466. }.bind(this),
  467. }).always(function () {
  468. this.setState({
  469. loading: false
  470. });
  471. }.bind(this));
  472. },
  473. //锁定
  474. locking() {
  475. let deletedIds;
  476. let statust;
  477. let mobiles;
  478. let names;
  479. let rolesId = [];
  480. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  481. let rowItem = this.state.selectedRows[idx];
  482. if (rowItem.id) {
  483. deletedIds = rowItem.id;
  484. statust = rowItem.status;
  485. names = rowItem.name;
  486. mobiles = rowItem.mobile;
  487. rolesId = rowItem.rolesId
  488. };
  489. };
  490. this.setState({
  491. selectedRowKeys: [],
  492. loading: true
  493. });
  494. $.ajax({
  495. method: "POST",
  496. dataType: "json",
  497. crossDomain: false,
  498. url: globalConfig.context + "/api/admin/superviser/updateAdmin",
  499. data: {
  500. roles: rolesId,
  501. data: JSON.stringify({
  502. id: deletedIds,
  503. status: '锁定',
  504. name: names,
  505. mobile: mobiles,
  506. }),
  507. }
  508. }).done(function (data) {
  509. if (!data.error.length) {
  510. message.success('锁定成功!');
  511. this.setState({
  512. loading: false,
  513. });
  514. } else {
  515. message.warning(data.error[0].message);
  516. };
  517. this.loadData();
  518. }.bind(this));
  519. },
  520. //激活
  521. activation() {
  522. let deletedIds;
  523. let statust;
  524. let mobiles;
  525. let names;
  526. let rolesId = []
  527. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  528. let rowItem = this.state.selectedRows[idx];
  529. if (rowItem.id) {
  530. deletedIds = rowItem.id;
  531. statust = rowItem.status;
  532. names = rowItem.name;
  533. mobiles = rowItem.mobile;
  534. rolesId = rowItem.rolesId
  535. };
  536. };
  537. this.setState({
  538. selectedRowKeys: [],
  539. loading: true
  540. });
  541. $.ajax({
  542. method: "POST",
  543. dataType: "json",
  544. crossDomain: false,
  545. url: globalConfig.context + "/api/admin/superviser/updateAdmin",
  546. data: {
  547. roles: rolesId,
  548. data: JSON.stringify({
  549. id: deletedIds,
  550. status: '正常',
  551. name: names,
  552. mobile: mobiles,
  553. })
  554. }
  555. }).done(function (data) {
  556. if (!data.error.length) {
  557. message.success('激活成功!');
  558. this.setState({
  559. loading: false,
  560. });
  561. } else {
  562. message.warning(data.error[0].message);
  563. };
  564. this.loadData();
  565. }.bind(this));
  566. },
  567. //删除
  568. delectRow() {
  569. let deletedIds;
  570. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  571. let rowItem = this.state.selectedRows[idx];
  572. if (rowItem.id) {
  573. deletedIds = rowItem.id;
  574. };
  575. };
  576. this.setState({
  577. selectedRowKeys: [],
  578. loading: true
  579. });
  580. $.ajax({
  581. method: "POST",
  582. dataType: "json",
  583. crossDomain: false,
  584. url: globalConfig.context + "/api/admin/superviser/deleteById",
  585. data: {
  586. id: deletedIds,
  587. }
  588. }).done(function (data) {
  589. if (!data.error.length) {
  590. message.success('删除成功!');
  591. this.setState({
  592. loading: false,
  593. });
  594. } else {
  595. message.warning(data.error[0].message);
  596. };
  597. this.loadData(this.state.page);
  598. }.bind(this));
  599. },
  600. addClick() {
  601. this.addIdS()
  602. this.setState({
  603. datauser: {},
  604. showDesc: true,
  605. userDetaile: false,
  606. });
  607. },
  608. closeDesc(e, s) {
  609. this.setState({
  610. userDetaile: false,
  611. showDesc: e
  612. })
  613. if (s) {
  614. this.loadData(this.state.page);
  615. };
  616. },
  617. search() {
  618. this.state.userDetaile = false
  619. this.loadData();
  620. },
  621. searchs() {
  622. this.state.userDetaile = false
  623. this.loadDatas();
  624. },
  625. reset() {
  626. this.state.userNameSearch = '';
  627. this.state.organizationSearch = undefined;
  628. this.state.rolesSearch = undefined;
  629. this.state.postSearch = undefined;
  630. this.state.stationSearch = undefined;
  631. this.state.statusSeach = undefined;
  632. this.state.signNameSearch = '';
  633. this.state.mobileSearch = '';
  634. this.state.auto = '';
  635. this.state.theTypes = '';
  636. this.loadData();
  637. },
  638. resets() {
  639. this.state.userNameSearchs = '';
  640. this.state.organizationSearch = undefined;
  641. this.state.rolesSearch = undefined;
  642. this.state.postSearch = undefined;
  643. this.state.stationSearch = undefined;
  644. this.state.statusSeach = undefined;
  645. this.state.signNameSearch = '';
  646. this.state.mobileSearch = '';
  647. this.state.auto = '';
  648. this.state.theTypes = '';
  649. this.loadDatas();
  650. },
  651. searchSwitch() {
  652. this.setState({
  653. searchMore: !this.state.searchMore
  654. });
  655. },
  656. //主管初始加载(自动补全)
  657. supervisor(e) {
  658. $.ajax({
  659. method: "post",
  660. dataType: "json",
  661. crossDomain: false,
  662. url: globalConfig.context + "/api/admin/organization/selectName",
  663. data: {
  664. name: e
  665. },
  666. success: function (data) {
  667. let thedata = data.data;
  668. if (!thedata) {
  669. if (data.error && data.error.length) {
  670. message.warning(data.error[0].message);
  671. };
  672. thedata = {};
  673. };
  674. this.setState({
  675. customerArr: thedata,
  676. });
  677. }.bind(this),
  678. }).always(function () {
  679. this.setState({
  680. loading: false
  681. });
  682. }.bind(this));
  683. },
  684. //上级主管输入框失去焦点是判断客户是否存在
  685. selectAuto(value, options) {
  686. this.setState({
  687. auto: value
  688. })
  689. },
  690. blurChange(e) {
  691. let theType = '';
  692. let contactLists = this.state.customerArr || [];
  693. if (e) {
  694. contactLists.map(function (item) {
  695. if (item.name == e.toString()) {
  696. theType = item.id;
  697. }
  698. });
  699. }
  700. this.setState({
  701. theTypes: theType
  702. })
  703. },
  704. //值改变时请求客户名称
  705. httpChange(e) {
  706. if (e.length >= 1) {
  707. this.supervisor(e);
  708. }
  709. this.setState({
  710. auto: e
  711. })
  712. },
  713. changeList(arr) {
  714. const newArr = [];
  715. this.state.columns.forEach(item => {
  716. arr.forEach(val => {
  717. if (val === item.title) {
  718. newArr.push(item);
  719. }
  720. });
  721. });
  722. this.setState({
  723. changeList: newArr
  724. });
  725. },
  726. // 筛选数据
  727. getList() {
  728. this.setState({
  729. loading: true,
  730. });
  731. $.ajax({
  732. method: "get",
  733. dataType: "json",
  734. crossDomain: false,
  735. url: globalConfig.context + "/api/admin/amb/selectAll",
  736. success: function (data) {
  737. this.setState({
  738. loading: false,
  739. });
  740. if (data.error && data.error.length === 0) {
  741. let menuList = data.data
  742. this.setState({
  743. level1Data: menuList ? this.handleTreeData(menuList) : []
  744. });
  745. } else {
  746. message.warning(data.error[0].message);
  747. }
  748. }.bind(this),
  749. }).always(
  750. function () {
  751. this.setState({
  752. loading: false,
  753. });
  754. }.bind(this)
  755. );
  756. },
  757. // 树状默认数据处理
  758. handleTreeData(treeData) {
  759. let nodeDta = [];
  760. treeData.map(item => {
  761. let treeObj = {};
  762. treeObj.key = item.id
  763. treeObj.id = item.id
  764. treeObj.value = item.id
  765. treeObj.label = item.name
  766. treeObj.title = item.name
  767. treeObj.lvl = item.lvl
  768. treeObj.parentId = item.parentId
  769. item.list ? treeObj.children = this.handleTreeData(item.list) : null;
  770. nodeDta.push(treeObj)
  771. })
  772. return nodeDta
  773. },
  774. render() {
  775. const rowSelection = {
  776. selectedRowKeys: this.state.selectedRowKeys,
  777. onChange: (selectedRowKeys, selectedRows) => {
  778. this.setState({
  779. selectedRows: selectedRows.slice(-1),
  780. selectedRowKeys: selectedRowKeys.slice(-1)
  781. });
  782. },
  783. onSelectAll: (selected, selectedRows, changeRows) => {
  784. this.setState({
  785. selectedRowKeys: []
  786. })
  787. },
  788. };
  789. const dataSources = this.state.customerArr || [];
  790. const options = dataSources.map((group, index) =>
  791. <Select.Option key={index} value={group.name}>{group.name}</Select.Option>
  792. )
  793. const hasSelected = this.state.selectedRowKeys.length > 0;
  794. const { RangePicker } = DatePicker;
  795. let departmentArr = this.state.departmentArr || [];
  796. let roleArr = this.state.roleArr || [];
  797. return (
  798. <div className="user-content">
  799. <div className="content-title">
  800. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  801. <TabPane tab="搜索" key="1">
  802. <div className="user-search">
  803. <Input
  804. placeholder="用户姓名"
  805. style={{ width: "150px" }}
  806. value={this.state.userNameSearch}
  807. onChange={e => {
  808. this.setState({ userNameSearch: e.target.value });
  809. }}
  810. />
  811. {window.adminData.isSuperAdmin ? (
  812. <Select
  813. placeholder="部门"
  814. style={{ width: 160 }}
  815. value={this.state.organizationSearch}
  816. onChange={e => {
  817. this.setState({ organizationSearch: e });
  818. }}
  819. >
  820. {departmentArr.map(function (item) {
  821. return (
  822. <Select.Option key={item.id}>{item.name}</Select.Option>
  823. );
  824. })}
  825. </Select>
  826. ) : (
  827. ""
  828. )}
  829. <Select
  830. placeholder="角色"
  831. style={{ width: 160 }}
  832. value={this.state.rolesSearch}
  833. onChange={e => {
  834. this.setState({ rolesSearch: e });
  835. }}
  836. >
  837. {roleArr.map(function (item) {
  838. return (
  839. <Select.Option key={item.id}>
  840. {item.roleName}
  841. </Select.Option>
  842. );
  843. })}
  844. </Select>
  845. <div
  846. className="search-more"
  847. style={{ display: "inline-block" }}
  848. >
  849. <Select
  850. placeholder="职务"
  851. style={{ width: 160 }}
  852. value={this.state.postSearch}
  853. onChange={e => {
  854. this.setState({ postSearch: e });
  855. }}
  856. >
  857. {post.map(function (item) {
  858. return (
  859. <Select.Option key={item.value}>
  860. {item.key}
  861. </Select.Option>
  862. );
  863. })}
  864. </Select>
  865. <Select
  866. placeholder="岗位"
  867. style={{ width: 160 }}
  868. value={this.state.stationSearch}
  869. onChange={e => {
  870. this.setState({ stationSearch: e });
  871. }}
  872. >
  873. {station.map(function (item) {
  874. return (
  875. <Select.Option key={item.value}>
  876. {item.key}
  877. </Select.Option>
  878. );
  879. })}
  880. </Select>
  881. <Select
  882. placeholder="状态"
  883. style={{ width: 160 }}
  884. value={this.state.statusSeach}
  885. onChange={e => {
  886. this.setState({ statusSeach: e });
  887. }}
  888. >
  889. <Select.Option value={0}>正常</Select.Option>
  890. <Select.Option value={1}>锁定</Select.Option>
  891. </Select>
  892. <Input
  893. placeholder="登录用户名"
  894. style={{ width: "150px" }}
  895. value={this.state.signNameSearch}
  896. onChange={e => {
  897. this.setState({ signNameSearch: e.target.value });
  898. }}
  899. />
  900. <AutoComplete
  901. className="certain-category-search"
  902. dropdownClassName="certain-category-search-dropdown"
  903. dropdownMatchSelectWidth={false}
  904. dropdownStyle={{ width: 200 }}
  905. size="large"
  906. style={{
  907. width: "150px",
  908. height: "28px",
  909. marginLeft: "10px"
  910. }}
  911. dataSource={options}
  912. placeholder="输入上级主管名字"
  913. value={this.state.auto}
  914. onChange={this.httpChange}
  915. filterOption={true}
  916. onBlur={this.blurChange}
  917. onSelect={this.selectAuto}
  918. >
  919. <Input />
  920. </AutoComplete>
  921. </div>
  922. <Button type="primary" onClick={this.search}>
  923. 搜索
  924. </Button>
  925. <Button onClick={this.reset}>重置</Button>
  926. <Button
  927. style={{ background: "red", border: "none", color: "#fff", display: "none" }}
  928. disabled={!hasSelected}
  929. onClick={this.delectRow}
  930. >
  931. 删除
  932. <Icon type="minus" />
  933. </Button>
  934. {/* <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span> */}
  935. </div>
  936. </TabPane>
  937. <TabPane tab="操作" key="2">
  938. <Button
  939. style={{
  940. background: "#333333",
  941. border: "none",
  942. color: "#fff",
  943. marginBottom: 10,
  944. marginTop: 12,
  945. marginRight: 10
  946. }}
  947. disabled={!hasSelected}
  948. onClick={this.locking}
  949. >
  950. 锁定
  951. <Icon type="lock" />
  952. </Button>
  953. <Button
  954. style={{ background: "green", border: "none", color: "#fff", marginTop: 12 }}
  955. disabled={!hasSelected}
  956. onClick={this.activation}
  957. >
  958. 激活
  959. <Icon type="unlock" />
  960. </Button>
  961. {/* </TabPane>
  962. <TabPane tab="新增" key="3"> */}
  963. <Button
  964. type="primary"
  965. className="addButton"
  966. style={{ float: "left", marginBottom: 10, marginTop: 12 }}
  967. onClick={this.addClick}
  968. >
  969. 新增用户
  970. <Icon type="user" />
  971. </Button>
  972. {/* </TabPane>
  973. <TabPane tab="离职转交" key="4"> */}
  974. <Button
  975. type="primary"
  976. className="addButton"
  977. style={{ float: "left", marginBottom: 10, marginTop: 12 }}
  978. onClick={this.resources}
  979. disabled={!hasSelected}
  980. >
  981. 离职一键转交
  982. <Icon type="user" />
  983. </Button>
  984. </TabPane>
  985. <TabPane tab="更改表格显示数据" key="3">
  986. <div style={{ marginLeft: 10 }}>
  987. <ChooseList
  988. columns={this.state.columns}
  989. changeFn={this.changeList}
  990. changeList={this.state.changeList}
  991. top={55}
  992. margin={11}
  993. />
  994. </div>
  995. </TabPane>
  996. </Tabs>
  997. <div className="patent-table">
  998. <Spin spinning={this.state.loading}>
  999. <Table
  1000. columns={
  1001. this.state.changeList
  1002. ? this.state.changeList
  1003. : this.state.columns
  1004. }
  1005. style={{
  1006. cursor: 'pointer',
  1007. }}
  1008. dataSource={this.state.dataSource}
  1009. rowSelection={rowSelection}
  1010. pagination={this.state.pagination}
  1011. onRowClick={this.tableRowClick}
  1012. />
  1013. </Spin>
  1014. </div>
  1015. {this.state.showDesc &&
  1016. <Newuser
  1017. role={this.state.role}
  1018. addId={this.state.addId}
  1019. roleArr={this.state.roleArr}
  1020. departmentArr={this.state.departmentArr}
  1021. userDetaile={this.state.userDetaile}
  1022. datauser={this.state.datauser}
  1023. showDesc={this.state.showDesc}
  1024. closeDesc={this.closeDesc}
  1025. level1Data={this.state.level1Data}
  1026. />}
  1027. <div className="patent-desc">
  1028. <Modal
  1029. maskClosable={false}
  1030. visible={this.state.visible}
  1031. onOk={this.checkResources}
  1032. onCancel={this.handleCancel}
  1033. width="800px"
  1034. title="离职一键转交"
  1035. footer=""
  1036. className="admin-desc-content"
  1037. >
  1038. <Input
  1039. placeholder="用户姓名"
  1040. style={{
  1041. width: "150px",
  1042. marginRight: "10px",
  1043. marginBottom: "10px"
  1044. }}
  1045. value={this.state.userNameSearchs}
  1046. onChange={e => {
  1047. this.setState({ userNameSearchs: e.target.value });
  1048. }}
  1049. />
  1050. <Button type="primary" onClick={this.searchs}>
  1051. 搜索
  1052. </Button>
  1053. <Button onClick={this.resets}>重置</Button>
  1054. <div className="patent-table">
  1055. <Spin spinning={this.state.loading}>
  1056. <Table
  1057. columns={this.state.column}
  1058. dataSource={this.state.dataSourceData}
  1059. pagination={this.state.paginations}
  1060. style={{
  1061. cursor: 'pointer',
  1062. }}
  1063. // onRowClick={this.tableRowClick}
  1064. />
  1065. </Spin>
  1066. </div>
  1067. </Modal>
  1068. </div>
  1069. </div>
  1070. </div>
  1071. );
  1072. }
  1073. }));
  1074. export default User;