Explorar o código

添加权限判断+路由跳转

xiaohaizhao hai 1 ano
pai
achega
e398a5f82d
Modificáronse 1 ficheiros con 28 adicións e 9 borrados
  1. 28 9
      pages/index/modules/spectaculars.vue

+ 28 - 9
pages/index/modules/spectaculars.vue

@@ -1,19 +1,19 @@
 <template>
-    <view class="container">
-        <view hover-class="navigator-hover" class="item">
+    <view class="container" v-if="showList.length">
+        <navigator v-if="isShow('在线设备')" url="/pages/facility/index?page=设备中心" hover-class="navigator-hover" class="item">
             <view class="label">在线设备</view>
             <view class="count u-line-1">{{ statistics.today_devices }}</view>
-        </view>
+        </navigator>
 
-        <view hover-class="navigator-hover" class="item">
+        <navigator v-if="isShow('今日警告')" url="/pages/alerts/index" hover-class="navigator-hover" class="item">
             <view class="label">今日警告</view>
             <view class="count u-line-1">{{ statistics.today_warns }}</view>
-        </view>
+        </navigator>
 
-        <view hover-class="navigator-hover" class="item">
+        <navigator v-if="isShow('今日工单')" url="/packageA/workOrder/index" hover-class="navigator-hover" class="item">
             <view class="label">今日工单</view>
             <view class="count u-line-1">{{ statistics.today_orders }}</view>
-        </view>
+        </navigator>
     </view>
 </template>
 
@@ -26,11 +26,25 @@ export default {
                 today_devices: 0,
                 today_warns: 0,
                 today_orders: 0,
-            }
+            },
+            showList: []
         };
     },
+    computed: {
+        isShow() {
+            return function (name) {
+                return this.showList.includes(name)
+            }
+        }
+    },
     created() {
         this.getDetail()
+        let auth = uni.getStorageSync('authList'),
+            showList = [];
+        typeof auth.设备中心 == 'object' && showList.push("在线设备");
+        typeof auth.告警中心 == 'object' && showList.push("今日警告");
+        typeof auth.工单 == 'object' && showList.push("今日工单");
+        this.showList = showList;
     },
     methods: {
         getDetail() {
@@ -50,7 +64,6 @@ export default {
 <style lang="scss" scoped>
 .container {
     display: flex;
-    justify-content: space-between;
     width: 355px;
     height: 72px;
     margin: 0 auto;
@@ -63,6 +76,8 @@ export default {
         box-sizing: border-box;
         border-radius: 4px;
         background: #FFFFFF;
+        margin-right: 9.5px;
+        flex-shrink: 0;
 
         .label {
             line-height: 20px;
@@ -80,5 +95,9 @@ export default {
             margin-top: 10px;
         }
     }
+
+    .item:last-child {
+        margin-right: 0;
+    }
 }
 </style>