From 8e0f0843bb1981a527d21e267cb4d12d5e5cfe33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=87=91?= Date: Fri, 26 Apr 2024 17:16:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96request=E5=8C=85=E8=A3=85?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=20=E5=AE=8C=E5=96=84role=E7=9A=84=E5=A4=9A?= =?UTF-8?q?=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/switch/index.tsx | 1 - src/locales/lang/pages/system/roles/en-US.ts | 5 +- src/locales/lang/pages/system/roles/zh-CN.ts | 6 +- src/pages/system/roles/index.tsx | 9 ++- src/pages/system/roles/store.ts | 4 +- src/request.ts | 18 +++-- src/service/base.ts | 6 +- src/utils/tree.ts | 99 +++++++++++++++------------- 8 files changed, 83 insertions(+), 65 deletions(-) diff --git a/src/components/switch/index.tsx b/src/components/switch/index.tsx index 626049b..846c931 100644 --- a/src/components/switch/index.tsx +++ b/src/components/switch/index.tsx @@ -3,7 +3,6 @@ import { Switch as AntSwitch, SwitchProps } from 'antd' export const Switch = ({ value, ...props }: SwitchProps) => { - console.log(value, props) return ( ) diff --git a/src/locales/lang/pages/system/roles/en-US.ts b/src/locales/lang/pages/system/roles/en-US.ts index fa21c42..fd5d255 100644 --- a/src/locales/lang/pages/system/roles/en-US.ts +++ b/src/locales/lang/pages/system/roles/en-US.ts @@ -10,7 +10,10 @@ export default { description: 'Remarks', option: 'Operation', }, + search: { + placeholder: 'Please enter a name' + }, edit: { title: 'Edit Role', }, -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/locales/lang/pages/system/roles/zh-CN.ts b/src/locales/lang/pages/system/roles/zh-CN.ts index 226f1ee..50ba023 100644 --- a/src/locales/lang/pages/system/roles/zh-CN.ts +++ b/src/locales/lang/pages/system/roles/zh-CN.ts @@ -9,9 +9,11 @@ export default { sort: '排序', description: '备注', option: '操作', - }, - edit:{ + search: { + placeholder: '请输入名称' + }, + edit: { title: '编辑角色', }, } \ No newline at end of file diff --git a/src/pages/system/roles/index.tsx b/src/pages/system/roles/index.tsx index d72a458..5bc17ce 100644 --- a/src/pages/system/roles/index.tsx +++ b/src/pages/system/roles/index.tsx @@ -1,4 +1,5 @@ import Switch from '@/components/switch' +import { IMenu } from '@/types/menus' import { ActionType, PageContainer, @@ -9,7 +10,7 @@ import { import { createLazyFileRoute } from '@tanstack/react-router' import { useStyle } from './style.ts' import { memo, useEffect, useMemo, useRef, useState } from 'react' -import { useAtom, useAtomValue, useSetAtom } from 'jotai' +import { useAtom, useAtomValue } from 'jotai' import { deleteRoleAtom, pageAtom, @@ -42,7 +43,7 @@ const MenuTree = (props: any) => { return + checkedKeys={getTreeCheckedStatus(menuList!, value)}/> } @@ -54,7 +55,7 @@ const Roles = memo(() => { const [ form ] = Form.useForm() const actionRef = useRef() const [ page, setPage ] = useAtom(pageAtom) - const setSearch = useSetAtom(searchAtom) + const [ search, setSearch ] = useAtom(searchAtom) const [ roleIds, setRoleIds ] = useAtom(roleIdsAtom) const { data, isLoading, isFetching, refetch } = useAtomValue(rolesAtom) const { isPending, mutate, isSuccess } = useAtomValue(saveOrUpdateRoleAtom) @@ -178,9 +179,11 @@ const Roles = memo(() => { }} toolbar={{ search: { + loading: isFetching && !!search.key, onSearch: (value: string) => { setSearch({ key: value }) }, + placeholder: t('system.roles.search.placeholder') }, actions: [