Forráskód Böngészése

chore: 调整pda菜单表

xyh 2 éve
szülő
commit
d15c8b3a67

+ 13 - 11
packages/app/src/pages/pda-menu/filter/index.tsx

@@ -1,24 +1,26 @@
 import {FilterButtonGroup, FilterField, FilterFieldWrapper} from '@components';
 import {Card} from 'antd';
-import {FC, useState} from 'react';
-import {useContextSection, useTableSearchEvent} from '@hooks';
+import {FC} from 'react';
+import {useContextSection, useFilterField, useTableSearchToolEvents} from '@hooks';
 import {context, searchContext} from '../context';
 
 const Filter: FC = function () {
-  const [value, onChange] = useState('');
-  const onSearch = useTableSearchEvent(context, {name: value});
-  const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
+  const [field, {onChange, resetState}] = useFilterField({name: ''}, true);
+  const [, {onSearch, onReset}] = useTableSearchToolEvents(context, field, {
+    resetCallback: resetState,
+  });
+  const {isSearching} = useContextSection(searchContext, state => state[0]);
 
   return (
     <Card>
       <FilterFieldWrapper>
-        <FilterField name='menuName' label='菜单名称' value={value} onChange={onChange} />
-        <FilterButtonGroup
-          onSearch={onSearch}
-          onRefresh={refetch}
-          offset={12}
-          isSearching={isSearching}
+        <FilterField
+          name='menuName'
+          label='菜单名称'
+          value={field.name}
+          onChange={onChange('name')}
         />
+        <FilterButtonGroup onSearch={onSearch} isSearching={isSearching} onReset={onReset} />
       </FilterFieldWrapper>
     </Card>
   );

+ 1 - 2
packages/app/src/pages/pda-menu/table/hooks.tsx

@@ -6,7 +6,6 @@ import {
   DOUBLE_BTN_WIDTH,
   HUGE_TABLE_WIDTH,
   MIDDLE_TABLE_WIDTH,
-  MINIMAL_TABLE_WIDTH,
   NORMAL_TABLE_WIDTH,
   SMALL_TABLE_WIDTH,
 } from '@utils';
@@ -17,7 +16,7 @@ const tableColumns: ColumnsType<MenuListData> = [
     title: '菜单ID',
     dataIndex: 'url',
     key: 'url',
-    width: MINIMAL_TABLE_WIDTH,
+    width: SMALL_TABLE_WIDTH,
   },
   {
     title: '菜单名称',

+ 2 - 2
packages/app/src/pages/pda-menu/table/index.tsx

@@ -12,7 +12,7 @@ const TableList: FC = function () {
     return {pId: '0', name};
   });
 
-  const [{data, count}, {refetch}] = useQueryTableList({
+  const [{data, count, isFetching}, {refetch}] = useQueryTableList({
     queryFn: getPDAMenuList,
     params,
     pageContext,
@@ -23,7 +23,7 @@ const TableList: FC = function () {
   return (
     <>
       <Card className='table-wrapper'>
-        <TableTools onClick={onAdd} />
+        <TableTools onAdd={onAdd} onRefresh={refetch} isRefreshing={isFetching} />
 
         <Table
           data-testid='menu_table'