ezhizao_zx 5 månader sedan
förälder
incheckning
6d7c58074b
4 ändrade filer med 69 tillägg och 19 borttagningar
  1. 21 0
      src/main.js
  2. 22 5
      src/utils/request.js
  3. 6 0
      src/views/dialog/notification.vue
  4. 20 14
      src/views/index.vue

+ 21 - 0
src/main.js

@@ -23,6 +23,7 @@ import App from './App'
 import store from './store'
 import router from './router'
 import directive from './directive' // directive
+import Notification from './views/dialog/notification.vue'
 
 // 注册指令
 import plugins from './plugins' // plugins
@@ -88,6 +89,26 @@ app.component('ImagePreview', ImagePreview)
 app.component('RightToolbar', RightToolbar)
 app.component('Editor', Editor)
 app.component('CountTo', CountTo)
+app.component('Notification', Notification)
+
+// const globalDialogInstance = app._context.components.Notification;
+
+// app.config.globalProperties.$showDialog = function (data) {
+//   const instance = globalDialogInstance.setup();
+//   console.log(data)
+//   // instance.$el.innerHTML = data;
+//   document.body.appendChild(instance.$el);
+//   instance.open();
+// };
+
+// app.mixin({
+//   onBeforeMount() {
+//     globalVueInstance = this;
+//   },
+//   onUnmounted() {
+//     globalVueInstance = null;
+//   }
+// });
 
 app.use(router)
 app.use(store)

+ 22 - 5
src/utils/request.js

@@ -6,6 +6,8 @@ import { tansParams, blobValidate } from '@/utils/ruoyi'
 import cache from '@/plugins/cache'
 import { saveAs } from 'file-saver'
 import useUserStore from '@/store/modules/user'
+import notification from '../views/dialog/notification.vue'
+// import { getCurrentInstance } from 'vue';
 // import { reject } from 'lodash-es'
 
 let downloadLoadingInstance
