diff --git a/src/pages/Suite/components/AddModal.tsx b/src/pages/Suite/components/AddModal.tsx index fc3d2273140613676f257909de7cde7141d32b88..23a3fcdf6c88942ff68e7672899aa86183ba0e10 100644 --- a/src/pages/Suite/components/AddModal.tsx +++ b/src/pages/Suite/components/AddModal.tsx @@ -10,6 +10,7 @@ import { createCases } from "../services"; import { createModule } from "@/pages/Suite/services" import { ReactComponent as CancelIcon } from "@/assets/case/cancel.svg" import { ReactComponent as ConfirmIcon } from "@/assets/case/confirm.svg" +import { ToneCaseItem } from "@/pages/Suite/components/ToneCase" type IProps = { onOk: () => void; @@ -315,27 +316,7 @@ const ReactComponent: React.ForwardRefRenderFunction = (props, re - + setRunMethod(target.value)} /> + + { + runMethod === "manual" ? + + + - + -
+
diff --git a/src/pages/Suite/components/Case/index.tsx b/src/pages/Suite/components/Case/index.tsx index 8fb4c434c1111e707d09f76e8b70628a96ec6034..b6141373dc78dfc52111a7ec834414eb447ad147 100644 --- a/src/pages/Suite/components/Case/index.tsx +++ b/src/pages/Suite/components/Case/index.tsx @@ -6,7 +6,7 @@ import Logo from "@/assets/logo.png" import { ReactComponent as Priority } from "@/assets/case/priority.svg" import BaseChild from "./Base" import EditChild from "./Edit" -import { renameCase, deleteCases } from "@/pages/Suite/services" +import { renameCase, deleteCases, updateCase } from "@/pages/Suite/services" import { IDomEditor } from "@wangeditor/editor" type IProps = { @@ -44,16 +44,23 @@ const Case: React.FC = (props) => { const { code, msg } = await deleteCases({ id: [currentCase.id] }) if (code !== 200) return message.error(msg) refresh() + message.success("操作成功!") } const handleSave = () => { - const infoForm: FormInstance = editInfoRef.current + const infoForm: FormInstance & any = editInfoRef.current infoForm.validateFields() - .then((values) => { - console.log(values) - const { vm }: any = infoForm - const custom_fields = vm.children - + .then(async (values: any) => { + const params = infoForm?.formResultChangeValue() + + const { code, msg } = await updateCase(currentCase.id, params) + if (code !== 200) { + message.error(msg) + return + } + refresh() + message.success("操作成功!") + handleCancelSave() }) } @@ -65,8 +72,6 @@ const Case: React.FC = (props) => { const handleCancelSave = () => { setEditing(false) - const infoForm: FormInstance = editInfoRef.current - infoForm.resetFields() } return ( diff --git a/src/pages/Suite/components/RightContent/index.tsx b/src/pages/Suite/components/RightContent/index.tsx index b6f1f7488f71cd52679dd9ef9f3a616fc67570e7..a578636a0fe6a0f2e242b20456816d01fa70527e 100644 --- a/src/pages/Suite/components/RightContent/index.tsx +++ b/src/pages/Suite/components/RightContent/index.tsx @@ -56,7 +56,12 @@ const RightContent: React.FC = (props) => { } setCases(data) if (data.length > 0) { - if (!activeCase || !data.map((i: any) => i.id).includes(activeCase.id)) + if (activeCase && activeCase.id) { + const idx = data.findIndex((i: any) => i.id === activeCase.id) + if (!idx) + setActiveCase(data[idx]) + } + else setActiveCase(data[0]) } setLoading(false) diff --git a/src/pages/Suite/components/ToneCase.tsx b/src/pages/Suite/components/ToneCase.tsx new file mode 100644 index 0000000000000000000000000000000000000000..07e2ad5df8fad986b06fbc3256f31dea207d9fbe --- /dev/null +++ b/src/pages/Suite/components/ToneCase.tsx @@ -0,0 +1,60 @@ +import React from "react" +import { Form, Space, Typography } from "antd" +import styled from "styled-components" +import SelectSuiteModal from "./RightContent/SelectSuiteModal" +import { CloseOutlined } from "@ant-design/icons" + +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); + } +` +type IProps = { + [k: string]: any +} + +export const ToneCaseItem: React.FC = (props) => { + const { onChange, defaultValue = null } = props + const ref = React.useRef(null) as any + const [isChecked, setIsChecked] = React.useState(defaultValue) + + React.useEffect(() => { + setIsChecked(defaultValue) + }, [defaultValue]) + + const onOk = (conf: any) => { + setIsChecked(conf) + onChange(conf) + } + + return <> + + { + isChecked ? + ref.current?.show(isChecked?.id)} + > + + {isChecked?.name} + + + : + ref.current?.show()}> + + + + + 添加用例 + + + + } + + + +} \ No newline at end of file diff --git a/src/pages/Suite/services.ts b/src/pages/Suite/services.ts index eb9922c1be03766f6abbac2af919d39c318ec56a..5227b9a9f287411bfaa001795e66318ad160133c 100644 --- a/src/pages/Suite/services.ts +++ b/src/pages/Suite/services.ts @@ -42,8 +42,8 @@ export const moveCase = async (data: { parent: any, cases: any[] }) => { } //更新测试用例 -export const editCase = async (case_id: string, data: ICase) => { - return request(`/api/case/edit/${case_id}`, { method: "delete", data }) +export const updateCase = async (case_id: string, data: ICase) => { + return request(`/api/case/edit/${case_id}`, { method: "post", data }) } export type IModule = {