From 95b8ae0b4ea967c7d934b2c7cac051f03a5bb9b7 Mon Sep 17 00:00:00 2001 From: wulibaibao <13366578180@163.com> Date: Thu, 12 May 2022 18:26:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E7=94=A8=E4=BE=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=93=8D=E4=BD=9C=E6=AD=A5=E9=AA=A4=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=EF=BC=8CformItem=E7=BB=84=E4=BB=B6=E6=8F=90?= =?UTF-8?q?=E5=8F=96=EF=BC=8C=E6=96=B0=E5=BB=BA=E7=94=A8=E4=BE=8B=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 267 ++++++------- src/pages/Suite/components/AddModal.tsx | 181 +++++---- src/pages/Suite/components/Case/Base.tsx | 33 +- src/pages/Suite/components/FormItems.tsx | 361 +++++++++++++++++- src/pages/Suite/components/LeftList/index.tsx | 27 +- .../Suite/components/RightContent/index.tsx | 42 +- src/pages/Suite/utils.ts | 3 + 7 files changed, 665 insertions(+), 249 deletions(-) diff --git a/package.json b/package.json index 49a9e6f..b0310a9 100644 --- a/package.json +++ b/package.json @@ -1,134 +1,137 @@ { - "name": "test-lib-front", - "version": "1.0.0", - "private": true, - "description": "An out-of-box UI solution for enterprise applications", - "scripts": { - "analyze": "cross-env ANALYZE=1 umi build", - "build": "umi build", - "deploy": "npm run build && npm run gh-pages", - "dev": "npm run start:dev", - "gh-pages": "gh-pages -d dist", - "i18n-remove": "pro i18n-remove --locale=zh-CN --write", - "postinstall": "umi g tmp", - "lint": "umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier && npm run tsc", - "lint-staged": "lint-staged", - "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", - "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style", - "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", - "lint:prettier": "prettier -c --write \"src/**/*\" --end-of-line auto", - "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less", - "openapi": "umi openapi", - "precommit": "lint-staged", - "prettier": "prettier -c --write \"src/**/*\"", - "start": "cross-env UMI_ENV=dev umi dev", - "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev", - "start:no-mock": "cross-env MOCK=none UMI_ENV=dev umi dev", - "start:no-ui": "cross-env UMI_UI=none UMI_ENV=dev umi dev", - "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev umi dev", - "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev umi dev", - "pretest": "node ./tests/beforeTest", - "test": "umi test", - "test:all": "node ./tests/run-tests.js", - "test:component": "umi test ./src/components", - "serve": "umi-serve", - "tsc": "tsc --noEmit" - }, - "lint-staged": { - "**/*.less": "stylelint --syntax less", - "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js", - "**/*.{js,jsx,tsx,ts,less,md,json}": [ - "prettier --write" - ] - }, - "browserslist": [ - "> 1%", - "last 2 versions", - "not ie <= 10" - ], - "dependencies": { - "@ant-design/charts": "^0.9.4", - "@ant-design/icons": "^4.7.0", - "@ant-design/pro-descriptions": "^1.6.8", - "@ant-design/pro-form": "^1.18.3", - "@ant-design/pro-layout": "^6.15.3", - "@ant-design/pro-table": "^2.30.8", - "@antv/data-set": "^0.11.0", - "@antv/l7": "^2.3.7", - "@antv/l7-maps": "^2.3.7", - "@antv/l7-react": "^2.1.9", - "@types/react-color": "^3.0.6", - "@types/react-custom-scrollbars": "^4.0.10", - "@types/reactcss": "^1.2.6", - "@types/styled-components": "^5.1.24", - "@umijs/route-utils": "^1.0.36", - "@wangeditor/editor": "^5.0.1", - "@wangeditor/plugin-md": "^1.0.0", - "ahooks": "^3.1.13", - "antd": "^4.19.3", - "bizcharts": "^3.5.3-beta.0", - "bizcharts-plugin-slider": "^2.1.1-beta.1", - "classnames": "^2.2.6", - "clipboard": "^2.0.11", - "gg-editor": "^2.0.2", - "lodash": "^4.17.11", - "lodash-decorators": "^6.0.0", - "moment": "^2.25.3", - "numeral": "^2.0.6", - "nzh": "^1.0.3", - "omit.js": "^2.0.2", - "react": "^17.0.0", - "react-color": "^2.19.3", - "react-custom-scrollbars": "^4.2.1", - "react-dev-inspector": "^1.1.1", - "react-dom": "^17.0.0", - "react-fittext": "^1.0.0", - "react-helmet-async": "^1.0.4", - "react-router": "^4.3.1", - "react-split-pane": "^0.1.92", - "reactcss": "^1.2.3", - "styled-components": "^5.3.5", - "umi": "^3.5.0", - "umi-serve": "^1.9.10" - }, - "devDependencies": { - "@ant-design/pro-cli": "^2.0.2", - "@types/express": "^4.17.0", - "@types/history": "^4.7.2", - "@types/jest": "^26.0.0", - "@types/lodash": "^4.14.144", - "@types/react": "^17.0.0", - "@types/react-dom": "^17.0.0", - "@types/react-helmet": "^6.1.0", - "@umijs/fabric": "^2.6.2", - "@umijs/openapi": "^1.1.14", - "@umijs/plugin-blocks": "^2.0.5", - "@umijs/plugin-esbuild": "^1.0.1", - "@umijs/plugin-openapi": "^1.2.0", - "@umijs/preset-ant-design-pro": "^1.2.0", - "@umijs/preset-dumi": "^1.1.7", - "@umijs/preset-react": "^1.8.17", - "@umijs/yorkie": "^2.0.3", - "carlo": "^0.9.46", - "cross-env": "^7.0.0", - "cross-port-killer": "^1.1.1", - "detect-installer": "^1.0.1", - "enzyme": "^3.11.0", - "eslint": "^7.1.0", - "express": "^4.17.1", - "gh-pages": "^3.0.0", - "jsdom-global": "^3.0.2", - "lint-staged": "^10.0.0", - "mockjs": "^1.0.1-beta3", - "prettier": "^2.3.2", - "puppeteer-core": "^8.0.0", - "stylelint": "^13.0.0", - "typescript": "^4.2.2" - }, - "engines": { - "node": ">=10.0.0" - }, - "gitHooks": { - "commit-msg": "fabric verify-commit" - } + "name": "test-lib-front", + "version": "1.0.0", + "private": true, + "description": "An out-of-box UI solution for enterprise applications", + "scripts": { + "analyze": "cross-env ANALYZE=1 umi build", + "build": "umi build", + "deploy": "npm run build && npm run gh-pages", + "dev": "npm run start:dev", + "gh-pages": "gh-pages -d dist", + "i18n-remove": "pro i18n-remove --locale=zh-CN --write", + "postinstall": "umi g tmp", + "lint": "umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier && npm run tsc", + "lint-staged": "lint-staged", + "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", + "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style", + "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", + "lint:prettier": "prettier -c --write \"src/**/*\" --end-of-line auto", + "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less", + "openapi": "umi openapi", + "precommit": "lint-staged", + "prettier": "prettier -c --write \"src/**/*\"", + "start": "cross-env UMI_ENV=dev umi dev", + "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev", + "start:no-mock": "cross-env MOCK=none UMI_ENV=dev umi dev", + "start:no-ui": "cross-env UMI_UI=none UMI_ENV=dev umi dev", + "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev umi dev", + "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev umi dev", + "pretest": "node ./tests/beforeTest", + "test": "umi test", + "test:all": "node ./tests/run-tests.js", + "test:component": "umi test ./src/components", + "serve": "umi-serve", + "tsc": "tsc --noEmit" + }, + "lint-staged": { + "**/*.less": "stylelint --syntax less", + "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js", + "**/*.{js,jsx,tsx,ts,less,md,json}": [ + "prettier --write" + ] + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 10" + ], + "dependencies": { + "@ant-design/charts": "^0.9.4", + "@ant-design/icons": "^4.7.0", + "@ant-design/pro-descriptions": "^1.6.8", + "@ant-design/pro-form": "^1.18.3", + "@ant-design/pro-layout": "^6.15.3", + "@ant-design/pro-table": "^2.30.8", + "@antv/data-set": "^0.11.0", + "@antv/l7": "^2.3.7", + "@antv/l7-maps": "^2.3.7", + "@antv/l7-react": "^2.1.9", + "@types/react-color": "^3.0.6", + "@types/react-custom-scrollbars": "^4.0.10", + "@types/reactcss": "^1.2.6", + "@types/styled-components": "^5.1.24", + "@umijs/route-utils": "^1.0.36", + "@wangeditor/editor": "^5.0.1", + "@wangeditor/plugin-md": "^1.0.0", + "ahooks": "^3.1.13", + "antd": "^4.19.3", + "bizcharts": "^3.5.3-beta.0", + "bizcharts-plugin-slider": "^2.1.1-beta.1", + "classnames": "^2.2.6", + "clipboard": "^2.0.11", + "gg-editor": "^2.0.2", + "immutability-helper": "^3.1.1", + "lodash": "^4.17.11", + "lodash-decorators": "^6.0.0", + "moment": "^2.25.3", + "numeral": "^2.0.6", + "nzh": "^1.0.3", + "omit.js": "^2.0.2", + "react": "^17.0.0", + "react-color": "^2.19.3", + "react-custom-scrollbars": "^4.2.1", + "react-dev-inspector": "^1.1.1", + "react-dnd": "^14.0.4", + "react-dnd-html5-backend": "^14.0.2", + "react-dom": "^17.0.0", + "react-fittext": "^1.0.0", + "react-helmet-async": "^1.0.4", + "react-router": "^4.3.1", + "react-split-pane": "^0.1.92", + "reactcss": "^1.2.3", + "styled-components": "^5.3.5", + "umi": "^3.5.23", + "umi-serve": "^1.9.10" + }, + "devDependencies": { + "@ant-design/pro-cli": "^2.0.2", + "@types/express": "^4.17.0", + "@types/history": "^4.7.2", + "@types/jest": "^26.0.0", + "@types/lodash": "^4.14.144", + "@types/react": "^17.0.0", + "@types/react-dom": "^17.0.0", + "@types/react-helmet": "^6.1.0", + "@umijs/fabric": "^2.6.2", + "@umijs/openapi": "^1.1.14", + "@umijs/plugin-blocks": "^2.0.5", + "@umijs/plugin-esbuild": "^1.0.1", + "@umijs/plugin-openapi": "^1.2.0", + "@umijs/preset-ant-design-pro": "^1.2.0", + "@umijs/preset-dumi": "^1.1.7", + "@umijs/preset-react": "^1.8.17", + "@umijs/yorkie": "^2.0.3", + "carlo": "^0.9.46", + "cross-env": "^7.0.0", + "cross-port-killer": "^1.1.1", + "detect-installer": "^1.0.1", + "enzyme": "^3.11.0", + "eslint": "^7.1.0", + "express": "^4.17.1", + "gh-pages": "^3.0.0", + "jsdom-global": "^3.0.2", + "lint-staged": "^10.0.0", + "mockjs": "^1.0.1-beta3", + "prettier": "^2.3.2", + "puppeteer-core": "^8.0.0", + "stylelint": "^13.0.0", + "typescript": "^4.2.2" + }, + "engines": { + "node": ">=10.0.0" + }, + "gitHooks": { + "commit-msg": "fabric verify-commit" + } } diff --git a/src/pages/Suite/components/AddModal.tsx b/src/pages/Suite/components/AddModal.tsx index 12a0b60..6cc71b2 100644 --- a/src/pages/Suite/components/AddModal.tsx +++ b/src/pages/Suite/components/AddModal.tsx @@ -1,11 +1,11 @@ import React from "react" -import { Modal, Space, Typography, Button, Form, Input, Select, Radio, Switch, Divider, message, Row } from "antd" +import { Modal, Space, Typography, Button, Form, Input, Select, Radio, Switch, Col, Divider, message, Row } from "antd" import RichTextEditor from "@/components/RichTextEditor" import { deviceArchOptions, deviceTypeOptions, priorityListOptions, runMethodOptions, runModelOptions, testTypeOptions } from "../utils"; import { createCases } from "../services"; import { ToneCaseItem } from "@/pages/Suite/components/ToneCase" import { CustomForm } from "@/components/CustomStyled"; -import { ModuleSelect, PrioritySelect } from "@/pages/Suite/components/FormItems" +import { TagSelect, TestSuiteSelect, ModuleClassSelect, PrioritySelect, OperatStepsTables } from "@/pages/Suite/components/FormItems" type IProps = { onOk: () => void; @@ -16,34 +16,10 @@ type IRefs = { [k: string]: any } -const RICH_EDITER_DEFAULT_TEXT = [ - { - type: "paragrapha", children: [{ text: "工具:", bold: true }] - }, - { - type: "paragrapha", children: [{ text: "", }] - }, - { - type: "paragrapha", children: [{ text: "版本:", bold: true }] - }, - { - type: "paragrapha", children: [{ text: "", }] - }, - { - type: "paragrapha", children: [{ text: "步骤:", bold: true }] - }, - { - type: "paragrapha", children: [{ text: "", }] - }, - { - type: "paragrapha", children: [{ text: "用例说明:", bold: true }] - }, -] - const ReactComponent: React.ForwardRefRenderFunction = (props, ref) => { const { onOk } = props - const [visible, setVisible] = React.useState(false) + const [visible, setVisible] = React.useState(true) const [loading, setLoading] = React.useState(false) const [source, setSource] = React.useState(undefined) const [runMethod, setRunMethod] = React.useState("auto") @@ -135,9 +111,7 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re > = (props, re device_arch: "x86" }} > - - - - - {/* 模块分类 */} - - - - - - - - - - setRunMethod(target.value)} /> - - - { - runMethod === "manual" ? - - - - - - - */} + + + + + + + + + + + + + {/* 功能模块 */} + + + + + + + + + + + + + + + + + + + + setRunMethod(target.value)} /> + + { + runMethod === "manual" ? + + ({ label: i, value: i }))) + } + /> + + ) +} + +type AddProps = { + onOk: (val: any, callback: () => void) => void; + title: string; +} + +export const EditAddBtn: React.FC = ({ onOk, title }) => { + const [editing, setEditing] = React.useState(false) + const [inp, setInp] = React.useState("") + + const defaultState = () => { + setEditing(false) + setInp("") + } + + const hanldeOK = () => { + onOk(inp, defaultState) + } + + React.useEffect(() => { + return () => { + defaultState() + } + }, []) + + if (editing) + return ( + + setInp(target.value)} + style={{ width: "70%", marginRight: 12 }} + /> +
+ +
+
+ +
+
+ ) + + return ( + <> + + setEditing(true)} + > + + + + {title} + + + ) +} + +export const TagSelect: React.FC = (props) => { + const [pendding, setPendding] = React.useState(false) + + const { data, refresh } = useRequest(() => request(`/api/case/labels/`), { initialData: [] }) + const { run } = useRequest( + (name: string) => request(`/api/case/label/`, { method: "post", data: { name } }), + { manual: true, formatResult(res) { return res } } + ) + + const onOk = async (inp: string, callback: () => void) => { + if (!inp) return + if (pendding) return + setPendding(true) + const res = await run(inp) + const { code, msg } = res + setPendding(false) + if (code !== 200) { + message.error(msg) + return + } + refresh() + callback() + } + + return ( + + ({ ...i, value: i.name, label: i.name })) + } + dropdownRender={ + menu => ( + <> + {menu} + + + ) + } + /> + + ) +} + export const ModuleSelect: React.FC = () => { const { state: { modules }, refreshModules } = useCaseProvider() diff --git a/src/pages/Suite/components/LeftList/index.tsx b/src/pages/Suite/components/LeftList/index.tsx index e392b86..4a808f0 100644 --- a/src/pages/Suite/components/LeftList/index.tsx +++ b/src/pages/Suite/components/LeftList/index.tsx @@ -127,7 +127,7 @@ const LeftList: React.FC = (props) => { const addChildrenItem = (list: any, id: number, level: number, data: any) => { return list.reduce((p: any, c: any) => { if (level === c.level && id === c.id) - return p.concat({ ...c, children_nums: c.children_nums + 1, children: c.children ? c.children.concat(data) : [data] }) + return p.concat({ ...c, children_nums: c.children_nums + 1, children: c.children ? c.children.concat(data) : [].concat(data) }) if (c.children) return p.concat({ ...c, children: addChildrenItem(c.children, id, level, data) }) return p.concat(c) @@ -136,19 +136,22 @@ const LeftList: React.FC = (props) => { const createChildModule = async (row: any) => { if (rename) return + const { id, level } = row const $key = `${id}-${level}` - if (!treeExpanedKeys.includes($key)) { - setTreeExpandedKeys(k => k.concat($key)) - } const $id = `${id}-${level + 1}-新分类` - const newData = addChildrenItem(modules, id, level, { id: $id, name: "新分类", parent: id, level: level + 1, children_nums: 0 }) + const $new = { id: $id, name: "新分类", parent: id, level: level + 1, children_nums: 0 } + setRename(`${$id}-${level + 1}`) + + if (!treeExpanedKeys.includes($key)) + setTreeExpandedKeys(k => k.concat($key)) + + const newData = addChildrenItem(modules, id, level, $new) + dispath({ type: "update", - payload: { - modules: newData - } + payload: { modules: newData } }) } @@ -222,7 +225,6 @@ const LeftList: React.FC = (props) => { justify="space-between" align="middle" active={+mod_id === c.id ? 1 : 0} - > { $key !== rename ? @@ -363,8 +365,11 @@ const LeftList: React.FC = (props) => { if (code !== 200) { return message.error(msg) } - dispath({ type: "update", payload: { modules: data } }) - setTreeExpandedKeys([]) + dispath({ + type: "update", payload: { + modules: modules.concat(data) + } + }) setEdit(false) } diff --git a/src/pages/Suite/components/RightContent/index.tsx b/src/pages/Suite/components/RightContent/index.tsx index bbb369e..3d0f232 100644 --- a/src/pages/Suite/components/RightContent/index.tsx +++ b/src/pages/Suite/components/RightContent/index.tsx @@ -1,6 +1,6 @@ import React from "react" import { Button, Divider, Empty, Input, Row, Space, Typography, message } from "antd" -import { DownOutlined, UpOutlined } from "@ant-design/icons" +import { DownOutlined, UpOutlined, RightOutlined } from "@ant-design/icons" // import SuiteList from "./SuiteList" @@ -16,7 +16,7 @@ import { useParams } from "umi" import CaseChild from "@/pages/Suite/components/Case" import { useCaseProvider } from "../../provider" import Loading from "@/components/Loading" -import SplitPane, { Pane } from "react-split-pane" +import SplitPane from "react-split-pane" import styled from "styled-components" import { useSize } from "ahooks" import SuiteTable from "./SuiteTable" @@ -91,13 +91,14 @@ const RightContent: React.FC = (props) => { const defaultParams = { mod_id } const { refreshModules, state } = useCaseProvider() - const { modules } = state const [loading, setLoading] = React.useState(true) const [cases, setCases] = React.useState([]) const [selectCases, setSelectCases] = React.useState([]) const [activeCase, setActiveCase] = React.useState(null) + const [source, setSource] = React.useState(undefined) + const [filter, setFilter] = React.useState(false) const [inp, setInp] = React.useState("") @@ -111,12 +112,14 @@ const RightContent: React.FC = (props) => { const getModalCase = async (params: any = pageParams) => { setLoading(true) - const { code, data } = await queryModalCases(params) + const response = await queryModalCases(params) + const { code, data } = response if (code !== 200) { setLoading(false) - return setCases([]) + return } setCases(data) + setSource(response) setLoading(false) } @@ -172,26 +175,35 @@ const RightContent: React.FC = (props) => { message.success('下载成功'); } - const currnetModule = React.useMemo(() => { - if (mod_id) { - const idx = modules.findIndex((i: any) => i.id === +mod_id) - return modules[idx] - } - return null - }, [mod_id, modules]) - const contentRef = React.useRef(null) as any const contentSize = useSize(contentRef) + const currentPath = React.useMemo(() => { + if (!source) return [] + const { path } = source + const list = (path as any).split("/").filter(Boolean) + return list + }, [source]) + return (
+ {currentPath.map((i: string, idx: any) => ( + + + {i} + + { + currentPath.length - 1 > idx && + + } + + ))} - {currnetModule ? `${currnetModule.name}` : `所有用例`} + ({cases.length}) - ({currnetModule ? currnetModule.count : cases.length}) diff --git a/src/pages/Suite/utils.ts b/src/pages/Suite/utils.ts index 06729e1..555c7a1 100644 --- a/src/pages/Suite/utils.ts +++ b/src/pages/Suite/utils.ts @@ -57,6 +57,9 @@ export const deviceTypeMap = arrayToMap(deviceTypeOptions) export const deviceArchOptions = [ { label: "x86", value: "x86" }, { label: "arch64", value: "arch64" }, + { label: "riscv", value: "risc-v" }, + { label: "loongarch", value: "loongarch" }, + { label: "noarch", value: "noarch" }, { label: "其他", value: "others" }, ] export const deviceArchMap = arrayToMap(deviceArchOptions) -- Gitee From d3f5288203001e1b7219af8cbae2425bbd49bc3c Mon Sep 17 00:00:00 2001 From: wulibaibao <13366578180@163.com> Date: Fri, 13 May 2022 18:08:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E7=94=A8=E4=BE=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=A1=A8=E5=8D=95=E8=A1=A5=E5=85=A8=EF=BC=8C=E5=9B=9E?= =?UTF-8?q?=E6=98=BE=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Suite/components/AddModal.tsx | 39 +++---- src/pages/Suite/components/Case/Base.tsx | 62 ++++++----- src/pages/Suite/components/Case/Edit.tsx | 41 ++++--- src/pages/Suite/components/Case/index.tsx | 10 +- src/pages/Suite/components/FormItems.tsx | 102 +++++++++++------- .../RightContent/SelectSuiteModal.tsx | 17 +-- .../components/RightContent/SuiteTable.tsx | 7 +- src/pages/Suite/components/ToneCase.tsx | 4 +- src/pages/Suite/utils.ts | 2 +- 9 files changed, 153 insertions(+), 131 deletions(-) diff --git a/src/pages/Suite/components/AddModal.tsx b/src/pages/Suite/components/AddModal.tsx index 6cc71b2..3a5c6eb 100644 --- a/src/pages/Suite/components/AddModal.tsx +++ b/src/pages/Suite/components/AddModal.tsx @@ -1,11 +1,11 @@ import React from "react" import { Modal, Space, Typography, Button, Form, Input, Select, Radio, Switch, Col, Divider, message, Row } from "antd" -import RichTextEditor from "@/components/RichTextEditor" import { deviceArchOptions, deviceTypeOptions, priorityListOptions, runMethodOptions, runModelOptions, testTypeOptions } from "../utils"; import { createCases } from "../services"; import { ToneCaseItem } from "@/pages/Suite/components/ToneCase" import { CustomForm } from "@/components/CustomStyled"; import { TagSelect, TestSuiteSelect, ModuleClassSelect, PrioritySelect, OperatStepsTables } from "@/pages/Suite/components/FormItems" +import { useParams } from "umi" type IProps = { onOk: () => void; @@ -19,16 +19,19 @@ type IRefs = { const ReactComponent: React.ForwardRefRenderFunction = (props, ref) => { const { onOk } = props - const [visible, setVisible] = React.useState(true) + const { mod_id } = useParams() as any + + const [visible, setVisible] = React.useState(false) const [loading, setLoading] = React.useState(false) const [source, setSource] = React.useState(undefined) const [runMethod, setRunMethod] = React.useState("auto") + const [steps, setSteps] = React.useState([]) React.useImperativeHandle(ref, () => ({ show(_: any) { setSource(_) setVisible(true) - form.setFieldsValue(_) + form.setFieldsValue({ ..._, parent: mod_id ? + mod_id : undefined }) } })) @@ -51,27 +54,27 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re const handleOk = async () => { if (loading) return - setLoading(true) form.validateFields() .then(async (values: any) => { - const vm = richEditerRef.current - values.custom_fields = vm.getText() !== "" ? vm.children : null - + console.log(values) + const { device_arch } = values if (runMethod !== "manual") { if (!isCheckedCase) { - setLoading(false) message.error("请选择T-One用例!") return } values.tone_case = isCheckedCase.tone_case_id values.base_fields = isCheckedCase } + setLoading(true) const { msg, code } = await createCases({ ...values, + device_arch: device_arch.toString(), + steps }) + setLoading(false) if (code !== 200) { - setLoading(false) message.error(msg) return } @@ -80,7 +83,7 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re onOk() message.success("添加成功") }).catch(err => { - setLoading(false) + console.log(err) }) } @@ -90,12 +93,6 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re setIsCheckedCase(conf) } - const richEditerRef = React.useRef(null) as any - - const handleChange = (vm: any) => { - richEditerRef.current = vm - } - return ( = (props, re run_method: "auto", is_available: true, device_type: "vm", - device_arch: "x86" }} > @@ -138,11 +134,11 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re - + - + @@ -165,8 +161,8 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re - - + + - */} - - + - */} - - 运行步骤 + 操作步骤 - + + + + + + + -
- -
) } diff --git a/src/pages/Suite/components/Case/index.tsx b/src/pages/Suite/components/Case/index.tsx index 9e9a29e..26f5612 100644 --- a/src/pages/Suite/components/Case/index.tsx +++ b/src/pages/Suite/components/Case/index.tsx @@ -15,10 +15,10 @@ type IProps = { } const priorityText = new Map([ - [0, "不可缺少"], + [0, "系统不可缺少"], [1, "重要而不必需"], - [2, "偏一点功能"], - [3, "可靠性等功能"] + [2, "相对非核心功能"], + [3, "系统可靠性等功能"] ]) const Case: React.FC = (props) => { @@ -151,6 +151,10 @@ const Case: React.FC = (props) => { }
+ + 描述:{currentCase?.desc} + + ({ id: i, - desc: "", + step: "", result: "" }))) @@ -65,20 +64,28 @@ const DraggableBodyRow = ({ index, moveRow, className, style, ...restProps }: an ); }; -export const OperatStepsTables: React.FC = () => { - const [source, setSource] = React.useState(OPERAT_STEP_TABLE_SOURCE) +type StepTableProps = { + dataSource: any[]; + onChange: (arr: any) => void +} + +export const OperatStepsTables: React.FC = ({ dataSource, onChange }) => { + const [source, setSource] = React.useState(dataSource && dataSource.length !== 0 ? dataSource : OPERAT_STEP_TABLE_SOURCE) - const handleFieldChange = (row: any, field: string, value: string) => { - const { id } = row; + const handleFieldChange = (index: any, field: string, value: string) => { setSource( - source.reduce((pre, cur, index) => { - if (cur.id === id) - return pre.concat({ ...cur, [field]: value, id: index + 1 }) - return pre.concat({ ...cur, id: index + 1 }) + source.reduce((pre, cur, idx) => { + if (index === idx) + return pre.concat({ ...cur, [field]: value }) + return pre.concat(cur) }, []) ) } + React.useEffect(() => { + onChange(source) + }, [source]) + const columns: TableColumnProps[] = [{ title: '', width: 16, @@ -89,50 +96,49 @@ export const OperatStepsTables: React.FC = () => {
) }, { - dataIndex: "id", title: "编号", - render(_) { - return {_} + render(_, row, index) { + return {index + 1} } }, { - dataIndex: "desc", + dataIndex: "step", title: "步骤描述", - render(_, row) { + render(_, row, index) { return ( handleFieldChange(row, "desc", target.value)} + onChange={({ target }) => handleFieldChange(index, "step", target.value)} /> ) } }, { dataIndex: "result", title: "预期结果", - render(_, row) { + render(_, row, index) { return ( handleFieldChange(row, "result", target.value)} + onChange={({ target }) => handleFieldChange(index, "result", target.value)} /> ) } }, { title: "操作", - render(row) { - return remove(row)}>删除 + render(_, row, idx) { + return remove(idx)}>删除 } }] - const remove = (row: any) => { - setSource(refreshIds(source.filter((i) => i.id !== row.id))) + const remove = (index: number) => { + setSource(source.filter((i, idx) => idx !== index)) } const add = () => { - const data = refreshIds(source.concat({ desc: "", result: "" })) + const data = source.concat({ desc: "", result: "" }) setSource(data) } @@ -145,24 +151,19 @@ export const OperatStepsTables: React.FC = () => { const moveRow = React.useCallback( (dragIndex, hoverIndex) => { const dragRow = source[dragIndex]; - setSource( - refreshIds( - source.reduce((pre, cur, index) => { - if (index === hoverIndex) - return pre.concat(cur, dragRow) - if (index === dragIndex) - return pre - return pre.concat(cur) - }, []) - ) + source.reduce((pre, cur, index) => { + if (index === hoverIndex) + return pre.concat(cur, dragRow) + if (index === dragIndex) + return pre + return pre.concat(cur) + }, []) ); }, [source], ); - const refreshIds = (data: any[]) => data.map((i, idx) => ({ ...i, id: idx + 1 })) - return ( @@ -206,7 +207,7 @@ export const PrioritySelect: React.FC = () => ( const getPaths = (list: any[]) => list.reduce((pre: any[], cur: any): any[] => { if (cur.children) return pre.concat(getPaths(cur.children)) - return pre.concat(cur.path) + return pre.concat({ label: cur.path, value: cur.id }) }, []) const flatten = (obj: any) => { @@ -224,7 +225,7 @@ export const ModuleClassSelect: React.FC = () => { ({ ...i, value: i.name, label: i.name })) } @@ -324,7 +326,7 @@ export const TagSelect: React.FC = (props) => { menu => ( <> {menu} - + ) } @@ -455,4 +457,28 @@ export const ModuleSelect: React.FC = () => { ) +} + +const CaseTagStyled = styled.span` + height: 16px; + width: 31px; + border: 1px solid #0085FF; + border-radius: 2px; + margin-right: 2px; + span { + font-size: 10px; + color: #0085FF; + transform: scale(.8); + display: inline-block; + } +` + +export const CaseTag: React.FC = ({ children }) => { + return ( + + + {children} + + + ) } \ No newline at end of file diff --git a/src/pages/Suite/components/RightContent/SelectSuiteModal.tsx b/src/pages/Suite/components/RightContent/SelectSuiteModal.tsx index 3e47226..904ec7c 100644 --- a/src/pages/Suite/components/RightContent/SelectSuiteModal.tsx +++ b/src/pages/Suite/components/RightContent/SelectSuiteModal.tsx @@ -46,16 +46,7 @@ const SelectSuiteModal: React.ForwardRefRenderFunction = (props, React.useImperativeHandle(ref, () => ({ show(_: any) { - // console.log(_) setIsCheckedCaseKey(_) - // for (let x = 0; x < suiteCases.length; x++) { - // const { test_case_list, id } = suiteCases[x] - // const idx = test_case_list.findIndex((i: any) => i.id === _) - // if (~idx) { - // setTreeExpandedKeys([`${id}-${x}`]) - // break; - // } - // } setVisible(true) } })) @@ -99,15 +90,15 @@ const SelectSuiteModal: React.ForwardRefRenderFunction = (props, children: data.map((item: any) => ({ key: item.tone_case_id, title: () => { - const { suite_id, suite_name, test_type, tone_case_id, tone_name } = item + const { suite_id, suite_name, test_type, tone_case_id, tone_case_name } = item return ( onCheck({ - suite_id, suite_name, test_type, tone_case_id, tone_name + suite_id, suite_name, test_type, tone_case_id, tone_case_name })} > - {item.tone_name} + {tone_case_name} ) }, diff --git a/src/pages/Suite/components/RightContent/SuiteTable.tsx b/src/pages/Suite/components/RightContent/SuiteTable.tsx index 84373c7..62351cb 100644 --- a/src/pages/Suite/components/RightContent/SuiteTable.tsx +++ b/src/pages/Suite/components/RightContent/SuiteTable.tsx @@ -5,6 +5,7 @@ import { TableColumnProps, Typography } from "antd" import React from "react" import styled from "styled-components" import { priorityColorMap } from "@/pages/Suite/utils" +import { CaseTag } from "@/pages/Suite/components/FormItems" type PriorityLevelColorProps = { color: string; @@ -54,7 +55,11 @@ const SuiteTable: React.FC = (props) => { title: "标签", width: 150, render(row) { - return + if (row.labels !== "") { + const list = row.labels.split(",").map((i: any) => {i}) + return + } + return "-" } }, { title: "优先级", diff --git a/src/pages/Suite/components/ToneCase.tsx b/src/pages/Suite/components/ToneCase.tsx index d2cce59..303901d 100644 --- a/src/pages/Suite/components/ToneCase.tsx +++ b/src/pages/Suite/components/ToneCase.tsx @@ -53,8 +53,8 @@ export const ToneCaseItem: React.FC = (props) => { style={{ maxWidth: size?.width ? size.width - 30 : "unset", marginRight: 4 }} > - {isChecked?.suite_name}: - {isChecked?.tone_name} + {isChecked?.suite_name}: + {isChecked?.tone_case_name} onOk(undefined)} /> diff --git a/src/pages/Suite/utils.ts b/src/pages/Suite/utils.ts index 555c7a1..451a99c 100644 --- a/src/pages/Suite/utils.ts +++ b/src/pages/Suite/utils.ts @@ -60,7 +60,7 @@ export const deviceArchOptions = [ { label: "riscv", value: "risc-v" }, { label: "loongarch", value: "loongarch" }, { label: "noarch", value: "noarch" }, - { label: "其他", value: "others" }, + // { label: "其他", value: "others" }, ] export const deviceArchMap = arrayToMap(deviceArchOptions) -- Gitee