فهرست منبع

refactor: 在表格使用搜索时重置表格回到第一页

lanjianrong 4 سال پیش
والد
کامیت
5e75a1de7a
3فایلهای تغییر یافته به همراه17 افزوده شده و 5 حذف شده
  1. 1 0
      src/pages/Customer/Business/index.jsx
  2. 3 0
      src/pages/Product/Cloud/index.jsx
  3. 13 5
      src/pages/Product/Lock/LockStore/index.jsx

+ 1 - 0
src/pages/Customer/Business/index.jsx

@@ -43,6 +43,7 @@ const Business = ({ dispatch, groupList, shouldUpdate, loading }) => {
 
   const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
   const handleSearch = value => {
+    tRef.current?.reloadAndRest()
     setState({ ...state, params: { ...state.params, search: value } })
   }
 

+ 3 - 0
src/pages/Product/Cloud/index.jsx

@@ -18,6 +18,7 @@ export const roadpricingEnum = {
 
 const Cloud = () => {
   const { pathname = '' } = useLocation()
+  const tRef = useRef()
   const columnStateType = pathname?.match(/\/([^/]*)$/)[1]?.toUpperCase()
   const dispatch = useDispatch()
   const { toggleDrawer, setDrawerProps } = useModal()
@@ -257,11 +258,13 @@ const Cloud = () => {
   }
 
   const handleSearch = value => {
+    tRef.current?.reloadAndRest()
     setState({ ...state, params: { ...state.params, search: value } })
   }
 
   return (
     <BasicTable
+      actionRef={tRef}
       rowKey={record => record._id}
       columnStateType={columnStateType}
       params={state.params}

+ 13 - 5
src/pages/Product/Lock/LockStore/index.jsx

@@ -115,6 +115,7 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
   })
 
   const handleSearch = value => {
+    tRef.current?.reloadAndRest()
     setState({ ...state, params: { ...state.params, search: value } })
   }
 
@@ -196,7 +197,8 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
       render: (keyNum, record) => (
         <span
           onClick={() => showDrawer(record.id)}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {keyNum}
         </span>
       )
@@ -273,7 +275,10 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
       title: '销售时间',
       dataIndex: 'sellTime',
       key: 'sellTime',
-      width: 90
+      filterDropdown: filterDropdownProps => <FilterDatePicker {...filterDropdownProps} />,
+      filters: true,
+      sorter: true,
+      width: 100
     },
     {
       title: '维护状态',
@@ -307,7 +312,8 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
       render: (text, record) => (
         <span
           onClick={() => showDrawerClient(record.clientId)}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {text}
         </span>
       )
@@ -321,7 +327,8 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
       render: (text, record) => (
         <span
           onClick={() => showCompanyDrawer(record.customerId)}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {text}
         </span>
       )
@@ -333,7 +340,8 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
       render: (text, record) => (
         <span
           onClick={() => showDrawerResponsible(record.responsibleId)}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {text}
         </span>
       )