index.vue 5.2 KB

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