UserManage.jsx 53.5 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 164 165 166

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

  useEffect(() => {
    setExpendKey(menuID);
    console.log(expendKey);
  }, [menuID]);
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
  // 获取用户机构树
  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]);
  const resizeListener = () => {
    flagRef.current += 1;
    setFlag(flagRef.current);
  };
皮倩雯's avatar
皮倩雯 committed
394 395
  // 模糊查询匹配的样式
  const searchStyle = val => {
396 397 398
    if (!val) {
      return val;
    }
皮倩雯's avatar
皮倩雯 committed
399 400
    let n;
    if (showSearchStyle) {
401
      n = val.replace(new RegExp(searchWord, 'g'), `<span style='color:red'>${searchWord}</span>`);
皮倩雯's avatar
皮倩雯 committed
402 403 404 405 406
    } else {
      n = val;
    }
    return <div dangerouslySetInnerHTML={{ __html: n }} />;
  };
407 408 409 410
  // 获取搜索框的值
  const handleSearch = e => {
    setSearchWord(e.target.value);
  };
皮倩雯's avatar
皮倩雯 committed
411
  // 复选框
陈前坚's avatar
陈前坚 committed
412
  const rowSelection = {
413 414
    selectedRowKeys,
    onChange: (RowKeys, Rows) => {
415 416
      console.log(RowKeys);
      console.log(Rows);
417
      setSelectedRowKeys(RowKeys);
皮倩雯's avatar
皮倩雯 committed
418
      getCheckList(RowKeys);
419 420
      setUserIDs(RowKeys.toString()); // 数组转字符串,逗号连接
      setOrgIDs(Rows.map(item => item.OUID).toString());
陈前坚's avatar
陈前坚 committed
421
      // 选中行数大于0时设置批量操作可行
422
      if (RowKeys.length > 0) {
423
        setSelectColor({});
陈前坚's avatar
陈前坚 committed
424 425 426 427 428 429
        setMultiOperate(false);
        setMultiOperateButtonType('primary');
      } else {
        setMultiOperate(true);
        setMultiOperateButtonType('default');
      }
陈前坚's avatar
陈前坚 committed
430 431
    },
  };
陈前坚's avatar
陈前坚 committed
432 433 434 435
  // 渲染机构树
  const mapTree = org => {
    const haveChildren = Array.isArray(org.children) && org.children.length > 0;
    return {
皮倩雯's avatar
皮倩雯 committed
436
      title: (
皮倩雯's avatar
皮倩雯 committed
437
        <div className={styles.title1}>
438 439 440 441 442 443 444 445
          <span className={styles.titleText}>
            {org.children.length == 0 ? (
              <ApartmentOutlined style={{ fontSize: '14px', color: '#1890FF' }} />
            ) : (
              <span />
            )}
            <span style={{ marginLeft: '5px' }}>{org.text}</span>
          </span>
446 447 448 449 450 451 452 453 454 455 456 457
          <span
            className={classnames({
              [styles.tip1]: true,
              [styles.listHover]: org === hoverItemIndex,
            })}
            onMouseEnter={() => {
              setHoverItemIndex(org);
            }}
            onMouseLeave={() => {
              setHoverItemIndex('');
            }}
          >
458
            <Tooltip title="添加用户" className={styles.fs1}>
459 460 461 462 463 464 465 466 467 468 469 470
              <UserAddOutlined
                style={{ marginLeft: 20, lineHeight: '24px' }}
                onClick={e => {
                  e.stopPropagation();
                  addUser();
                }}
                onMouseEnter={e => {
                  setOrgID(org);
                  setOrgTitle1(org.text);
                  console.log(org);
                }}
              />
皮倩雯's avatar
皮倩雯 committed
471
            </Tooltip>
皮倩雯's avatar
皮倩雯 committed
472
            <Dropdown overlay={orgButtonMenu1}>
473
              <EllipsisOutlined
474
                style={{ marginLeft: 10, fontSize: '20px', lineHeight: '24px' }}
475
                onClick={e => e.stopPropagation()}
皮倩雯's avatar
皮倩雯 committed
476 477 478 479 480 481 482 483 484
                onMouseEnter={e => {
                  setOrgID(org);
                  setOrgTitle1(org.text);
                  getDescription(org.id);
                  getMapSetByGroupID(org.id);
                  setCurrentSelectOrg1(org.id);
                  setId(org.text);
                  console.log(org);
                }}
485
              />
皮倩雯's avatar
皮倩雯 committed
486 487 488 489
            </Dropdown>
          </span>
        </div>
      ),
陈前坚's avatar
陈前坚 committed
490 491 492 493 494
      key: org.id,
      // 判断它是否存在子集,若果存在就进行再次进行遍历操作,知道不存在子集便对其他的元素进行操作
      children: haveChildren ? org.children.map(i => mapTree(i)) : [],
    };
  };
495

皮倩雯's avatar
皮倩雯 committed
496 497 498 499 500 501 502 503 504 505
  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
506
  // 重新渲染树
