You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
4.3 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <div id="app" :class="{ 'screen-route-app': isScreenRoute }">
  3. <div v-if="isScreenRoute" class="screen-route-shell">
  4. <div class="screen-route-scale" :style="screenScaleStyle">
  5. <transition name="fade" mode="out-in">
  6. <router-view></router-view>
  7. </transition>
  8. </div>
  9. </div>
  10. <transition v-else name="fade" mode="out-in">
  11. <router-view></router-view>
  12. </transition>
  13. <!-- 全局审批通知管理器 -->
  14. <approval-notification-manager v-if="!isScreenRoute" ref="approvalNotificationManager"></approval-notification-manager>
  15. </div>
  16. </template>
  17. <script>
  18. import ApprovalNotificationManager from '@/components/ApprovalNotificationManager.vue'
  19. import { SCREEN_DESIGN_HEIGHT, SCREEN_DESIGN_WIDTH, setScreenScale } from '@/utils/screenAdapt'
  20. export default {
  21. name: 'App',
  22. components: {
  23. ApprovalNotificationManager
  24. },
  25. data() {
  26. return {
  27. query: {},
  28. version: '1.3.3',
  29. isScreenRoute: false,
  30. screenScale: 1
  31. }
  32. },
  33. computed: {
  34. screenScaleStyle() {
  35. const scale = this.screenScale > 0 ? this.screenScale : 1
  36. const percent = `${100 / scale}%`
  37. return {
  38. width: percent,
  39. height: percent,
  40. transform: `scale(${scale})`,
  41. transformOrigin: 'left top'
  42. }
  43. }
  44. },
  45. watch: {
  46. '$route.path': {
  47. immediate: true,
  48. handler() {
  49. this.syncScreenRouteMode()
  50. }
  51. }
  52. },
  53. created () {
  54. this.versionReload()
  55. },
  56. mounted() {
  57. window.addEventListener('resize', this.handleWindowResize)
  58. this.syncScreenRouteMode()
  59. },
  60. beforeDestroy() {
  61. window.removeEventListener('resize', this.handleWindowResize)
  62. document.body.classList.remove('screen-route-body')
  63. setScreenScale(1)
  64. },
  65. methods: {
  66. /**
  67. * 版本检查及自动刷新
  68. */
  69. versionReload(){
  70. let version = this.version //版本号(每次上线前需要更新下版本号)
  71. console.log('最新系统版本: ',version)
  72. console.log('当前系统版本: ',this.version)
  73. let versionLocal = localStorage.getItem('_version_');
  74. if(version!=versionLocal){
  75. localStorage.setItem('_version_',version);
  76. this.version=versionLocal;
  77. location.reload();
  78. }
  79. },
  80. isScreenPath(path) {
  81. return /^\/screen-/.test(String(path || ''))
  82. },
  83. syncScreenRouteMode() {
  84. this.isScreenRoute = this.isScreenPath(this.$route && this.$route.path)
  85. this.updateScreenBodyClass()
  86. this.updateScreenScale()
  87. },
  88. updateScreenBodyClass() {
  89. if (this.isScreenRoute) {
  90. document.body.classList.add('screen-route-body')
  91. } else {
  92. document.body.classList.remove('screen-route-body')
  93. }
  94. },
  95. handleWindowResize() {
  96. this.updateScreenScale()
  97. },
  98. updateScreenScale() {
  99. if (!this.isScreenRoute) {
  100. this.screenScale = 1
  101. setScreenScale(1)
  102. return
  103. }
  104. const width = window.innerWidth || document.documentElement.clientWidth || SCREEN_DESIGN_WIDTH
  105. const height = window.innerHeight || document.documentElement.clientHeight || SCREEN_DESIGN_HEIGHT
  106. const scaleX = width / SCREEN_DESIGN_WIDTH
  107. const scaleY = height / SCREEN_DESIGN_HEIGHT
  108. const scale = Math.min(scaleX, scaleY)
  109. this.screenScale = scale > 0 ? Number(scale.toFixed(6)) : 1
  110. setScreenScale(this.screenScale)
  111. },
  112. /**
  113. * 手动触发审批通知检查供外部调用
  114. */
  115. checkApprovalNotifications() {
  116. if (this.$refs.approvalNotificationManager) {
  117. this.$refs.approvalNotificationManager.manualCheck()
  118. }
  119. },
  120. /**
  121. * 清除指定申请单的通知记录审批完成后调用
  122. * @param {string} applyNo - 申请单号
  123. */
  124. clearApprovalNotification(applyNo) {
  125. if (this.$refs.approvalNotificationManager) {
  126. this.$refs.approvalNotificationManager.clearNotification(applyNo)
  127. }
  128. }
  129. }
  130. }
  131. </script>
  132. <style>
  133. body.screen-route-body {
  134. overflow: hidden;
  135. background: #000;
  136. }
  137. #app.screen-route-app {
  138. width: 100vw;
  139. height: 100vh;
  140. overflow: hidden;
  141. }
  142. .screen-route-shell {
  143. width: 100%;
  144. height: 100%;
  145. overflow: hidden;
  146. }
  147. .screen-route-scale {
  148. width: 100%;
  149. height: 100%;
  150. overflow: hidden;
  151. will-change: transform;
  152. }
  153. .screen-route-scale > * {
  154. width: 100% !important;
  155. height: 100% !important;
  156. }
  157. </style>