Просмотр исходного кода

feat: 新增通知中心增加权限

outaozhen 4 лет назад
Родитель
Сommit
d695f67431

+ 14 - 0
src/pages/Hr/Notification/components/AddMessage.jsx

@@ -103,6 +103,20 @@ const AddMessage = props => {
             ) : null
           }
         </ProFormDependency>
+        <ProFormDependency name={['msgType', 'media']}>
+          {({ msgType, media }) =>
+            msgType === msgTypeEnum.NotificationOne && media === mediaType.VersionUpdate ? (
+              <ProFormRadio.Group
+                name="refresh"
+                rules={[{ required: true, message: '请选择刷新机制' }]}
+                options={[
+                  { label: '手动刷新', value: 0 },
+                  { label: '强制刷新', value: 1 }
+                ]}
+              />
+            ) : null
+          }
+        </ProFormDependency>
       </ModalForm>
     </div>
   )

+ 10 - 7
src/pages/Hr/Notification/index.jsx

@@ -4,7 +4,7 @@ import InfiniteScroll from 'react-infinite-scroll-component'
 import { queryMessageList, sendMessage } from '@/services/staff'
 import AddMessage from './components/AddMessage'
 import consts from '@/consts'
-import { useRequest, useIntl } from 'umi'
+import { useRequest, useIntl, useAccess } from 'umi'
 import { useModal } from '@/components/Modal'
 import MessageDrawer from './components/MessageDrawer'
 import ws, { CmdType } from '@/utils/ws'
@@ -76,21 +76,25 @@ const Notification = () => {
     toggleDrawer()
   }
 
+  const hasPerm = useAccess()?.validatePermByType('notification_add')
+
   return (
     <div className="bg-hex-ffffff rounded-md px-6 pb-6">
       <div className="flex justify-between items-center">
         <h4 className="py-4 text-xl">通知中心</h4>
-        <AddMessage onConfirm={trySendMessage} />
+        {hasPerm ? <AddMessage onConfirm={trySendMessage} /> : null}
       </div>
-      <div id="scrollableDiv" style={{ height: 'calc(100vh - 125px - 3.5rem)', overflowY: 'auto' }}>
+      <div
+        id="scrollableDiv"
+        className="pr-4"
+        style={{ height: 'calc(100vh - 125px - 3.5rem)', overflowY: 'auto' }}>
         <InfiniteScroll
           dataLength={state.total}
           next={loadMoreData}
           hasMore={state.hasMore}
           loader={<Skeleton avatar paragraph={{ rows: 1 }} active />}
           endMessage={<Divider plain>别再滚啦,已是尽头</Divider>}
-          scrollableTarget="scrollableDiv"
-        >
+          scrollableTarget="scrollableDiv">
           <List
             itemLayout="horizontal"
             // pagination={{ pageSize: 5 }}
@@ -102,8 +106,7 @@ const Notification = () => {
                   title={
                     <span
                       className="cursor-pointer text-primary"
-                      onClick={() => showMessageDrawer(item)}
-                    >
+                      onClick={() => showMessageDrawer(item)}>
                       {item.title}
                     </span>
                   }