lanjianrong пре 4 година
родитељ
комит
9bf3a33c96
1 измењених фајлова са 36 додато и 33 уклоњено
  1. 36 33
      src/pages/Hr/Notification/index.jsx

+ 36 - 33
src/pages/Hr/Notification/index.jsx

@@ -26,7 +26,7 @@ const Notification = () => {
     if (code === consts.RET_CODE.SUCCESS) {
       setState({
         ...state,
-        message: state.message.concat(message),
+        message: params?.current === 1 ? message : state.message.concat(message),
         total,
         loading: false,
         hasMore: total > params.current * state.pageSize,
@@ -38,42 +38,45 @@ const Notification = () => {
     initData({ current: 1 })
   }, [])
   const loadMoreData = () => {
+    console.log('11')
     initData({ current: state.current + 1 })
   }
   return (
     <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}
-          next={loadMoreData}
-          hasMore={state.hasMore}
-          loader={<Skeleton avatar paragraph={{ rows: 1 }} active />}
-          endMessage={<Divider plain>别再滚啦,已是尽头</Divider>}
-          scrollableTarget="scrollableDiv"
-        >
-          <List
-            itemLayout="horizontal"
-            // pagination={{ pageSize: 5 }}
-            dataSource={state.message}
-            renderItem={item => (
-              <List.Item key={item.id}>
-                <List.Item.Meta
-                  avatar={<Avatar src={item.avatar} />}
-                  title={<a href="#">{item.title}</a>}
-                  description={
-                    <div className="mb-1">
-                      <Tag color="purple">{msgTypeEnum[item.msgType]}</Tag> '发布于',
-                      <span className="ml-2">全公司</span>
-                    </div>
-                  }
-                />
-                {item.content}
-                <div className="mt-1 text-hex-aaa">{item.createTime}</div>
-              </List.Item>
-            )}
-          />
-        </InfiniteScroll>
+      <span className="py-4">通知中心</span>
+      <div style={{ height: 'calc(100vh - 96px - 3.5rem)', overflowY: 'auto' }}>
+        <div id="scrollableDiv">
+          <InfiniteScroll
+            dataLength={state.message?.length}
+            next={loadMoreData}
+            hasMore={state.hasMore}
+            loader={<Skeleton avatar paragraph={{ rows: 1 }} active />}
+            endMessage={<Divider plain>别再滚啦,已是尽头</Divider>}
+            scrollableTarget="scrollableDiv"
+          >
+            <List
+              itemLayout="horizontal"
+              // pagination={{ pageSize: 5 }}
+              dataSource={state.message}
+              renderItem={item => (
+                <List.Item key={item.id}>
+                  <List.Item.Meta
+                    avatar={<Avatar src={item.avatar} />}
+                    title={<a href="#">{item.title}</a>}
+                    description={
+                      <div className="mb-1">
+                        <Tag color="purple">{msgTypeEnum[item.msgType]}</Tag> '发布于',
+                        <span className="ml-2">全公司</span>
+                      </div>
+                    }
+                  />
+                  {item.content}
+                  <div className="mt-1 text-hex-aaa">{item.createTime}</div>
+                </List.Item>
+              )}
+            />
+          </InfiniteScroll>
+        </div>
       </div>
     </div>
   )