陈前坚's avatar
陈前坚 committed
507 508
  const updateTrees = () => {
    setTreeLoading(true);
mayongxin's avatar
mayongxin committed
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
    // 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
532 533 534 535
    GetOUTreeNew({ selectOU: -1 })
      .then(newres => {
        if (newres.code === 0) {
          let res = newres.data;
536
          console.log(res);
陈前坚's avatar
陈前坚 committed
537
          setTreeLoading(false);
538
          setTreeData(res);
陈前坚's avatar
陈前坚 committed
539
          setTreeDataCopy(res);
皮倩雯's avatar
皮倩雯 committed
540 541 542 543 544
          let aa = [];
          res.forEach(i => {
            aa.push(i.id);
          });
          setKeepTree(aa);
545

546 547
          // 第一次加载,默认选择第一个组织
          if (treeState) {
皮倩雯's avatar
皮倩雯 committed
548
            onSelect([res[0].id]);
549 550
            setTreeState(false);
          }
陈前坚's avatar
陈前坚 committed
551 552 553 554
        } else {
          setTreeLoading(false);
          notification.error({
            message: '获取失败',
皮倩雯's avatar
皮倩雯 committed
555
            // eslint-disable-next-line no-undef
陈前坚's avatar
陈前坚 committed
556 557
            description: res.message,
          });
陈前坚's avatar
陈前坚 committed
558 559 560
        }
      })
      .catch(err => {
陈前坚's avatar
陈前坚 committed
561
        setTreeLoading(false);
陈前坚's avatar
陈前坚 committed
562 563
        message.error(err);
      });
陈前坚's avatar
陈前坚 committed
564
  };
张烨's avatar
张烨 committed
565

566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
  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
600
  // 点击树节点,获取当前机构下所有用户
陈前坚's avatar
陈前坚 committed
601
  const onSelect = (props, e) => {
602
    console.log(props);
603
    console.log(e);
皮倩雯's avatar
皮倩雯 committed
604 605 606 607
    if (e) {
      props[0] = e.node.key;
    } else {
      props[0] = props.toString();
608
    }
皮倩雯's avatar
皮倩雯 committed
609
    setKeep1(props);
陈前坚's avatar
陈前坚 committed
610
    setTableLoading(true);
陈前坚's avatar
陈前坚 committed
611
    if (!props[0]) {
张烨's avatar
张烨 committed
612
      setCurrentSelectOrg(currentSelectOrg);
皮倩雯's avatar
皮倩雯 committed
613
      setCurrentSelectOrg1(currentSelectOrg);
陈前坚's avatar
陈前坚 committed
614
    } else {
张烨's avatar
张烨 committed
615
      setCurrentSelectOrg(props[0]);
皮倩雯's avatar
皮倩雯 committed
616
      setCurrentSelectOrg1(props[0]);
陈前坚's avatar
陈前坚 committed
617
    }
mayongxin's avatar
mayongxin committed
618
    GetMapSetByGroupID({
皮倩雯's avatar
皮倩雯 committed
619 620 621
      groupID: props[0],
    }).then(res => {
      if (res.code === 0) {
皮倩雯's avatar
皮倩雯 committed
622
        console.log(res);
皮倩雯's avatar
皮倩雯 committed
623
        if (res.code.MapRange != null) {
624 625 626
          setCurrentOrgArea(res.data.MapRange);
          setCurrentOrgDistinct(res.data.AreeName);
        }
mayongxin's avatar
mayongxin committed
627
      }
皮倩雯's avatar
皮倩雯 committed
628
    });
张烨's avatar
张烨 committed
629
    setOrgID(props[0] || currentSelectOrg);
陈前坚's avatar
陈前坚 committed
630 631
    // 树节点变化(即props不为空)时才请求,避免重复请求
    if (props[0]) {
632 633
      console.log(props[0]);
      setMenuID(props[0]);
皮倩雯's avatar
皮倩雯 committed
634
      // eslint-disable-next-line no-console
陈前坚's avatar
陈前坚 committed
635 636
      getOneOUUserListNew(props[0] || currentSelectOrg)
        .then(res => {
637
          setCurrentOrgOperate(false); // 重置禁用当前机构操作为false
638
          setMultiOperate(true); // 重新禁止用户批量操作
639
          setSelectedRowKeys([]); // 重置选中用户数
陈前坚's avatar
陈前坚 committed
640 641 642 643
          if (res.code === 0) {
            setTableLoading(false);
            setSearchWord(''); // 搜索框置空
            setOrgTitle(res.data.GroupName);
644
            setDescription(res.data.Description);
陈前坚's avatar
陈前坚 committed
645 646 647 648 649 650 651 652 653 654 655
            // 返回用户表数据结构处理,扁平化
            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
656
            setShowSearchStyle(false);
陈前坚's avatar
陈前坚 committed
657 658 659
            setTableData(table);
          } else {
            setTableLoading(false);
皮倩雯's avatar
皮倩雯 committed
660 661 662 663
            // notification.error({
            //   message: '获取失败',
            //   description: res.msg,
            // });
陈前坚's avatar
陈前坚 committed
664 665 666
          }
        })
        .catch(err => {
陈前坚's avatar
陈前坚 committed
667
          setTableLoading(false);
陈前坚's avatar
陈前坚 committed
668 669 670 671 672
          message.error(err);
        });
    } else {
      setTableLoading(false);
    }
陈前坚's avatar
陈前坚 committed
673
  };
陈前坚's avatar
陈前坚 committed
674

675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
  // 添加用户刷新表数据
  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
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731
  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
732
  // 返回用户表数据结构处理,扁平化
733 734 735 736 737 738 739
  const getUsers = orgObj => {
    let result = orgObj.Users;
    result.map(item => {
      item.OUID = orgObj.GroupId;
      item.OUName = orgObj.GroupName;
      return item;
    });
740
    if (orgObj.Childs.length > 0) result = [...result, ...orgObj.Childs.map(o => getUsers(o))];
741 742 743 744 745 746 747 748
    return result;
  };
  const flatten = arr => {
    while (arr.some(item => Array.isArray(item))) {
      arr = [].concat(...arr);
    }
    return arr;
  };
