UserManage.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import React, { Component } from 'react';
  2. import { Modal, Badge } from 'antd';
  3. import { FilterTable } from 'wptpc-design';
  4. import { auth } from '@/conf/config';
  5. import { arrayToObj } from '@/utils/utils';
  6. import { fetchApiGet } from '@/apis';
  7. const apiUrl = `${auth}/role/authuser`;
  8. const isUseList = [
  9. {
  10. value: -1, label: '全部',
  11. },
  12. {
  13. value: 0, label: '未授权',
  14. },
  15. {
  16. value: 1, label: '授权中',
  17. },
  18. ]
  19. const isUseObj = arrayToObj(isUseList);
  20. const jobStateBadgeObj = {
  21. 0: 'default',
  22. 1: 'processing',
  23. }
  24. export default class Index extends Component {
  25. constructor() {
  26. super();
  27. this.state = {
  28. }
  29. }
  30. render() {
  31. const { visible, selectedRowKeys, getSelections, onOk, onCancel, deptTreeData, selectedRole } = this.props;
  32. const filterSetting = {
  33. defaultExpand: true,
  34. isClearSearch: false,
  35. formFields: [
  36. { label: '授权状态:', type: 'select', option: isUseList, styles: { width: 150 }, key: 'ihas', defaultValue: -1 },
  37. { label: '部门:', placeholder: '请选择', type: 'cascader', option: deptTreeData, styles: { width: 180 }, key: 'dept_id', defaultValue: [-1] },
  38. { label: '用户名称:', type: 'input', key: 'ding_name', placeholder: '请输入关键字', allowEnterSearch: true },
  39. ],
  40. beforeSearchFunc: params => {
  41. if (!params.dept_id) {
  42. params.dept_id = -1;
  43. } else {
  44. params.dept_id = params.dept_id.join(',');
  45. }
  46. params.role_id = selectedRole.id;
  47. },
  48. }
  49. const tableSetting = {
  50. columnConfig: [
  51. {
  52. title: '名称',
  53. dataIndex: 'ding_name',
  54. },
  55. {
  56. title: '授权状态',
  57. dataIndex: 'ihas',
  58. render: text => <span><Badge status={jobStateBadgeObj[text]} />{isUseObj[text]}</span>,
  59. },
  60. {
  61. title: '部门',
  62. dataIndex: 'dept_cn',
  63. },
  64. ],
  65. hasSelection: true,
  66. rowKey: 'ding_id',
  67. selectedRowKeys,
  68. getSelections,
  69. }
  70. return (
  71. <Modal
  72. title="用户管理"
  73. visible={visible}
  74. onOk={onOk}
  75. onCancel={onCancel}
  76. width={760}
  77. destroyOnClose
  78. >
  79. <FilterTable fetchApi={fetchApiGet} filterSetting={filterSetting} tableSetting={tableSetting} apiUrl={apiUrl} isPage={false} />
  80. </Modal>
  81. )
  82. }
  83. }