|
@@ -1,6 +1,6 @@
|
|
import styles from "./index.module.scss";
|
|
import styles from "./index.module.scss";
|
|
import LeftBar from "@/components/LeftBar";
|
|
import LeftBar from "@/components/LeftBar";
|
|
-import React from "react";
|
|
|
|
|
|
+import React, { useEffect, useRef } from "react";
|
|
import SpinLoding from "@/components/SpinLoding";
|
|
import SpinLoding from "@/components/SpinLoding";
|
|
import { Route, Switch } from "react-router-dom";
|
|
import { Route, Switch } from "react-router-dom";
|
|
import AuthRoute from "@/components/AuthRoute";
|
|
import AuthRoute from "@/components/AuthRoute";
|
|
@@ -139,59 +139,60 @@ const dataInTemp = [
|
|
},
|
|
},
|
|
];
|
|
];
|
|
|
|
|
|
-// 根据权限来判断
|
|
|
|
-const powerInfo = getPowerInfo();
|
|
|
|
-
|
|
|
|
-console.log('ppppppppppp',powerInfo);
|
|
|
|
-
|
|
|
|
|
|
+export default function Object() {
|
|
|
|
+ const data = useRef<any>([]);
|
|
|
|
+ const dataIn = useRef<any>([]);
|
|
|
|
|
|
-powerInfo.forEach((v: any) => {
|
|
|
|
- if (v.id === 100) {
|
|
|
|
- dataTemp[0].done = true;
|
|
|
|
- v.children.forEach((v2: any) => {
|
|
|
|
- if (v2.id === 102 && v2.authority) dataInTemp[0].done = true;
|
|
|
|
- if (v2.id === 105 && v2.authority) dataInTemp[1].done = true;
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- if (v.id === 200) dataTemp[1].done = true;
|
|
|
|
- if (v.id === 300) {
|
|
|
|
- dataTemp[2].done = true;
|
|
|
|
- v.children.forEach((v2: any) => {
|
|
|
|
- if (v2.id === 302 && v2.authority) dataInTemp[2].done = true;
|
|
|
|
- if (v2.id === 305 && v2.authority) dataInTemp[3].done = true;
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- if (v.id === 400) {
|
|
|
|
- dataTemp[3].done = true;
|
|
|
|
- v.children.forEach((v2: any) => {
|
|
|
|
- if (v2.id === 402 && v2.authority) dataInTemp[4].done = true;
|
|
|
|
- if (v2.id === 405 && v2.authority) dataInTemp[5].done = true;
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- if (v.id === 500) {
|
|
|
|
- v.children.forEach((v2: any) => {
|
|
|
|
- if (v2.id === 505 && v2.authority) dataInTemp[6].done = true;
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ // 根据权限来判断
|
|
|
|
+ const powerInfo = getPowerInfo();
|
|
|
|
+ powerInfo.forEach((v: any) => {
|
|
|
|
+ if (v.id === 100) {
|
|
|
|
+ dataTemp[0].done = true;
|
|
|
|
+ v.children.forEach((v2: any) => {
|
|
|
|
+ if (v2.id === 102 && v2.authority) dataInTemp[0].done = true;
|
|
|
|
+ if (v2.id === 105 && v2.authority) dataInTemp[1].done = true;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (v.id === 200) dataTemp[1].done = true;
|
|
|
|
+ if (v.id === 300) {
|
|
|
|
+ dataTemp[2].done = true;
|
|
|
|
+ v.children.forEach((v2: any) => {
|
|
|
|
+ if (v2.id === 302 && v2.authority) dataInTemp[2].done = true;
|
|
|
|
+ if (v2.id === 305 && v2.authority) dataInTemp[3].done = true;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (v.id === 400) {
|
|
|
|
+ dataTemp[3].done = true;
|
|
|
|
+ v.children.forEach((v2: any) => {
|
|
|
|
+ if (v2.id === 402 && v2.authority) dataInTemp[4].done = true;
|
|
|
|
+ if (v2.id === 405 && v2.authority) dataInTemp[5].done = true;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (v.id === 500) {
|
|
|
|
+ v.children.forEach((v2: any) => {
|
|
|
|
+ if (v2.id === 505 && v2.authority) dataInTemp[6].done = true;
|
|
|
|
+ });
|
|
|
|
+ dataTemp[4].done = true;
|
|
|
|
+ }
|
|
|
|
+ if (v.id === 600) {
|
|
|
|
+ dataTemp[5].done = true;
|
|
|
|
+ v.children.forEach((v2: any) => {
|
|
|
|
+ if (v2.id === 602 && v2.authority) dataInTemp[7].done = true;
|
|
|
|
+ if (v2.id === 605 && v2.authority) dataInTemp[8].done = true;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
});
|
|
});
|
|
- dataTemp[4].done = true;
|
|
|
|
- }
|
|
|
|
- if (v.id === 600) {
|
|
|
|
- dataTemp[5].done = true;
|
|
|
|
- v.children.forEach((v2: any) => {
|
|
|
|
- if (v2.id === 602 && v2.authority) dataInTemp[7].done = true;
|
|
|
|
- if (v2.id === 605 && v2.authority) dataInTemp[8].done = true;
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-});
|
|
|
|
-const data = dataTemp.filter((v) => v.done);
|
|
|
|
-
|
|
|
|
-const dataIn = dataInTemp.filter((v) => v.done);
|
|
|
|
|
|
+ data.current = dataTemp.filter((v) => v.done);
|
|
|
|
+ console.log(1231231,data.current);
|
|
|
|
+
|
|
|
|
+ dataIn.current = dataInTemp.filter((v) => v.done);
|
|
|
|
+ // 没有藏品登记页面的权限 跳到有权限的页面
|
|
|
|
+ if (data.current[0].id !== 1) {
|
|
|
|
+ history.replace(data.current[0].path);
|
|
|
|
+ }
|
|
|
|
+ }, []);
|
|
|
|
|
|
-// 没有藏品登记页面的权限 跳到有权限的页面
|
|
|
|
-if (data[0].id !== 1) {
|
|
|
|
- history.replace(data[0].path);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-export default function Object() {
|
|
|
|
return (
|
|
return (
|
|
<div className={styles.Object}>
|
|
<div className={styles.Object}>
|
|
<div className="leftBar">
|
|
<div className="leftBar">
|
|
@@ -201,7 +202,7 @@ export default function Object() {
|
|
<div className="rightMain">
|
|
<div className="rightMain">
|
|
<React.Suspense fallback={<SpinLoding />}>
|
|
<React.Suspense fallback={<SpinLoding />}>
|
|
<Switch>
|
|
<Switch>
|
|
- {data.map((v, i) => (
|
|
|
|
|
|
+ {data.current.map((v: any, i: number) => (
|
|
<AuthRoute
|
|
<AuthRoute
|
|
exact
|
|
exact
|
|
// exact={i === 0 ? true : false}
|
|
// exact={i === 0 ? true : false}
|
|
@@ -219,7 +220,7 @@ export default function Object() {
|
|
<AuthRoute path="/object/6/look" component={LookObject6} />
|
|
<AuthRoute path="/object/6/look" component={LookObject6} />
|
|
|
|
|
|
{/* 新增 */}
|
|
{/* 新增 */}
|
|
- {dataIn.map((v) => (
|
|
|
|
|
|
+ {dataIn.current.map((v: any) => (
|
|
<AuthRoute key={v.id} path={v.path} component={v.Com} />
|
|
<AuthRoute key={v.id} path={v.path} component={v.Com} />
|
|
))}
|
|
))}
|
|
|
|
|