陈前坚's avatar
陈前坚 committed
749
  // 添加用户
750
  const addUser = e => {
陈前坚's avatar
陈前坚 committed
751 752
    setUserVisible(true);
  };
陈前坚's avatar
陈前坚 committed
753 754
  // 添加顶级机构
  const addOrg = () => {
陈前坚's avatar
陈前坚 committed
755
    setAddOrgVisible(true);
陈前坚's avatar
陈前坚 committed
756
    setOrgID('-1');
陈前坚's avatar
陈前坚 committed
757
  };
陈前坚's avatar
陈前坚 committed
758
  // 添加下级机构
759
  const addSubOrg = e => {
陈前坚's avatar
陈前坚 committed
760 761 762 763
    setAddOrgVisible(true);
  };
  // 编辑机构
  const editOrg = () => {
陈前坚's avatar
陈前坚 committed
764
    setEditOrgVisible(true);
陈前坚's avatar
陈前坚 committed
765
  };
陈前坚's avatar
陈前坚 committed
766 767
  // 删除机构
  const deleteOrg = () => {
陈前坚's avatar
陈前坚 committed
768
    setDeleteOrgVisible(true);
769 770 771 772 773 774 775
    console.log(orgID);
    console.log(keep1);
    if (orgID.id == keep1) {
      setTreeState(true);
    } else {
      setTreeState(false);
    }
陈前坚's avatar
陈前坚 committed
776
  };
皮倩雯's avatar
皮倩雯 committed
777
  // 编辑机构范围
mayongxin's avatar
mayongxin committed
778
  const EditOrgScope = () => {
皮倩雯's avatar
皮倩雯 committed
779 780
    setEditOrgExtentVisible(true);
  };
陈前坚's avatar
陈前坚 committed
781

陈前坚's avatar
陈前坚 committed
782
  // 在currentUser变化后获取角色列表
783 784 785 786 787
  // useEffect(() => {
  //   if (currentUser && currentUser.userID) {
  //     getRoleList();
  //   }
  // }, [currentUser]);
陈前坚's avatar
陈前坚 committed
788

陈前坚's avatar
陈前坚 committed
789
  /** ***用户批量操作****** */
陈前坚's avatar
陈前坚 committed
790
  // 关联角色
陈前坚's avatar
陈前坚 committed
791
  const relateRoles = () => {
皮倩雯's avatar
皮倩雯 committed
792
    setMult('Yes');
陈前坚's avatar
陈前坚 committed
793
    getEmptyRoleList();
794
    // getCheckList()
陈前坚's avatar
陈前坚 committed
795
    setRoleVisible(true);
陈前坚's avatar
陈前坚 committed
796
    setMultiRelateRoles(true);
陈前坚's avatar
陈前坚 committed
797 798 799 800 801 802 803 804 805 806 807 808
  };
  // 更改机构
  const changeOrgs = () => {
    setChangeOrgVisible(true);
    setMultiChangeOrgs(true);
  };
  // 删除用户
  const deleteUsers = () => {
    setDeleteUserVisible(true);
    setMultiDelete(true);
  };

陈前坚's avatar
陈前坚 committed
809
  /** ***右侧表格相关操作****** */
陈前坚's avatar
陈前坚 committed
810
  // 关联角色
陈前坚's avatar
陈前坚 committed
811
  const relateRole = record => {
812
    // getEmptyRoleList(record.userID);
皮倩雯's avatar
皮倩雯 committed
813 814 815
    setMult('No');
    console.log(record);
    getRoleList(record);
陈前坚's avatar
陈前坚 committed
816
    setRoleVisible(true);
张烨's avatar
张烨 committed
817
    setCurrentUser(record);
818
    setSelectColor(record);
陈前坚's avatar
陈前坚 committed
819
  };
陈前坚's avatar
陈前坚 committed
820
  // 更改机构
陈前坚's avatar
陈前坚 committed
821
  const changeOrg = record => {
822
    setChangeOrgVisible(true);
张烨's avatar
张烨 committed
823
    setCurrentUser(record);
824
    setSelectColor(record);
陈前坚's avatar
陈前坚 committed
825
    setCurrentSelectOldOrg(record.OUID);
陈前坚's avatar
陈前坚 committed
826
  };
陈前坚's avatar
陈前坚 committed
827
  // 修改密码
陈前坚's avatar
陈前坚 committed
828 829
  const changePassword = record => {
    setPasswordVisible(true);
张烨's avatar
张烨 committed
830
    setCurrentUser(record);
831
    setSelectColor(record);
陈前坚's avatar
陈前坚 committed
832
  };
陈前坚's avatar
陈前坚 committed
833
  // 编辑用户
陈前坚's avatar
陈前坚 committed
834 835
  const editUser = record => {
    setEditUserVisible(true);
张烨's avatar
张烨 committed
836
    setCurrentUser(record);
837
    setSelectColor(record);
陈前坚's avatar
陈前坚 committed
838
  };
陈前坚's avatar
陈前坚 committed
839
  // 冻结用户
陈前坚's avatar
陈前坚 committed
840
  const freezeUser = record => {
皮倩雯's avatar
皮倩雯 committed
841
    // setFreezeUserVisible(true);
张烨's avatar
张烨 committed
842
    setCurrentUser(record);
843
    setSelectColor(record);
皮倩雯's avatar
皮倩雯 committed
844 845 846 847 848 849 850 851 852 853 854 855
    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
856
          currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
皮倩雯's avatar
皮倩雯 committed
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871
          notification.success({
            message: '提交成功',
            duration: 2,
          });
        } else {
          notification.error({
            message: '提交失败',
            description: res.msg,
          });
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
陈前坚's avatar
陈前坚 committed
872
  };
