Commit ebe22401 authored by Maofei94's avatar Maofei94

perf: web拖拽问题

parent ecbf51d8
Pipeline #22347 passed with stages
in 19 minutes 21 seconds
...@@ -44,7 +44,8 @@ const MobileConfigPage = props => { ...@@ -44,7 +44,8 @@ const MobileConfigPage = props => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
const { data } = res; const { data } = res;
let array = data[0].children.length > 0 && [...data[0].children]; let array =
(data[0].children.length > 0 && [...data[0].children]) || [];
let arr = []; let arr = [];
array.map(item => { array.map(item => {
arr.push({ arr.push({
......
...@@ -254,6 +254,8 @@ const WebConfigPage = props => { ...@@ -254,6 +254,8 @@ const WebConfigPage = props => {
onUpdate={handleUpdateOnMenuChange} onUpdate={handleUpdateOnMenuChange}
configFiles={configFiles} configFiles={configFiles}
updateMenuTree={updateMenuTree} updateMenuTree={updateMenuTree}
userMode={userMode}
webid={tabPaneItem?.id}
subSystemValue={tabPaneItem?.subSystemValue} subSystemValue={tabPaneItem?.subSystemValue}
/> />
</ProCard> </ProCard>
......
...@@ -20,10 +20,18 @@ import { ...@@ -20,10 +20,18 @@ import {
getWebMenuInfo, // 查 getWebMenuInfo, // 查
dragMenu, // 菜单拖拽 dragMenu, // 菜单拖拽
getProductList, getProductList,
getWebModuleTree,
} from '@/services/webConfig/api'; } from '@/services/webConfig/api';
const MiniMenu = props => { const MiniMenu = props => {
const { menu, configFiles, subSystemValue, updateMenuTree } = props; const {
menu,
configFiles,
subSystemValue,
updateMenuTree,
userMode,
webid,
} = props;
const [flag, setFlag] = useState(1); // 刷新标志 const [flag, setFlag] = useState(1); // 刷新标志
const [loading, setLoading] = useState(false); // 加载 const [loading, setLoading] = useState(false); // 加载
const [menuID, setMenuID] = useState(''); // 选中的树ID const [menuID, setMenuID] = useState(''); // 选中的树ID
...@@ -40,6 +48,7 @@ const MiniMenu = props => { ...@@ -40,6 +48,7 @@ const MiniMenu = props => {
const [submitLoading, setSubmitLoading] = useState(false); const [submitLoading, setSubmitLoading] = useState(false);
const [newTreeList, setNewTreeList] = useState([]); const [newTreeList, setNewTreeList] = useState([]);
const [productList, setProductList] = useState([]); const [productList, setProductList] = useState([]);
const [menuList, setMenuList] = useState([]); // 菜单树
/* ***************************************************** */ /* ***************************************************** */
const [curMenuType, setCurMenuType] = useState(''); const [curMenuType, setCurMenuType] = useState('');
...@@ -47,7 +56,7 @@ const MiniMenu = props => { ...@@ -47,7 +56,7 @@ const MiniMenu = props => {
// 获取菜单信息 // 获取菜单信息
useEffect(() => { useEffect(() => {
getInfo(); getInfo();
}, [menuID]); }, [menuID, webid]);
useEffect(() => { useEffect(() => {
getProductList().then(res => { getProductList().then(res => {
const { code, data } = res; const { code, data } = res;
...@@ -56,11 +65,36 @@ const MiniMenu = props => { ...@@ -56,11 +65,36 @@ const MiniMenu = props => {
} }
}); });
}, []); }, []);
useEffect(() => {
setLoading(true);
getWebModuleTree(userMode || 'super')
.then(res => {
setLoading(false);
console.log(res);
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);
let arr2 =
arr[0].children.find(item => item.text === '菜单管理').children ||
[];
setMenuList(arr2 || []);
console.log(arr, webid, arr2);
}
})
.catch(err => {
setLoading(false);
});
return () => {
setLoading(false);
};
}, [flag, webid]);
useEffect(() => { useEffect(() => {
console.log(menu, 'menu'); console.log(menu, 'menu');
setNewTreeList(menu.children || []); setNewTreeList(menuList || []);
}, [menu]); }, [menuList]);
// 处理数据 // 处理数据
const mapTree = val => { const mapTree = val => {
...@@ -164,7 +198,7 @@ const MiniMenu = props => { ...@@ -164,7 +198,7 @@ const MiniMenu = props => {
setFlag(flag + 1); setFlag(flag + 1);
setNodeType(''); setNodeType('');
setNodeObj(''); setNodeObj('');
updateMenuTree('delete', nodeObj); // updateMenuTree('delete', nodeObj);
notification.success({ notification.success({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -228,7 +262,7 @@ const MiniMenu = props => { ...@@ -228,7 +262,7 @@ const MiniMenu = props => {
setAddVisible(false); setAddVisible(false);
setAddTwoVisible(false); setAddTwoVisible(false);
setFlag(flag + 1); setFlag(flag + 1);
updateMenuTree('add', item); // updateMenuTree('add', item);
notification.success({ notification.success({
message: '提示', message: '提示',
description: '新增成功', description: '新增成功',
...@@ -265,7 +299,7 @@ const MiniMenu = props => { ...@@ -265,7 +299,7 @@ const MiniMenu = props => {
if (res.success) { if (res.success) {
setFlag(flag + 1); setFlag(flag + 1);
updateMenuTree('edit'); // updateMenuTree('edit');
notification.success({ notification.success({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -354,8 +388,8 @@ const MiniMenu = props => { ...@@ -354,8 +388,8 @@ const MiniMenu = props => {
}).then(res => { }).then(res => {
console.log(res); console.log(res);
if (res.success) { if (res.success) {
updateMenuTree(); // updateMenuTree();
// setFlag(flag + 1); setFlag(flag + 1);
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
...@@ -413,11 +447,11 @@ const MiniMenu = props => { ...@@ -413,11 +447,11 @@ const MiniMenu = props => {
</Tooltip> </Tooltip>
</div> </div>
</div> </div>
{menu.children.length > 0 && ( {menuList.length > 0 && (
<Tree <Tree
showIcon showIcon
onSelect={handleSelect} onSelect={handleSelect}
treeData={menu.children.map(item => mapTree(item))} treeData={menuList.map(item => mapTree(item))}
blockNode blockNode
draggable draggable
autoExpandParent autoExpandParent
......
...@@ -38,7 +38,6 @@ axios.interceptors.request.use( function (request){ ...@@ -38,7 +38,6 @@ axios.interceptors.request.use( function (request){
if(request.url!='/Publish/OMS/OMSLogin'&&request.url!='/Publish/OMS/FileCenter/SaveMobileApk'&&request.url!='/Publish/OMS/GateWayConfig') if(request.url!='/Publish/OMS/OMSLogin'&&request.url!='/Publish/OMS/FileCenter/SaveMobileApk'&&request.url!='/Publish/OMS/GateWayConfig')
request.url=getWay+request.url request.url=getWay+request.url
} }
console.log(request,pandaPublish)
return request return request
}, function (error) { }, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger // Any status codes that falls outside the range of 2xx cause this function to trigger
......
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