index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="page root">
  3. <view class="page-back" />
  4. <view style="height: 25px" />
  5. <uni-nav-bar
  6. :title="$t('statistic.title')"
  7. :border="false"
  8. left-icon="back"
  9. background-color="transparent"
  10. color="#FFFFFF"
  11. @click-left="onBack"
  12. />
  13. <uni-row class="flex-row align-center" style="margin-left: 15px; padding-top: 8px">
  14. <view v-for="(item, index) of tabs" :key="index" style="margin-right: 20px">
  15. <text
  16. :class="index === currentTab ? 'tab-selected' : 'tab-normal'"
  17. @click="onTabChanged(index)"
  18. >
  19. {{ item }}
  20. </text>
  21. </view>
  22. </uni-row>
  23. <swiper class="view-pager" :current="currentTab" duration="100" @change="onSwiperChanged($event)">
  24. <swiper-item style="height: 100%; overflow-y: scroll">
  25. <!-- 首页 -->
  26. <front-page ref="frontPage" />
  27. </swiper-item>
  28. <swiper-item style="height: 100%; overflow-y: scroll">
  29. <!-- 维修统计 -->
  30. <repair-page ref="repairPage" />
  31. </swiper-item>
  32. <swiper-item style="height: 100%; overflow-y: scroll">
  33. <!-- 保养统计 -->
  34. <maintenance-page ref="maintenancePage" />
  35. </swiper-item>
  36. <swiper-item style="height: 100%; overflow-y: scroll">
  37. <!-- 巡检统计 -->
  38. <inspection-page ref="inspectionPage" />
  39. </swiper-item>
  40. </swiper>
  41. </view>
  42. </template>
  43. <script setup>
  44. import { getCurrentInstance, nextTick, onMounted, ref } from "vue";
  45. import FrontPage from '@/components/statistic/front.vue'
  46. import RepairPage from '@/components/statistic/rapair.vue'
  47. import MaintenancePage from '@/components/statistic/maintenance.vue'
  48. import InspectionPage from '@/components/statistic/inspection.vue'
  49. const { appContext } = getCurrentInstance()
  50. const t = appContext.config.globalProperties.$t
  51. const frontPage = ref()
  52. const repairPage = ref()
  53. const maintenancePage = ref()
  54. const inspectionPage = ref()
  55. const currentTab = ref(0)
  56. const tabs = [t('statistic.tab0'),t('statistic.tab1'), t('statistic.tab2'), t('statistic.tab3')]
  57. const onTabChanged = (index) => {
  58. setPage(index)
  59. }
  60. const onSwiperChanged = (event) => {
  61. setPage(event.detail.current)
  62. }
  63. const setPage = async (index) => {
  64. currentTab.value = index
  65. // 延迟加载数据,避免多次请求
  66. await nextTick()
  67. if (index === 0) {
  68. frontPage.value.loadData()
  69. } else if (index === 1) {
  70. repairPage.value.loadData()
  71. } else if (index === 2) {
  72. maintenancePage.value.loadData()
  73. } else if (index === 3) {
  74. inspectionPage.value.loadData()
  75. }
  76. }
  77. const onBack = () => {
  78. uni.navigateBack()
  79. };
  80. onMounted(() => frontPage.value.loadData())
  81. </script>
  82. <style scoped lang="scss">
  83. .page {
  84. padding: 0;
  85. }
  86. .root {
  87. width: 100%;
  88. height: 100%;
  89. position: relative;
  90. box-sizing: border-box;
  91. overflow: hidden;
  92. }
  93. .tab-selected {
  94. font-size: 18px;
  95. font-weight: 500;
  96. color: white;
  97. }
  98. .tab-normal {
  99. font-size: 14px;
  100. color: white;
  101. }
  102. .divider {
  103. width: 1px;
  104. height: 114px;
  105. background-color: #CACCCF;
  106. margin: 0 24px;
  107. }
  108. .divider-v {
  109. width: auto;
  110. height: 1.5px;
  111. border-bottom: 1.5px #CACCCF dashed;
  112. margin: 0 20px;
  113. }
  114. .divider-h {
  115. width: 1.5px;
  116. height: 50px;
  117. border-left: 1.5px #CACCCF dashed;
  118. margin: 0 4px;
  119. }
  120. .count-label {
  121. color: #666666;
  122. font-size: 14px;
  123. }
  124. .count-value {
  125. color: #333333;
  126. font-size: 18px;
  127. font-weight: 500;
  128. }
  129. .mt-5 {
  130. margin-top: 5px;
  131. }
  132. .mt-8 {
  133. margin-top: 8px;
  134. }
  135. .pl-10 {
  136. padding-left: 10px;
  137. }
  138. .view-pager {
  139. height: calc(100% - 44px - 60px);
  140. }
  141. </style>