index.vue 5.3 KB

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