webMenu.jsx 21.7 KB
Newer Older
1
/* eslint-disable no-debugger */
皮倩雯's avatar
皮倩雯 committed
2 3 4
/* eslint-disable array-callback-return */
/* eslint-disable no-plusplus */
/* eslint-disable consistent-return */
5
import React, { useEffect, useState, useRef } from 'react';
张烨's avatar
张烨 committed
6 7
import { notification, Tooltip, Modal, Spin, Empty } from 'antd';
import Tree from '@/components/ExpendableTree';
张烨's avatar
张烨 committed
8 9 10 11 12 13
import {
  FileAddTwoTone,
  FolderAddTwoTone,
  FolderFilled,
  FileOutlined,
  DeleteTwoTone,
14
  DeliveredProcedureOutlined,
张烨's avatar
张烨 committed
15 16
} from '@ant-design/icons';
import classnames from 'classnames';
张烨's avatar
张烨 committed
17
import styles from './webMenu.less';
张烨's avatar
张烨 committed
18 19 20
import AddForm from './AddForm';
import EditForm from './editForm';
import CheckList from './checkBox';
21
import ImportOrExport from './ImportOrExport';
张烨's avatar
张烨 committed
22 23 24 25 26
import {
  addWebMenu, // 增
  deleteWebMenu, // 删
  editWebMenu, // 改
  getWebMenuInfo, // 查
Maofei94's avatar
Maofei94 committed
27
  dragMenu, // 菜单拖拽
Maofei94's avatar
Maofei94 committed
28
  getWebModuleTree,
Maofei94's avatar
Maofei94 committed
29
  pEditWebMenu,
张烨's avatar
张烨 committed
30
} from '@/services/webConfig/api';
张烨's avatar
张烨 committed
31 32

