user.jsx 37 KB

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