From 81cf2dce078d32f40066d2eeb17f51b0d79cf495 Mon Sep 17 00:00:00 2001 From: wulibaibao <13366578180@163.com> Date: Thu, 29 Sep 2022 15:07:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8F=98=E5=8A=A8=E5=AF=BC=E8=88=AA=E6=97=A0=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98&=E6=8A=A5=E5=91=8A=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B5=8B=E8=AF=95=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Header/index.tsx | 57 ++++++++++--------- .../TestResult/FuncResult.table.tsx | 40 +++++++++---- src/pages/Plan/index.tsx | 22 ++++--- 3 files changed, 73 insertions(+), 46 deletions(-) diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index d989899..c47fcaf 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -1,7 +1,7 @@ import React from "react" import { HeaderCls } from './headerStyled'; import { Avatar, Typography, Space, Col, Menu, Row } from "antd" -import { history, useModel } from '@umijs/max'; +import { history, useModel, useAccess } from '@umijs/max'; import type { MenuProps } from "antd" import RightContent from '@/components/RightContent'; import { switchMenuIcon } from "./MenuItemRender"; @@ -24,34 +24,39 @@ const Header: React.FC> = (props) => { const { initialState } = useModel("@@initialState") const { menuData, matchMenuKeys, logo } = props - const renderMenuData = passRoute(menuData) - .reduce((pre: any, cur: any) => { - const { routes, path, name } = cur; + const access = useAccess() - const $item: any = { - label: name, - icon: switchMenuIcon(cur), - key: path, - } - if (routes && routes.length > 0) { - const $children = passRoute(routes) - if ($children.length > 0) { - $item["popupClassName"] = styles["headerMenuPopupCls"] - $item["children"] = $children.map((i: any) => ({ - label: i.name, - key: i.path, - })) - $item["label"] = ( - <> - {name} - - - ) + const renderMenuData = React.useMemo(() => { + return passRoute(menuData) + .reduce((pre: any, cur: any) => { + const { routes, path, name } = cur; + + if (cur.access && !access[cur.access]?.()) return pre + const $item: any = { + label: name, + icon: switchMenuIcon(cur), + key: path, } + if (routes && routes.length > 0) { + const $children = passRoute(routes) + if ($children.length > 0) { + $item["popupClassName"] = styles["headerMenuPopupCls"] + $item["children"] = $children.map((i: any) => ({ + label: i.name, + key: i.path, + })) + $item["label"] = ( + <> + {name} + + + ) + } - } - return pre.concat($item) - }, []) + } + return pre.concat($item) + }, []) + }, [menuData, initialState.currentUser]) const onClick: MenuProps['onClick'] = e => { history.push(e.key) diff --git a/src/pages/Plan/Report/components/TestResult/FuncResult.table.tsx b/src/pages/Plan/Report/components/TestResult/FuncResult.table.tsx index 853ae33..707d8db 100644 --- a/src/pages/Plan/Report/components/TestResult/FuncResult.table.tsx +++ b/src/pages/Plan/Report/components/TestResult/FuncResult.table.tsx @@ -5,6 +5,7 @@ import React from "react"; import { FullSpace } from "../../styled"; import { StateIcon } from "../utils" import { PriorityTag } from "@/components/Public/PriorityTag" +import OverflowText from "@/components/Public/OverflowText"; const FuncPassRate: React.FC> = ({ dataSource }) => { const columns: TableColumnProps[] = [{ @@ -27,16 +28,33 @@ const FuncPassRate: React.FC> = ({ dataSource }) => { render(_) { return } - }, { + }, + { + dataIndex: "expect", + title: "期望值", + render(_) { + return {_ || "-"} + } + }, + { + dataIndex: "current", + title: "当前值", + render(_) { + return {_ || "-"} + } + }, + /* { dataIndex: "run_method", title: "运行方式", render(_) { return runMethodMap.get(_) ?? "-" } - }, { + }, + { dataIndex: "creator", title: "负责人" - },] + }, */ + ] return ( @@ -47,14 +65,14 @@ const FuncPassRate: React.FC> = ({ dataSource }) => { size="small" rowKey={"id"} pagination={false} - /* pagination={{ - hideOnSinglePage: true, - showSizeChanger: true, - showQuickJumper: true, - showTotal(total) { - return `共 ${total} 条 ` - }, - }} */ + /* pagination={{ + hideOnSinglePage: true, + showSizeChanger: true, + showQuickJumper: true, + showTotal(total) { + return `共 ${total} 条 ` + }, + }} */ /> ) diff --git a/src/pages/Plan/index.tsx b/src/pages/Plan/index.tsx index 204b43d..b126ee1 100644 --- a/src/pages/Plan/index.tsx +++ b/src/pages/Plan/index.tsx @@ -30,18 +30,22 @@ const TestPlan: React.FC = (props) => { { initialData: [], onSuccess(data) { - if (data && data.legnth > 0) { - const firstId = data[0]?.id - if (!plan_id) - history.replace(`/plan/${firstId}`) - else { - const idx = data.findIndex((p: any) => p.id === + plan_id) - if (idx === -1) + try { + if (data && data.length > 0) { + const firstId = data[0]?.id + if (!plan_id) history.replace(`/plan/${firstId}`) + else { + const idx = data.findIndex((p: any) => p.id === + plan_id) + if (idx === -1) + history.replace(`/plan/${firstId}`) + } } + setTimeout(() => setLoading(false), 300) + } + catch (error) { + console.log(error) } - - setTimeout(() => setLoading(false), 300) }, onError() { setLoading(false) -- Gitee