diff --git a/src/pages/Suite/components/AddModal.tsx b/src/pages/Suite/components/AddModal.tsx index 23a3fcdf6c88942ff68e7672899aa86183ba0e10..988425777c3719d12ea8d9f189da7ec2732bab0e 100644 --- a/src/pages/Suite/components/AddModal.tsx +++ b/src/pages/Suite/components/AddModal.tsx @@ -27,18 +27,6 @@ const CustomForm = styled(Form)` } ` -const Casetag = styled.div` - background-color: rgba(0,0,0,0.05); - border-radius: 2px; - padding: 3px 6px; - display: inline-block; - cursor: pointer; - :hover { - color: rgba(24,144,255,1); - background-color: rgba(24,144,255,0.05); - } -` - const ModuleSelect: React.FC = () => { const { state: { modules }, refreshModules } = useCaseProvider() @@ -186,7 +174,7 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re form.validateFields() .then(async (values: any) => { - if (runMethod !== "manual") { + if (runMethod === "manual") { if (!isCheckedCase) { setLoading(false) message.error("请选择T-One用例!") @@ -273,6 +261,7 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re } + onCancel={handleCancel} > = (props, re { - runMethod === "manual" ? + runMethod !== "manual" ? : diff --git a/src/pages/Task/Detail/index.tsx b/src/pages/Task/Detail/index.tsx index 3f68cbe9a87d1b47c0ab0b30e19499f1119f9f2b..538c2cb8fb84c3e369ef5cc5114bbf52f4d99049 100644 --- a/src/pages/Task/Detail/index.tsx +++ b/src/pages/Task/Detail/index.tsx @@ -1,47 +1,114 @@ import React from "react" -import { Space, Row, Typography, Button, Breadcrumb } from "antd" +import { Space, Row, Typography, Button, Breadcrumb, Col, Spin, Empty } from "antd" import { useParams, Link } from "umi" +import { useRequest } from "ahooks" +import { viewTask } from "../services" +import InsertRunResult from "../components/InsertRunResult" +import TestResultTable from "../components/TestResultTable" +import { createEditor } from "@wangeditor/editor" const TaskDetail: React.FC = () => { + const { task_id } = useParams() as any - const handleInsertResult = () => { + const { data: source, loading, refresh } = useRequest(() => viewTask(task_id), {}) - } + const inertResultModalRef = React.useRef(null) as any + if (loading) return + if (!source) return + + const { data } = source return ( -
- - - - - +
+
+ + + + 测试任务 - - - 任务详情 - - - - - { } - - - - - - 基本信息 - - - - - - - 测试结果 - - - - -
+ + 任务详情 + + { + data.run_method === "manual" && + ( + !data.run_result ? + : + + ) + } + + + + + + {data?.name} + + + + + + 测试方案: + {data.plan} + + + + + 运行方式: + {data.run_method} + + + + + 创建人: + {data.owner} + + + + + 创建时间: + {data.gmt_created} + + + + + 描述: + {data.desc} + + + + +
+
+ { + data.run_method === "manual" && + ( + data.run_result ? +
: + + ) + } + { + data.run_method !== "manual" && + + } +
+ +
) } diff --git a/src/pages/Task/components/AddTaskModal.tsx b/src/pages/Task/components/AddTaskModal.tsx index b3e47528e34a63ec63d2190398e200b7eef37741..073b0063f7c6d6e71d0cccd2d4790277c0454f8b 100644 --- a/src/pages/Task/components/AddTaskModal.tsx +++ b/src/pages/Task/components/AddTaskModal.tsx @@ -1,6 +1,16 @@ import React from "react" -import { Modal, Form, Input, Space, Button, Select, Radio } from "antd" +import { Modal, Form, Input, Space, Button, Select, Radio, message } from "antd" +import { useRequest } from "ahooks"; +import { request } from "umi"; +import { runMethodOptions } from "@/pages/Suite/utils" +import styled from "styled-components" +import { createTask } from "../services"; +const CustomForm = styled(Form)` + .ant-form-item { + margin-bottom: 12px; + } +` type IProps = { onOk: () => void; onCancel?: () => void; @@ -16,6 +26,22 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re const [visible, setVisible] = React.useState(false) const [loading, setLoading] = React.useState(false) const [source, setSource] = React.useState(undefined) + const [runMethod, setRunMethod] = React.useState("manual") + + const { data: plans } = useRequest(() => request(`/api/plan`), {}) + const { data: cases } = useRequest(() => request(`/api/case/`), {}) + + const plansOptions = React.useMemo(() => { + if (plans && plans.data.length > 0) + return plans.data.map((i: any) => ({ label: i.name, value: i.id })) + return [] + }, [plans]) + + const casesOptions = React.useMemo(() => { + if (cases && cases.data.length > 0) + return cases.data.map((i: any) => ({ label: i.name, value: i.id })) + return [] + }, [cases]) React.useImperativeHandle(ref, () => ({ show(_: any) { @@ -31,52 +57,76 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re setVisible(false) setLoading(false) setSource(undefined) + setRunMethod("manual") + form.resetFields() } const handleOk = async () => { if (loading) return setLoading(true) - onOk() - handleCancel() + + form.validateFields() + .then(async (values) => { + const { code, msg } = await createTask(values) + if (code !== 200) { + setLoading(false) + message.error(msg) + return + } + + onOk() + handleCancel() + }).catch((err) => { + setLoading(false) + }) } return ( - +
} onCancel={handleCancel} - onOk={handleOk} > -
- + - - - - - - - 自动 - 手动 - + + setRunMethod(target.value)} /> + + + +