AppMain.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <section class="app-main" :style="{ paddingTop: show ? '140px' : '80px' }">
  3. <div class="app-main-view">
  4. <transition name="fade-transform" mode="out-in">
  5. <keep-alive v-if="$route.name">
  6. <router-view :key="$route.name" />
  7. </keep-alive>
  8. <router-view v-else />
  9. </transition>
  10. <!-- 通知框 -->
  11. <notify-box :mes-type="mesType" @reset="handleReset" />
  12. <zj-watermark color="rgba(200,200,200,.3)" position="absolute" :str="str" z-index="99" />
  13. </div>
  14. </section>
  15. </template>
  16. <script>
  17. import { mapGetters } from 'vuex'
  18. import { setModuleId } from '@/utils/request'
  19. import { getListInvoiceOrderTWO } from '@/api/dashboard'
  20. import NotifyBox from '@/components/NotifyBox'
  21. export default {
  22. name: 'AppMain',
  23. components: {
  24. NotifyBox
  25. },
  26. data() {
  27. return {
  28. currentPage: 1,
  29. pageSize: 10,
  30. listTotal: 0,
  31. invoiceOrderList: [],
  32. timer: null,
  33. mesType: null
  34. }
  35. },
  36. computed: {
  37. ...mapGetters(['show']),
  38. cachedViews() {
  39. return this.$store.state.tagsView.cachedViews
  40. },
  41. key() {
  42. return this.$route.path
  43. },
  44. str() {
  45. return this.$store.state?.user?.name
  46. }
  47. },
  48. watch: {
  49. $route() {
  50. setModuleId(this.$route.meta.moduleId)
  51. }
  52. },
  53. beforeCreate() {
  54. setModuleId(this.$route.meta.moduleId)
  55. },
  56. mounted() {
  57. this.handleInterVal()
  58. },
  59. beforeDestroy() {
  60. this.handleClearInterVal()
  61. },
  62. methods: {
  63. handleInterVal() {
  64. this.handleClearInterVal()
  65. this.timer = setInterval(() => {
  66. this.getListInvoiceOrderTWO()
  67. }, 20000)
  68. },
  69. handleClearInterVal() {
  70. clearInterval(this.timer)
  71. this.timer = null
  72. },
  73. open() {
  74. const That = this
  75. this.$notify({
  76. title: '通知',
  77. type: 'info',
  78. duration: 0,
  79. position: 'bottom-right',
  80. dangerouslyUseHTMLString: true,
  81. message: (
  82. <div>
  83. 通知:您有一条新的物流通知发货单号${this.invoiceOrderList[0].id},
  84. <el-link type='primary' underline={false} onClick={() => That.handleJump()}>
  85. 点击查看详情
  86. </el-link>
  87. </div>
  88. ),
  89. onClose() {
  90. That.handleInterVal()
  91. }
  92. })
  93. },
  94. // 获取物流列表
  95. async getListInvoiceOrderTWO() {
  96. const data = {
  97. pageSize: this.pageSize,
  98. pageNum: this.currentPage
  99. }
  100. const res = await getListInvoiceOrderTWO(data)
  101. this.invoiceOrderList = res.data.records
  102. this.listTotal = res.data.total
  103. if (res.data.records.length) {
  104. this.open()
  105. this.handleClearInterVal()
  106. } else {
  107. this.handleInterVal()
  108. }
  109. },
  110. handleJump() {
  111. this.mesType = 3
  112. this.$store.commit('user/showMessage', 'yes')
  113. this.$notify.closeAll()
  114. },
  115. handleReset() {
  116. this.mesType = null
  117. }
  118. }
  119. }
  120. </script>
  121. <style scoped>
  122. .app-main {
  123. /*50 = navbar */
  124. height: 100vh;
  125. width: 100%;
  126. position: relative;
  127. overflow: hidden;
  128. }
  129. .fixed-header + .app-main {
  130. /* padding-top: 50px; */
  131. /* padding-top: 80px; */
  132. }
  133. .app-main-view {
  134. width: 100%;
  135. height: 100%;
  136. position: relative;
  137. overflow-x: hidden;
  138. overflow-y: auto;
  139. }
  140. </style>