user.jsx 29 KB

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