ezhizao_zx 4 miesięcy temu
rodzic
commit
5df6ab87e8

+ 5 - 1
src/store/modules/settings.js

@@ -21,7 +21,8 @@ const useSettingsStore = defineStore(
       dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle,
       genLotBySub: false,
       showMessage: false,
-      showNotification: false
+      showNotification: false,
+      closeNotification: false
     }),
     actions: {
       // 修改布局设置
@@ -36,6 +37,9 @@ const useSettingsStore = defineStore(
         this.title = title
         useDynamicTitle();
       },
+      setCloseNotification(value) {
+        this.closeNotification = value
+      },
       initGenLotBySub(config) {
         getConfigKey('business.production.genLotBySub').then(res => {
           // console.log(res)

+ 7 - 2
src/utils/request.js

@@ -8,6 +8,7 @@ import { saveAs } from 'file-saver'
 import useUserStore from '@/store/modules/user'
 import useSettingsStore from '@/store/modules/settings'
 import Notification from '../plugins/notification'
+import auth from '@/plugins/auth'
 // import emitter from '../eventBus'
 // import { getCurrentInstance } from 'vue';
 // import { reject } from 'lodash-es'
@@ -66,7 +67,7 @@ service.interceptors.request.use(
     // 当登录状态为已登录时才可以获取公告
     // console.log(config)
     // console.log(checkBeforeUrl(config.url))
-    if (getToken() && !isToken && tenantInfo && !checkBeforeUrl(config.url)) {
+    if (getToken() && !isToken && tenantInfo && !checkBeforeUrl(config.url) && !useSettingsStore().closeNotification) {
       // 所有条件都具备的情况下需先请求公告
       let url = import.meta.env.VITE_APP_BASE_API + '/business/notification/getUnshowedNotification'
       const showNotification = useSettingsStore().showNotification
@@ -84,7 +85,11 @@ service.interceptors.request.use(
         if (res.data.code == 200) {
         } else if (res.data.code == 202) {
           notifications = res.data.data
-          requestable = false
+          if (auth.hasPermi('business:notification:close')) {
+            Notification(notifications[0])
+          } else {
+            requestable = false
+          }
           // showDialog()
         }
       }

+ 6 - 2
src/views/dialog/updateAnnouncement.vue

@@ -1,6 +1,6 @@
 <template>
   <!-- 公告 -->
-  <el-dialog v-model="visible" :show-close="canClose()" width="500" :close-on-click-modal="false"
+  <el-dialog v-model="visible" :show-close="canClose()" width="500" :close-on-click-modal="false" @close="close"
     :close-on-press-escape="false">
     <template #header>
       <div class="my-header">
@@ -16,6 +16,7 @@ import { ElDialog } from 'element-plus';
 import auth from '@/plugins/auth'
 import 'element-plus/theme-chalk/el-dialog.css'; // 引入 el-dialog 的样式
 import 'element-plus/theme-chalk/el-button.css';
+import useSettingsStore from '@/store/modules/settings'
 // import { ElDialog } from 'element-plus';
 export default {
   name: 'Notification',
@@ -40,13 +41,16 @@ export default {
     const open = () => {
       visible.value = true
     }
+    const close = () => {
+      useSettingsStore().setCloseNotification(true)
+    }
     const canClose = () => {
       if (auth.hasPermi('business:notification:close')) {
         return true
       }
       return false
     }
-    return { visible, canClose, open }
+    return { visible, canClose, open, close }
   }
 }