Commit d906d18f authored by 皮倩雯's avatar 皮倩雯

fix: 'web配置菜单树增加搜索'

parent 53382b58
Pipeline #82713 failed with stages
......@@ -3,7 +3,7 @@
/* eslint-disable no-plusplus */
/* eslint-disable consistent-return */
import React, { useEffect, useState, useRef } from 'react';
import { notification, Tooltip, Modal, Spin, Empty } from 'antd';
import { notification, Tooltip, Modal, Spin, Empty, Input } from 'antd';
import Tree from '@/components/ExpendableTree';
import {
FileAddTwoTone,
......@@ -29,6 +29,7 @@ import {
pEditWebMenu,
} from '@/services/webConfig/api';
const { Search } = Input;
const MiniMenu = props => {
const {
menu,
......@@ -63,6 +64,7 @@ const MiniMenu = props => {
const [menuList, setMenuList] = useState([]); // 菜单树
const [keepId, setKeepId] = useState('');
const [mapDataList, setMapDataList] = useState(new Set());
const [keywords, setKeywords] = useState('');
/* ***************************************************** */
const [curMenuType, setCurMenuType] = useState('');
......@@ -70,11 +72,9 @@ const MiniMenu = props => {
// 获取菜单信息
useEffect(() => {
console.log(menuID, flag);
if (flag === 1) {
setExpendKey(menuID);
}
console.log(expendKey);
getInfo();
}, [menuID, webid]);
// useEffect(() => {
......@@ -137,13 +137,10 @@ const MiniMenu = props => {
};
// 树的点击事件
const handleSelect = (prop, treeNode) => {
console.log(prop);
console.log(treeNode);
if (treeNode) {
const {
node: { menuType },
} = treeNode;
console.log(menuType);
switch (menuType) {
case 'Web4MenuGroup':
setNodeType(2);
......@@ -208,8 +205,6 @@ const MiniMenu = props => {
// 删除的回调
const deleteMenuTip = (val, e) => {
e.stopPropagation();
console.log(val);
console.log(e);
setModalTitle(val.text);
setNodeObj(val);
setDelVisible(true);
......@@ -249,7 +244,6 @@ const MiniMenu = props => {
})
.catch(err => {
setModalLoading(false);
console.error(err);
});
};
// 导入导出菜单组
......@@ -314,11 +308,9 @@ const MiniMenu = props => {
.then(res => {
setSubmitLoading(false);
if (res.code === 0) {
console.log(res.data);
setAddVisible(false);
setAddTwoVisible(false);
// setFlag(flag + 1);
console.log(prop);
getTree(res.data);
// updateMenuTree('add', item);
notification.success({
......@@ -336,7 +328,6 @@ const MiniMenu = props => {
})
.catch(err => {
setSubmitLoading(false);
console.error(err);
});
};
const treeCallback = value => {
......@@ -349,7 +340,6 @@ const MiniMenu = props => {
setLoading(true);
let baseUrl = handleGeturl(prop.imageUrl);
let obj = { ...prop, baseUrl };
console.log(obj);
if (nodeType === 1) {
// obj.relatedRoleList = roleList || '';
editWebMenu({
......@@ -441,8 +431,8 @@ const MiniMenu = props => {
}
}
};
const getTree = e => {
getWebModuleTree(userMode || 'super')
const getTree = (e, word) => {
getWebModuleTree(userMode || 'super', word)
.then(res => {
setLoading(false);
const { code, data } = res;
......@@ -455,12 +445,9 @@ const MiniMenu = props => {
setMenuList(arr2 || []);
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);
......@@ -583,6 +570,14 @@ const MiniMenu = props => {
}
});
};
const onSearch = value => {
getTree('', value);
};
const onChangeSearch = e => {
setKeywords(e.target.value);
};
return (
<Spin spinning={loading} tip="loading...">
<div
......@@ -625,8 +620,19 @@ const MiniMenu = props => {
</Tooltip>
</div>
</div>
<Search
style={{
marginBottom: 8,
width: '98%',
marginLeft: '7px',
}}
value={keywords}
placeholder="快速搜索菜单"
onChange={onChangeSearch}
onSearch={onSearch}
/>
{menuList.length > 0 && (
<div style={{ height: 'calc(100vh - 240px)', overflowY: 'scroll' }}>
<div style={{ height: 'calc(100vh - 280px)', overflowY: 'scroll' }}>
<Tree
showIcon
onSelect={handleSelect}
......
......@@ -6,12 +6,11 @@ import { CITY_SERVICE, get, PUBLISH_SERVICE, post, postForm, PANDA_GIS } from '.
* 获取所有网站配置
* @param {*} userMode
*/
export const getWebModuleTree = userMode =>
get(
`${PUBLISH_SERVICE}/PlatformCenter/WebModuleTree?${qs.stringify({
userMode,
})}`,
);
export const getWebModuleTree = (userMode, keyword) =>
get(`${PUBLISH_SERVICE}/PlatformCenter/WebModuleTree`, {
userMode,
keyword,
});
/**
* 获取主题下拉选项
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment