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

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

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