Pārlūkot izejas kodu

工作台完善,auth为处理权限文件

xiaohaizhao 2 gadi atpakaļ
vecāks
revīzija
2179e64bb4
2 mainītis faili ar 57 papildinājumiem un 65 dzēšanām
  1. 31 65
      pages/index/modules/workbench.vue
  2. 26 0
      utils/auth.js

+ 31 - 65
pages/index/modules/workbench.vue

@@ -2,8 +2,8 @@
     <view class="container">
         <swiper class="swiper square-dot" indicator-color="#D7E3FD" indicator-active-color="#3874F6" :indicator-dots="true"
             :circular="true" duration="500">
-            <swiper-item class="swiper-item" v-for="(it, i) in apps" key="i">
-                <navigator url="#" class="app" v-for="item in it" key="label">
+            <swiper-item class="swiper-item" v-for="(it, i) in apps" :key="i">
+                <navigator :url="item.path" open-type="navigate" class="app" v-for="item in it" :key="item.label">
                     <view class="icon" :style="{ backgroundColor: item.color }">
                         <text class="iconfont" :class="item.icon" style="font-size: 6.400vw;" />
                     </view>
@@ -21,75 +21,41 @@ export default {
     name: 'workbench',
     data() {
         return {
-            apps: [
-                [{
-                    label: "巡检中心",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }, {
-                    label: "巡检中心1",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }, {
-                    label: "巡检中心12",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }, {
-                    label: "巡检中心123",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }, {
-                    label: "巡检中心1234",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }], [{
-                    label: "巡检中心",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }, {
-                    label: "巡检中心1",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }, {
-                    label: "巡检中心12",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }, {
-                    label: "巡检中心123",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }, {
-                    label: "巡检中心1234",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }], [{
+            apps: []
+        };
+    },
+    created() {
+        this.rander();
+    },
+    methods: {
+        rander() {
+            const clist = ['#5487F7', '#F29C37', '#9A6FF8', '#5AB73F', '#5487F7']
+            let authList = uni.getStorageSync('authList'),
+                list = [{
                     label: "巡检中心",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
+                    icon: "icon-xunjianzhongxin"
                 }, {
-                    label: "巡检中心1",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
+                    label: "警告中心",
+                    icon: "icon-xunjianzhongxin"
                 }, {
-                    label: "巡检中心12",
+                    label: "设备中心",
                     icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
+                    path: "/packageA/facility/index"
                 }, {
-                    label: "巡检中心123",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
+                    label: "取水系统",
+                    icon: "icon-xunjianzhongxin"
                 }, {
-                    label: "巡检中心1234",
-                    icon: "icon-xunjianzhongxin",
-                    color: "#5487F7"
-                }]
-            ]
-        };
-    },
-    created() { },
-    methods: {
-        rander() {
-            let colorList = ['x']
+                    label: "雨洪系统",
+                    icon: "icon-xunjianzhongxin"
+                }].filter(v => authList[v.label]),
+                apps = [];
+            for (let i = list.length / 5; i > 0; i--) {
+                apps[apps.length] = list.splice(0, 5).map((v, i) => {
+                    v.color = clist[i]
+                    return v
+                })
+            };
+            this.apps = apps;
         }
     }
 }

+ 26 - 0
utils/auth.js

@@ -0,0 +1,26 @@
+function parsingAuth(list) {
+    let authList = {}
+    list.forEach(system => {
+        // let systemObj = {}
+        system.modules.forEach(app => {
+            let appObj = {}
+            app.apps.forEach(m => {
+                appObj[m.meta.title] = {
+                    path: m.path,
+                    pathDetail: m.path_index,
+                    pathDetail: m.path_index,
+                    name: m.name,
+                    option: m.meta.auth.map(v => v.option),
+                    optionname: m.meta.auth.map(v => v.optionname)
+                }
+            })
+            // systemObj[app.systemmodulename] = appObj;
+            authList[app.systemmodulename] = appObj;
+        })
+        // authList[system.systemname] = systemObj;
+    });
+    uni.setStorageSync('authList', authList)
+}
+module.exports = {
+    parsingAuth
+}