陈前坚's avatar
陈前坚 committed
873
  // 删除用户
陈前坚's avatar
陈前坚 committed
874
  const deleteUser = record => {
皮倩雯's avatar
皮倩雯 committed
875 876
    console.log(record.userName);
    setCurrentUser(record.userName);
877
    setSelectColor(record);
皮倩雯's avatar
皮倩雯 committed
878 879 880 881 882 883 884 885 886 887 888
    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
889
          currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
皮倩雯's avatar
皮倩雯 committed
890 891 892 893 894 895 896 897 898 899 900
        } else {
          notification.error({
            message: '提交失败',
            description: res.msg,
          });
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
陈前坚's avatar
陈前坚 committed
901
  };
902

皮倩雯's avatar
皮倩雯 committed
903
  // 用户鉴权
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921
  //   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
922
      if (res.code === 0) {
923 924 925 926 927 928
        setSelctValue(res.data);
        console.log(res.data);
      }
    });
  };
  const onTypeChange = value => {
929
    setSelctValue(value.target.value);
930
  };
皮倩雯's avatar
皮倩雯 committed
931
  const authUser = record => {
mayongxin's avatar
mayongxin committed
932
    setCurrentUser(record);
皮倩雯's avatar
皮倩雯 committed
933 934
    console.log(selectValue);
    AddUserAuthSetting({
935
      userId: record.userID,
皮倩雯's avatar
皮倩雯 committed
936
      userLevel: selectValue,
937 938
    }).then(res => {
      if (res.code === 0) {
939
        message.info('提交成功');
940
      }
941
    });
皮倩雯's avatar
皮倩雯 committed
942
  };
943

陈前坚's avatar
陈前坚 committed
944 945
  // 查找用户
  const submitSearchUser = () => {
皮倩雯's avatar
皮倩雯 committed
946
    GetUserByKeyNew({ key: searchWord })
陈前坚's avatar
陈前坚 committed
947
      .then(res => {
皮倩雯's avatar
皮倩雯 committed
948
        if (res.code === 0) {
949
          setSelectedRowKeys([]); // 重置选中用户数
950
          setCurrentOrgOperate(true); // 禁止当前机构操作
951
          setMultiOperate(true); // 禁用批量操作
952
          setOrgTitle('全部机构搜索结果'); // 设置表头
953
          setCurrentSelectOrg('-1'); // 清空选中机构
皮倩雯's avatar
皮倩雯 committed
954
          console.log(res.data);
皮倩雯's avatar
皮倩雯 committed
955
          setShowSearchStyle(true);
mayongxin's avatar
mayongxin committed
956 957
          setTableData(res.data);
          setTableLength(res.data.length);
陈前坚's avatar
陈前坚 committed
958 959
        } else {
          notification.error({
皮倩雯's avatar
皮倩雯 committed
960 961 962
            message: '提示',
            duration: 3,
            description: res.msg,
陈前坚's avatar
陈前坚 committed
963 964 965 966 967 968 969
          });
        }
      })
      .catch(err => {
        message.error(err);
      });
  };
张烨's avatar
张烨 committed
970

陈前坚's avatar
陈前坚 committed
971 972
  /** ***表单提交相关操作****** */
  // 根据当前 userID 获取用户关联角色
973
  const getRoleList = e => {
974
    setLoading(true);
975
    GetUserRelationListNew({ userID: e.userID })
陈前坚's avatar
陈前坚 committed
976
      .then(res => {
皮倩雯's avatar
皮倩雯 committed
977 978
        console.log(111);

皮倩雯's avatar
皮倩雯 committed
979
        if (res.code === 0) {
mayongxin's avatar
mayongxin committed
980
          const { roleList, stationList } = res.data;
皮倩雯's avatar
皮倩雯 committed
981
          console.log(roleList);
982 983
          setRolelist(roleList);
          setStationlist(stationList);
984
          setLoading(false);
陈前坚's avatar
陈前坚 committed
985
        } else {
皮倩雯's avatar
皮倩雯 committed
986
          console.log(res);
987
          setLoading(false);
陈前坚's avatar
陈前坚 committed
988 989 990
        }
      })
      .catch(err => {
991
        setLoading(false);
陈前坚's avatar
陈前坚 committed
992 993 994 995
        setTableLoading(false);
        message.error(err);
      });
  };
陈前坚's avatar
陈前坚 committed
996 997 998
  // 获取全部未勾选的角色列表与站点列表
  const getEmptyRoleList = () => {
    setLoading(true);
皮倩雯's avatar
皮倩雯 committed
999
    GetUserRelationListNew({ userID: 0 })
陈前坚's avatar
陈前坚 committed
1000
      .then(res => {
皮倩雯's avatar
皮倩雯 committed
1001
        console.log(222);
皮倩雯's avatar
皮倩雯 committed
1002
        if (res.code === 0) {
mayongxin's avatar
mayongxin committed
1003
          const { roleList, stationList } = res.data;
陈前坚's avatar
陈前坚 committed
1004 1005
          setRolelist(roleList);
          setStationlist(stationList);
1006
          setLoading(false);
陈前坚's avatar
陈前坚 committed
1007
        } else {
皮倩雯's avatar
皮倩雯 committed
1008
          console.log(res.msg);
1009
          setLoading(false);
陈前坚's avatar
陈前坚 committed
1010 1011 1012 1013 1014 1015 1016 1017
        }
      })
      .catch(err => {
        setLoading(false);
        setTableLoading(false);
        message.error(err);
      });
  };
