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 => {
setLoading(false);
if (res.code === 0) {
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 = [];
array.map(item => {
arr.push({
......
......@@ -254,6 +254,8 @@ const WebConfigPage = props => {
onUpdate={handleUpdateOnMenuChange}
configFiles={configFiles}
updateMenuTree={updateMenuTree}
userMode={userMode}
webid={tabPaneItem?.id}
subSystemValue={tabPaneItem?.subSystemValue}
/>
</ProCard>
......
......@@ -20,10 +20,18 @@ import {
getWebMenuInfo, // 查
dragMenu, // 菜单拖拽
getProductList,
getWebModuleTree,
} from '@/services/webConfig/api';
const MiniMenu = props => {
const { menu, configFiles, subSystemValue, updateMenuTree } = props;
const {
menu,
configFiles,
subSystemValue,
updateMenuTree,
userMode,
webid,
} = props;
const [flag, setFlag] = useState(1); // 刷新标志
const [loading, setLoading] = useState(false); // 加载
const [menuID, setMenuID] = useState(''); // 选中的树ID
......@@ -40,6 +48,7 @@ const MiniMenu = props => {
const [submitLoading, setSubmitLoading] = useState(false);
const [newTreeList, setNewTreeList] = useState([]);
const [productList, setProductList] = useState([]);
const [menuList, setMenuList] = useState([]); // 菜单树
/* ***************************************************** */
const [curMenuType, setCurMenuType] = useState('');
......@@ -47,7 +56,7 @@ const MiniMenu = props => {
// 获取菜单信息
useEffect(() => {
getInfo();
}, [menuID]);
}, [menuID, webid]);
useEffect(() => {
getProductList().then(res => {
const { code, data } = res;
......@@ -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(() => {
console.log(menu, 'menu');
setNewTreeList(menu.children || []);
}, [menu]);
setNewTreeList(menuList || []);
}, [menuList]);
// 处理数据
const mapTree = val => {
......@@ -164,7 +198,7 @@ const MiniMenu = props => {
setFlag(flag + 1);
setNodeType('');
setNodeObj('');
updateMenuTree('delete', nodeObj);
// updateMenuTree('delete', nodeObj);
notification.success({
message: '提示',
duration: 3,
......@@ -228,7 +262,7 @@ const MiniMenu = props => {
setAddVisible(false);
setAddTwoVisible(false);
setFlag(flag + 1);
updateMenuTree('add', item);
// updateMenuTree('add', item);
notification.success({
message: '提示',
description: '新增成功',
......@@ -265,7 +299,7 @@ const MiniMenu = props => {
if (res.success) {
setFlag(flag + 1);
updateMenuTree('edit');
// updateMenuTree('edit');
notification.success({
message: '提示',
duration: 3,
......@@ -354,8 +388,8 @@ const MiniMenu = props => {
}).then(res => {
console.log(res);
if (res.success) {
updateMenuTree();
// setFlag(flag + 1);
// updateMenuTree();
setFlag(flag + 1);
} else {
notification.error({
message: '提示',
......@@ -413,11 +447,11 @@ const MiniMenu = props => {
</Tooltip>
</div>
</div>
{menu.children.length > 0 && (
{menuList.length > 0 && (
<Tree
showIcon
onSelect={handleSelect}
treeData={menu.children.map(item => mapTree(item))}
treeData={menuList.map(item => mapTree(item))}
blockNode
draggable
autoExpandParent
......
......@@ -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')
request.url=getWay+request.url
}
console.log(request,pandaPublish)
return request
}, function (error) {
// 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