Ver código fonte

fix(user): table reset

Lind 3 anos atrás
pai
commit
2303b813c2

+ 1 - 1
package.json

@@ -70,7 +70,7 @@
     "@formily/reactive-react": "2.0.0-rc.17",
     "@formily/shared": "2.0.0-rc.17",
     "@jetlinks/pro-list": "^1.10.8",
-    "@jetlinks/pro-table": "^2.63.8",
+    "@jetlinks/pro-table": "^2.63.9",
     "@umijs/route-utils": "^1.0.36",
     "ahooks": "^2.10.9",
     "antd": "^4.17.0-alpha.9",

+ 8 - 1
src/components/SearchComponent/index.tsx

@@ -39,6 +39,7 @@ interface Props<T> {
   field: ProColumns<T>[];
   onSearch: (params: any) => void;
   target?: string;
+  onReset?: () => void;
 }
 
 const termType = [
@@ -57,7 +58,12 @@ const termType = [
 const service = new Service();
 const defaultTerm = { termType: 'like' };
 
-const SearchComponent = <T extends Record<string, any>>({ field, onSearch, target }: Props<T>) => {
+const SearchComponent = <T extends Record<string, any>>({
+  field,
+  onSearch,
+  target,
+  onReset,
+}: Props<T>) => {
   const intl = useIntl();
   const [expand, setExpand] = useState<boolean>(true);
   const initForm = server2Ui([{ terms: [defaultTerm], type: 'and' }, { terms: [defaultTerm] }]);
@@ -325,6 +331,7 @@ const SearchComponent = <T extends Record<string, any>>({ field, onSearch, targe
     temp.terms2 = temp.terms2.map(() => defaultTerm);
     setInitParams(temp);
     await form.reset();
+    onReset?.();
   };
   return (
     <div>

+ 5 - 1
src/pages/system/User/index.tsx

@@ -181,8 +181,12 @@ const User = observer(() => {
       <Card style={{ marginBottom: '20px' }}>
         <SearchComponent
           field={columns}
-          onSearch={(data) => setParam({ terms: data })}
+          onSearch={(data) => setParam({ terms: data, total: null })}
           target="user"
+          onReset={() => {
+            setParam({});
+            actionRef.current?.reset?.();
+          }}
         />
       </Card>
       <ProTable<UserItem>