user.jsx 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  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: "正常"
  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: 'roles',
  295. key: 'roles',
  296. }, {
  297. title: '用户姓名',
  298. dataIndex: 'name',
  299. key: 'name',
  300. }, {
  301. title: '转交',
  302. dataIndex: 'ee',
  303. key: 'ee',
  304. render: (text, record, index) => {
  305. return <div>
  306. <Popconfirm title={'请确认转交【' + record.name + '】'} onConfirm={(e) => { this.examineOK(record) }} okText="确认" cancelText="取消">
  307. <Button style={{ marginRight: '5px' }} onClick={(e) => { e.stopPropagation() }} type="primary">转交</Button>
  308. </Popconfirm>
  309. </div>
  310. }
  311. },
  312. ],
  313. dataSourceData: [],
  314. };
  315. },
  316. //点击离职一键转交
  317. resources() {
  318. this.loadDatas();
  319. let deletedIds;
  320. let rowItem;
  321. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  322. rowItem = this.state.selectedRows[idx];
  323. // console.log(rowItem.id);
  324. if (rowItem.id) {
  325. deletedIds = rowItem.id;
  326. };
  327. };
  328. this.setState({
  329. visible: true,
  330. aid: deletedIds
  331. });
  332. },
  333. //关闭离职一键转交
  334. handleCancel() {
  335. this.setState({
  336. visible: false,
  337. selectedRowKeys: []
  338. }, () => {
  339. this.loadData(this.state.page);
  340. });
  341. },
  342. //一键离职
  343. examineOK(record) {
  344. // console.log(record);
  345. this.setState({
  346. loading: true
  347. });
  348. $.ajax({
  349. method: "POST",
  350. dataType: "json",
  351. crossDomain: false,
  352. url: globalConfig.context + "/api/admin/role/dimission",
  353. data: {
  354. aid: this.state.aid,
  355. transferId: record.id,
  356. }
  357. }).done(function (data) {
  358. if (!data.error.length) {
  359. message.success('转交成功!');
  360. this.handleCancel()
  361. } else {
  362. message.warning(data.error[0].message);
  363. };
  364. this.setState({
  365. loading: false,
  366. visible2: false
  367. });
  368. }.bind(this));
  369. },
  370. // 设置默认table(用来默认不显示某列数据 isNoD:true)
  371. defaultcolumns() {
  372. const newArr = [];
  373. this.state.columns.forEach((item) => {
  374. if (item.isNoD) {
  375. return
  376. } else {
  377. newArr.push(item);
  378. }
  379. });
  380. this.setState({
  381. changeList: newArr,
  382. }, () => {
  383. this.loadData();
  384. });
  385. },
  386. componentWillMount() {
  387. this.defaultcolumns();
  388. this.loadData();
  389. this.departmentList();
  390. this.rolesList();
  391. this.getList();
  392. },
  393. tableRowClick(record, index) {
  394. this.rolesArrS(record)
  395. },
  396. //新建获取id
  397. addIdS() {
  398. $.ajax({
  399. method: "get",
  400. dataType: "json",
  401. crossDomain: false,
  402. url: globalConfig.context + '/api/admin/superviser/newId',
  403. data: {},
  404. success: function (data) {
  405. this.setState({
  406. addId: data.data
  407. });
  408. }.bind(this),
  409. }).always(function () {
  410. this.setState({
  411. loading: false
  412. });
  413. }.bind(this));
  414. },
  415. //部门
  416. departmentList() {
  417. this.setState({
  418. loading: true
  419. });
  420. $.ajax({
  421. method: "get",
  422. dataType: "json",
  423. crossDomain: false,
  424. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  425. data: {
  426. },
  427. success: function (data) {
  428. let thedata = data.data;
  429. let theArr = [];
  430. if (!thedata) {
  431. if (data.error && data.error.length) {
  432. message.warning(data.error[0].message);
  433. };
  434. thedata = {};
  435. } else {
  436. thedata.map(function (item, index) {
  437. theArr.push({
  438. key: index,
  439. name: item.name,
  440. id: item.id,
  441. depNo: item.depNo
  442. })
  443. })
  444. }
  445. this.setState({
  446. departmentArr: theArr,
  447. })
  448. }.bind(this),
  449. }).always(function () {
  450. this.setState({
  451. loading: false
  452. });
  453. }.bind(this));
  454. },
  455. //修改时获取角色数组
  456. rolesArrS(e) {
  457. $.ajax({
  458. method: "get",
  459. dataType: "json",
  460. crossDomain: false,
  461. url: globalConfig.context + "/api/admin/role",
  462. data: {
  463. uid: e.id
  464. },
  465. success: function (data) {
  466. let thedata = data.data;
  467. let theArr = [];
  468. let theId = []
  469. if (!thedata) {
  470. if (data.error && data.error.length) {
  471. message.warning(data.error[0].message);
  472. };
  473. thedata = {};
  474. } else {
  475. }
  476. this.setState({
  477. role: thedata,
  478. userDetaile: true,
  479. showDesc: true,
  480. datauser: e
  481. })
  482. }.bind(this),
  483. }).always(function () {
  484. }.bind(this));
  485. },
  486. //角色
  487. rolesList() {
  488. this.setState({
  489. loading: true
  490. });
  491. $.ajax({
  492. method: "get",
  493. dataType: "json",
  494. crossDomain: false,
  495. url: globalConfig.context + "/api/roles",
  496. data: {
  497. },
  498. success: function (data) {
  499. let thedata = data.data;
  500. let theArr = [];
  501. if (!thedata) {
  502. if (data.error && data.error.length) {
  503. message.warning(data.error[0].message);
  504. };
  505. thedata = {};
  506. } else {
  507. thedata.map(function (item, index) {
  508. theArr.push({
  509. key: index,
  510. roleName: item.roleName,
  511. id: item.id,
  512. })
  513. })
  514. }
  515. this.setState({
  516. roleArr: theArr,
  517. })
  518. }.bind(this),
  519. }).always(function () {
  520. this.setState({
  521. loading: false
  522. });
  523. }.bind(this));
  524. },
  525. //锁定
  526. locking() {
  527. let deletedIds;
  528. let statust;
  529. let mobiles;
  530. let names;
  531. let rolesId = [];
  532. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  533. let rowItem = this.state.selectedRows[idx];
  534. if (rowItem.id) {
  535. deletedIds = rowItem.id;
  536. statust = rowItem.status;
  537. names = rowItem.name;
  538. mobiles = rowItem.mobile;
  539. rolesId = rowItem.rolesId
  540. };
  541. };
  542. this.setState({
  543. selectedRowKeys: [],
  544. loading: true
  545. });
  546. $.ajax({
  547. method: "POST",
  548. dataType: "json",
  549. crossDomain: false,
  550. url: globalConfig.context + "/api/admin/superviser/updateAdmin",
  551. data: {
  552. roles: rolesId,
  553. data: JSON.stringify({
  554. id: deletedIds,
  555. status: '锁定',
  556. name: names,
  557. mobile: mobiles,
  558. }),
  559. }
  560. }).done(function (data) {
  561. if (!data.error.length) {
  562. message.success('锁定成功!');
  563. this.setState({
  564. loading: false,
  565. });
  566. } else {
  567. message.warning(data.error[0].message);
  568. };
  569. this.loadData();
  570. }.bind(this));
  571. },
  572. //激活
  573. activation() {
  574. let deletedIds;
  575. let statust;
  576. let mobiles;
  577. let names;
  578. let rolesId = []
  579. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  580. let rowItem = this.state.selectedRows[idx];
  581. if (rowItem.id) {
  582. deletedIds = rowItem.id;
  583. statust = rowItem.status;
  584. names = rowItem.name;
  585. mobiles = rowItem.mobile;
  586. rolesId = rowItem.rolesId
  587. };
  588. };
  589. this.setState({
  590. selectedRowKeys: [],
  591. loading: true
  592. });
  593. $.ajax({
  594. method: "POST",
  595. dataType: "json",
  596. crossDomain: false,
  597. url: globalConfig.context + "/api/admin/superviser/updateAdmin",
  598. data: {
  599. roles: rolesId,
  600. data: JSON.stringify({
  601. id: deletedIds,
  602. status: '正常',
  603. name: names,
  604. mobile: mobiles,
  605. })
  606. }
  607. }).done(function (data) {
  608. if (!data.error.length) {
  609. message.success('激活成功!');
  610. this.setState({
  611. loading: false,
  612. });
  613. } else {
  614. message.warning(data.error[0].message);
  615. };
  616. this.loadData();
  617. }.bind(this));
  618. },
  619. //删除
  620. delectRow() {
  621. let deletedIds;
  622. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  623. let rowItem = this.state.selectedRows[idx];
  624. if (rowItem.id) {
  625. deletedIds = rowItem.id;
  626. };
  627. };
  628. this.setState({
  629. selectedRowKeys: [],
  630. loading: true
  631. });
  632. $.ajax({
  633. method: "POST",
  634. dataType: "json",
  635. crossDomain: false,
  636. url: globalConfig.context + "/api/admin/superviser/deleteById",
  637. data: {
  638. id: deletedIds,
  639. }
  640. }).done(function (data) {
  641. if (!data.error.length) {
  642. message.success('删除成功!');
  643. this.setState({
  644. loading: false,
  645. });
  646. } else {
  647. message.warning(data.error[0].message);
  648. };
  649. this.loadData(this.state.page);
  650. }.bind(this));
  651. },
  652. addClick() {
  653. this.addIdS()
  654. this.setState({
  655. datauser: {},
  656. showDesc: true,
  657. userDetaile: false,
  658. });
  659. },
  660. closeDesc(e, s) {
  661. this.setState({
  662. userDetaile: false,
  663. showDesc: e
  664. })
  665. if (s) {
  666. this.loadData(this.state.page);
  667. };
  668. },
  669. search() {
  670. this.state.userDetaile = false
  671. this.loadData();
  672. },
  673. searchs() {
  674. this.state.userDetaile = false
  675. this.loadDatas();
  676. },
  677. reset() {
  678. this.state.ambManage = undefined
  679. this.state.ambId = undefined;
  680. this.state.amb = 1;
  681. this.state.userNameSearch = undefined;
  682. this.state.organizationSearch = undefined;
  683. this.state.rolesSearch = undefined;
  684. this.state.postSearch = undefined;
  685. this.state.stationSearch = undefined;
  686. this.state.statusSeach = undefined;
  687. this.state.signNameSearch = undefined;
  688. this.state.mobileSearch = undefined;
  689. this.state.auto = undefined;
  690. this.state.theTypes = undefined;
  691. this.loadData();
  692. },
  693. resets() {
  694. this.state.userNameSearchs = '';
  695. this.state.organizationSearch = undefined;
  696. this.state.rolesSearch = undefined;
  697. this.state.postSearch = undefined;
  698. this.state.stationSearch = undefined;
  699. this.state.statusSeach = undefined;
  700. this.state.signNameSearch = '';
  701. this.state.mobileSearch = '';
  702. this.state.auto = '';
  703. this.state.theTypes = '';
  704. this.loadDatas();
  705. },
  706. searchSwitch() {
  707. this.setState({
  708. searchMore: !this.state.searchMore
  709. });
  710. },
  711. //主管初始加载(自动补全)
  712. supervisor(e) {
  713. $.ajax({
  714. method: "post",
  715. dataType: "json",
  716. crossDomain: false,
  717. url: globalConfig.context + "/api/admin/organization/selectName",
  718. data: {
  719. name: e
  720. },
  721. success: function (data) {
  722. let thedata = data.data;
  723. if (!thedata) {
  724. if (data.error && data.error.length) {
  725. message.warning(data.error[0].message);
  726. };
  727. thedata = {};
  728. };
  729. this.setState({
  730. customerArr: thedata,
  731. });
  732. }.bind(this),
  733. }).always(function () {
  734. this.setState({
  735. loading: false
  736. });
  737. }.bind(this));
  738. },
  739. //上级主管输入框失去焦点是判断客户是否存在
  740. selectAuto(value, options) {
  741. this.setState({
  742. auto: value
  743. })
  744. },
  745. blurChange(e) {
  746. let theType = '';
  747. let contactLists = this.state.customerArr || [];
  748. if (e) {
  749. contactLists.map(function (item) {
  750. if (item.name == e.toString()) {
  751. theType = item.id;
  752. }
  753. });
  754. }
  755. this.setState({
  756. theTypes: theType
  757. })
  758. },
  759. //值改变时请求客户名称
  760. httpChange(e) {
  761. if (e.length >= 1) {
  762. this.supervisor(e);
  763. }
  764. this.setState({
  765. auto: e
  766. })
  767. },
  768. changeList(arr) {
  769. const newArr = [];
  770. this.state.columns.forEach(item => {
  771. arr.forEach(val => {
  772. if (val === item.title) {
  773. newArr.push(item);
  774. }
  775. });
  776. });
  777. this.setState({
  778. changeList: newArr
  779. });
  780. },
  781. // 筛选数据
  782. getList() {
  783. this.setState({
  784. loading: true,
  785. });
  786. $.ajax({
  787. method: "get",
  788. dataType: "json",
  789. crossDomain: false,
  790. url: globalConfig.context + "/api/admin/amb/selectAll",
  791. success: function (data) {
  792. this.setState({
  793. loading: false,
  794. });
  795. if (data.error && data.error.length === 0) {
  796. let menuList = data.data
  797. this.setState({
  798. level1Data: menuList ? this.handleTreeData(menuList) : []
  799. });
  800. } else {
  801. message.warning(data.error[0].message);
  802. }
  803. }.bind(this),
  804. }).always(
  805. function () {
  806. this.setState({
  807. loading: false,
  808. });
  809. }.bind(this)
  810. );
  811. },
  812. // 树状默认数据处理
  813. handleTreeData(treeData) {
  814. let nodeDta = [];
  815. treeData.map(item => {
  816. let treeObj = {};
  817. treeObj.key = item.id
  818. treeObj.id = item.id
  819. treeObj.value = item.id
  820. treeObj.label = item.name
  821. treeObj.title = item.name
  822. treeObj.lvl = item.lvl
  823. treeObj.parentId = item.parentId
  824. item.list ? treeObj.children = this.handleTreeData(item.list) : null;
  825. nodeDta.push(treeObj)
  826. })
  827. return nodeDta
  828. },
  829. render() {
  830. const rowSelection = {
  831. selectedRowKeys: this.state.selectedRowKeys,
  832. onChange: (selectedRowKeys, selectedRows) => {
  833. this.setState({
  834. selectedRows: selectedRows.slice(-1),
  835. selectedRowKeys: selectedRowKeys.slice(-1)
  836. });
  837. },
  838. onSelectAll: (selected, selectedRows, changeRows) => {
  839. this.setState({
  840. selectedRowKeys: []
  841. })
  842. },
  843. };
  844. const dataSources = this.state.customerArr || [];
  845. const options = dataSources.map((group, index) =>
  846. <Select.Option key={index} value={group.name}>{group.name}</Select.Option>
  847. )
  848. const hasSelected = this.state.selectedRowKeys.length > 0;
  849. const { RangePicker } = DatePicker;
  850. let departmentArr = this.state.departmentArr || [];
  851. let roleArr = this.state.roleArr || [];
  852. return (
  853. <div className="user-content">
  854. <div className="content-title">
  855. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  856. <TabPane tab="搜索" key="1">
  857. <div className="user-search" style={{ paddingBottom: 10 }}>
  858. <Input
  859. placeholder="用户姓名"
  860. style={{ width: "180px" }}
  861. value={this.state.userNameSearch}
  862. onChange={e => {
  863. this.setState({ userNameSearch: e.target.value });
  864. }}
  865. />
  866. {window.adminData.isSuperAdmin ? (
  867. <Select
  868. placeholder="部门"
  869. style={{ width: 180 }}
  870. value={this.state.organizationSearch}
  871. onChange={e => {
  872. this.setState({ organizationSearch: e });
  873. }}
  874. >
  875. {departmentArr.map(function (item) {
  876. return (
  877. <Select.Option key={item.id}>{item.name}</Select.Option>
  878. );
  879. })}
  880. </Select>
  881. ) : (
  882. ""
  883. )}
  884. <Select
  885. placeholder="角色"
  886. style={{ width: 180 }}
  887. value={this.state.rolesSearch}
  888. onChange={e => {
  889. this.setState({ rolesSearch: e });
  890. }}
  891. >
  892. {roleArr.map(function (item) {
  893. return (
  894. <Select.Option key={item.id}>
  895. {item.roleName}
  896. </Select.Option>
  897. );
  898. })}
  899. </Select>
  900. <Select
  901. placeholder="职务"
  902. style={{ width: 180 }}
  903. value={this.state.postSearch}
  904. onChange={e => {
  905. this.setState({ postSearch: e });
  906. }}
  907. >
  908. {post.map(function (item) {
  909. return (
  910. <Select.Option key={item.value}>
  911. {item.key}
  912. </Select.Option>
  913. );
  914. })}
  915. </Select>
  916. <Select
  917. placeholder="岗位"
  918. style={{ width: 180 }}
  919. value={this.state.stationSearch}
  920. onChange={e => {
  921. this.setState({ stationSearch: e });
  922. }}
  923. >
  924. {station.map(function (item) {
  925. return (
  926. <Select.Option key={item.value}>
  927. {item.key}
  928. </Select.Option>
  929. );
  930. })}
  931. </Select>
  932. <Select
  933. placeholder="状态"
  934. style={{ width: 180 }}
  935. value={this.state.statusSeach}
  936. onChange={e => {
  937. this.setState({ statusSeach: e });
  938. }}
  939. >
  940. <Select.Option value={0}>正常</Select.Option>
  941. <Select.Option value={1}>锁定</Select.Option>
  942. </Select>
  943. <Input
  944. placeholder="登录用户名"
  945. style={{ width: "180px" }}
  946. value={this.state.signNameSearch}
  947. onChange={e => {
  948. this.setState({ signNameSearch: e.target.value });
  949. }}
  950. />
  951. <AutoComplete
  952. className="certain-category-search"
  953. dropdownClassName="certain-category-search-dropdown"
  954. dropdownMatchSelectWidth={false}
  955. style={{ width: 180 }}
  956. dataSource={options}
  957. placeholder="输入上级主管名字"
  958. value={this.state.auto}
  959. onChange={this.httpChange}
  960. filterOption={true}
  961. onBlur={this.blurChange}
  962. onSelect={this.selectAuto}
  963. >
  964. <Input />
  965. </AutoComplete>
  966. <div style={{ marginTop: 10 }}>
  967. <Select
  968. placeholder="巴主"
  969. style={{ width: 180 }}
  970. value={this.state.ambManage}
  971. onChange={e => {
  972. this.setState({ ambManage: e });
  973. }}
  974. >
  975. <Select.Option value={0}>非巴主</Select.Option>
  976. <Select.Option value={1}>巴主</Select.Option>
  977. </Select>
  978. <TreeSelect
  979. style={{ width: 300 }}
  980. value={this.state.ambId}
  981. dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
  982. treeData={this.state.level1Data}
  983. placeholder="请选择分巴"
  984. showSearch
  985. treeNodeFilterProp="title"
  986. onChange={(e) => {
  987. this.setState({
  988. ambId: e,
  989. });
  990. }}
  991. />
  992. {
  993. !!this.state.ambId &&
  994. <Select
  995. placeholder=""
  996. style={{ width: 180 }}
  997. value={this.state.amb}
  998. onChange={e => {
  999. this.setState({ amb: e });
  1000. }}
  1001. >
  1002. <Select.Option value={1}>本巴</Select.Option>
  1003. <Select.Option value={2}>全部</Select.Option>
  1004. </Select>
  1005. }
  1006. <Button style={{ marginRight: 10 }} type="primary" onClick={this.search}>搜索</Button>
  1007. <Button style={{ marginRight: 10 }} onClick={this.reset}>重置</Button>
  1008. <Button
  1009. style={{ background: "red", border: "none", color: "#fff", display: "none" }}
  1010. disabled={!hasSelected}
  1011. onClick={this.delectRow}
  1012. >
  1013. 删除
  1014. <Icon type="minus" />
  1015. </Button>
  1016. </div>
  1017. {/* <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span> */}
  1018. </div>
  1019. </TabPane>
  1020. <TabPane tab="操作" key="2">
  1021. <Button
  1022. style={{
  1023. background: "#333333",
  1024. border: "none",
  1025. color: "#fff",
  1026. marginBottom: 10,
  1027. marginTop: 12,
  1028. marginRight: 10
  1029. }}
  1030. disabled={!hasSelected}
  1031. onClick={this.locking}
  1032. >
  1033. 锁定
  1034. <Icon type="lock" />
  1035. </Button>
  1036. <Button
  1037. style={{ background: "green", border: "none", color: "#fff", marginTop: 12 }}
  1038. disabled={!hasSelected}
  1039. onClick={this.activation}
  1040. >
  1041. 激活
  1042. <Icon type="unlock" />
  1043. </Button>
  1044. {/* </TabPane>
  1045. <TabPane tab="新增" key="3"> */}
  1046. <Button
  1047. type="primary"
  1048. className="addButton"
  1049. style={{ float: "left", marginBottom: 10, marginTop: 12 }}
  1050. onClick={this.addClick}
  1051. >
  1052. 新增用户
  1053. <Icon type="user" />
  1054. </Button>
  1055. {/* </TabPane>
  1056. <TabPane tab="离职转交" key="4"> */}
  1057. <Button
  1058. type="primary"
  1059. className="addButton"
  1060. style={{ float: "left", marginBottom: 10, marginTop: 12 }}
  1061. onClick={this.resources}
  1062. disabled={!hasSelected}
  1063. >
  1064. 离职一键转交
  1065. <Icon type="user" />
  1066. </Button>
  1067. </TabPane>
  1068. <TabPane tab="更改表格显示数据" key="3">
  1069. <div style={{ marginLeft: 10 }}>
  1070. <ChooseList
  1071. columns={this.state.columns}
  1072. changeFn={this.changeList}
  1073. changeList={this.state.changeList}
  1074. top={55}
  1075. margin={11}
  1076. />
  1077. </div>
  1078. </TabPane>
  1079. </Tabs>
  1080. <div className="patent-table">
  1081. <Spin spinning={this.state.loading}>
  1082. <Table
  1083. bordered
  1084. columns={
  1085. this.state.changeList
  1086. ? this.state.changeList
  1087. : this.state.columns
  1088. }
  1089. style={{
  1090. cursor: 'pointer',
  1091. }}
  1092. dataSource={this.state.dataSource}
  1093. rowSelection={rowSelection}
  1094. pagination={this.state.pagination}
  1095. onRowClick={this.tableRowClick}
  1096. />
  1097. </Spin>
  1098. </div>
  1099. {this.state.showDesc &&
  1100. <Newuser
  1101. role={this.state.role}
  1102. addId={this.state.addId}
  1103. roleArr={this.state.roleArr}
  1104. departmentArr={this.state.departmentArr}
  1105. userDetaile={this.state.userDetaile}
  1106. datauser={this.state.datauser}
  1107. showDesc={this.state.showDesc}
  1108. closeDesc={this.closeDesc}
  1109. level1Data={this.state.level1Data}
  1110. />}
  1111. <div className="patent-desc">
  1112. <Modal
  1113. maskClosable={false}
  1114. visible={this.state.visible}
  1115. onOk={this.checkResources}
  1116. onCancel={this.handleCancel}
  1117. width="800px"
  1118. title="离职一键转交"
  1119. footer=""
  1120. className="admin-desc-content"
  1121. >
  1122. <Input
  1123. placeholder="用户姓名"
  1124. style={{
  1125. width: "180px",
  1126. marginRight: "10px",
  1127. marginBottom: "10px"
  1128. }}
  1129. value={this.state.userNameSearchs}
  1130. onChange={e => {
  1131. this.setState({ userNameSearchs: e.target.value });
  1132. }}
  1133. />
  1134. <Button type="primary" onClick={this.searchs}>
  1135. 搜索
  1136. </Button>
  1137. <Button onClick={this.resets}>重置</Button>
  1138. <div className="patent-table">
  1139. <Spin spinning={this.state.loading}>
  1140. <Table
  1141. columns={this.state.column}
  1142. dataSource={this.state.dataSourceData}
  1143. pagination={this.state.paginations}
  1144. style={{
  1145. cursor: 'pointer',
  1146. }}
  1147. // onRowClick={this.tableRowClick}
  1148. />
  1149. </Spin>
  1150. </div>
  1151. </Modal>
  1152. </div>
  1153. </div>
  1154. </div>
  1155. );
  1156. }
  1157. }));
  1158. export default User;