AppMain.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 { getListInvoiceOrder } 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. methods: {
  60. handleInterVal() {
  61. this.handleClearInterVal()
  62. this.timer = setInterval(() => {
  63. this.getListInvoiceOrder()
  64. }, 20000)
  65. },
  66. handleClearInterVal() {
  67. clearInterval(this.timer)
  68. this.timer = null
  69. },
  70. open() {
  71. const That = this
  72. this.$notify({
  73. title: '通知',
  74. type: 'info',
  75. duration: 0,
  76. position: 'bottom-right',
  77. dangerouslyUseHTMLString: true,
  78. message: (
  79. <div>
  80. 通知:您有一条新的物流通知发货单号${this.invoiceOrderList[0].id},
  81. <el-link type='primary' underline={false} onClick={() => That.handleJump()}>
  82. 点击查看详情
  83. </el-link>
  84. </div>
  85. ),
  86. onClose() {
  87. That.handleInterVal()
  88. }
  89. })
  90. },
  91. // 获取物流列表
  92. async getListInvoiceOrder() {
  93. const data = {
  94. pageSize: this.pageSize,
  95. pageNum: this.currentPage
  96. }
  97. const res = await getListInvoiceOrder(data)
  98. this.invoiceOrderList = res.data.records
  99. this.listTotal = res.data.total
  100. if (res.data.records.length) {
  101. this.open()
  102. this.handleClearInterVal()
  103. } else {
  104. this.handleInterVal()
  105. }
  106. },
  107. handleJump() {
  108. this.mesType = 3
  109. this.$store.commit('user/showMessage', 'yes')
  110. this.$notify.closeAll()
  111. },
  112. handleReset() {
  113. this.mesType = null
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped>
  119. .app-main {
  120. /*50 = navbar */
  121. height: 100vh;
  122. width: 100%;
  123. position: relative;
  124. overflow: hidden;
  125. }
  126. .fixed-header + .app-main {
  127. /* padding-top: 50px; */
  128. /* padding-top: 80px; */
  129. }
  130. .app-main-view {
  131. width: 100%;
  132. height: 100%;
  133. position: relative;
  134. overflow-x: hidden;
  135. overflow-y: auto;
  136. }
  137. </style>