UserManage.jsx 55.4 KB
Newer Older
皮倩雯's avatar
皮倩雯 committed
1
/* eslint-disable eqeqeq */
2
import React, { useState, useEffect, useRef } from 'react';
陈前坚's avatar
陈前坚 committed
3
import {
4
  // Tree,
陈前坚's avatar
陈前坚 committed
5 6 7 8 9 10 11
  Table,
  Space,
  message,
  Modal,
  Input,
  notification,
  Tooltip,
陈前坚's avatar
陈前坚 committed
12
  Card,
陈前坚's avatar
陈前坚 committed
13
  Button,
14
  Spin,
陈前坚's avatar
陈前坚 committed
15 16
  Dropdown,
  Menu,
皮倩雯's avatar
皮倩雯 committed
17
  Popconfirm,
18 19
  Form,
  Radio,
陈前坚's avatar
陈前坚 committed
20 21
} from 'antd';
import {
22
  UserOutlined,
陈前坚's avatar
陈前坚 committed
23
  UserAddOutlined,
陈前坚's avatar
陈前坚 committed
24
  UsergroupAddOutlined,
陈前坚's avatar
陈前坚 committed
25
  EditOutlined,
陈前坚's avatar
陈前坚 committed
26
  EditTwoTone,
陈前坚's avatar
陈前坚 committed
27
  DeleteOutlined,
28
  IdcardOutlined,
陈前坚's avatar
陈前坚 committed
29
  UnlockOutlined,
陈前坚's avatar
陈前坚 committed
30
  ApartmentOutlined,
陈前坚's avatar
陈前坚 committed
31
  StopOutlined,
陈前坚's avatar
陈前坚 committed
32 33
  DoubleLeftOutlined,
  DoubleRightOutlined,
陈前坚's avatar
陈前坚 committed
34
  DownOutlined,
mayongxin's avatar
mayongxin committed
35
  BorderlessTableOutlined,
皮倩雯's avatar
皮倩雯 committed
36 37 38 39 40
  LockOutlined,
  PlusSquareFilled,
  EllipsisOutlined,
  PlusOutlined,
  SyncOutlined,
41
  ClusterOutlined,
陈前坚's avatar
陈前坚 committed
42
} from '@ant-design/icons';
43
import PageContainer from '@/components/BasePageContainer';
陈前坚's avatar
陈前坚 committed
44 45
import voca from 'voca';
import zhCN from 'antd/es/locale/zh_CN';
46 47
import {
  addToOrg,
陈前坚's avatar
陈前坚 committed
48
  addToOrgs,
49 50 51
  getOneOUUserListNew,
  getUserRelationList,
  getUserTree,
皮倩雯's avatar
皮倩雯 committed
52
  // eslint-disable-next-line import/named
张烨's avatar
张烨 committed
53 54
  deleteUser as postDeleteUser,
  setUserState as postSetUserState,
陈前坚's avatar
陈前坚 committed
55
  multiDeleteUsers,
mayongxin's avatar
mayongxin committed
56
  setOrgArea,
mayongxin's avatar
mayongxin committed
57
  getOrgArea,
mayongxin's avatar
mayongxin committed
58
  GetMapSetByGroupID,
mayongxin's avatar
mayongxin committed
59 60 61 62 63 64
  GetOUTreeNew,
  GetUserRelationListNew,
  GetUserByKeyNew,
  UserStateOUNew,
  JumpToAnotherOUNew,
  DeleteUserNew,
皮倩雯's avatar
皮倩雯 committed
65
  loadAllUserRole,
66
  DragGroup,
邓超's avatar
邓超 committed
67
} from '@/services/userManage/api';
68
import { AddUserAuthSetting, GetUserAuthSet } from '@/services/database/api';
69
import Tree from '@/components/ExpendableTree';
陈前坚's avatar
陈前坚 committed
70
import classnames from 'classnames';
71
import DraggleLayout from 'components/DraggleLayout';
陈前坚's avatar
陈前坚 committed
72
import AddUserModal from './AddUserModal';
73 74 75 76 77 78
import AddSubOrgModal from './AddSubOrgModal';
import EditOrgModal from './EditOrgModal';
import DeleteOrgModal from './DeleteOrgModal';
import RelateRoleModal from './RelateRoleModal';
import EditUserModal from './EditUserModal';
import ChangePasswordModal from './ChangePasswordModal';
皮倩雯's avatar
皮倩雯 committed
79 80
import MapScopeEditModal from '@/components/MapScope';
import AuthModal from './AuthModal';
陈前坚's avatar
陈前坚 committed
81
import styles from './UserManage.less';
皮倩雯's avatar
皮倩雯 committed
82
import { createGuid } from '@/utils/transformUtil';
邓超's avatar
邓超 committed
83 84 85 86 87
const TdCell = props => {
  // onMouseEnter, onMouseLeave在数据量多的时候,会严重阻塞表格单元格渲染,严重影响性能
  const { onMouseEnter, onMouseLeave, ...restProps } = props;
  return <td {...restProps} />;
};
陈前坚's avatar
陈前坚 committed
88 89

