index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view v-if="hasFunction" class="page" @click.stop="closeDropdowns">
  3. <view class="tabs-container">
  4. <view class="tabs">
  5. <view v-if="hasScanFunction" class="tab" :class="{ active: activeTab === 'scan' }" @click="activeTab = 'scan'">
  6. 扫码率</view>
  7. <view v-if="hasReportFunction" class="tab" :class="{ active: activeTab === 'export' }"
  8. @click="activeTab = 'export'">报表导出</view>
  9. <view v-if="hasBlacklistFunction" class="tab" :class="{ active: activeTab === 'blacklist' }"
  10. @click="activeTab = 'blacklist'">黑名单汇总</view>
  11. <view v-if="hasGanmaolingFunction" class="tab" :class="{ active: activeTab === 'ganmaoling' }"
  12. @click="activeTab = 'ganmaoling'">感冒灵大批量</view>
  13. </view>
  14. </view>
  15. <view class="content" v-show="activeTab === 'scan' && hasScanFunction">
  16. <ScanningRate ref="scanRate" />
  17. </view>
  18. <view class="content" :style="{ padding: '0', marginTop: '85rpx' }"
  19. v-show="activeTab === 'export' && hasReportFunction">
  20. <ReportExport />
  21. </view>
  22. <view class="content" :style="{ padding: '0', marginTop: '85rpx' }"
  23. v-show="activeTab === 'blacklist' && hasBlacklistFunction">
  24. <Blacklist />
  25. </view>
  26. <view class="content" :style="{ padding: '0', marginTop: '85rpx' }"
  27. v-show="activeTab === 'ganmaoling' && hasGanmaolingFunction">
  28. <Ganmaoling />
  29. </view>
  30. </view>
  31. <view v-else-if="!functionLoading" class="page">
  32. <Empty text="您无权限访问" />
  33. </view>
  34. </template>
  35. <script>
  36. import LoadingImg from "../../static/images/loading.png";
  37. import ReportExport from "./reportExport/index.vue";
  38. import ScanningRate from "./customerScanningRate/index.vue";
  39. import Blacklist from "./blacklist/index.vue";
  40. import Ganmaoling from "./ganmaoling/index.vue";
  41. import Empty from "../../wigets/empty.vue";
  42. import { hasFunction } from '../../utils/utils.js'
  43. export default {
  44. components: {
  45. ScanningRate,
  46. ReportExport,
  47. Blacklist,
  48. Ganmaoling,
  49. Empty,
  50. },
  51. data() {
  52. return {
  53. hasScanFunction: false,
  54. hasReportFunction: false,
  55. hasBlacklistFunction: false,
  56. hasGanmaolingFunction: false,
  57. // hasScanFunction: true,
  58. // hasReportFunction: true,
  59. // hasBlacklistFunction: true,
  60. // hasGanmaolingFunction: true,
  61. loading: true,
  62. LoadingImg,
  63. activeTab: "scan",
  64. activeRange: 1,
  65. filterModalOpen: false,
  66. filterForm: { report: "", product: "" },
  67. filterDropdown: { report: false, product: false },
  68. filterDateRange: [],
  69. functionLoading: true,
  70. // functionLoading: false,
  71. };
  72. },
  73. created() {
  74. this.getFunc()
  75. },
  76. computed: {
  77. hasFunction() {
  78. return this.hasScanFunction || this.hasReportFunction || this.hasBlacklistFunction
  79. }
  80. },
  81. methods: {
  82. closeDropdowns() {
  83. this.$refs.scanRate.closeDropdown();
  84. },
  85. async getFunc() {
  86. uni.showLoading({
  87. title: '加载中',
  88. mask: true,
  89. })
  90. await hasFunction(['scan-rate-list', 'trace-code-task', 'blacklist-customers-list', 'large-medicines-list']).then(res => {
  91. this.hasScanFunction = res[0]
  92. this.hasReportFunction = res[1]
  93. this.hasBlacklistFunction = res[2]
  94. this.hasGanmaolingFunction = res[3]
  95. }).catch(err => {
  96. this.hasScanFunction = false
  97. this.hasReportFunction = false
  98. this.hasBlacklistFunction = false
  99. this.hasGanmaolingFunction = false
  100. // uni.hideLoading()
  101. })
  102. if (this.hasScanFunction) {
  103. this.active = 'scan'
  104. } else if (this.hasReportFunction) {
  105. this.activeTab = 'export'
  106. } else if (this.hasBlacklistFunction) {
  107. this.activeTab = 'blacklist'
  108. } else if (this.hasGanmaolingFunction) {
  109. this.activeTab = 'ganmaoling'
  110. }
  111. this.functionLoading = false
  112. uni.hideLoading()
  113. }
  114. },
  115. };
  116. </script>
  117. <style>
  118. .page {
  119. box-sizing: border-box;
  120. height: calc(100vh - env(safe-area-inset-bottom));
  121. overflow-y: auto;
  122. box-sizing: border-box;
  123. background: #f3f6f9;
  124. padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
  125. }
  126. .content {
  127. padding: 30rpx;
  128. margin-top: 180rpx;
  129. padding-bottom: 160rpx;
  130. }
  131. .tabs-container {
  132. position: fixed;
  133. top: 0;
  134. left: 0;
  135. width: 100%;
  136. height: 116rpx;
  137. background: #f3f6f9;
  138. z-index: 99;
  139. margin-top: -8rpx;
  140. }
  141. .tabs {
  142. box-sizing: border-box;
  143. width: calc(100% - 16rpx);
  144. display: flex;
  145. background: #fff;
  146. border-radius: 16rpx;
  147. padding: 12rpx;
  148. margin: 8rpx;
  149. }
  150. .tab {
  151. flex: 1;
  152. text-align: center;
  153. padding: 18rpx 0;
  154. border-radius: 12rpx;
  155. font-size: 28rpx;
  156. }
  157. .tab.active {
  158. background: #2c69ff;
  159. color: #fff;
  160. }
  161. </style>