const MiniMenu = props => {
33 34 35 36 37 38 39 40 41 42
  const {
    menu,
    configFiles,
    subSystemValue,
    updateMenuTree,
    userMode,
    webid,
    productList,
    allProductList,
  } = props;
张烨's avatar
张烨 committed
43 44 45 46 47
  const [flag, setFlag] = useState(1); // 刷新标志
  const [loading, setLoading] = useState(false); // 加载
  const [menuID, setMenuID] = useState(''); // 选中的树ID
  const [nodeType, setNodeType] = useState(''); // 选中的节点类型
  const [info, setInfo] = useState({});
48
  const [infoAll, setInfoAll] = useState({});
49
  const [importOrExportVisible, setImportOrExportVisible] = useState(false); // 导入导出弹窗
张烨's avatar
张烨 committed
50 51 52 53 54 55 56 57 58
  const [addVisible, setAddVisible] = useState(false); // 新增弹窗
  const [addTwoVisible, setAddTwoVisible] = useState(false); // 编辑弹窗
  const [delVisible, setDelVisible] = useState(false); // 删除弹窗
  const [nodeObj, setNodeObj] = useState({});
  const [addType, setAddType] = useState(''); // 添加下级类型
  const [modalTitle, setModalTitle] = useState('');
  const [roleList, setRoleList] = useState([]); // 复选框选中的值
  const [modalLoading, setModalLoading] = useState(false);
  const [submitLoading, setSubmitLoading] = useState(false);
Maofei94's avatar
Maofei94 committed
59
  const [newTreeList, setNewTreeList] = useState([]);
60 61
  const [checkList, setCheckList] = useState([]);
  const [flagg, setFlagg] = useState(0);
62
  const [expendKey, setExpendKey] = useState(''); // 保存默认展开项
Maofei94's avatar
Maofei94 committed
63
  const [menuList, setMenuList] = useState([]); // 菜单树
64
  const [keepId, setKeepId] = useState('');
65
  const [mapDataList, setMapDataList] = useState(new Set());
张烨's avatar
张烨 committed
66 67 68

  /* *****************************************************  */
  const [curMenuType, setCurMenuType] = useState('');
69
  const parentRef = useRef();
张烨's avatar
张烨 committed
70 71 72

  // 获取菜单信息
  useEffect(() => {
73 74 75 76
    console.log(menuID, flag);
    if (flag === 1) {
      setExpendKey(menuID);
    }
77
    console.log(expendKey);
张烨's avatar
张烨 committed
78
    getInfo();
Maofei94's avatar
Maofei94 committed
79
  }, [menuID, webid]);
80 81 82
  // useEffect(() => {
  //   getTree();
  // }, []);
Maofei94's avatar
Maofei94 committed
83
  useEffect(() => {
84
    getTree();
Maofei94's avatar
Maofei94 committed
85 86 87
    return () => {
      setLoading(false);
    };
88
  }, [webid]);
Maofei94's avatar
Maofei94 committed
89

张烨's avatar
张烨 committed
90 91 92 93 94 95 96
  // 处理数据
  const mapTree = val => {
    const obj = { ...val };
    const hasChild = obj.children.length > 0;
    return {
      title: (
        <div className={styles.title}>
97
          <div className={styles.titleText}>{obj.text}</div>
张烨's avatar
张烨 committed
98
          <div className={styles.tip}>
99 100 101 102 103 104 105 106
            {obj.menuType === 'Web4MenuGroup' && (
              <Tooltip title="导入导出菜单组" className={styles.fs}>
                <DeliveredProcedureOutlined
                  style={{ color: '#178BF7' }}
                  onClick={e => importAndExport(obj, e)}
                />
              </Tooltip>
            )}
张烨's avatar
张烨 committed
107
            {obj.menuType === 'Web4MenuGroup' && (
张烨's avatar
张烨 committed
108
              <Tooltip title="新增菜单组" className={styles.fs}>
张烨's avatar
张烨 committed
109
                <FolderAddTwoTone onClick={e => addMenuGroupTip(obj, e)} />
张烨's avatar
张烨 committed
110 111
              </Tooltip>
            )}
张烨's avatar
张烨 committed
112
            {obj.menuType === 'Web4MenuGroup' && (
张烨's avatar
张烨 committed
113
              <Tooltip title="新增功能菜单" className={styles.fs}>
张烨's avatar
张烨 committed
114
                <FileAddTwoTone onClick={e => addMenuTip(obj, e)} />
张烨's avatar
张烨 committed
115 116 117 118
              </Tooltip>
            )}

            <Tooltip title="删除菜单" className={styles.fs}>
张烨's avatar
张烨 committed
119
              <DeleteTwoTone onClick={e => deleteMenuTip(obj, e)} />
张烨's avatar
张烨 committed
120 121 122 123 124
            </Tooltip>
          </div>
        </div>
      ),
      key: obj.menuID,
125
      icon: obj.menuType === 'Web4MenuGroup' ? <FolderFilled /> : <FileOutlined />,
张烨's avatar
张烨 committed
126 127 128 129
      menuType: obj.menuType,
      children: hasChild ? obj.children.map(i => mapTree(i)) : [],
    };
  };
130 131 132 133 134 135 136 137
  const mapData = (val, e) => {
    const obj = { ...val };
    const hasChild = obj.children.length > 0;
    if (hasChild) {
      obj.children.map(i => mapData(i));
    }
    mapDataList.add(obj);
  };
张烨's avatar
张烨 committed
138 139
  // 树的点击事件
  const handleSelect = (prop, treeNode) => {
140 141
    console.log(prop);
    console.log(treeNode);
张烨's avatar
张烨 committed
142 143 144 145
    if (treeNode) {
      const {
        node: { menuType },
      } = treeNode;
146
      console.log(menuType);
张烨's avatar
张烨 committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
      switch (menuType) {
        case 'Web4MenuGroup':
          setNodeType(2);
          setAddType(2);
          break;
        default:
          setNodeType(1);
          setAddType(1);
          break;
      }
    }
    if (prop[0]) {
      setMenuID(prop[0]);
    }
  };

  const getInfo = id => {
    if (!menuID) {
      return;
    }
    setLoading(true);
张烨's avatar
张烨 committed
168
    getWebMenuInfo({
张烨's avatar
张烨 committed
169 170 171 172 173
      menuID,
      _dc: Date.now(),
    })
      .then(res => {
        setLoading(false);
174
        if (res.code === 0) {
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
          let infoList = res.data.relatedRoleList.map(item => ({
            groupName: item.groupName,
            isChecked: item.isChecked,
            list: item.list,
            checkedList: new Set([]),
          }));
          setInfo(infoList);
          setInfoAll({ ...res.data });
          let data = new Set();
          infoList.map(item => {
            if (item.isChecked == true) {
              data.add(item.groupName);
            }
            item.list.map(i => {
              if (i.related) {
                item.checkedList.add(i.relatedRoleCode);
              }
            });
          });
          setCheckList(data);
张烨's avatar
张烨 committed
195 196 197 198
        } else {
          notification.error({
            message: '提示',
            duration: 10,
199
            description: res.msg || '获取失败',
张烨's avatar
张烨 committed
200 201 202 203 204 205 206 207 208
          });
        }
      })
      .catch(err => {
        setLoading(false);
        console.error(err);
      });
  };
  // 删除的回调
张烨's avatar
张烨 committed
209 210
  const deleteMenuTip = (val, e) => {
    e.stopPropagation();
211
    console.log(val);
212
    console.log(e);
张烨's avatar
张烨 committed
213 214 215 216 217 218
    setModalTitle(val.text);
    setNodeObj(val);
    setDelVisible(true);
  };
  const delMenu = () => {
    setModalLoading(true);
张烨's avatar
张烨 committed
219
    deleteWebMenu({
张烨's avatar
张烨 committed
220 221 222 223 224
      menuID: nodeObj.menuID,
      _dc: Date.now(),
    })
      .then(res => {
        setModalLoading(false);
225
        if (res.code === 0) {
张烨's avatar
张烨 committed
226
          setDelVisible(false);
227
          // setFlag(flag + 1);
228 229 230 231 232 233 234 235
          if (nodeObj.menuID == menuID) {
            getTree();
            setMenuID(keepId.menuID);
            setNodeType(2);
            setNodeObj(keepId);
          } else {
            getTree();
          }
Maofei94's avatar
Maofei94 committed
236
          // updateMenuTree('delete', nodeObj);
张烨's avatar
张烨 committed
237 238 239 240 241 242 243 244 245
          notification.success({
            message: '提示',
            duration: 3,
            description: '删除成功',
          });
        } else {
          notification.error({
            message: '提示',
            duration: 10,
246
            description: res.msg || '删除失败',
张烨's avatar
张烨 committed
247 248 249 250 251
          });
        }
      })
      .catch(err => {
        setModalLoading(false);
张烨's avatar
张烨 committed
252
        console.error(err);
张烨's avatar
张烨 committed
253 254
      });
  };
255 256 257 258 259 260
  // 导入导出菜单组
  const importAndExport = (val, e) => {
    e.stopPropagation();
    setNodeObj(val);
    setImportOrExportVisible(true);
  };
张烨's avatar
张烨 committed
261
  // 新增菜单组
张烨's avatar
张烨 committed
262 263
  const addMenuGroupTip = (val, e) => {
    e.stopPropagation();
Maofei94's avatar
Maofei94 committed
264
    setModalTitle(`在${val.text}下新增菜单组`);
张烨's avatar
张烨 committed
265
    setNodeObj(val);
张烨's avatar
张烨 committed
266
    setAddType(2);
张烨's avatar
张烨 committed
267 268 269 270
    setAddVisible(true);
  };
  const rootAddGroup = () => {
    setNodeObj('');
Maofei94's avatar
Maofei94 committed
271
    setModalTitle('新增最上级菜单组');
张烨's avatar
张烨 committed
272
    setAddType(2);
张烨's avatar
张烨 committed
273 274 275
    setAddVisible(true);
  };
  // 新增功能菜单
张烨's avatar
张烨 committed
276 277
  const addMenuTip = (val, e) => {
    e.stopPropagation();
张烨's avatar
张烨 committed
278
    setNodeObj(val);
Maofei94's avatar
Maofei94 committed
279
    setModalTitle(`在${val.text}下新增功能菜单`);
张烨's avatar
张烨 committed
280
    setAddType(1);
张烨's avatar
张烨 committed
281 282 283
    setAddTwoVisible(true);
  };
  const rootAdd = () => {
Maofei94's avatar
Maofei94 committed
284
    setModalTitle('新增最上级功能菜单');
张烨's avatar
张烨 committed
285
    setNodeObj('');
张烨's avatar
张烨 committed
286
    setAddType(1);
张烨's avatar
张烨 committed
287 288
    setAddTwoVisible(true);
  };
Maofei94's avatar
Maofei94 committed
289 290 291 292 293 294
  const handleGeturl = val => {
    let url;
    const isSite = val.includes('CityTemp');
    if (isSite) {
      url = val;
    } else {
295
      url = localStorage.getItem('pd2-baseUrl') ? localStorage.getItem('pd2-baseUrl') + val : val;
Maofei94's avatar
Maofei94 committed
296 297 298
    }
    return url;
  };
299 300
  // 导入或导出弹窗回调
  const onFinishCallBack = () => {};
张烨's avatar
张烨 committed
301 302
  // 新增提交的回调
  const submitCallback = (prop, item) => {
303
    console.log(subSystemValue, 'subSystemValue');
张烨's avatar
张烨 committed
304
    setSubmitLoading(true);
Maofei94's avatar
Maofei94 committed
305 306
    let baseUrl = handleGeturl(prop.imageUrl);
    let obj = { ...prop, baseUrl };
307
    const parentID = item.menuID ? Number(item.menuID) : -1;
张烨's avatar
张烨 committed
308
    addWebMenu({
张烨's avatar
张烨 committed
309 310
      _dc: Date.now(),
      parentID,
张烨's avatar
张烨 committed
311
      subSystemValue,
张烨's avatar
张烨 committed
312 313 314 315
      ...obj,
    })
      .then(res => {
        setSubmitLoading(false);
316
        if (res.code === 0) {
317
          console.log(res.data);
张烨's avatar
张烨 committed
318 319
          setAddVisible(false);
          setAddTwoVisible(false);
320
          // setFlag(flag + 1);
321 322
          console.log(prop);
          getTree(res.data);
Maofei94's avatar
Maofei94 committed
323
          // updateMenuTree('add', item);
张烨's avatar
张烨 committed
324 325 326 327 328 329 330 331
          notification.success({
            message: '提示',
            description: '新增成功',
            duration: 3,
          });
        } else {
          notification.error({
            message: '提示',
332
            description: res.msg || '新增失败',
张烨's avatar
张烨 committed
333 334 335 336 337 338 339 340 341
            duration: 10,
          });
        }
      })
      .catch(err => {
        setSubmitLoading(false);
        console.error(err);
      });
  };
342 343 344 345
  const treeCallback = value => {
    if (value) {
      console.log(value);
    }
346
  };
张烨's avatar
张烨 committed
347 348 349
  // 编辑的回调
  const editSubmitCallback = prop => {
    setLoading(true);
Maofei94's avatar
Maofei94 committed
350 351
    let baseUrl = handleGeturl(prop.imageUrl);
    let obj = { ...prop, baseUrl };
352
    console.log(obj);
张烨's avatar
张烨 committed
353
    if (nodeType === 1) {
354
      // obj.relatedRoleList = roleList || '';
Maofei94's avatar
Maofei94 committed
355 356
      editWebMenu({
        _dc: Date.now(),
357
        menuID: Number(menuID),
Maofei94's avatar
Maofei94 committed
358 359 360 361 362
        // subSystemValue,
        ...obj,
      })
        .then(res => {
          setLoading(false);
363
          if (res.code === 0) {
364 365
            // setFlag(flag + 1);
            getTree();
Maofei94's avatar
Maofei94 committed
366 367 368 369 370 371 372 373 374 375
            // updateMenuTree('edit');
            notification.success({
              message: '提示',
              duration: 3,
              description: '编辑成功',
            });
          } else {
            notification.error({
              message: '提示',
              duration: 3,
皮倩雯's avatar
皮倩雯 committed
376
              description: res.msg || '编辑失败',
Maofei94's avatar
Maofei94 committed
377 378 379 380 381 382 383 384 385
            });
          }
        })
        .catch(err => {
          // eslint-disable-next-line no-console
          console.error(err);
          setLoading(false);
        });
    } else {
386 387
      // 新接口改为editWebMenu 原来为pEditWebMenu
      editWebMenu({
Maofei94's avatar
Maofei94 committed
388
        _dc: Date.now(),
389
        menuID: Number(menuID),
Maofei94's avatar
Maofei94 committed
390 391
        // subSystemValue,
        ...obj,
392 393
        product: null,
        baseUrl: null,
394
        hideInMenu: false,
张烨's avatar
张烨 committed
395
      })
Maofei94's avatar
Maofei94 committed
396 397
        .then(res => {
          setLoading(false);
398
          if (res.code === 0) {
399 400
            // setFlag(flag + 1);
            getTree();
Maofei94's avatar
Maofei94 committed
401 402 403 404 405 406 407 408 409 410
            // updateMenuTree('edit');
            notification.success({
              message: '提示',
              duration: 3,
              description: '编辑成功',
            });
          } else {
            notification.error({
              message: '提示',
              duration: 3,
411
              description: res.msg || '编辑失败',
Maofei94's avatar
Maofei94 committed
412 413 414 415 416 417 418 419 420
            });
          }
        })
        .catch(err => {
          // eslint-disable-next-line no-console
          console.error(err);
          setLoading(false);
        });
    }
张烨's avatar
张烨 committed
421 422
  };
  const valueCallback = val => {
423 424 425 426 427 428 429 430 431
    console.log(val);
    // let arr = [...val];
    // let arr2 = [];
    // arr.map(item => {
    //   if (item.related) {
    //     arr2.push(item.relatedRoleCode);
    //   }
    // });
    setRoleList(val.toString());
张烨's avatar
张烨 committed
432
  };
433 434 435 436 437 438 439 440 441 442 443
  // 返回拖拽完毕后的信息
  const loop = (data, key, parentID, callback) => {
    for (let i = 0; i < data.length; i++) {
      if (data[i].menuID === key) {
        return callback(data[i], i, data, parentID);
      }
      if (data[i].children) {
        loop(data[i].children, key, data[i].menuID, callback);
      }
    }
  };
444
  const getTree = e => {
445 446 447 448 449 450 451 452 453
    getWebModuleTree(userMode || 'super')
      .then(res => {
        setLoading(false);
        const { code, data } = res;
        if (code === 0) {
          let arr = data
            .filter(item => item.id === 'Web4SingleStation')
            .map(r => r.children.filter(i => i.id === webid))
            .flat(2);
454
          let arr2 = arr[0].children.find(item => item.text === '菜单管理').children || [];
455
          setMenuList(arr2 || []);
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
          if (e) {
            arr2.map(item => mapData(item, e));
            console.log([...mapDataList]);
            let aa = [...mapDataList].find(i => i.menuID == e);
            console.log(aa);
            setMenuID(aa.menuID);
            setExpendKey(aa.menuID);
            console.log(expendKey);
            switch (aa.menuType) {
              case 'Web4MenuGroup':
                setNodeType(2);
                setAddType(2);
                break;
              default:
                setNodeType(1);
                setAddType(1);
                break;
            }
          }
          setKeepId(arr2[0]);

477 478
          // 进页面后默认展示第一条数据
          if (arr2.length > 0) {
邓超's avatar
邓超 committed
479 480 481 482 483 484 485 486 487 488 489 490 491
            if (flag === 1) {
              setMenuID(arr2[0].menuID);
              switch (arr2[0].menuType) {
                case 'Web4MenuGroup':
                  setNodeType(2);
                  setAddType(2);
                  break;
                default:
                  setNodeType(1);
                  setAddType(1);
                  break;
              }
            }
492 493 494

            setFlag(flag + 1);
          }
495 496 497 498 499 500
        }
      })
      .catch(err => {
        setLoading(false);
      });
  };
Maofei94's avatar
Maofei94 committed
501 502
  // 树的拖动
  const handleDrop = infos => {
503 504 505
    const dropKey = infos.node.key;
    const dragKey = infos.dragNode.key;
    const dropPos = infos.node.pos.split('-');
506
    const dropPosition = infos.dropPosition - Number(dropPos[dropPos.length - 1]);
507

508 509 510 511 512 513 514 515
    const data = [...menuList];
    // 找到拖拽的元素
    let dragObj;
    let dropObj;
    let id;
    let dragList;
    loop(data, dropKey, -1, item => {
      dropObj = item;
Maofei94's avatar
Maofei94 committed
516
    });
517
    loop(data, dragKey, -1, (item, index, arr) => {
518
      if (infos.dropToGap || dropObj.menuType !== 'Web4Menu') {
519 520
        arr.splice(index, 1);
        dragObj = item;
Maofei94's avatar
Maofei94 committed
521 522
      }
    });
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
    if (!infos.dropToGap) {
      // Drop on the content
      loop(data, dropKey, -1, item => {
        item.children = item.children || [];
        if (item.menuType !== 'Web4Menu') {
          // where to insert 示例添加到头部,可以是随意位置
          item.children.unshift(dragObj);
          id = item.menuID;
          dragList = item.children.map(val => val.menuID);
        }
      });
    } else if (
      (infos.node.props.children || []).length > 0 && // Has children
      infos.node.props.expanded && // Is expanded
      dropPosition === 1 // On the bottom gap
    ) {
      loop(data, dropKey, -1, item => {
        item.children = item.children || [];
        // where to insert 示例添加到头部,可以是随意位置
        item.children.unshift(dragObj);
        id = item.menuID;
        dragList = item.children.map(val => val.menuID);
      });
    } else {
      let ar;
      let i;
      loop(data, dropKey, -1, (item, index, arr, parentID) => {
        ar = arr;
        i = index;
        id = parentID;
      });
Maofei94's avatar
Maofei94 committed
554
      if (dropPosition === -1) {
555 556 557
        ar.splice(i, 0, dragObj);
      } else {
        ar.splice(i + 1, 0, dragObj);
Maofei94's avatar
Maofei94 committed
558
      }
559 560 561 562 563
      dragList = ar.map(val => val.menuID);
    }
    // 如果拖拽到菜单下不做任何处理
    if (!dragList) {
      return;
Maofei94's avatar
Maofei94 committed
564
    }
565
    console.log(dragList, 'dragList');
Maofei94's avatar
Maofei94 committed
566
    dragMenu({
567 568 569
      menuID: dragKey,
      newParentID: id || -1,
      menuList: String(dragList) || '',
Maofei94's avatar
Maofei94 committed
570 571 572
      _version: 9999,
      _dc: Date.now(),
    }).then(res => {
573
      if (res.code === 0) {
Maofei94's avatar
Maofei94 committed
574
        // updateMenuTree();
575 576
        getTree();
        // setFlag(flag + 1);
Maofei94's avatar
Maofei94 committed
577 578 579 580
      } else {
        notification.error({
          message: '提示',
          duration: 3,
581
          description: res.msg || '操作失败',
Maofei94's avatar
Maofei94 committed
582 583 584 585
        });
      }
    });
  };
张烨's avatar
张烨 committed
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
  return (
    <Spin spinning={loading} tip="loading...">
      <div
        className={classnames({
          [styles.box]: true,
        })}
      >
        <div
          className={classnames({
            [styles.left]: true,
          })}
        >
          <div
            className={classnames({
              [styles.leftTop]: true,
            })}
          >
            菜单列表
604
            <div className={classnames(styles.tRight)}>
605 606 607 608 609 610 611 612 613
              <Tooltip title="导入导出菜单组" className={styles.fs}>
                <DeliveredProcedureOutlined
                  style={{ color: '#178BF7', marginRight: '10px' }}
                  onClick={() => {
                    setNodeObj('');
                    setImportOrExportVisible(true);
                  }}
                />
              </Tooltip>
Maofei94's avatar
Maofei94 committed
614
              <Tooltip title="新增最上级菜单组">
张烨's avatar
张烨 committed
615 616 617 618 619
                <FolderAddTwoTone
                  className={`${styles.icon1} ${styles.icon}`}
                  onClick={() => rootAddGroup()}
                />
              </Tooltip>
Maofei94's avatar
Maofei94 committed
620
              <Tooltip title="新增最上级功能菜单">
张烨's avatar
张烨 committed
621 622 623 624 625 626 627
                <FileAddTwoTone
                  onClick={() => rootAdd()}
                  className={`${styles.icon2} ${styles.icon}`}
                />
              </Tooltip>
            </div>
          </div>
Maofei94's avatar
Maofei94 committed
628
          {menuList.length > 0 && (
629 630 631 632 633 634 635 636 637 638
            <div style={{ height: 'calc(100vh - 240px)', overflowY: 'scroll' }}>
              <Tree
                showIcon
                onSelect={handleSelect}
                treeData={menuList.map(item => mapTree(item))}
                blockNode
                draggable
                autoExpandParent
                selectedKeys={[menuID]}
                onDrop={handleDrop}
639
                expandedKeys={expendKey}
640 641
              />
            </div>
张烨's avatar
张烨 committed
642 643 644 645
          )}
        </div>
        <Modal
          visible={addVisible}
Maofei94's avatar
Maofei94 committed
646
          title={modalTitle}
张烨's avatar
张烨 committed
647 648 649 650 651 652 653
          bodyStyle={{ width: '100%', minHeight: '100px' }}
          style={{ top: 80 }}
          width="600px"
          destroyOnClose
          footer={null}
          cancelText="取消"
          okText="确认"
Maofei94's avatar
Maofei94 committed
654
          maskClosable={false}
张烨's avatar
张烨 committed
655 656 657 658 659 660 661 662
          onCancel={() => setAddVisible(false)}
          onConfirm={() => {
            submitCallback();
          }}
        >
          <AddForm
            nodeObj={nodeObj}
            addType={addType}
张烨's avatar
张烨 committed
663
            configFiles={configFiles}
张烨's avatar
张烨 committed
664 665
            submitCallback={submitCallback}
            submitLoading={submitLoading}
Maofei94's avatar
Maofei94 committed
666
            productList={productList}
667
            allProductList={allProductList}
张烨's avatar
张烨 committed
668 669 670 671
          />
        </Modal>
        <Modal
          visible={addTwoVisible}
Maofei94's avatar
Maofei94 committed
672
          title={modalTitle}
张烨's avatar
张烨 committed
673 674 675 676 677
          bodyStyle={{ width: '100%', minHeight: '100px' }}
          style={{ top: 80 }}
          width="600px"
          destroyOnClose
          footer={null}
Maofei94's avatar
Maofei94 committed
678
          maskClosable={false}
张烨's avatar
张烨 committed
679 680 681 682 683 684 685
          cancelText="取消"
          okText="确认"
          onCancel={() => setAddTwoVisible(false)}
        >
          <AddForm
            submitLoading={submitLoading}
            nodeObj={nodeObj}
张烨's avatar
张烨 committed
686
            configFiles={configFiles}
张烨's avatar
张烨 committed
687
            addType={addType}
688
            allProductList={allProductList}
Maofei94's avatar
Maofei94 committed
689
            productList={productList}
张烨's avatar
张烨 committed
690 691 692 693 694 695 696 697 698 699 700 701
            submitCallback={submitCallback}
          />
        </Modal>
        <Modal
          visible={delVisible}
          title="请确认"
          bodyStyle={{ width: '100%', minHeight: '100px' }}
          style={{ top: 80 }}
          width="400px"
          destroyOnClose
          cancelText="取消"
          okText="确认"
Maofei94's avatar
Maofei94 committed
702
          maskClosable={false}
张烨's avatar
张烨 committed
703 704 705 706
          onCancel={() => setDelVisible(false)}
          onOk={() => delMenu()}
          confirmLoading={modalLoading}
        >
707 708 709 710 711 712 713 714 715
          {nodeObj.children && nodeObj.children.length > 0 ? (
            <span>
              是否删除<span style={{ color: 'red' }}>{modalTitle}</span>及其子菜单?
            </span>
          ) : (
            <span>
              是否删除<span style={{ color: 'red' }}>{modalTitle}</span>?
            </span>
          )}
张烨's avatar
张烨 committed
716 717 718 719 720 721
        </Modal>
        <div
          className={classnames({
            [styles.middle]: true,
          })}
        >
Maofei94's avatar
Maofei94 committed
722 723
          菜单配置
          {nodeType ? (
张烨's avatar
张烨 committed
724 725 726
            <EditForm
              nodeType={nodeType}
              info={info}
727 728
              infoAll={infoAll}
              checkList={checkList}
张烨's avatar
张烨 committed
729
              configFiles={configFiles}
Maofei94's avatar
Maofei94 committed
730
              productList={productList}
731
              allProductList={allProductList}
张烨's avatar
张烨 committed
732
              submitCallback={editSubmitCallback}
Maofei94's avatar
Maofei94 committed
733
              valueCallback={valueCallback}
张烨's avatar
张烨 committed
734
            />
Maofei94's avatar
Maofei94 committed
735
          ) : (
736
            <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="当前未选中菜单" />
张烨's avatar
张烨 committed
737 738
          )}
        </div>
739 740 741 742 743 744 745 746 747 748
        <ImportOrExport
          visible={importOrExportVisible}
          onFinish={onFinishCallBack}
          onCancel={() => {
            setImportOrExportVisible(false);
            getTree();
          }}
          subSystemValue={subSystemValue}
          nodeObj={nodeObj}
        />
Maofei94's avatar
Maofei94 committed
749
        {/* <div
张烨's avatar
张烨 committed
750 751 752 753 754 755 756 757 758 759
          className={classnames({
            [styles.rightBox]: true,
          })}
        >
          关联角色
          <CheckList
            info={info}
            nodeType={nodeType}
            valueCallback={valueCallback}
          />
Maofei94's avatar
Maofei94 committed
760
        </div> */}
张烨's avatar
张烨 committed
761 762 763 764 765 766
      </div>
    </Spin>
  );
};

export default MiniMenu;