1018

皮倩雯's avatar
皮倩雯 committed
1019
  const getCheckList = e => {
1020
    console.log(e);
皮倩雯's avatar
皮倩雯 committed
1021 1022 1023 1024 1025 1026 1027 1028 1029
    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);
          });
1030
        }
皮倩雯's avatar
皮倩雯 committed
1031 1032 1033 1034 1035
        if (res.data.siteList !== undefined) {
          // eslint-disable-next-line array-callback-return
          Object.keys(res.data.siteList).map((item1, index1) => {
            bb.push(item1);
          });
1036
        }
皮倩雯's avatar
皮倩雯 committed
1037 1038 1039 1040
        console.log(aa);
        console.log(bb);
        setMultiRoleList(aa);
        setMultiStationList(bb);
1041
      }
皮倩雯's avatar
皮倩雯 committed
1042 1043
    });
  };
陈前坚's avatar
陈前坚 committed
1044
  // 提交-更改机构
皮倩雯's avatar
皮倩雯 committed
1045
  const submitChangeOrg = () => {
mayongxin's avatar
mayongxin committed
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
    // 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
1068 1069 1070
      userID: currentUser.userID,
      oldOUID: currentUser.OUID,
      newOUID: newOrgID,
mayongxin's avatar
mayongxin committed
1071
    })
陈前坚's avatar
陈前坚 committed
1072
      .then(res => {
陈前坚's avatar
陈前坚 committed
1073 1074 1075 1076
        if (res.code === 0) {
          setChangeOrgVisible(false);
          // 跳转到新组织机构下的用户表
          onSelect([newOrgID]);
皮倩雯's avatar
皮倩雯 committed
1077
          // setExpandedKeys([`${newOrgID}`]);
陈前坚's avatar
陈前坚 committed
1078 1079
          notification.success({
            message: '提交成功',
1080
            duration: 2,
陈前坚's avatar
陈前坚 committed
1081 1082 1083 1084
          });
        } else {
          notification.error({
            message: '提交失败',
陈前坚's avatar
陈前坚 committed
1085
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1086 1087 1088 1089 1090 1091
          });
        }
      })
      .catch(err => {
        message.error(err);
      });
皮倩雯's avatar
皮倩雯 committed
1092
  };
1093

皮倩雯's avatar
皮倩雯 committed
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104
  // 提交-批量更改机构
  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
1105 1106
          notification.success({
            message: '提交成功',
1107
            duration: 2,
陈前坚's avatar
陈前坚 committed
1108 1109 1110 1111
          });
        } else {
          notification.error({
            message: '提交失败',
mayongxin's avatar
mayongxin committed
1112
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1113 1114 1115 1116 1117 1118
          });
        }
      })
      .catch(err => {
        message.error(err);
      });
皮倩雯's avatar
皮倩雯 committed
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176

  // 提交-冻结用户
  // 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
1177
  // 提交-删除用户