@@ -45,9 +47,10 @@ service.interceptors.request.use(
     // appKey 根据该值,获取菜单,不要修改
     config.headers['appKey'] = 'ezhizao-identity'
     let requestable = true
+    let notifications = []
     // 当登录状态为已登录时才可以获取公告
     console.log(config)
-    if (getToken() && !isToken && tenantInfo && config.url != '/ezhizao-dms-sys/getInfo') {
+    if (getToken() && !isToken && tenantInfo && config.url != '/ezhizao-dms-sys/getInfo' && config.url != '/ezhizao-dms-sys/getRouters') {
       // 所有条件都具备的情况下需先请求公告
       let url = import.meta.env.VITE_APP_BASE_API + '/business/notification/getUnshowedNotification'
       const res = await axios({
@@ -63,7 +66,8 @@ service.interceptors.request.use(
       if (res.data.code == 200) {
 
       } else if (res.data.code == 202) {
-        // requestable = false
+        notifications = res.data.data
+        requestable = false
       }
     }
     // get请求映射params参数
@@ -96,7 +100,7 @@ service.interceptors.request.use(
         }
       }
     }
-    return requestable ? config : Promise.reject(new Error('请求被拦截,系统正在更新维护'))
+    return requestable ? config : Promise.reject({ message: 'SHOW NOTIFICATION', data: notifications })
   },
   (error) => {
     console.log(error)
@@ -150,14 +154,17 @@ service.interceptors.response.use(
     }
   },
   (error) => {
-    console.log('err' + error)
-    let { message } = error
+    // console.log(error)
+    // console.log('err' + error)
+    let { message, data } = error
     if (message == 'Network Error') {
       message = '后端接口连接异常'
     } else if (message.includes('timeout')) {
       message = '数据过多查询超时'
     } else if (message.includes('Request failed with status code')) {
       message = '系统接口' + message.substr(message.length - 3) + '异常'
+    } else if (message.includes('SHOW NOTIFICATION')) {
+      showDialog(data)
     }
     ElMessage({ message: message, type: 'error', duration: 5 * 1000 })
     return Promise.reject(error)
@@ -228,4 +235,14 @@ export function downloadPdf(url, params, filename, config) {
   })
 }
 
+function showDialog(message) {
+  // const instance = getCurrentInstance();
+  // console.log(instance)
+  // if (instance && instance.proxy && instance.proxy.showNotification) {
+  //   instance.proxy.showNotification(message);
+  // } else {
+  //   console.error('Cannot show dialog: current instance is null or $showDialog is not available.');
+  // }
+}
+
 export default service

+ 6 - 0
src/views/dialog/notification.vue

@@ -13,4 +13,10 @@
 const title = ref('测试公告')
 const content = ref('测试公告内容')
 const visible = ref(false)
+const open = () => {
+  visible.value = true
+}
+const close = () => {
+  visible.value = false
+}
 </script>

+ 20 - 14
src/views/index.vue

@@ -41,22 +41,19 @@
   </div>
 </template>
 <script setup>
-import totalIcon2 from '@/assets/images/dashboard-total-icon-2.png'
-import totalIcon3 from '@/assets/images/dashboard-total-icon-3.png'
+// import totalIcon2 from '@/assets/images/dashboard-total-icon-2.png'
+// import totalIcon3 from '@/assets/images/dashboard-total-icon-3.png'
 import { parseTime } from '@/utils/tools.js'
 
 import {
-  getProductionPlanDetailSubDetails,
-  getProcessDetailsByTechnicalProcessId,
-  getSubDetailProcessEquipments
 } from '@/api/business/productionTask'
 
-import { index } from '@/api/business/production'
+// import { index } from '@/api/business/production'
 
 //import { getDashboardStatistics } from '@/api/ss/visitor/general.js'
 //import { getTenant } from '@/utils/auth'
 
-import * as echarts from 'echarts'
+// import * as echarts from 'echarts'
 const statisticOption = reactive({
   title: {
     text: '企业与标识每日注册统计',
@@ -180,32 +177,39 @@ const handleChangeMonth = (val) => {
   font-size: 16px;
   justify-content: space-between;
 }
-.dashboard-total-item > .dashboard-total-item-label {
+
+.dashboard-total-item>.dashboard-total-item-label {
   flex: 1;
   display: flex;
   flex-direction: column;
   line-height: 32px;
   padding: 0 16px;
 }
-.dashboard-total-item > .dashboard-total-item-label > span:first-child {
+
+.dashboard-total-item>.dashboard-total-item-label>span:first-child {
   font-weight: bold;
   font-size: 18px;
 }
-.dashboard-total-item > .dashboard-total-item-label > span:last-child {
+
+.dashboard-total-item>.dashboard-total-item-label>span:last-child {
   color: #6b6b6b;
 }
-.dashboard-total-item > .dashboard-total-item-label > span:last-child > span:first-child {
+
+.dashboard-total-item>.dashboard-total-item-label>span:last-child>span:first-child {
   margin-right: 8px;
 }
-.dashboard-total-item > .dashboard-total-item-label > span:last-child > span:last-child {
+
+.dashboard-total-item>.dashboard-total-item-label>span:last-child>span:last-child {
   color: #4367df;
 }
-.dashboard-total-item > .number-label {
+
+.dashboard-total-item>.number-label {
   font-size: 40px;
   margin-left: 16px;
   font-weight: bold;
   color: #5a6ac3;
 }
+
 .statistic-container {
   position: relative;
   margin-top: 24px;
@@ -215,12 +219,14 @@ const handleChangeMonth = (val) => {
   padding-bottom: 8px;
   padding-left: 4px;
 }
-.statistic-container > .month-picker {
+
+.statistic-container>.month-picker {
   position: absolute;
   top: 16px;
   left: 240px;
   line-height: 24px;
 }
+
 .item-statistic-container {
   height: 560px;
 }