user.jsx 35 KB

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