const UserManage = () => {
皮倩雯's avatar
皮倩雯 committed
90 91
  const { TreeNode } = Tree;

92 93
  const [form] = Form.useForm();
  const { Item } = Form;
94
  const [selectValue, setSelctValue] = useState(); // 用户鉴权
95 96

  const [width, setWidth] = useState(50);
陈前坚's avatar
陈前坚 committed
97
  const [treeLoading, setTreeLoading] = useState(false);
陈前坚's avatar
陈前坚 committed
98
  const [tableLoading, setTableLoading] = useState(false);
陈前坚's avatar
陈前坚 committed
99
  const [loading, setLoading] = useState(true);
100
  const [currentOrgOperate, setCurrentOrgOperate] = useState(false); // 是否禁用当前机构操作
陈前坚's avatar
陈前坚 committed
101 102
  const [multiOperate, setMultiOperate] = useState(true); // 是否禁用用户批量操作
  const [multiOperateButtonType, setMultiOperateButtonType] = useState(''); // 更改批量操作按钮样式
陈前坚's avatar
陈前坚 committed
103

陈前坚's avatar
陈前坚 committed
104
  const [treeData, setTreeData] = useState([]); // 用户机构树
陈前坚's avatar
陈前坚 committed
105
  const [treeDataCopy, setTreeDataCopy] = useState([]); // 机构树数据备份,用于更改机构
陈前坚's avatar
陈前坚 committed
106 107
  const [treeState, setTreeState] = useState(true); // 树第一次加载
  const [treeVisible, setTreeVisible] = useState(true); // 树是否可见
陈前坚's avatar
陈前坚 committed
108
  const [tableData, setTableData] = useState([]); // 用户表
109
  const [selectColor, setSelectColor] = useState({}); // 当前选中颜色,操作时设置
陈前坚's avatar
陈前坚 committed
110
  const [orgFilters, setOrgFilters] = useState([]); // 用户列筛选
陈前坚's avatar
陈前坚 committed
111
  const [searchWord, setSearchWord] = useState(''); // 关键字
皮倩雯's avatar
皮倩雯 committed
112
  const [currentSelectOrg1, setCurrentSelectOrg1] = useState('-1');
113
  const [currentSelectOrg, setCurrentSelectOrg] = useState('-1'); // 左侧机构树-选中组织,字符串类型默认全部机构'-1',注意用户表中的OUID是数字
陈前坚's avatar
陈前坚 committed
114
  const [currentSelectOldOrg, setCurrentSelectOldOrg] = useState([]); // 更改机构时的树-原先选中组织
皮倩雯's avatar
皮倩雯 committed
115
  const [showSearchStyle, setShowSearchStyle] = useState(false); // 是否显示模糊查询样式
陈前坚's avatar
陈前坚 committed
116

陈前坚's avatar
陈前坚 committed
117 118 119 120 121
  /** ***Modal弹框,是否可视**** */
  const [userVisible, setUserVisible] = useState(false); // 添加用户
  const [addOrgVisible, setAddOrgVisible] = useState(false); // 添加机构
  const [editOrgVisible, setEditOrgVisible] = useState(false); // 编辑机构
  const [deleteOrgVisible, setDeleteOrgVisible] = useState(false); // 删除机构
mayongxin's avatar
mayongxin committed
122
  const [editOrgExtentVisible, setEditOrgExtentVisible] = useState(false); // 删除机构
陈前坚's avatar
陈前坚 committed
123
  const [roleVisible, setRoleVisible] = useState(false); // 关联角色
陈前坚's avatar
陈前坚 committed
124 125 126
  const [changeOrgVisible, setChangeOrgVisible] = useState(false); // 更改机构
  const [passwordVisible, setPasswordVisible] = useState(false); // 修改密码
  const [editUserVisible, setEditUserVisible] = useState(false); // 编辑用户
皮倩雯's avatar
皮倩雯 committed
127
  // const [freezeUserVisible, setFreezeUserVisible] = useState(false); // 冻结用户
陈前坚's avatar
陈前坚 committed
128
  const [deleteUserVisible, setDeleteUserVisible] = useState(false); // 删除用户
mayongxin's avatar
mayongxin committed
129
  const [authUserVisible, setAuthUserVisible] = useState(false); // 鉴权用户
陈前坚's avatar
陈前坚 committed
130

陈前坚's avatar
陈前坚 committed
131
  const [orgTitle, setOrgTitle] = useState('当前机构'); // 弹框标题
皮倩雯's avatar
皮倩雯 committed
132
  const [orgTitle1, setOrgTitle1] = useState('当前机构'); // 弹框标题
133
  const [description, setDescription] = useState(''); // 机构描述信息
134 135
  const [selectedRowKeys, setSelectedRowKeys] = useState([]); // 已选用户数,机构改变时重置
  const [tableLength, setTableLength] = useState(0); // 当前机构用户总数
陈前坚's avatar
陈前坚 committed
136
  const [orgID, setOrgID] = useState(); // 当前选择的机构ID
陈前坚's avatar
陈前坚 committed
137 138
  const [newOrgID, setNewOrgID] = useState(); // 更改机构新选择的ID
  const [currentUser, setCurrentUser] = useState({}); // 当前用户
139

皮倩雯's avatar
皮倩雯 committed
140 141 142
  const [mult, setMult] = useState(''); // 判断是否是批量关联
  const [multiRoleList, setMultiRoleList] = useState([]);
  const [multistationList, setMultiStationList] = useState([]);
陈前坚's avatar
陈前坚 committed
143 144 145 146
  const [userIDs, setUserIDs] = useState(''); // 批量删除的用户
  const [orgIDs, setOrgIDs] = useState(''); // 批量操作的机构
  const [multiDelete, setMultiDelete] = useState(false); // 是否批量删除用户
  const [multiChangeOrgs, setMultiChangeOrgs] = useState(false); // 是否批量更改机构
陈前坚's avatar
陈前坚 committed
147
  const [multiRelateRoles, setMultiRelateRoles] = useState(false); // 是否批量更改机构
陈前坚's avatar
陈前坚 committed
148

陈前坚's avatar
陈前坚 committed
149 150
  const [rolelist, setRolelist] = useState([]); // 角色列表
  const [stationlist, setStationlist] = useState([]); // 站点列表
mayongxin's avatar
mayongxin committed
151

皮倩雯's avatar
皮倩雯 committed
152 153 154 155
  const [orgAreas, setOrgAreas] = useState([]);
  const [currentOrgArea, setCurrentOrgArea] = useState('');
  const [currentOrgDistinct, setCurrentOrgDistinct] = useState('');
  const [saveExtentFlag, setSaveExtentFlag] = useState(0);
皮倩雯's avatar
皮倩雯 committed
156
  const [filteredValue, setFilteredValue] = useState([]);
皮倩雯's avatar
皮倩雯 committed
157 158
  const [keep1, setKeep1] = useState([4]); // 存储树选择
  const [id, setId] = useState('');
陈前坚's avatar
陈前坚 committed
159
  const { Search } = Input;
160
  const [hoverItemIndex, setHoverItemIndex] = useState(0); // hover流程索引
161
  const [keepTree, setKeepTree] = useState([]); // 保存所有一级id用于控制只展开一项一级菜单
162 163

  const [expendKey, setExpendKey] = useState(''); // 保存默认展开项
164
  const [expendKeyOrg, setExpendKeyOrg] = useState(''); // 保存默认展开项
165 166 167
  const [menuID, setMenuID] = useState(''); // 选中的树IDs
  const [keepId, setKeepId] = useState('');
  const [flag, setFlag] = useState(1); // 刷新标志
168 169
  const userContainer = useRef();
  const flagRef = useRef(1);
170 171

  const [searchWordOrg, setSearchWordOrg] = useState('');
172 173
  const setRowClassName = record =>
    record.userID === selectColor.userID ? styles.clickRowStyle : '';
陈前坚's avatar
陈前坚 committed
174 175 176 177 178 179
  // 用户表列名
  const columns = [
    {
      title: '登录名',
      dataIndex: 'loginName',
      key: 'loginName',
180
      // width: 100,
181
      // fixed: 'left',
皮倩雯's avatar
皮倩雯 committed
182
      render: item => searchStyle(item),
陈前坚's avatar
陈前坚 committed
183 184 185 186 187
    },
    {
      title: '用户姓名',
      dataIndex: 'userName',
      key: 'userName',
188
      // width: 100,
皮倩雯's avatar
皮倩雯 committed
189
      render: item => searchStyle(item),
陈前坚's avatar
陈前坚 committed
190
    },
191 192 193 194
    {
      title: '所在机构',
      dataIndex: 'OUName',
      key: 'OUName',
195
      // width: 150,
196
      ellipsis: true,
陈前坚's avatar
陈前坚 committed
197
      filters: orgFilters,
198
      filteredValue,
陈前坚's avatar
陈前坚 committed
199
      onFilter: (value, record) => record.OUName === value,
200
    },
陈前坚's avatar
陈前坚 committed
201 202 203 204
    {
      title: '手机号码',
      dataIndex: 'phone',
      key: 'phone',
205
      // width: 150,
陈前坚's avatar
陈前坚 committed
206
      ellipsis: true,
皮倩雯's avatar
皮倩雯 committed
207 208 209
      render: text => {
        if (text) {
          return searchStyle(text);
210
        }
tianfen's avatar
tianfen committed
211
        return <span>未绑定</span>;
212
      },
陈前坚's avatar
陈前坚 committed
213 214 215 216 217
    },
    {
      title: '钉钉账户',
      dataIndex: 'ddid',
      key: 'ddid',
218
      // width: 150,
陈前坚's avatar
陈前坚 committed
219 220 221 222
      render: record => {
        if (record) {
          return (
            <Tooltip title={record}>
223
              <span style={{ color: '#50aefc', cursor: 'pointer' }}>已绑定</span>
陈前坚's avatar
陈前坚 committed
224 225 226
            </Tooltip>
          );
        }
tianfen's avatar
tianfen committed
227
        return <span>未绑定</span>;
陈前坚's avatar
陈前坚 committed
228
      },
陈前坚's avatar
陈前坚 committed
229 230 231 232 233
    },
    {
      title: '微信账户',
      dataIndex: 'wxid',
      key: 'wxid',
234
      // width: 140,
陈前坚's avatar
陈前坚 committed
235 236 237 238
      render: record => {
        if (record) {
          return (
            <Tooltip title={record}>
239
              <span style={{ color: '#50aefc', cursor: 'pointer' }}>已绑定</span>
陈前坚's avatar
陈前坚 committed
240 241 242
            </Tooltip>
          );
        }
tianfen's avatar
tianfen committed
243
        return <span>未绑定</span>;
陈前坚's avatar
陈前坚 committed
244
      },
陈前坚's avatar
陈前坚 committed
245 246 247 248
    },
    {
      title: '操作',
      key: 'action',
陈前坚's avatar
陈前坚 committed
249
      // fixed: 'right',
250
      // width: 200,
251
      align: 'center',
陈前坚's avatar
陈前坚 committed
252
      render: record => (
陈前坚's avatar
陈前坚 committed
253
        <Space size="middle">
254
          <Tooltip title="关联权限">
255
            <IdcardOutlined
陈前坚's avatar
陈前坚 committed
256
              onClick={() => relateRole(record)}
257
              style={{ fontSize: '20px', color: '#1890FF' }}
陈前坚's avatar
陈前坚 committed
258 259 260 261 262 263 264 265 266
            />
          </Tooltip>
          <Tooltip title="更改机构">
            <ApartmentOutlined
              onClick={() => changeOrg(record)}
              style={{ fontSize: '16px', color: '#1890FF' }}
            />
          </Tooltip>
          <Tooltip title="修改密码">
陈前坚's avatar
陈前坚 committed
267
            <UnlockOutlined
陈前坚's avatar
陈前坚 committed
268 269 270 271 272
              onClick={() => changePassword(record)}
              style={{ fontSize: '16px', color: '#1890FF' }}
            />
          </Tooltip>
          <Tooltip title="编辑用户">
273
            <EditTwoTone onClick={() => editUser(record)} style={{ fontSize: '16px' }} />
陈前坚's avatar
陈前坚 committed
274
          </Tooltip>
皮倩雯's avatar
皮倩雯 committed
275
          {(record.state == 0 || record.state == null) && (
276
            <>
277
              {/* {     console.log(record.state,'record.state')} */}
278
              <Tooltip title="冻结用户">
皮倩雯's avatar
皮倩雯 committed
279 280 281 282 283
                <Popconfirm
                  placement="bottomRight"
                  title={
                    <p>
                      即将冻结用户{' '}
284
                      <span className={styles.redText}>{voca.stripTags(record.loginName)}</span>
皮倩雯's avatar
皮倩雯 committed
285 286 287 288 289 290 291
                      ,是否确认冻结?
                    </p>
                  }
                  okText="确认"
                  cancelText="取消"
                  onConfirm={() => freezeUser(record)}
                >
292
                  <StopOutlined style={{ fontSize: '16px', color: '#e86060' }} />
皮倩雯's avatar
皮倩雯 committed
293
                </Popconfirm>
294 295 296
              </Tooltip>
            </>
          )}
皮倩雯's avatar
皮倩雯 committed
297
          {record.state == 1 && (
298
            <>
299
              {console.log(record.state, 'record.state1')}
300
              <Tooltip title="解冻用户">
皮倩雯's avatar
皮倩雯 committed
301 302 303 304 305
                <Popconfirm
                  placement="bottomRight"
                  title={
                    <p>
                      即将解冻用户{' '}
306
                      <span className={styles.redText}>{voca.stripTags(record.loginName)}</span>
皮倩雯's avatar
皮倩雯 committed
307 308 309 310 311 312 313
                      ,是否确认解冻?
                    </p>
                  }
                  okText="确认"
                  cancelText="取消"
                  onConfirm={() => freezeUser(record)}
                >
314
                  <UserOutlined style={{ fontSize: '16px', color: '#1890ff' }} />
皮倩雯's avatar
皮倩雯 committed
315
                </Popconfirm>
316 317 318
              </Tooltip>
            </>
          )}
319
          {/* <Tooltip title="用户鉴权">
320
            <Popconfirm
321 322 323
              placement="bottomRight"
              title={
                <div style={{ width: '130px' }}>
324 325
                  <Form form={form}>
                    <Item>
皮倩雯's avatar
皮倩雯 committed
326
                      <Radio.Group value={selectValue} onChange={onTypeChange}>
327 328 329 330 331 332 333
                        <Space direction="vertical">
                          <Radio value={0}>访客</Radio>
                          <Radio value={1}>普通用户</Radio>
                          <Radio value={2}>管理员</Radio>
                          <Radio value={3}>超级管理员</Radio>
                        </Space>
                      </Radio.Group>
334
                    </Item>
335 336
                  </Form>
                </div>
337 338 339 340 341
              }
              okText="确认"
              cancelText="取消"
              onConfirm={() => authUser(record)}
            >
342 343 344 345
              <LockOutlined
                onClick={() => jianquan(record)}
                style={{ fontSize: '16px', color: '#1890ff' }}
              />
346
            </Popconfirm>
347
          </Tooltip> */}
陈前坚's avatar
陈前坚 committed
348
          <Tooltip title="删除用户">
皮倩雯's avatar
皮倩雯 committed
349 350 351 352 353
            <Popconfirm
              placement="bottomRight"
              title={
                <p>
                  即将删除用户{' '}
354
                  <span className={styles.redText}>{voca.stripTags(record.loginName)}</span>
皮倩雯's avatar
皮倩雯 committed
355 356 357 358 359 360 361 362 363 364
                  ,是否确认删除?
                </p>
              }
              // title={`确认删除用户${currentUser}`}
              okText="确认"
              cancelText="取消"
              onConfirm={() => deleteUser(record)}
            >
              <DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
            </Popconfirm>
陈前坚's avatar
陈前坚 committed
365
          </Tooltip>
陈前坚's avatar
陈前坚 committed
366 367 368 369
        </Space>
      ),
    },
  ];
370 371 372 373 374

  useEffect(() => {
    setExpendKey(menuID);
    console.log(expendKey);
  }, [menuID]);
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
  // 获取用户机构树
  useEffect(() => {
    window.addEventListener('resize', resizeListener);
    updateTrees();
    return () => {
      window.removeEventListener('resize', resizeListener);
    };
  }, []);

  // 更新获取初始范围
  useEffect(() => {
    getOrgArea().then(res => {
      if (res.msg === 'Ok') {
        console.log(res);
        setOrgAreas(res.Results);
      }
    });
  }, [saveExtentFlag]);
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410

  useEffect(() => {
    if (!changeOrgVisible) {
      setExpendKeyOrg('');
      setSearchWordOrg('');
      GetOUTreeNew({ keyword: '' })
        .then(newres => {
          if (newres.code === 0) {
            let res = newres.data;
            setTreeDataCopy(res);
          }
        })
        .catch(err => {
          setTreeLoading(false);
          message.error(err);
        });
    }
  }, [changeOrgVisible]);
411 412 413 414
  const resizeListener = () => {
    flagRef.current += 1;
    setFlag(flagRef.current);
  };
皮倩雯's avatar
皮倩雯 committed
415 416
  // 模糊查询匹配的样式
  const searchStyle = val => {
417 418 419
    if (!val) {
      return val;
    }
皮倩雯's avatar
皮倩雯 committed
420 421
    let n;
    if (showSearchStyle) {
422
      n = val.replace(new RegExp(searchWord, 'g'), `<span style='color:red'>${searchWord}</span>`);
皮倩雯's avatar
皮倩雯 committed
423 424 425 426 427
    } else {
      n = val;
    }
    return <div dangerouslySetInnerHTML={{ __html: n }} />;
  };
428 429 430 431
  // 获取搜索框的值
  const handleSearch = e => {
    setSearchWord(e.target.value);
  };
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466

  // 获取搜索框的值
  const handleSearchOrg = e => {
    setSearchWordOrg(e.target.value);
  };

  const submitSearch = () => {
    GetOUTreeNew({ keyword: searchWordOrg })
      .then(newres => {
        if (newres.code === 0) {
          let res = newres.data;
          setTreeDataCopy(res);
          console.log(res);
          let aa = [];
          res.map(i => {
            if (i.children.length > 0) {
              aa.push(i.id);
            }
            console.log(i.id);
            aa = i.id;
          });
          setExpendKeyOrg(aa.toString());
        } else {
          notification.error({
            message: '获取失败',
            // eslint-disable-next-line no-undef
            description: res.message,
          });
        }
      })
      .catch(err => {
        setTreeLoading(false);
        message.error(err);
      });
  };
皮倩雯's avatar
皮倩雯 committed
467
  // 复选框
陈前坚's avatar
陈前坚 committed
468
  const rowSelection = {
469 470
    selectedRowKeys,
    onChange: (RowKeys, Rows) => {
471 472
      console.log(RowKeys);
      console.log(Rows);
473
      setSelectedRowKeys(RowKeys);
皮倩雯's avatar
皮倩雯 committed
474
      getCheckList(RowKeys);
475 476
      setUserIDs(RowKeys.toString()); // 数组转字符串,逗号连接
      setOrgIDs(Rows.map(item => item.OUID).toString());
陈前坚's avatar
陈前坚 committed
477
      // 选中行数大于0时设置批量操作可行
478
      if (RowKeys.length > 0) {
479
        setSelectColor({});
陈前坚's avatar
陈前坚 committed
480 481 482 483 484 485
        setMultiOperate(false);
        setMultiOperateButtonType('primary');
      } else {
        setMultiOperate(true);
        setMultiOperateButtonType('default');
      }
陈前坚's avatar
陈前坚 committed
486 487
    },
  };
陈前坚's avatar
陈前坚 committed
488 489 490 491
  // 渲染机构树
  const mapTree = org => {
    const haveChildren = Array.isArray(org.children) && org.children.length > 0;
    return {
皮倩雯's avatar
皮倩雯 committed
492
      title: (
皮倩雯's avatar
皮倩雯 committed
493
        <div className={styles.title1}>
494 495
          <span className={styles.titleText}>
            {org.children.length == 0 ? (
496 497 498 499 500 501 502 503
              <ApartmentOutlined
                style={{
                  fontSize: '14px',
                  color: '#1890FF',
                  verticalAlign: 'middle',
                  marginTop: '-3px',
                }}
              />
504 505 506 507 508
            ) : (
              <span />
            )}
            <span style={{ marginLeft: '5px' }}>{org.text}</span>
          </span>
509 510 511 512 513 514 515 516 517 518 519 520
          <span
            className={classnames({
              [styles.tip1]: true,
              [styles.listHover]: org === hoverItemIndex,
            })}
            onMouseEnter={() => {
              setHoverItemIndex(org);
            }}
            onMouseLeave={() => {
              setHoverItemIndex('');
            }}
          >
521
            <Tooltip title="添加用户" className={styles.fs1}>
522 523 524 525 526 527 528 529 530 531 532 533
              <UserAddOutlined
                style={{ marginLeft: 20, lineHeight: '24px' }}
                onClick={e => {
                  e.stopPropagation();
                  addUser();
                }}
                onMouseEnter={e => {
                  setOrgID(org);
                  setOrgTitle1(org.text);
                  console.log(org);
                }}
              />
皮倩雯's avatar
皮倩雯 committed
534
            </Tooltip>
皮倩雯's avatar
皮倩雯 committed
535
            <Dropdown overlay={orgButtonMenu1}>
536
              <EllipsisOutlined
537
                style={{ marginLeft: 10, fontSize: '20px', lineHeight: '24px' }}
538
                onClick={e => e.stopPropagation()}
皮倩雯's avatar
皮倩雯 committed
539 540 541 542
                onMouseEnter={e => {
                  setOrgID(org);
                  setOrgTitle1(org.text);
                  getDescription(org.id);
543
                  // getMapSetByGroupID(org.id);
皮倩雯's avatar
皮倩雯 committed
544 545 546 547
                  setCurrentSelectOrg1(org.id);
                  setId(org.text);
                  console.log(org);
                }}
548
              />
皮倩雯's avatar
皮倩雯 committed
549 550 551 552
            </Dropdown>
          </span>
        </div>
      ),
陈前坚's avatar
陈前坚 committed
553 554 555 556 557
      key: org.id,
      // 判断它是否存在子集,若果存在就进行再次进行遍历操作,知道不存在子集便对其他的元素进行操作
      children: haveChildren ? org.children.map(i => mapTree(i)) : [],
    };
  };
558

皮倩雯's avatar
皮倩雯 committed
559 560 561 562 563 564 565 566 567 568
  const mapTree1 = org => {
    const haveChildren = Array.isArray(org.children) && org.children.length > 0;
    return {
      title: org.text,
      key: org.id,
      // 判断它是否存在子集,若果存在就进行再次进行遍历操作,知道不存在子集便对其他的元素进行操作
      children: haveChildren ? org.children.map(i => mapTree1(i)) : [],
    };
  };

陈前坚's avatar
陈前坚 committed
569
  // 重新渲染树
陈前坚's avatar
陈前坚 committed
570 571
  const updateTrees = () => {
    setTreeLoading(true);
mayongxin's avatar
mayongxin committed
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
    // getUserTree(-1, -1)
    //   .then(res => {
    //     if (res.length > 0) {
    //       setTreeLoading(false);
    //       setTreeData(res);
    //       setTreeDataCopy(res);
    //       // 第一次加载,默认选择第一个组织
    //       if (treeState) {
    //         onSelect([res[0].id], false);
    //         setTreeState(false);
    //       }
    //     } else {
    //       setTreeLoading(false);
    //       notification.error({
    //         message: '获取失败',
    //         description: res.message,
    //       });
    //     }
    //   })
    //   .catch(err => {
    //     setTreeLoading(false);
    //     message.error(err);
    //   });
皮倩雯's avatar
皮倩雯 committed
595 596 597 598
    GetOUTreeNew({ selectOU: -1 })
      .then(newres => {
        if (newres.code === 0) {
          let res = newres.data;
599
          console.log(res);
陈前坚's avatar
陈前坚 committed
600
          setTreeLoading(false);
601
          setTreeData(res);
陈前坚's avatar
陈前坚 committed
602
          setTreeDataCopy(res);
皮倩雯's avatar
皮倩雯 committed
603 604 605 606 607
          let aa = [];
          res.forEach(i => {
            aa.push(i.id);
          });
          setKeepTree(aa);
608

609 610
          // 第一次加载,默认选择第一个组织
          if (treeState) {
皮倩雯's avatar
皮倩雯 committed
611
            onSelect([res[0].id]);
612 613
            setTreeState(false);
          }
陈前坚's avatar
陈前坚 committed
614 615 616 617
        } else {
          setTreeLoading(false);
          notification.error({
            message: '获取失败',
皮倩雯's avatar
皮倩雯 committed
618
            // eslint-disable-next-line no-undef
陈前坚's avatar
陈前坚 committed
619 620
            description: res.message,
          });
陈前坚's avatar
陈前坚 committed
621 622 623
        }
      })
      .catch(err => {
陈前坚's avatar
陈前坚 committed
624
        setTreeLoading(false);
陈前坚's avatar
陈前坚 committed
625 626
        message.error(err);
      });
陈前坚's avatar
陈前坚 committed
627
  };
张烨's avatar
张烨 committed
628

629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
  const updateTrees1 = e => {
    console.log(e);
    setTreeLoading(true);
    GetOUTreeNew({ selectOU: -1 })
      .then(newres => {
        if (newres.code === 0) {
          let res = newres.data;
          console.log(res);
          setTreeLoading(false);
          setTreeData(res);
          setTreeDataCopy(res);
          let aa = [];
          res.forEach(i => {
            aa.push(i.id);
          });
          setKeepTree(aa);
          console.log(e);
          setMenuID(e.toString());
          setExpendKey(e);
        } else {
          setTreeLoading(false);
          notification.error({
            message: '获取失败',
            // eslint-disable-next-line no-undef
            description: res.message,
          });
        }
      })
      .catch(err => {
        setTreeLoading(false);
        message.error(err);
      });
  };

陈前坚's avatar
陈前坚 committed
663
  // 点击树节点,获取当前机构下所有用户
陈前坚's avatar
陈前坚 committed
664
  const onSelect = (props, e) => {
665
    console.log(props);
666
    console.log(e);
皮倩雯's avatar
皮倩雯 committed
667 668 669 670
    if (e) {
      props[0] = e.node.key;
    } else {
      props[0] = props.toString();
671
    }
皮倩雯's avatar
皮倩雯 committed
672
    setKeep1(props);
陈前坚's avatar
陈前坚 committed
673
    setTableLoading(true);
陈前坚's avatar
陈前坚 committed
674
    if (!props[0]) {
张烨's avatar
张烨 committed
675
      setCurrentSelectOrg(currentSelectOrg);
皮倩雯's avatar
皮倩雯 committed
676
      setCurrentSelectOrg1(currentSelectOrg);
陈前坚's avatar
陈前坚 committed
677
    } else {
张烨's avatar
张烨 committed
678
      setCurrentSelectOrg(props[0]);
皮倩雯's avatar
皮倩雯 committed
679
      setCurrentSelectOrg1(props[0]);
陈前坚's avatar
陈前坚 committed
680
    }
mayongxin's avatar
mayongxin committed
681
    GetMapSetByGroupID({
皮倩雯's avatar
皮倩雯 committed
682 683 684
      groupID: props[0],
    }).then(res => {
      if (res.code === 0) {
皮倩雯's avatar
皮倩雯 committed
685
        console.log(res);
皮倩雯's avatar
皮倩雯 committed
686
        if (res.code.MapRange != null) {
687 688 689
          setCurrentOrgArea(res.data.MapRange);
          setCurrentOrgDistinct(res.data.AreeName);
        }
mayongxin's avatar
mayongxin committed
690
      }
皮倩雯's avatar
皮倩雯 committed
691
    });
张烨's avatar
张烨 committed
692
    setOrgID(props[0] || currentSelectOrg);
陈前坚's avatar
陈前坚 committed
693 694
    // 树节点变化(即props不为空)时才请求,避免重复请求
    if (props[0]) {
695 696
      console.log(props[0]);
      setMenuID(props[0]);
皮倩雯's avatar
皮倩雯 committed
697
      // eslint-disable-next-line no-console
陈前坚's avatar
陈前坚 committed
698 699
      getOneOUUserListNew(props[0] || currentSelectOrg)
        .then(res => {
700
          setCurrentOrgOperate(false); // 重置禁用当前机构操作为false
701
          setMultiOperate(true); // 重新禁止用户批量操作
702
          setSelectedRowKeys([]); // 重置选中用户数
陈前坚's avatar
陈前坚 committed
703 704 705 706
          if (res.code === 0) {
            setTableLoading(false);
            setSearchWord(''); // 搜索框置空
            setOrgTitle(res.data.GroupName);
707
            setDescription(res.data.Description);
陈前坚's avatar
陈前坚 committed
708 709 710 711 712 713 714 715 716 717 718
            // 返回用户表数据结构处理,扁平化
            const temp = flatten(getUsers(res.data));
            // 设置过滤字段
            let arr = temp.map(item => item.OUName);
            arr = arr.filter((value, index) => arr.indexOf(value) === index);
            setOrgFilters(arr.map(item => ({ text: item, value: item })));
            setTableLength(temp.length);
            const table = temp.map((item, index) => {
              item.key = index;
              return item;
            });
皮倩雯's avatar
皮倩雯 committed
719
            setShowSearchStyle(false);
陈前坚's avatar
陈前坚 committed
720 721 722
            setTableData(table);
          } else {
            setTableLoading(false);
皮倩雯's avatar
皮倩雯 committed
723 724 725 726
            // notification.error({
            //   message: '获取失败',
            //   description: res.msg,
            // });
陈前坚's avatar
陈前坚 committed
727 728 729
          }
        })
        .catch(err => {
陈前坚's avatar
陈前坚 committed
730
          setTableLoading(false);
陈前坚's avatar
陈前坚 committed
731 732 733 734 735
          message.error(err);
        });
    } else {
      setTableLoading(false);
    }
陈前坚's avatar
陈前坚 committed
736
  };
陈前坚's avatar
陈前坚 committed
737

738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
  // 添加用户刷新表数据
  const onSelect1 = () => {
    console.log(orgID);
    setTableLoading(true);
    // eslint-disable-next-line no-console
    getOneOUUserListNew(orgID.id || currentSelectOrg)
      .then(res => {
        setCurrentOrgOperate(false); // 重置禁用当前机构操作为false
        setMultiOperate(true); // 重新禁止用户批量操作
        setSelectedRowKeys([]); // 重置选中用户数
        if (res.code === 0) {
          setTableLoading(false);
          setSearchWord(''); // 搜索框置空
          setOrgTitle(res.data.GroupName);
          setDescription(res.data.Description);
          // 返回用户表数据结构处理,扁平化
          const temp = flatten(getUsers(res.data));
          // 设置过滤字段
          let arr = temp.map(item => item.OUName);
          arr = arr.filter((value, index) => arr.indexOf(value) === index);
          setOrgFilters(arr.map(item => ({ text: item, value: item })));
          setTableLength(temp.length);
          const table = temp.map((item, index) => {
            item.key = index;
            return item;
          });
          setShowSearchStyle(false);
          setTableData(table);
        } else {
          setTableLoading(false);
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
  };

皮倩雯's avatar
皮倩雯 committed
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
  const getDescription = e => {
    getOneOUUserListNew(e).then(res => {
      if (res.code === 0) {
        setDescription(res.data.Description);
      }
    });
  };

  const getMapSetByGroupID = e => {
    GetMapSetByGroupID({
      groupID: e,
    }).then(res => {
      if (res.code === 0) {
        console.log(res);
        setCurrentOrgArea(res.data.MapRange);
        setCurrentOrgDistinct(res.data.AreeName);
      }
    });
  };
陈前坚's avatar
陈前坚 committed
795
  // 返回用户表数据结构处理,扁平化
796 797 798 799 800 801 802
  const getUsers = orgObj => {
    let result = orgObj.Users;
    result.map(item => {
      item.OUID = orgObj.GroupId;
      item.OUName = orgObj.GroupName;
      return item;
    });
803
    if (orgObj.Childs.length > 0) result = [...result, ...orgObj.Childs.map(o => getUsers(o))];
804 805 806 807 808 809 810 811
    return result;
  };
  const flatten = arr => {
    while (arr.some(item => Array.isArray(item))) {
      arr = [].concat(...arr);
    }
    return arr;
  };
陈前坚's avatar
陈前坚 committed
812
  // 添加用户
813
  const addUser = e => {
陈前坚's avatar
陈前坚 committed
814 815
    setUserVisible(true);
  };
陈前坚's avatar
陈前坚 committed
816 817
  // 添加顶级机构
  const addOrg = () => {
陈前坚's avatar
陈前坚 committed
818
    setAddOrgVisible(true);
陈前坚's avatar
陈前坚 committed
819
    setOrgID('-1');
陈前坚's avatar
陈前坚 committed
820
  };
陈前坚's avatar
陈前坚 committed
821
  // 添加下级机构
822
  const addSubOrg = e => {
陈前坚's avatar
陈前坚 committed
823 824 825 826
    setAddOrgVisible(true);
  };
  // 编辑机构
  const editOrg = () => {
陈前坚's avatar
陈前坚 committed
827
    setEditOrgVisible(true);
陈前坚's avatar
陈前坚 committed
828
  };
陈前坚's avatar
陈前坚 committed
829 830
  // 删除机构
  const deleteOrg = () => {
陈前坚's avatar
陈前坚 committed
831
    setDeleteOrgVisible(true);
832 833 834 835 836 837 838
    console.log(orgID);
    console.log(keep1);
    if (orgID.id == keep1) {
      setTreeState(true);
    } else {
      setTreeState(false);
    }
陈前坚's avatar
陈前坚 committed
839
  };
皮倩雯's avatar
皮倩雯 committed
840
  // 编辑机构范围
mayongxin's avatar
mayongxin committed
841
  const EditOrgScope = () => {
皮倩雯's avatar
皮倩雯 committed
842 843
    setEditOrgExtentVisible(true);
  };
陈前坚's avatar
陈前坚 committed
844

陈前坚's avatar
陈前坚 committed
845
  // 在currentUser变化后获取角色列表
846 847 848 849 850
  // useEffect(() => {
  //   if (currentUser && currentUser.userID) {
  //     getRoleList();
  //   }
  // }, [currentUser]);
陈前坚's avatar
陈前坚 committed
851

陈前坚's avatar
陈前坚 committed
852
  /** ***用户批量操作****** */
陈前坚's avatar
陈前坚 committed
853
  // 关联角色
陈前坚's avatar
陈前坚 committed
854
  const relateRoles = () => {
皮倩雯's avatar
皮倩雯 committed
855
    setMult('Yes');
陈前坚's avatar
陈前坚 committed
856
    getEmptyRoleList();
857
    // getCheckList()
陈前坚's avatar
陈前坚 committed
858
    setRoleVisible(true);
陈前坚's avatar
陈前坚 committed
859
    setMultiRelateRoles(true);
陈前坚's avatar
陈前坚 committed
860 861 862 863 864 865 866 867 868 869 870 871
  };
  // 更改机构
  const changeOrgs = () => {
    setChangeOrgVisible(true);
    setMultiChangeOrgs(true);
  };
  // 删除用户
  const deleteUsers = () => {
    setDeleteUserVisible(true);
    setMultiDelete(true);
  };

陈前坚's avatar
陈前坚 committed
872
  /** ***右侧表格相关操作****** */
陈前坚's avatar
陈前坚 committed
873
  // 关联角色
陈前坚's avatar
陈前坚 committed
874
  const relateRole = record => {
875
    // getEmptyRoleList(record.userID);
皮倩雯's avatar
皮倩雯 committed
876 877 878
    setMult('No');
    console.log(record);
    getRoleList(record);
陈前坚's avatar
陈前坚 committed
879
    setRoleVisible(true);
张烨's avatar
张烨 committed
880
    setCurrentUser(record);
881
    setSelectColor(record);
陈前坚's avatar
陈前坚 committed
882
  };
陈前坚's avatar
陈前坚 committed
883
  // 更改机构
陈前坚's avatar
陈前坚 committed
884
  const changeOrg = record => {
885
    setChangeOrgVisible(true);
张烨's avatar
张烨 committed
886
    setCurrentUser(record);
887
    setSelectColor(record);
陈前坚's avatar
陈前坚 committed
888
    setCurrentSelectOldOrg(record.OUID);
陈前坚's avatar
陈前坚 committed
889
  };
陈前坚's avatar
陈前坚 committed
890
  // 修改密码
陈前坚's avatar
陈前坚 committed
891 892
  const changePassword = record => {
    setPasswordVisible(true);
张烨's avatar
张烨 committed
893
    setCurrentUser(record);
894
    setSelectColor(record);
陈前坚's avatar
陈前坚 committed
895
  };
陈前坚's avatar
陈前坚 committed
896
  // 编辑用户
陈前坚's avatar
陈前坚 committed
897 898
  const editUser = record => {
    setEditUserVisible(true);
张烨's avatar
张烨 committed
899
    setCurrentUser(record);
900
    setSelectColor(record);
陈前坚's avatar
陈前坚 committed
901
  };
陈前坚's avatar
陈前坚 committed
902
  // 冻结用户
陈前坚's avatar
陈前坚 committed
903
  const freezeUser = record => {
皮倩雯's avatar
皮倩雯 committed
904
    // setFreezeUserVisible(true);
张烨's avatar
张烨 committed
905
    setCurrentUser(record);
906
    setSelectColor(record);
皮倩雯's avatar
皮倩雯 committed
907 908 909 910 911 912 913 914 915 916 917 918
    let state = '';
    console.log(record);
    if (record.state === '0' || record.state === null) {
      state = '1';
    } else {
      state = '0';
    }
    UserStateOUNew({ ouid: record.userID })
      .then(res => {
        if (res.code === 0) {
          // 重新获取用户表
          // eslint-disable-next-line no-unused-expressions
919
          currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
皮倩雯's avatar
皮倩雯 committed
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
          notification.success({
            message: '提交成功',
            duration: 2,
          });
        } else {
          notification.error({
            message: '提交失败',
            description: res.msg,
          });
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
陈前坚's avatar
陈前坚 committed
935
  };
陈前坚's avatar
陈前坚 committed
936
  // 删除用户
陈前坚's avatar
陈前坚 committed
937
  const deleteUser = record => {
皮倩雯's avatar
皮倩雯 committed
938 939
    console.log(record.userName);
    setCurrentUser(record.userName);
940
    setSelectColor(record);
皮倩雯's avatar
皮倩雯 committed
941 942 943 944 945 946 947 948 949 950 951
    DeleteUserNew({
      userID: record.userID,
      ouID: record.OUID,
    })
      .then(res => {
        if (res.code === 0) {
          notification.success({
            message: '提交成功',
            duration: 2,
          });
          // eslint-disable-next-line no-unused-expressions
952
          currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
皮倩雯's avatar
皮倩雯 committed
953 954 955 956 957 958 959 960 961 962 963
        } else {
          notification.error({
            message: '提交失败',
            description: res.msg,
          });
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
陈前坚's avatar
陈前坚 committed
964
  };
965

皮倩雯's avatar
皮倩雯 committed
966
  // 用户鉴权
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984
  //   useEffect(() => {
  //     currentUser.userID
  //     GetUserAuthSet({
  //         UserId: currentUser.userID
  //     }).then(
  //         res => {
  //             if(res.code == 0){
  //                 setSelctValue(res.data)
  //                 console.log(selectValue);
  //                 console.log(res.data);
  //             }
  //         }
  //     )
  // }, [currentUser])
  const jianquan = record => {
    GetUserAuthSet({
      UserId: record.userID,
    }).then(res => {
皮倩雯's avatar
皮倩雯 committed
985
      if (res.code === 0) {
986 987 988 989 990 991
        setSelctValue(res.data);
        console.log(res.data);
      }
    });
  };
  const onTypeChange = value => {
992
    setSelctValue(value.target.value);
993
  };
皮倩雯's avatar
皮倩雯 committed
994
  const authUser = record => {
mayongxin's avatar
mayongxin committed
995
    setCurrentUser(record);
皮倩雯's avatar
皮倩雯 committed
996 997
    console.log(selectValue);
    AddUserAuthSetting({
998
      userId: record.userID,
皮倩雯's avatar
皮倩雯 committed
999
      userLevel: selectValue,
1000 1001
    }).then(res => {
      if (res.code === 0) {
1002
        message.info('提交成功');
1003
      }
1004
    });
皮倩雯's avatar
皮倩雯 committed
1005
  };
1006

陈前坚's avatar
陈前坚 committed
1007 1008
  // 查找用户
  const submitSearchUser = () => {
皮倩雯's avatar
皮倩雯 committed
1009
    GetUserByKeyNew({ key: searchWord })
陈前坚's avatar
陈前坚 committed
1010
      .then(res => {
皮倩雯's avatar
皮倩雯 committed
1011
        if (res.code === 0) {
1012
          setSelectedRowKeys([]); // 重置选中用户数
1013
          setCurrentOrgOperate(true); // 禁止当前机构操作
1014
          setMultiOperate(true); // 禁用批量操作
1015
          setOrgTitle('全部机构搜索结果'); // 设置表头
1016
          setCurrentSelectOrg('-1'); // 清空选中机构
皮倩雯's avatar
皮倩雯 committed
1017
          console.log(res.data);
皮倩雯's avatar
皮倩雯 committed
1018
          setShowSearchStyle(true);
mayongxin's avatar
mayongxin committed
1019 1020
          setTableData(res.data);
          setTableLength(res.data.length);
陈前坚's avatar
陈前坚 committed
1021 1022
        } else {
          notification.error({
皮倩雯's avatar
皮倩雯 committed
1023 1024 1025
            message: '提示',
            duration: 3,
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1026 1027 1028 1029 1030 1031 1032
          });
        }
      })
      .catch(err => {
        message.error(err);
      });
  };
张烨's avatar
张烨 committed
1033

陈前坚's avatar
陈前坚 committed
1034 1035
  /** ***表单提交相关操作****** */
  // 根据当前 userID 获取用户关联角色
1036
  const getRoleList = e => {
1037
    setLoading(true);
1038
    GetUserRelationListNew({ userID: e.userID })
陈前坚's avatar
陈前坚 committed
1039
      .then(res => {
皮倩雯's avatar
皮倩雯 committed
1040 1041
        console.log(111);

皮倩雯's avatar
皮倩雯 committed
1042
        if (res.code === 0) {
mayongxin's avatar
mayongxin committed
1043
          const { roleList, stationList } = res.data;
皮倩雯's avatar
皮倩雯 committed
1044
          console.log(roleList);
1045 1046
          setRolelist(roleList);
          setStationlist(stationList);
1047
          setLoading(false);
陈前坚's avatar
陈前坚 committed
1048
        } else {
皮倩雯's avatar
皮倩雯 committed
1049
          console.log(res);
1050
          setLoading(false);
陈前坚's avatar
陈前坚 committed
1051 1052 1053
        }
      })
      .catch(err => {
1054
        setLoading(false);
陈前坚's avatar
陈前坚 committed
1055 1056 1057 1058
        setTableLoading(false);
        message.error(err);
      });
  };
陈前坚's avatar
陈前坚 committed
1059 1060 1061
  // 获取全部未勾选的角色列表与站点列表
  const getEmptyRoleList = () => {
    setLoading(true);
皮倩雯's avatar
皮倩雯 committed
1062
    GetUserRelationListNew({ userID: 0 })
陈前坚's avatar
陈前坚 committed
1063
      .then(res => {
皮倩雯's avatar
皮倩雯 committed
1064
        console.log(222);
皮倩雯's avatar
皮倩雯 committed
1065
        if (res.code === 0) {
mayongxin's avatar
mayongxin committed
1066
          const { roleList, stationList } = res.data;
陈前坚's avatar
陈前坚 committed
1067 1068
          setRolelist(roleList);
          setStationlist(stationList);
1069
          setLoading(false);
陈前坚's avatar
陈前坚 committed
1070
        } else {
皮倩雯's avatar
皮倩雯 committed
1071
          console.log(res.msg);
1072
          setLoading(false);
陈前坚's avatar
陈前坚 committed
1073 1074 1075 1076 1077 1078 1079 1080
        }
      })
      .catch(err => {
        setLoading(false);
        setTableLoading(false);
        message.error(err);
      });
  };
1081

皮倩雯's avatar
皮倩雯 committed
1082
  const getCheckList = e => {
1083
    console.log(e);
皮倩雯's avatar
皮倩雯 committed
1084 1085 1086 1087 1088 1089 1090 1091 1092
    let aa = [];
    let bb = [];
    loadAllUserRole(e).then(res => {
      if (res.code === 0) {
        if (res.data.roleList !== undefined) {
          // eslint-disable-next-line array-callback-return
          Object.keys(res.data.roleList).map((item, index) => {
            aa.push(item);
          });
1093
        }
皮倩雯's avatar
皮倩雯 committed
1094 1095 1096 1097 1098
        if (res.data.siteList !== undefined) {
          // eslint-disable-next-line array-callback-return
          Object.keys(res.data.siteList).map((item1, index1) => {
            bb.push(item1);
          });
1099
        }
皮倩雯's avatar
皮倩雯 committed
1100 1101 1102 1103
        console.log(aa);
        console.log(bb);
        setMultiRoleList(aa);
        setMultiStationList(bb);
1104
      }
皮倩雯's avatar
皮倩雯 committed
1105 1106
    });
  };
陈前坚's avatar
陈前坚 committed
1107
  // 提交-更改机构
皮倩雯's avatar
皮倩雯 committed
1108
  const submitChangeOrg = () => {
mayongxin's avatar
mayongxin committed
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
    // addToOrg(currentUser.userID, currentUser.OUID, newOrgID)
    // .then(res => {
    //   if (res.success) {
    //     setChangeOrgVisible(false);
    //     // 跳转到新组织机构下的用户表
    //     onSelect([newOrgID]);
    //     // setExpandedKeys([`${newOrgID}`]);
    //     notification.success({
    //       message: '提交成功',
    //       duration: 2,
    //     });
    //   } else {
    //     notification.error({
    //       message: '提交失败',
    //       description: res.message,
    //     });
    //   }
    // })
    // .catch(err => {
    //   message.error(err);
    // });
    JumpToAnotherOUNew({
皮倩雯's avatar
皮倩雯 committed
1131 1132 1133
      userID: currentUser.userID,
      oldOUID: currentUser.OUID,
      newOUID: newOrgID,
mayongxin's avatar
mayongxin committed
1134
    })
陈前坚's avatar
陈前坚 committed
1135
      .then(res => {
陈前坚's avatar
陈前坚 committed
1136 1137 1138 1139
        if (res.code === 0) {
          setChangeOrgVisible(false);
          // 跳转到新组织机构下的用户表
          onSelect([newOrgID]);
皮倩雯's avatar
皮倩雯 committed
1140
          // setExpandedKeys([`${newOrgID}`]);
陈前坚's avatar
陈前坚 committed
1141 1142
          notification.success({
            message: '提交成功',
1143
            duration: 2,
陈前坚's avatar
陈前坚 committed
1144 1145 1146 1147
          });
        } else {
          notification.error({
            message: '提交失败',
陈前坚's avatar
陈前坚 committed
1148
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1149 1150 1151 1152 1153 1154
          });
        }
      })
      .catch(err => {
        message.error(err);
      });
皮倩雯's avatar
皮倩雯 committed
1155
  };
1156

皮倩雯's avatar
皮倩雯 committed
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
  // 提交-批量更改机构
  const submitChangeOrgs = () =>
    addToOrgs(userIDs, orgIDs, newOrgID)
      .then(res => {
        if (res.code === 0) {
          setChangeOrgVisible(false);
          // 跳转到新组织机构下的用户表
          const temp = orgIDs.split(',');
          // 批量更改机构成功后设置老的orgIDs为全部是newOrgID的数组,并转字符串
          setOrgIDs(temp.map(() => newOrgID).toString());
          onSelect([newOrgID]);
陈前坚's avatar
陈前坚 committed
1168 1169
          notification.success({
            message: '提交成功',
1170
            duration: 2,
陈前坚's avatar
陈前坚 committed
1171 1172 1173 1174
          });
        } else {
          notification.error({
            message: '提交失败',
mayongxin's avatar
mayongxin committed
1175
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1176 1177 1178 1179 1180 1181
          });
        }
      })
      .catch(err => {
        message.error(err);
      });
皮倩雯's avatar
皮倩雯 committed
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239

  // 提交-冻结用户
  // const submitFreezeUser = () => {
  //   let state = '';
  //   if (currentUser.state === '0' || currentUser.state === null) {
  //     state = '1';
  //   } else {
  //     state = '0';
  //   }
  //   // postSetUserState(currentUser.userID, state)
  //   //   .then(res => {
  //   //     if (res.success) {
  //   //       setFreezeUserVisible(false);
  //   //       // 重新获取用户表
  //   //       // eslint-disable-next-line no-unused-expressions
  //   //       currentSelectOrg === '-1'
  //   //         ? submitSearchUser()
  //   //         : onSelect([currentSelectOrg]);
  //   //       notification.success({
  //   //         message: '提交成功',
  //   //         duration: 2,
  //   //       });
  //   //     } else {
  //   //       notification.error({
  //   //         message: '提交失败',
  //   //         description: res.message,
  //   //       });
  //   //     }
  //   //   })
  //   //   .catch(err => {
  //   //     setTableLoading(false);
  //   //     message.error(err);
  //   //   });
  //   UserStateOUNew({ ouid: currentUser.userID, state })
  //     .then(res => {
  //       if (res.code === 0) {
  //         // setFreezeUserVisible(false);
  //         // 重新获取用户表
  //         // eslint-disable-next-line no-unused-expressions
  //         currentSelectOrg === '-1'
  //           ? submitSearchUser()
  //           : onSelect([currentSelectOrg]);
  //         notification.success({
  //           message: '提交成功',
  //           duration: 2,
  //         });
  //       } else {
  //         notification.error({
  //           message: '提交失败',
  //           description: res.msg,
  //         });
  //       }
  //     })
  //     .catch(err => {
  //       setTableLoading(false);
  //       message.error(err);
  //     });
  // };
陈前坚's avatar
陈前坚 committed
1240
  // 提交-删除用户
陈前坚's avatar
陈前坚 committed
1241
  const submitDeleteUser = () => {
皮倩雯's avatar
皮倩雯 committed
1242 1243 1244 1245 1246 1247
    DeleteUserNew({
      userID: currentUser.userID,
      ouID: currentUser.OUID,
    })
      .then(res => {
        if (res.code === 0) {
陈前坚's avatar
陈前坚 committed
1248 1249
          notification.success({
            message: '提交成功',
1250
            duration: 2,
陈前坚's avatar
陈前坚 committed
1251
          });
1252
          // eslint-disable-next-line no-unused-expressions
1253
          currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
陈前坚's avatar
陈前坚 committed
1254 1255 1256
        } else {
          notification.error({
            message: '提交失败',
mayongxin's avatar
mayongxin committed
1257
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267
          });
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
  };
  // 提交-批量删除用户
  const submitDeleteUsers = () => {
陈前坚's avatar
陈前坚 committed
1268
    multiDeleteUsers(userIDs)
陈前坚's avatar
陈前坚 committed
1269 1270 1271 1272 1273
      .then(res => {
        if (res.code === 0) {
          setDeleteUserVisible(false);
          notification.success({
            message: '提交成功',
1274
            duration: 2,
陈前坚's avatar
陈前坚 committed
1275
          });
1276
          // 重新获取用户表,查找用户时currentSelectOrg为'-1',无需跳转
1277
          // eslint-disable-next-line no-unused-expressions
1278
          currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
陈前坚's avatar
陈前坚 committed
1279
        } else {
陈前坚's avatar
陈前坚 committed
1280 1281
          notification.error({
            message: '提交失败',
陈前坚's avatar
陈前坚 committed
1282
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1283 1284 1285 1286 1287 1288 1289
          });
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
陈前坚's avatar
陈前坚 committed
1290
  };
1291
  // 重置默认第一个
1292
  const handleReset = () => {
1293 1294 1295 1296 1297 1298
    GetOUTreeNew({ selectOU: -1 })
      .then(newres => {
        if (newres.code === 0) {
          let res = newres.data;
          setTreeLoading(false);
          setSearchWord('');
皮倩雯's avatar
皮倩雯 committed
1299
          setFilteredValue([]);
1300
          // 第一次加载,默认选择第一个组织
1301
          onSelect([res[0].id], false);
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
        } else {
          setTreeLoading(false);
          notification.error({
            message: '获取失败',
            // eslint-disable-next-line no-undef
            description: res.message,
          });
        }
      })
      .catch(err => {
        setTreeLoading(false);
        message.error(err);
      });
1315
  };
皮倩雯's avatar
皮倩雯 committed
1316
  const onChangeInput = filters => {
1317
    setFilteredValue(filters.OUName);
皮倩雯's avatar
皮倩雯 committed
1318
  };
1319

皮倩雯's avatar
皮倩雯 committed
1320
  // 更改机构范围
1321
  const submitExtent = (extent, areaName, flags) => {
皮倩雯's avatar
皮倩雯 committed
1322 1323 1324
    setTreeLoading(true);
    console.log(extent);
    console.log(areaName);
1325
    console.log(flags);
皮倩雯's avatar
皮倩雯 committed
1326
    console.log(currentSelectOrg1);
1327
    if (flags === 0) {
1328 1329 1330 1331
      setTreeLoading(false);
      notification.warn({
        message: '提交失败',
        description: '请框选范围',
皮倩雯's avatar
皮倩雯 committed
1332
      });
皮倩雯's avatar
皮倩雯 committed
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349
    } else if (extent) {
      setOrgArea({
        OUID: currentSelectOrg1,
        areaName,
        extent,
      }).then(res => {
        if (res.msg === '') {
          setTreeLoading(false);
          setEditOrgExtentVisible(false);
          setSaveExtentFlag(saveExtentFlag + 1);
          message.success('机构范围设置成功!');
        } else {
          setTreeLoading(false);
          setEditOrgExtentVisible(false);
          message.warn(res.Message);
        }
      });
mayongxin's avatar
mayongxin committed
1350
    }
皮倩雯's avatar
皮倩雯 committed
1351
  };
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368
  // 返回拖拽完毕后的信息
  const loop = (datas, key, parentID, callback) => {
    for (let i = 0; i < datas.length; i++) {
      if (datas[i].id === key) {
        return callback(datas[i], i, datas, parentID);
      }
      if (datas[i].children) {
        loop(datas[i].children, key, datas[i].id, callback);
      }
    }
  };
  // 树的拖拽
  const handleDrop = infos => {
    console.log(infos);
    const dropKey = infos.node.key;
    const dragKey = infos.dragNode.key;
    const dropPos = infos.node.pos.split('-');
1369
    const dropPosition = infos.dropPosition - Number(dropPos[dropPos.length - 1]);
陈前坚's avatar
陈前坚 committed
1370

1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423
    const datas = JSON.parse(JSON.stringify(treeData));
    console.log(dropKey, 'dropKey');
    console.log(dragKey, 'dragKey');
    // 找到拖拽的元素
    let dragObj;
    let dropObj;
    let parId;
    let dragList;
    // 保存拖拽到的节点信息
    loop(datas, dropKey, -1, item => {
      dropObj = item;
    });
    // 保存节点信息并删除节点
    loop(datas, dragKey, -1, (item, index, arr) => {
      arr.splice(index, 1);
      dragObj = item;
    });
    // 将节点插入到正确的位置
    if (!infos.dropToGap) {
      console.log('33333333333');
      dropObj.children = dropObj.children || [];
      // 在哪里插入,示例添加到头部,可以是随意位置
      dropObj.children.unshift(dragObj);
      parId = dropObj.id;
      dragList = dropObj.children.map(val => val.id);
    } else {
      let ar;
      let i;
      loop(datas, dropKey, -1, (item, index, arr, parentID) => {
        ar = arr;
        i = index;
        parId = parentID;
      });
      if (dropPosition === -1) {
        ar.splice(i, 0, dragObj);
      } else {
        ar.splice(i + 1, 0, dragObj);
      }
      dragList = ar.map(ele => ele.id);
    }
    DragGroup({
      dragGroupType: 2,
      groupId: dragKey.toString(),
      groupList: dragList.map(item => item.toString()),
      parentId: parId.toString(),
    }).then(res => {
      if (res.code === 0) {
        updateTrees();
      } else {
        message.error(res.msg);
      }
    });
  };
皮倩雯's avatar
皮倩雯 committed
1424 1425 1426
  const addChange = e => {
    e.domEvent.stopPropagation();
  };
1427

陈前坚's avatar
陈前坚 committed
1428 1429 1430
  /** ***操作按钮**** */
  // 机构操作
  const orgButtonMenu = (
皮倩雯's avatar
皮倩雯 committed
1431
    <Menu onClick={e => addChange(e)}>
1432
      <Menu.Item key="1" onClick={addUser} icon={<UserAddOutlined style={{ marginTop: '5px' }} />}>
陈前坚's avatar
陈前坚 committed
1433 1434
        添加用户
      </Menu.Item>
1435 1436 1437 1438
    </Menu>
  );
  const orgButtonMenu1 = (
    <Menu onClick={e => addChange(e)}>
1439 1440 1441 1442 1443
      <Menu.Item
        key="2"
        onClick={addSubOrg}
        icon={<ClusterOutlined style={{ marginTop: '5px' }} />}
      >
陈前坚's avatar
陈前坚 committed
1444
        添加下级机构
陈前坚's avatar
陈前坚 committed
1445
      </Menu.Item>
1446
      <Menu.Item key="3" onClick={editOrg} icon={<EditOutlined style={{ marginTop: '5px' }} />}>
陈前坚's avatar
陈前坚 committed
1447
        编辑当前机构
陈前坚's avatar
陈前坚 committed
1448
      </Menu.Item>
1449
      <Menu.Item key="4" onClick={deleteOrg} icon={<DeleteOutlined style={{ marginTop: '5px' }} />}>
陈前坚's avatar
陈前坚 committed
1450
        删除当前机构
陈前坚's avatar
陈前坚 committed
1451
      </Menu.Item>
1452
      {/* <Menu.Item
1453 1454 1455 1456
        key="5"
        onClick={EditOrgScope}
        icon={<BorderlessTableOutlined style={{ marginTop: '5px' }} />}
      >
mayongxin's avatar
mayongxin committed
1457
        编辑机构范围
1458
      </Menu.Item> */}
陈前坚's avatar
陈前坚 committed
1459 1460 1461 1462 1463
    </Menu>
  );
  // 用户批量操作
  const userButtonMenu = (
    <Menu>
1464
      <Menu.Item key="1" onClick={relateRoles} icon={<IdcardOutlined />}>
陈前坚's avatar
陈前坚 committed
1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475
        批量关联角色
      </Menu.Item>
      <Menu.Item key="2" onClick={changeOrgs} icon={<ApartmentOutlined />}>
        批量更改机构
      </Menu.Item>
      <Menu.Item key="3" onClick={deleteUsers} icon={<DeleteOutlined />}>
        批量删除用户
      </Menu.Item>
    </Menu>
  );

皮倩雯's avatar
皮倩雯 committed
1476 1477 1478
  const kee = () => {
    setUserVisible(false);
  };
1479

陈前坚's avatar
陈前坚 committed
1480
  return (
1481 1482
    <PageContainer className={styles.userManageContainer}>
      <div className={styles.contentContainer}>
陈前坚's avatar
陈前坚 committed
1483
        {/* 左侧机构树 */}
陈前坚's avatar
陈前坚 committed
1484
        <Spin spinning={treeLoading} tip="loading...">
陈前坚's avatar
陈前坚 committed
1485
          <Card
1486
            style={{ overflowY: 'hidden', height: '100%' }}
陈前坚's avatar
陈前坚 committed
1487 1488 1489 1490 1491
            className={classnames({
              [styles.orgContainer]: true,
              [styles.orgContainerHide]: !treeVisible,
            })}
          >
1492 1493 1494
            <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
              <div style={{ display: 'flex' }}>
                <span
陈前坚's avatar
陈前坚 committed
1495
                  style={{
1496 1497 1498
                    fontSize: '15px ',
                    fontWeight: 'bold',
                    marginLeft: '15px',
陈前坚's avatar
陈前坚 committed
1499
                  }}
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514
                >
                  机构列表
                </span>
                <Tooltip title="添加顶级机构">
                  <PlusSquareFilled
                    onClick={() => addOrg()}
                    style={{
                      color: '#1890FF',
                      fontSize: '25px',
                      verticalAlign: 'middle',
                      marginLeft: '64%',
                    }}
                  />
                </Tooltip>
              </div>
1515
              <hr style={{ width: '95%', color: '#eeecec', marginLeft: '15px' }} />
陈前坚's avatar
陈前坚 committed
1516
              {treeData.length > 0 && (
1517
                <div style={{ height: '100%', overflowY: 'scroll' }}>
1518 1519 1520 1521 1522 1523 1524 1525
                  <Tree
                    showIcon="true"
                    blockNode
                    autoExpandParent
                    onSelect={onSelect}
                    treeData={treeData.map(t => mapTree(t))}
                    draggable
                    onDrop={handleDrop}
1526
                    selectedKeys={[menuID]}
皮倩雯's avatar
皮倩雯 committed
1527
                    keepTree={keepTree}
1528
                    expandedKeys={expendKey}
1529 1530
                  />
                </div>
陈前坚's avatar
陈前坚 committed
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544
              )}
            </div>
            <div className={styles.switcher}>
              {treeVisible && (
                <Tooltip title="隐藏机构列表">
                  <DoubleLeftOutlined onClick={() => setTreeVisible(false)} />
                </Tooltip>
              )}
              {!treeVisible && (
                <Tooltip title="显示机构列表">
                  <DoubleRightOutlined onClick={() => setTreeVisible(true)} />
                </Tooltip>
              )}
            </div>
陈前坚's avatar
陈前坚 committed
1545
          </Card>
陈前坚's avatar
陈前坚 committed
1546
        </Spin>
1547

陈前坚's avatar
陈前坚 committed
1548
        {/* 右侧用户表 */}
陈前坚's avatar
陈前坚 committed
1549
        <div
1550
          ref={userContainer}
陈前坚's avatar
陈前坚 committed
1551
          className={classnames({
1552
            [styles.userContainer]: true,
陈前坚's avatar
陈前坚 committed
1553 1554
          })}
        >
陈前坚's avatar
陈前坚 committed
1555
          <div style={{ height: '50px' }}>
1556
            <span
1557
              className={styles.title}
1558
              title={`${orgTitle}(已选${selectedRowKeys.length}/共${tableLength}人)`}
1559 1560
            >
              {orgTitle}(已选{selectedRowKeys.length}/共{tableLength}人)
1561
            </span>
陈前坚's avatar
陈前坚 committed
1562
            <span style={{ float: 'right', margin: '10px' }}>
陈前坚's avatar
陈前坚 committed
1563
              <Search
1564 1565
                style={{ width: 260 }}
                placeholder="搜索登录名/用户姓名/手机号"
陈前坚's avatar
陈前坚 committed
1566 1567 1568 1569 1570
                onSearch={submitSearchUser}
                onChange={e => handleSearch(e)}
                enterButton
                value={searchWord}
              />
皮倩雯's avatar
皮倩雯 committed
1571

1572 1573 1574
              <Button icon={<SyncOutlined />} onClick={handleReset}>
                重置
              </Button>
皮倩雯's avatar
皮倩雯 committed
1575

陈前坚's avatar
陈前坚 committed
1576 1577 1578 1579 1580
              <Dropdown overlay={userButtonMenu} disabled={multiOperate}>
                <Button type={multiOperateButtonType}>
                  用户批量操作 <DownOutlined />
                </Button>
              </Dropdown>
陈前坚's avatar
陈前坚 committed
1581 1582
            </span>
          </div>
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
          {userContainer.current && (
            <Table
              // style={{ height: 'calc(100% -50px)' }}
              rowSelection={{
                type: 'checkbox',
                ...rowSelection,
              }}
              rowClassName={setRowClassName}
              size="small"
              rowKey={record => record.userID}
              locale={zhCN}
              bordered
              columns={columns}
              dataSource={tableData}
              loading={tableLoading}
              scroll={{
                x: 'max-content',
                y: `calc(${userContainer.current.clientHeight}px - 150px)`,
              }}
              // scroll={{ x: 'max-content' }}
              pagination={{
                showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
                pageSizeOptions: [10, 20, 50, 100],
                defaultPageSize: 20,
                showQuickJumper: true,
                showSizeChanger: true,
              }}
              onChange={onChangeInput}
            />
          )}
1613
        </div>
1614

陈前坚's avatar
陈前坚 committed
1615
        {/* Modal弹框 */}
1616
        {/* 添加用户 */}
陈前坚's avatar
陈前坚 committed
1617 1618 1619
        <AddUserModal
          visible={userVisible}
          orgID={orgID}
1620
          orgTitle1={orgTitle1}
皮倩雯's avatar
皮倩雯 committed
1621
          onCancel={kee}
1622 1623
          updateTrees1={updateTrees1}
          onSelect={onSelect}
陈前坚's avatar
陈前坚 committed
1624
        />
1625
        {/* 添加下级机构 */}
1626
        <AddSubOrgModal
1627
          visible={addOrgVisible}
1628
          orgTitle1={orgTitle1}
1629
          orgID={orgID}
1630
          onCancel={() => setAddOrgVisible(false)}
1631 1632
          onSelect={onSelect}
          updateTrees1={updateTrees1}
1633
        />
1634
        {/* 编辑机构 */}
1635
        <EditOrgModal
1636
          visible={editOrgVisible}
1637
          orgID={orgID}
1638
          orgTitle1={orgTitle1}
1639
          description={description}
1640
          onCancel={() => setEditOrgVisible(false)}
1641 1642 1643 1644
          updateTrees={updateTrees}
        />
        {/* 删除机构 */}
        <DeleteOrgModal
皮倩雯's avatar
皮倩雯 committed
1645
          title="删除机构"
1646
          visible={deleteOrgVisible}
1647
          orgTitle={orgTitle1}
1648 1649
          orgID={orgID}
          updateTrees={updateTrees}
1650
          onCancel={() => setDeleteOrgVisible(false)}
1651
        />
陈前坚's avatar
陈前坚 committed
1652
        {/* 关联角色 */}
1653 1654 1655 1656
        <RelateRoleModal
          currentUser={currentUser}
          userIDs={userIDs}
          currentSelectOrg={currentSelectOrg}
陈前坚's avatar
陈前坚 committed
1657
          visible={roleVisible}
1658
          rolelist={rolelist}
1659 1660 1661
          multiRoleList={multiRoleList}
          multistationList={multistationList}
          mult={mult}
1662 1663 1664 1665
          loading={loading}
          stationlist={stationlist}
          multiRelateRoles={multiRelateRoles}
          onSelect={onSelect}
陈前坚's avatar
陈前坚 committed
1666 1667 1668 1669
          onCancel={() => {
            setRoleVisible(false);
            setMultiRelateRoles(false);
          }}
1670
        />
陈前坚's avatar
陈前坚 committed
1671
        {/* 更改机构 */}
1672 1673 1674
        <Modal
          title="更改机构"
          visible={changeOrgVisible}
陈前坚's avatar
陈前坚 committed
1675
          onOk={multiChangeOrgs ? submitChangeOrgs : submitChangeOrg}
1676
          maskClosable={false}
陈前坚's avatar
陈前坚 committed
1677 1678 1679 1680
          onCancel={() => {
            setChangeOrgVisible(false);
            setMultiChangeOrgs(false);
          }}
1681 1682
          okText="确认"
          cancelText="取消"
1683
          width="500px"
1684
        >
1685 1686 1687 1688 1689 1690 1691 1692 1693
          {/* <span>请选择要更改的目标机构:</span> */}
          <Search
            style={{ width: 260, marginBottom: '10px' }}
            placeholder="请输入机构名称"
            onSearch={submitSearch}
            onChange={e => handleSearchOrg(e)}
            enterButton
            value={searchWordOrg}
          />
1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711
          <div style={{ height: '500px', overflowY: 'scroll' }}>
            {changeOrgVisible && treeDataCopy.length > 0 && (
              <Tree
                showIcon="true"
                showLine={{ showLeafIcon: false }}
                // defaultExpandAll
                // 未切换时原先的节点,注意要转字符串
                selectedKeys={[`${currentSelectOldOrg}`]}
                onSelect={value => {
                  setNewOrgID(value[0]);
                  // 切换后选中的节点
                  setCurrentSelectOldOrg(value[0]);
                }}
                expandedKeys={expendKeyOrg}
                treeData={treeDataCopy.map(t => mapTree1(t))}
              />
            )}
          </div>
1712
        </Modal>
陈前坚's avatar
陈前坚 committed
1713
        {/* 修改密码 */}
1714
        <ChangePasswordModal
陈前坚's avatar
陈前坚 committed
1715
          visible={passwordVisible}
1716
          currentUser={currentUser}
1717 1718
          submitSearchUser={submitSearchUser}
          currentSelectOrg={currentSelectOrg}
1719
          onSelect={onSelect}
陈前坚's avatar
陈前坚 committed
1720
          onCancel={() => setPasswordVisible(false)}
1721
        />
陈前坚's avatar
陈前坚 committed
1722
        {/* 编辑用户 */}
1723
        <EditUserModal
陈前坚's avatar
陈前坚 committed
1724
          visible={editUserVisible}
1725
          currentUser={currentUser}
1726 1727
          submitSearchUser={submitSearchUser}
          currentSelectOrg={currentSelectOrg}
1728
          onSelect={onSelect}
陈前坚's avatar
陈前坚 committed
1729
          onCancel={() => setEditUserVisible(false)}
1730
        />
陈前坚's avatar
陈前坚 committed
1731
        {/* 冻结用户 */}
皮倩雯's avatar
皮倩雯 committed
1732
        {/* <Modal
1733
          title="请确认"
陈前坚's avatar
陈前坚 committed
1734 1735 1736 1737 1738 1739
          visible={freezeUserVisible}
          onOk={submitFreezeUser}
          onCancel={() => setFreezeUserVisible(false)}
          okText="确认"
          cancelText="取消"
        >
张烨's avatar
张烨 committed
1740 1741
          <p>
            即将{+currentUser.state ? '激活' : '冻结'}用户{' '}
1742 1743 1744
            <span className={styles.redText}>
              {voca.stripTags(currentUser.loginName)}
            </span>
张烨's avatar
张烨 committed
1745 1746 1747
            ,是否确认
            {+currentUser.state ? '激活' : '冻结'}?
          </p>
皮倩雯's avatar
皮倩雯 committed
1748
        </Modal> */}
1749
        {/* 多选删除用户 */}
1750 1751 1752
        <Modal
          title="确认删除用户"
          visible={deleteUserVisible}
陈前坚's avatar
陈前坚 committed
1753
          onOk={multiDelete ? submitDeleteUsers : submitDeleteUser}
1754
          maskClosable={false}
陈前坚's avatar
陈前坚 committed
1755 1756 1757 1758
          onCancel={() => {
            setDeleteUserVisible(false);
            setMultiDelete(false);
          }}
1759 1760 1761
          okText="确认"
          cancelText="取消"
        >
1762
          <p>将删除多个用户, 是否确认删除?</p>
1763
        </Modal>
1764
        {/* <MapScopeEditModal
皮倩雯's avatar
皮倩雯 committed
1765
          title={id}
mayongxin's avatar
mayongxin committed
1766
          mapId={createGuid()}
mayongxin's avatar
mayongxin committed
1767
          visible={editOrgExtentVisible}
皮倩雯's avatar
皮倩雯 committed
1768
          stationId={currentSelectOrg1}
mayongxin's avatar
mayongxin committed
1769 1770 1771 1772
          onCancel={() => setEditOrgExtentVisible(false)}
          confirmModal={submitExtent}
          distinct={currentOrgDistinct}
          extent={currentOrgArea}
1773
        /> */}
1774
        {/* <AuthModal
皮倩雯's avatar
皮倩雯 committed
1775 1776 1777
          visible={authUserVisible}
          currentUser={currentUser}
          onCancel={() => setAuthUserVisible(false)}
1778
        /> */}
陈前坚's avatar
陈前坚 committed
1779 1780
      </div>
    </PageContainer>
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822
    // <DraggleLayout
    //     containerWidth={550}
    //     containerHeight={220}
    //     min={50}
    //     max={500}
    //     initLeftWidth={100}
    //     onWidthChange={w => setWidth(w)}
    //     handler={
    //       <div
    //         style={{
    //           width: 4,
    //           height: '100%',
    //           background: 'rgb(77, 81, 100)',
    //         }}
    //       />
    //     }
    //   >
    //     <div
    //       style={{
    //         backgroundColor: `rgb(36, 205, 208)`,
    //         color: `#fff`,
    //         height: '100%',
    //         display: 'flex',
    //         alignItems: 'center',
    //         justifyContent: 'center',
    //       }}
    //     >
    //       left
    //     </div>
    //     <div
    //       style={{
    //         backgroundColor: `rgb(116, 140, 253)`,
    //         color: `#fff`,
    //         height: '100%',
    //         display: 'flex',
    //         alignItems: 'center',
    //         justifyContent: 'center',
    //       }}
    //     >
    //       right
    //     </div>
    //   </DraggleLayout>
陈前坚's avatar
陈前坚 committed
1823 1824 1825 1826
  );
};

export default UserManage;