|
@@ -1,225 +1,167 @@
|
|
|
-import { useRequest } from '@umijs/max';
|
|
|
+import { useModel, useRequest } from '@umijs/max';
|
|
|
+import { Spin } from 'antd';
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
import menuStyle from './MenuStyle.less';
|
|
|
|
|
|
-const noIcon = require('@/assets/UnityMenu/noIcon.png');
|
|
|
const grayIcon = [
|
|
|
{
|
|
|
code: 'func-01-ops-BaseInfo',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-BaseInfo.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-BaseInfo.png'),
|
|
|
name: '水厂介绍',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-ops-DataView',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-DataView.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-DataView.png'),
|
|
|
name: '数据驾驶舱',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-ops-DeviceManagement',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-DeviceManagement.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-DeviceManagement.png'),
|
|
|
name: '设备管理',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-ops-ProManagement',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-ProManagement.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-ProManagement.png'),
|
|
|
name: '生产管理',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-ops-SecurityManagement',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-SecurityManagement.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-SecurityManagement.png'),
|
|
|
name: '安全管理',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-ops-LimitedSpace',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-LimitedSpace.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-LimitedSpace.png'),
|
|
|
name: '有限空间管理',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-ops-EnergyManagement',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-EnergyManagement.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-EnergyManagement.png'),
|
|
|
name: '能耗管理',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-ops-WaterQManagement',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-WaterQManagement.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-WaterQManagement.png'),
|
|
|
name: '水质管理',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-build-0',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-build-0.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-build-0.png'),
|
|
|
name: '数据中心',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-ops-ConfigManagement',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-ConfigManagement.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-ops-ConfigManagement.png'),
|
|
|
name: '配置管理',
|
|
|
},
|
|
|
|
|
|
{
|
|
|
code: 'func-01-build-0',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-build-0.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-build-0.png'),
|
|
|
name: '数据中心',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-build-3',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-build-3.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-build-3.png'),
|
|
|
name: '计划管理',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-build-4',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-build-4.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-build-4.png'),
|
|
|
name: '安全管理',
|
|
|
},
|
|
|
{
|
|
|
code: 'func-01-build-10',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/func-01-build-10.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/func-01-build-10.png'),
|
|
|
name: '流程管理',
|
|
|
},
|
|
|
|
|
|
{
|
|
|
code: '',
|
|
|
- iconPath: require('@/assets/UnityMenu/ICON/newModel.png'),
|
|
|
+ iconPath: require('@/Project/assets/UnityMenu/ICON/newModel.png'),
|
|
|
name: '新增功能',
|
|
|
},
|
|
|
];
|
|
|
+
|
|
|
function ModuleMenu(props: any) {
|
|
|
const {
|
|
|
- location: {
|
|
|
- query: { moduleCode, projectId },
|
|
|
- },
|
|
|
+ params: { subModule, clickMenu },
|
|
|
} = props;
|
|
|
+ const { projectMenu, queryProjectMenu, loading } = useModel('menu');
|
|
|
|
|
|
- const { data: waterMenuData } = useRequest(async () => {});
|
|
|
- const [curMenu, setCurMenu] = useState<Api.IMenu[]>([]);
|
|
|
-
|
|
|
- // useEffect(() => {
|
|
|
- // dispatch({
|
|
|
- // type: 'menu/getMenuByDepId',
|
|
|
- // callback: menu => {
|
|
|
- // let moduleMenu = (menu.children || []).find(item => item.Code == moduleCode);
|
|
|
- // if (moduleMenu) initMenu(moduleMenu, handleMenuClick);
|
|
|
- // },
|
|
|
- // payload: { version: 2, projectId },
|
|
|
- // });
|
|
|
- // }, []);
|
|
|
-
|
|
|
- const initMenu = (parent: Api.IMenu) => {
|
|
|
- if (parent?.children) {
|
|
|
- let menu = [
|
|
|
- ...parent.children,
|
|
|
- // {
|
|
|
- // Name: '新增功能',
|
|
|
- // ID: -1,
|
|
|
- // Code: '',
|
|
|
- // Type: 1,
|
|
|
- // Icon: require('@/assets/UnityMenu/ICON/newModel.png'),
|
|
|
- // WebPath: '',
|
|
|
- // UnityPath: '',
|
|
|
- // },
|
|
|
- ];
|
|
|
-
|
|
|
- for (let i = 0; i < menu.length; i++) {
|
|
|
- let element = menu[i];
|
|
|
- if (element.Type != 1) {
|
|
|
- menu.splice(i, 1);
|
|
|
- i--; //i
|
|
|
- continue;
|
|
|
- }
|
|
|
- // element.name = element.Name;
|
|
|
- // element.iconPath = element.Icon || noIcon;
|
|
|
- // element.active = element.children != undefined || element.UnityPath != '';
|
|
|
- if (!element.active) continue;
|
|
|
- }
|
|
|
- setCurMenu(menu);
|
|
|
- }
|
|
|
- };
|
|
|
// const backToProjectSelect = () => {
|
|
|
// UnityAction.sendMsg('back', '');
|
|
|
// };
|
|
|
const handleMenuClick = (element: Api.IMenu) => {
|
|
|
+ console.log(element);
|
|
|
if (!element.active) return;
|
|
|
- let menu = [];
|
|
|
- // console.log(element);
|
|
|
- // UnityAction.sendMsg('EnterApp', element);
|
|
|
- var parent = waterMenuData?.children.find(
|
|
|
- (item: Api.IMenu) => item.ID == element.ParentID,
|
|
|
- );
|
|
|
- if (parent) {
|
|
|
- menu.push(parent);
|
|
|
- var current = parent?.children.find(
|
|
|
- (item: Api.IMenu) => item.Code == element.Code,
|
|
|
+ clickMenu?.(element);
|
|
|
+ // let menu = [];
|
|
|
+ // // console.log(element);
|
|
|
+ // // UnityAction.sendMsg('EnterApp', element);
|
|
|
+ // var parent = waterMenuData?.children.find(
|
|
|
+ // (item: Api.IMenu) => item.ID == element.ParentID,
|
|
|
+ // );
|
|
|
+ // if (parent) {
|
|
|
+ // menu.push(parent);
|
|
|
+ // var current = parent?.children.find(
|
|
|
+ // (item: Api.IMenu) => item.Code == element.Code,
|
|
|
+ // );
|
|
|
+ // if (current) {
|
|
|
+ // menu.push(current);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ };
|
|
|
+
|
|
|
+ const getSrc = (item: Api.IMenu) => {
|
|
|
+ if (item.active) {
|
|
|
+ return (
|
|
|
+ item.Icon || require('@/Project/assets/UnityMenu/ICON/newModel.png')
|
|
|
);
|
|
|
- if (current) {
|
|
|
- menu.push(current);
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ return grayIcon.find((icon) => icon.code === item.Code)?.iconPath;
|
|
|
}
|
|
|
};
|
|
|
+ useEffect(() => {
|
|
|
+ queryProjectMenu(subModule);
|
|
|
+ }, []);
|
|
|
|
|
|
return (
|
|
|
- <>
|
|
|
- <div className={menuStyle.background}>
|
|
|
- <div className={menuStyle.menuContent}>
|
|
|
- <div className={menuStyle.wrap}>
|
|
|
- {curMenu.map((item) => (
|
|
|
- <div className={menuStyle.item}>
|
|
|
- <div
|
|
|
- onClick={() => handleMenuClick(item)}
|
|
|
- className={menuStyle.menu}
|
|
|
- style={
|
|
|
- item.active
|
|
|
- ? {}
|
|
|
- : item.ID === -1
|
|
|
- ? { cursor: 'not-allowed' }
|
|
|
- : {}
|
|
|
- }
|
|
|
- >
|
|
|
- <img
|
|
|
- className={menuStyle.pic}
|
|
|
- src={
|
|
|
- item.active
|
|
|
- ? item.Icon ||
|
|
|
- require('@/assets/UnityMenu/ICON/newModel.png')
|
|
|
- : grayIcon.find((icon) => icon.code === item.Code)
|
|
|
- ?.iconPath
|
|
|
- }
|
|
|
- style={item.active ? {} : { cursor: 'not-allowed' }}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div style={{ marginTop: '0.22rem', textAlign: 'center' }}>
|
|
|
- <span
|
|
|
- className={menuStyle.menuFriName}
|
|
|
- style={
|
|
|
- item.active
|
|
|
- ? {}
|
|
|
- : { color: '#6081B2', cursor: 'not-allowed' }
|
|
|
- }
|
|
|
- >
|
|
|
- {item.Name}
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- ))}
|
|
|
- </div>
|
|
|
+ <div className={menuStyle.background}>
|
|
|
+ <Spin spinning={loading}>
|
|
|
+ <div className={menuStyle.wrap}>
|
|
|
+ {projectMenu.map((item) => (
|
|
|
+ <div
|
|
|
+ key={item.ID}
|
|
|
+ className={`${menuStyle.item} ${
|
|
|
+ item.active ? '' : menuStyle.disabled
|
|
|
+ }`}
|
|
|
+ onClick={() => handleMenuClick(item)}
|
|
|
+ >
|
|
|
+ <img className={menuStyle.pic} src={getSrc(item)} />
|
|
|
+ <span className={menuStyle.menuFriName}>{item.Name}</span>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ {/* 新增功能 */}
|
|
|
+ {projectMenu.length > 0 && (
|
|
|
+ <div className={menuStyle.item} style={{ cursor: 'not-allowed' }}>
|
|
|
+ <img
|
|
|
+ className={menuStyle.pic}
|
|
|
+ src={require('@/Project/assets/UnityMenu/ICON/newModel.png')}
|
|
|
+ />
|
|
|
+ <span className={menuStyle.menuFriName}>新增功能</span>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
+ <div className={menuStyle.empty}></div>
|
|
|
+ <div className={menuStyle.empty}></div>
|
|
|
+ <div className={menuStyle.empty}></div>
|
|
|
+ <div className={menuStyle.empty}></div>
|
|
|
+ <div className={menuStyle.empty}></div>
|
|
|
+ <div className={menuStyle.empty}></div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- {/* {
|
|
|
- unityBack == undefined && <button
|
|
|
- className={style.enterBtn}
|
|
|
- type="button"
|
|
|
- onClick={e => {
|
|
|
- backToProjectSelect();
|
|
|
- e.stopPropagation();
|
|
|
- }}
|
|
|
- style={{
|
|
|
- position: 'absolute',
|
|
|
- right: 0,
|
|
|
- top: 100,
|
|
|
- }}
|
|
|
- >
|
|
|
- 返回
|
|
|
- </button>
|
|
|
- } */}
|
|
|
- </>
|
|
|
+ </Spin>
|
|
|
+ </div>
|
|
|
);
|
|
|
}
|
|
|
export default ModuleMenu;
|