index.vue 5.1 KB

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