From e81ede5d3b9fbbbb51ab83f4626e8acf535c9445 Mon Sep 17 00:00:00 2001 From: sahara Date: Fri, 17 Nov 2023 11:11:01 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RightContent/AvatarDropdown.tsx | 12 ++++++-- src/pages/Plan/CreatePage.tsx | 4 ++- src/pages/Plan/components/LeftList/index.tsx | 19 ++++++++---- .../Product/TestProduct/CreateProduct.tsx | 8 +++-- src/pages/Product/TestProduct/ProductCard.tsx | 2 +- src/pages/Product/TestProduct/services.ts | 4 +-- src/pages/Suite/components/AddModal.tsx | 16 +++++++++- .../components/FilterForm/CaseFilter.tsx | 29 +++++++++++++++++-- .../Suite/components/FilterForm/index.tsx | 3 +- src/pages/Suite/components/LeftList/index.tsx | 1 - .../RightContent/BatchDeleteCase.tsx | 2 +- .../components/RightContent/SuiteTable.tsx | 1 + .../Suite/components/RightContent/index.tsx | 8 ++--- src/pages/Suite/components/ToneCase.tsx | 21 +++++++++++--- src/pages/Suite/services.ts | 4 +++ src/pages/Suite/utils.ts | 2 +- src/pages/Sys/Suite/components/AddModal.tsx | 5 ++++ src/pages/Sys/Tags/index.tsx | 2 +- 18 files changed, 109 insertions(+), 34 deletions(-) diff --git a/src/components/RightContent/AvatarDropdown.tsx b/src/components/RightContent/AvatarDropdown.tsx index c86f429..1f61aff 100644 --- a/src/components/RightContent/AvatarDropdown.tsx +++ b/src/components/RightContent/AvatarDropdown.tsx @@ -38,13 +38,19 @@ const loginOut = async () => { return } //@ts-ignore + // else if (["group"].includes(window.webSiteEnv)) { + // const { data } = await request(`/api/user/logout`) + // window.location.href = data + // return + // } + else if (["group"].includes(window.webSiteEnv)) { - const { data } = await request(`/api/user/logout`) - window.location.href = data + await request(`/api/user/logout`) + window.location.href = '/' return } - else request(`/api/user/logout`) + else await request(`/api/auth/logout/`) if (window.location.pathname !== '/login' && !redirect) { history.replace({ pathname: '/login', diff --git a/src/pages/Plan/CreatePage.tsx b/src/pages/Plan/CreatePage.tsx index 6311d98..c67d7a5 100644 --- a/src/pages/Plan/CreatePage.tsx +++ b/src/pages/Plan/CreatePage.tsx @@ -52,11 +52,13 @@ const TestPlan: React.FC = (props) => { if (isEditPage) { const { code: c, msg: m } = await updateTestPlanDetail(plan_id, params) if (c !== 200) return message.error(m) - const { code, msg } = await updateTestPlanTasks(plan_id, { tasks: tasksAndCases?.tasks.map((i: any) => i.id) }) + if (!!tasksAndCases?.tasks.length){ + const { code, msg } = await updateTestPlanTasks(plan_id, { tasks: tasksAndCases.tasks.map((i: any) => i.id) }) if (code !== 200) { message.error(msg) return } + } onOk() refresh() message.success("操作成功") diff --git a/src/pages/Plan/components/LeftList/index.tsx b/src/pages/Plan/components/LeftList/index.tsx index 8f973b6..c90f8b0 100644 --- a/src/pages/Plan/components/LeftList/index.tsx +++ b/src/pages/Plan/components/LeftList/index.tsx @@ -37,9 +37,15 @@ const PlanLeftContent: React.FC = () => { const createModalRef = React.useRef<{ show: () => void }>(null) - const handleSearch = async (e: any) => { - if (e.code === "Enter") run({ content: e.target.value }) - } + // const handleSearch = async (e: any) => { + // if (e.code === "Enter") run({ content: e.target.value }) + // } + + // const handleIconSearch = async (e: any) => { + // run({ content: e.target.value }) + // } + + const onSearch = (value: string) => run({ content: value }); return (
@@ -50,14 +56,15 @@ const PlanLeftContent: React.FC = () => { > {`测试方案 (${planList?.length || 0})`} - } + // onKeyUp={handleSearch} + onSearch={onSearch} + // suffix={} /> { access.canTester() && diff --git a/src/pages/Product/TestProduct/CreateProduct.tsx b/src/pages/Product/TestProduct/CreateProduct.tsx index 53dce93..d42ba72 100644 --- a/src/pages/Product/TestProduct/CreateProduct.tsx +++ b/src/pages/Product/TestProduct/CreateProduct.tsx @@ -64,8 +64,10 @@ const CreateProduct: React.ForwardRefRenderFunction = (props, ref) ref, () => ({ async show(_: any = undefined) { if (Object.prototype.toString.call(_) === "[object Number]") { - const editSource = await getOneProduct(_) - form.setFieldsValue(editSource) + const editSource:any = await getOneProduct(_) + const result = data?.find((item:any) => item.id === editSource?.origin_plan_id) + const editData = Object.prototype.toString.call(result) === '[object Object]' ? editSource : { ...editSource, origin_plan_id: null } + form.setFieldsValue(editData) } run() setVisible(true) @@ -141,7 +143,7 @@ const CreateProduct: React.ForwardRefRenderFunction = (props, ref) > + children: ({ label: title, value: id }) )} + options={planList?.map(({ title, id }: any) => ({ label: title, value: id }) )} filterOption={ (input, option: any) => { return ( -- Gitee From fd8a1e605234eef6ffc56fd9dd06cc6ab3b49822 Mon Sep 17 00:00:00 2001 From: sahara Date: Tue, 12 Dec 2023 14:32:53 +0800 Subject: [PATCH 4/4] fix: interface request modification --- .../components/FilterForm/CaseFilter.tsx | 27 ++----------------- .../Suite/components/RightContent/index.tsx | 27 +++++++++++++++---- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/pages/Suite/components/FilterForm/CaseFilter.tsx b/src/pages/Suite/components/FilterForm/CaseFilter.tsx index b5fdd79..65b5aa0 100644 --- a/src/pages/Suite/components/FilterForm/CaseFilter.tsx +++ b/src/pages/Suite/components/FilterForm/CaseFilter.tsx @@ -5,7 +5,6 @@ import FilterForm from "." import { useCaseProvider } from "../../provider"; import styled from "styled-components" import { useSize } from "ahooks"; -import { queryReviewer } from "../../services"; const dateFormat = 'YYYY-MM-DD'; @@ -19,31 +18,9 @@ const FilterFormWrapper = styled.div` ` const CaseFilter: React.FC<{ [k: string]: any }> = (props) => { - const { onSizeChange } = props + const { onSizeChange, users } = props const { suites, labels } = useCaseProvider() - const [ users, setUsers ] = useState([]) - - const queryUsers = async () => { - try { - const { data, code, msg } = await queryReviewer({ page_num: 1, page_size: 100 }) - if( code === 200 ) { - let arr = data.splice(0) - arr = arr.map((item:any) => ({ - label: item.user_name, - value: item.user_name - })) - setUsers(arr) - return - } - return message.error(msg) - } catch (err) { - console.log(err) - } - } - - useEffect(() => { - queryUsers() - },[]) + const columns: any = [ { label: "测试套", diff --git a/src/pages/Suite/components/RightContent/index.tsx b/src/pages/Suite/components/RightContent/index.tsx index 7108c67..66f7e70 100644 --- a/src/pages/Suite/components/RightContent/index.tsx +++ b/src/pages/Suite/components/RightContent/index.tsx @@ -7,8 +7,7 @@ import BatchDeleteCase from "./BatchDeleteCase" // import FilterForm from "./FilterForm" import AddModal from "../AddModal" import ExportCase from "./ExportCase" - -import { exportCases, queryModalCases } from "../../services" +import { exportCases, queryModalCases, queryReviewer } from "../../services" import { useParams, useAccess } from "@umijs/max" import CaseChild from "@/pages/Suite/components/Case" @@ -96,7 +95,7 @@ const RightContent: React.FC = () => { const [cases, setCases] = React.useState([]) const [selectCases, setSelectCases] = React.useState([]) const [activeCase, setActiveCase] = React.useState(null) - + const [users, setUsers] = React.useState([]) const [source, setSource] = React.useState(undefined) const [filter, setFilter] = React.useState(false) @@ -124,6 +123,24 @@ const RightContent: React.FC = () => { setSource(response) } + const queryUsers = async () => { + const { data, code, msg } = await queryReviewer({ page_num: 1, page_size: 100 }) + try { + if( code === 200 && !!data.length) { + let arr = data.splice(0) + arr = arr.map((item:any) => ({ + label: item.user_name, + value: item.user_name + })) + setUsers(arr) + return + } + return message.error(msg) + } catch (err) { + console.log(err) + } + } + React.useEffect(() => { if (cases.length > 0) { if (activeCase && typeof activeCase.id === "number") { @@ -185,11 +202,11 @@ const RightContent: React.FC = () => { }, [source]) const handleFilterChange = (val: any) => { + queryUsers() const params = Object.keys(val).reduce((pre: any, cur: any) => { const ctx = val[cur] if (cur === "created_at" && ctx) { const [start_time, end_time] = ctx - console.log('crx',ctx) pre["start_time"] = moment(start_time).format(dateFormat) pre["end_time"] = moment(end_time).format(dateFormat) } @@ -303,7 +320,7 @@ const RightContent: React.FC = () => { filter && <> - + } -- Gitee