陈前坚's avatar
陈前坚 committed
1178
  const submitDeleteUser = () => {
皮倩雯's avatar
皮倩雯 committed
1179 1180 1181 1182 1183 1184
    DeleteUserNew({
      userID: currentUser.userID,
      ouID: currentUser.OUID,
    })
      .then(res => {
        if (res.code === 0) {
陈前坚's avatar
陈前坚 committed
1185 1186
          notification.success({
            message: '提交成功',
1187
            duration: 2,
陈前坚's avatar
陈前坚 committed
1188
          });
1189
          // eslint-disable-next-line no-unused-expressions
1190
          currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
陈前坚's avatar
陈前坚 committed
1191 1192 1193
        } else {
          notification.error({
            message: '提交失败',
mayongxin's avatar
mayongxin committed
1194
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
          });
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
  };
  // 提交-批量删除用户
  const submitDeleteUsers = () => {
陈前坚's avatar
陈前坚 committed
1205
    multiDeleteUsers(userIDs)
陈前坚's avatar
陈前坚 committed
1206 1207 1208 1209 1210
      .then(res => {
        if (res.code === 0) {
          setDeleteUserVisible(false);
          notification.success({
            message: '提交成功',
1211
            duration: 2,
陈前坚's avatar
陈前坚 committed
1212
          });
1213
          // 重新获取用户表,查找用户时currentSelectOrg为'-1',无需跳转
1214
          // eslint-disable-next-line no-unused-expressions
1215
          currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
陈前坚's avatar
陈前坚 committed
1216
        } else {
陈前坚's avatar
陈前坚 committed
1217 1218
          notification.error({
            message: '提交失败',
陈前坚's avatar
陈前坚 committed
1219
            description: res.msg,
陈前坚's avatar
陈前坚 committed
1220 1221 1222 1223 1224 1225 1226
          });
        }
      })
      .catch(err => {
        setTableLoading(false);
        message.error(err);
      });
陈前坚's avatar
陈前坚 committed
1227
  };
1228
  // 重置默认第一个
1229
  const handleReset = () => {
1230 1231 1232 1233 1234 1235
    GetOUTreeNew({ selectOU: -1 })
      .then(newres => {
        if (newres.code === 0) {
          let res = newres.data;
          setTreeLoading(false);
          setSearchWord('');
皮倩雯's avatar
皮倩雯 committed
1236
          setFilteredValue([]);
1237
          // 第一次加载,默认选择第一个组织
1238
          onSelect([res[0].id], false);
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
        } else {
          setTreeLoading(false);
          notification.error({
            message: '获取失败',
            // eslint-disable-next-line no-undef
            description: res.message,
          });
        }
      })
      .catch(err => {
        setTreeLoading(false);
        message.error(err);
      });
1252
  };
皮倩雯's avatar
皮倩雯 committed
1253
  const onChangeInput = filters => {
1254
    setFilteredValue(filters.OUName);
皮倩雯's avatar
皮倩雯 committed
1255
  };
1256

皮倩雯's avatar
皮倩雯 committed
1257
  // 更改机构范围
1258
  const submitExtent = (extent, areaName, flags) => {
皮倩雯's avatar
皮倩雯 committed
1259 1260 1261
    setTreeLoading(true);
    console.log(extent);
    console.log(areaName);
1262
    console.log(flags);
皮倩雯's avatar
皮倩雯 committed
1263
    console.log(currentSelectOrg1);
1264
    if (flags === 0) {
1265 1266 1267 1268
      setTreeLoading(false);
      notification.warn({
        message: '提交失败',
        description: '请框选范围',
皮倩雯's avatar
皮倩雯 committed
1269
      });
皮倩雯's avatar
皮倩雯 committed
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
    } 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
1287
    }
皮倩雯's avatar
皮倩雯 committed
1288
  };
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305
  // 返回拖拽完毕后的信息
  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('-');
1306
    const dropPosition = infos.dropPosition - Number(dropPos[dropPos.length - 1]);
陈前坚's avatar
陈前坚 committed
1307

1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360
    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
1361 1362 1363
  const addChange = e => {
    e.domEvent.stopPropagation();
  };
1364

陈前坚's avatar
陈前坚 committed
1365 1366 1367
  /** ***操作按钮**** */
  // 机构操作
  const orgButtonMenu = (
皮倩雯's avatar
皮倩雯 committed
1368
    <Menu onClick={e => addChange(e)}>
1369
      <Menu.Item key="1" onClick={addUser} icon={<UserAddOutlined style={{ marginTop: '5px' }} />}>
陈前坚's avatar
陈前坚 committed
1370 1371
        添加用户
      </Menu.Item>
1372 1373 1374 1375
    </Menu>
  );
  const orgButtonMenu1 = (
    <Menu onClick={e => addChange(e)}>
1376 1377 1378 1379 1380
      <Menu.Item
        key="2"
        onClick={addSubOrg}
        icon={<ClusterOutlined style={{ marginTop: '5px' }} />}
      >
陈前坚's avatar
陈前坚 committed
1381
        添加下级机构
陈前坚's avatar
陈前坚 committed
1382
      </Menu.Item>
1383
      <Menu.Item key="3" onClick={editOrg} icon={<EditOutlined style={{ marginTop: '5px' }} />}>
陈前坚's avatar
陈前坚 committed
1384
        编辑当前机构
陈前坚's avatar
陈前坚 committed
1385
      </Menu.Item>
1386
      <Menu.Item key="4" onClick={deleteOrg} icon={<DeleteOutlined style={{ marginTop: '5px' }} />}>
陈前坚's avatar
陈前坚 committed
1387
        删除当前机构
陈前坚's avatar
陈前坚 committed
1388
      </Menu.Item>
1389
      {/* <Menu.Item
1390 1391 1392 1393
        key="5"
        onClick={EditOrgScope}
        icon={<BorderlessTableOutlined style={{ marginTop: '5px' }} />}
      >
mayongxin's avatar
mayongxin committed
1394
        编辑机构范围
1395
      </Menu.Item> */}
陈前坚's avatar
陈前坚 committed
1396 1397 1398 1399 1400
    </Menu>
  );
  // 用户批量操作
  const userButtonMenu = (
    <Menu>
1401
      <Menu.Item key="1" onClick={relateRoles} icon={<IdcardOutlined />}>
陈前坚's avatar
陈前坚 committed
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412
        批量关联角色
      </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
1413 1414 1415
  const kee = () => {
    setUserVisible(false);
  };
1416
  console.log(userContainer.current?.clientHeight, 'userContainer.current.clientHeight');
陈前坚's avatar
陈前坚 committed
1417
  return (
1418 1419
    <PageContainer className={styles.userManageContainer}>
      <div className={styles.contentContainer}>
陈前坚's avatar
陈前坚 committed
1420
        {/* 左侧机构树 */}
陈前坚's avatar
陈前坚 committed
1421
        <Spin spinning={treeLoading} tip="loading...">
陈前坚's avatar
陈前坚 committed
1422
          <Card
1423
            style={{ overflowY: 'hidden', height: '100%' }}
陈前坚's avatar
陈前坚 committed
1424 1425 1426 1427 1428
            className={classnames({
              [styles.orgContainer]: true,
              [styles.orgContainerHide]: !treeVisible,
            })}
          >
1429 1430 1431
            <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
              <div style={{ display: 'flex' }}>
                <span
陈前坚's avatar
陈前坚 committed
1432
                  style={{
1433 1434 1435
                    fontSize: '15px ',
                    fontWeight: 'bold',
                    marginLeft: '15px',
陈前坚's avatar
陈前坚 committed
1436
                  }}
1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451
                >
                  机构列表
                </span>
                <Tooltip title="添加顶级机构">
                  <PlusSquareFilled
                    onClick={() => addOrg()}
                    style={{
                      color: '#1890FF',
                      fontSize: '25px',
                      verticalAlign: 'middle',
                      marginLeft: '64%',
                    }}
                  />
                </Tooltip>
              </div>
1452
              <hr style={{ width: '95%', color: '#eeecec', marginLeft: '15px' }} />
陈前坚's avatar
陈前坚 committed
1453
              {treeData.length > 0 && (
1454
                <div style={{ height: '100%', overflowY: 'scroll' }}>
1455 1456 1457 1458 1459 1460 1461 1462
                  <Tree
                    showIcon="true"
                    blockNode
                    autoExpandParent
                    onSelect={onSelect}
                    treeData={treeData.map(t => mapTree(t))}
                    draggable
                    onDrop={handleDrop}
1463
                    selectedKeys={[menuID]}
皮倩雯's avatar
皮倩雯 committed
1464
                    keepTree={keepTree}
1465
                    expandedKeys={expendKey}
1466 1467
                  />
                </div>
陈前坚's avatar
陈前坚 committed
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481
              )}
            </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
1482
          </Card>
陈前坚's avatar
陈前坚 committed
1483
        </Spin>
1484

陈前坚's avatar
陈前坚 committed
1485
        {/* 右侧用户表 */}
陈前坚's avatar
陈前坚 committed
1486
        <div
1487
          ref={userContainer}
陈前坚's avatar
陈前坚 committed
1488
          className={classnames({
1489
            [styles.userContainer]: true,
陈前坚's avatar
陈前坚 committed
1490 1491
          })}
        >
陈前坚's avatar
陈前坚 committed
1492
          <div style={{ height: '50px' }}>
1493
            <span
1494
              className={styles.title}
1495
              title={`${orgTitle}(已选${selectedRowKeys.length}/共${tableLength}人)`}
1496 1497
            >
              {orgTitle}(已选{selectedRowKeys.length}/共{tableLength}人)
1498
            </span>
陈前坚's avatar
陈前坚 committed
1499
            <span style={{ float: 'right', margin: '10px' }}>
陈前坚's avatar
陈前坚 committed
1500
              <Search
1501 1502
                style={{ width: 260 }}
                placeholder="搜索登录名/用户姓名/手机号"
陈前坚's avatar
陈前坚 committed
1503 1504 1505 1506 1507
                onSearch={submitSearchUser}
                onChange={e => handleSearch(e)}
                enterButton
                value={searchWord}
              />
皮倩雯's avatar
皮倩雯 committed
1508

1509 1510 1511
              <Button icon={<SyncOutlined />} onClick={handleReset}>
                重置
              </Button>
皮倩雯's avatar
皮倩雯 committed
1512

陈前坚's avatar
陈前坚 committed
1513 1514 1515 1516 1517
              <Dropdown overlay={userButtonMenu} disabled={multiOperate}>
                <Button type={multiOperateButtonType}>
                  用户批量操作 <DownOutlined />
                </Button>
              </Dropdown>
陈前坚's avatar
陈前坚 committed
1518 1519
            </span>
          </div>
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549
          {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}
            />
          )}
1550
        </div>
1551

陈前坚's avatar
陈前坚 committed
1552
        {/* Modal弹框 */}
1553
        {/* 添加用户 */}
陈前坚's avatar
陈前坚 committed
1554 1555 1556
        <AddUserModal
          visible={userVisible}
          orgID={orgID}
1557
          orgTitle1={orgTitle1}
皮倩雯's avatar
皮倩雯 committed
1558
          onCancel={kee}
1559 1560
          updateTrees1={updateTrees1}
          onSelect={onSelect}
陈前坚's avatar
陈前坚 committed
1561
        />
1562
        {/* 添加下级机构 */}
1563
        <AddSubOrgModal
1564
          visible={addOrgVisible}
1565
          orgTitle1={orgTitle1}
1566
          orgID={orgID}
1567
          onCancel={() => setAddOrgVisible(false)}
1568 1569
          onSelect={onSelect}
          updateTrees1={updateTrees1}
1570
        />
1571
        {/* 编辑机构 */}
1572
        <EditOrgModal
1573
          visible={editOrgVisible}
1574
          orgID={orgID}
1575
          orgTitle1={orgTitle1}
1576
          description={description}
1577
          onCancel={() => setEditOrgVisible(false)}
1578 1579 1580 1581
          updateTrees={updateTrees}
        />
        {/* 删除机构 */}
        <DeleteOrgModal
皮倩雯's avatar
皮倩雯 committed
1582
          title="删除机构"
1583
          visible={deleteOrgVisible}
1584
          orgTitle={orgTitle1}
1585 1586
          orgID={orgID}
          updateTrees={updateTrees}
1587
          onCancel={() => setDeleteOrgVisible(false)}
1588
        />
陈前坚's avatar
陈前坚 committed
1589
        {/* 关联角色 */}
1590 1591 1592 1593
        <RelateRoleModal
          currentUser={currentUser}
          userIDs={userIDs}
          currentSelectOrg={currentSelectOrg}
陈前坚's avatar
陈前坚 committed
1594
          visible={roleVisible}
1595
          rolelist={rolelist}
1596 1597 1598
          multiRoleList={multiRoleList}
          multistationList={multistationList}
          mult={mult}
1599 1600 1601 1602
          loading={loading}
          stationlist={stationlist}
          multiRelateRoles={multiRelateRoles}
          onSelect={onSelect}
陈前坚's avatar
陈前坚 committed
1603 1604 1605 1606
          onCancel={() => {
            setRoleVisible(false);
            setMultiRelateRoles(false);
          }}
1607
        />
陈前坚's avatar
陈前坚 committed
1608
        {/* 更改机构 */}
1609 1610 1611
        <Modal
          title="更改机构"
          visible={changeOrgVisible}
陈前坚's avatar
陈前坚 committed
1612
          onOk={multiChangeOrgs ? submitChangeOrgs : submitChangeOrg}
1613
          maskClosable={false}
陈前坚's avatar
陈前坚 committed
1614 1615 1616 1617
          onCancel={() => {
            setChangeOrgVisible(false);
            setMultiChangeOrgs(false);
          }}
1618 1619
          okText="确认"
          cancelText="取消"
1620
          width="500px"
1621
        >
张烨's avatar
张烨 committed
1622
          <span>请选择要更改的目标机构:</span>
陈前坚's avatar
陈前坚 committed
1623
          {changeOrgVisible && treeDataCopy.length > 0 && (
陈前坚's avatar
陈前坚 committed
1624 1625
            <Tree
              showIcon="true"
陈前坚's avatar
陈前坚 committed
1626
              showLine={{ showLeafIcon: false }}
1627
              // defaultExpandAll
陈前坚's avatar
陈前坚 committed
1628 1629 1630 1631 1632 1633
              // 未切换时原先的节点,注意要转字符串
              selectedKeys={[`${currentSelectOldOrg}`]}
              onSelect={value => {
                setNewOrgID(value[0]);
                // 切换后选中的节点
                setCurrentSelectOldOrg(value[0]);
陈前坚's avatar
陈前坚 committed
1634
              }}
皮倩雯's avatar
皮倩雯 committed
1635
              treeData={treeDataCopy.map(t => mapTree1(t))}
陈前坚's avatar
陈前坚 committed
1636 1637
            />
          )}
1638
        </Modal>
陈前坚's avatar
陈前坚 committed
1639
        {/* 修改密码 */}
1640
        <ChangePasswordModal
陈前坚's avatar
陈前坚 committed
1641
          visible={passwordVisible}
1642
          currentUser={currentUser}
1643 1644
          submitSearchUser={submitSearchUser}
          currentSelectOrg={currentSelectOrg}
1645
          onSelect={onSelect}
陈前坚's avatar
陈前坚 committed
1646
          onCancel={() => setPasswordVisible(false)}
1647
        />
陈前坚's avatar
陈前坚 committed
1648
        {/* 编辑用户 */}
1649
        <EditUserModal
陈前坚's avatar
陈前坚 committed
1650
          visible={editUserVisible}
1651
          currentUser={currentUser}
1652 1653
          submitSearchUser={submitSearchUser}
          currentSelectOrg={currentSelectOrg}
1654
          onSelect={onSelect}
陈前坚's avatar
陈前坚 committed
1655
          onCancel={() => setEditUserVisible(false)}
1656
        />
陈前坚's avatar
陈前坚 committed
1657
        {/* 冻结用户 */}
皮倩雯's avatar
皮倩雯 committed
1658
        {/* <Modal
1659
          title="请确认"
陈前坚's avatar
陈前坚 committed
1660 1661 1662 1663 1664 1665
          visible={freezeUserVisible}
          onOk={submitFreezeUser}
          onCancel={() => setFreezeUserVisible(false)}
          okText="确认"
          cancelText="取消"
        >
张烨's avatar
张烨 committed
1666 1667
          <p>
            即将{+currentUser.state ? '激活' : '冻结'}用户{' '}
1668 1669 1670
            <span className={styles.redText}>
              {voca.stripTags(currentUser.loginName)}
            </span>
张烨's avatar
张烨 committed
1671 1672 1673
            ,是否确认
            {+currentUser.state ? '激活' : '冻结'}?
          </p>
皮倩雯's avatar
皮倩雯 committed
1674
        </Modal> */}
1675
        {/* 多选删除用户 */}
1676 1677 1678
        <Modal
          title="确认删除用户"
          visible={deleteUserVisible}
陈前坚's avatar
陈前坚 committed
1679
          onOk={multiDelete ? submitDeleteUsers : submitDeleteUser}
1680
          maskClosable={false}
陈前坚's avatar
陈前坚 committed
1681 1682 1683 1684
          onCancel={() => {
            setDeleteUserVisible(false);
            setMultiDelete(false);
          }}
1685 1686 1687
          okText="确认"
          cancelText="取消"
        >
1688
          <p>将删除多个用户, 是否确认删除?</p>
1689
        </Modal>
mayongxin's avatar
mayongxin committed
1690
        <MapScopeEditModal
皮倩雯's avatar
皮倩雯 committed
1691
          title={id}
mayongxin's avatar
mayongxin committed
1692
          mapId={createGuid()}
mayongxin's avatar
mayongxin committed
1693
          visible={editOrgExtentVisible}
皮倩雯's avatar
皮倩雯 committed
1694
          stationId={currentSelectOrg1}
mayongxin's avatar
mayongxin committed
1695 1696 1697 1698 1699
          onCancel={() => setEditOrgExtentVisible(false)}
          confirmModal={submitExtent}
          distinct={currentOrgDistinct}
          extent={currentOrgArea}
        />
1700
        {/* <AuthModal
皮倩雯's avatar
皮倩雯 committed
1701 1702 1703
          visible={authUserVisible}
          currentUser={currentUser}
          onCancel={() => setAuthUserVisible(false)}
1704
        /> */}
陈前坚's avatar
陈前坚 committed
1705 1706
      </div>
    </PageContainer>
1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748
    // <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
1749 1750 1751 1752
  );
};

export default UserManage;