|
@@ -0,0 +1,225 @@
|
|
|
+import { useRequest } from '@umijs/max';
|
|
|
+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'),
|
|
|
+ name: '水厂介绍',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-ops-DataView',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-DataView.png'),
|
|
|
+ name: '数据驾驶舱',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-ops-DeviceManagement',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-DeviceManagement.png'),
|
|
|
+ name: '设备管理',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-ops-ProManagement',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-ProManagement.png'),
|
|
|
+ name: '生产管理',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-ops-SecurityManagement',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-SecurityManagement.png'),
|
|
|
+ name: '安全管理',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-ops-LimitedSpace',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-LimitedSpace.png'),
|
|
|
+ name: '有限空间管理',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-ops-EnergyManagement',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-EnergyManagement.png'),
|
|
|
+ name: '能耗管理',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-ops-WaterQManagement',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-WaterQManagement.png'),
|
|
|
+ name: '水质管理',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-build-0',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-build-0.png'),
|
|
|
+ name: '数据中心',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-ops-ConfigManagement',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-ops-ConfigManagement.png'),
|
|
|
+ name: '配置管理',
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ code: 'func-01-build-0',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-build-0.png'),
|
|
|
+ name: '数据中心',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-build-3',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-build-3.png'),
|
|
|
+ name: '计划管理',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-build-4',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-build-4.png'),
|
|
|
+ name: '安全管理',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'func-01-build-10',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/func-01-build-10.png'),
|
|
|
+ name: '流程管理',
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ code: '',
|
|
|
+ iconPath: require('@/assets/UnityMenu/ICON/newModel.png'),
|
|
|
+ name: '新增功能',
|
|
|
+ },
|
|
|
+];
|
|
|
+function ModuleMenu(props: any) {
|
|
|
+ const {
|
|
|
+ location: {
|
|
|
+ query: { moduleCode, projectId },
|
|
|
+ },
|
|
|
+ } = props;
|
|
|
+
|
|
|
+ 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) => {
|
|
|
+ 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,
|
|
|
+ );
|
|
|
+ if (current) {
|
|
|
+ menu.push(current);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ 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>
|
|
|
+ </div>
|
|
|
+ {/* {
|
|
|
+ unityBack == undefined && <button
|
|
|
+ className={style.enterBtn}
|
|
|
+ type="button"
|
|
|
+ onClick={e => {
|
|
|
+ backToProjectSelect();
|
|
|
+ e.stopPropagation();
|
|
|
+ }}
|
|
|
+ style={{
|
|
|
+ position: 'absolute',
|
|
|
+ right: 0,
|
|
|
+ top: 100,
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 返回
|
|
|
+ </button>
|
|
|
+ } */}
|
|
|
+ </>
|
|
|
+ );
|
|
|
+}
|
|
|
+export default ModuleMenu;
|