Przeglądaj źródła

fix: 通知中心滚动加载

outaozhen 4 lat temu
rodzic
commit
7c49598416
2 zmienionych plików z 17 dodań i 27 usunięć
  1. 1 1
      src/locales/zh-CN/menu.js
  2. 16 26
      src/pages/Hr/Notification/index.jsx

+ 1 - 1
src/locales/zh-CN/menu.js

@@ -18,7 +18,7 @@ export default {
   'menu.product.cloud.gs': '大司空概算',
   'menu.hr': '人资',
   'menu.hr.employee': '部门与员工',
-  'menu.hr.notification': '信息中心',
+  'menu.hr.notification': '通知中心',
   'menu.login': '登录',
   'menu.exception.403': '403',
   'menu.exception.404': '404',

+ 16 - 26
src/pages/Hr/Notification/index.jsx

@@ -17,47 +17,38 @@ const Notification = () => {
     pageSize: 10,
     total: 0
   })
-  // const loadMoreData = () => {
-  //   if (state.message.length >= 500) {
-  //     setState({ hasMore: false })
-  //     return
-  //   }
-  //   setTimeout(() => {
-  //     setState({
-  //       message: state.message.concat()
-  //     })
-  //   }, 500)
-  // }
-  const initData = async () => {
+  const initData = async params => {
     setState({ ...state, loading: true })
     const {
       data: { message = [] },
       code = -1
-    } = await queryMessage()
+    } = await queryMessage({ ...params })
     if (code === consts.RET_CODE.SUCCESS) {
-      setState({ ...state, message, loading: false })
+      setState({
+        ...state,
+        message,
+        loading: false,
+        current: params?.current || 1
+      })
     }
   }
   useEffect(() => {
-    initData()
+    initData({ current: 1, pageSize: 10 })
   }, [])
   // console.log(state.message.length)
   const loadMoreData = () => {
     if (state.total === state.message.length) {
       return
     }
-    setState(
-      {
-        loading: true,
-        current: state.current + 1
-      },
-      () => {
-        initData()
-      }
-    )
+    setState({
+      loading: true,
+      current: state.current + 1,
+      pageSize: state.pageSize
+    })
   }
   return (
-    <div className="bg-[#ffffff] rounded-md px-6 pb-6">
+    <div className="bg-hex-ffffff rounded-md px-6 pb-6">
+      <h3 className="pt-5 pb-4">通知中心</h3>
       <div id="scrollableDiv" style={{ height: 700, overflow: 'auto' }}>
         <InfiniteScroll
           dataLength={state.message.length}
@@ -67,7 +58,6 @@ const Notification = () => {
           endMessage={<Divider plain>别再滚啦,已是尽头</Divider>}
           scrollableTarget="scrollableDiv">
           <List
-            header={<div>信息中心</div>}
             itemLayout="horizontal"
             // pagination={{ pageSize: 5 }}
             dataSource={state.message}