Browse Source

添加权限组件

lex-xin 4 years ago
parent
commit
6234aa17f7

+ 74 - 0
src/components/Auth/index.vue

@@ -0,0 +1,74 @@
+<template>
+  <div class="auth" v-if="isAuth">
+    <slot></slot>
+  </div>
+</template>
+
+<script>
+  import store from '@/store'
+  export default {
+    name: 'auth',
+    props: {
+      auths: {
+        type: Object
+      },
+      router: {
+        type: Object
+      },
+      mulit: {
+        type: Boolean,
+        default() {
+          return false
+        }
+      }
+    },
+    data() {
+      return {
+        isAuth: false
+      }
+    },
+    async mounted() {
+      let permission = window.localStorage.getItem('permission')
+      permission = permission.split(',')
+      this.isAuth = this.hasAuths(permission) && this.hasRouters() ? true : false
+    },
+    methods: {
+      hasAuths(menus) {
+        const auths = this.auths
+        if(typeof auths === 'object') {
+          let sum = 0
+          for(const auth of auths) {
+            if(this.mulit) {
+               if(menus.includes(auth)) {
+                 sum ++
+               }
+            } else {
+              return menus.includes(auth)
+            }
+          }
+          if(sum === auths.length) {
+            return true
+          }
+        } else {
+          return menus.includes(auths)
+        }
+      },
+      hasRouters() {
+        const path = this.$route.path
+        if(this.router) {
+          return this.router.includes(path)
+        }
+        return true
+      }
+    }
+  }
+</script>
+
+<style scoped lang="less">
+  .auth {
+    display: inline-block;
+    & + .auth {
+      margin-left: 10px;
+    }
+  }
+</style>

+ 2 - 0
src/components/install.js

@@ -14,6 +14,7 @@ import descriptions from '@/components/Descriptions/Descriptions.vue'
 import remoteSearch from "@/components/remote-search"
 import tabRouter from '@/components/tab-router'
 import empty from '@/components/empty'
+import auth from '@/components/Auth'
 
 export default {
   install(Vue) {
@@ -28,5 +29,6 @@ export default {
     Vue.component(remoteSearch.name, remoteSearch)
     Vue.component(tabRouter.name, tabRouter)
     Vue.component(empty.name, empty)
+    Vue.component(auth.name, auth)
   }
 }

+ 1 - 1
src/views/businessManager/orderManager/incomeOut.vue

@@ -112,7 +112,7 @@
               scope.row.createTime | dateForMinFormat
             }}</template>
           </el-table-column>
-          <el-table-column align="center" width="100px" label="时间/分钟">
+          <el-table-column align="center" width="125px" label="时间/分钟">
             <template slot-scope="scope">
               <p>{{ "购买" + scope.row.transMinutes + "分钟" }}</p>
               <p>{{ "赠送" + scope.row.giveMinutes + "分钟" }}</p>

+ 1 - 1
src/views/operateManager/operateStudent.vue

@@ -141,7 +141,7 @@
           </el-table-column>
           <el-table-column align="center" prop="groupNames" label="乐团名称">
             <template slot-scope="scope">
-              <overflow-text width="165px" :text="scope.row.groupNames" />
+              <overflow-text width="100%" :text="scope.row.groupNames" />
             </template>
           </el-table-column>
           <el-table-column

+ 11 - 4
src/views/teamBuild/forecastName.vue

@@ -9,9 +9,16 @@
         </p>
 
         <div class="btnList">
-            <el-button type="primary" @click="codeStatus = true">预报名链接</el-button>
-            <el-button type="primary" @click="extendPaymentStatus = true">预报名时间延长</el-button>
-            <el-button type="primary">开启报名</el-button>
+          
+            <auth>
+              <el-button type="primary" @click="codeStatus = true">预报名链接</el-button>
+            </auth>
+            <auth>
+              <el-button type="primary" @click="extendPaymentStatus = true">预报名时间延长</el-button>
+            </auth>
+            <auth>
+              <el-button type="primary">开启报名</el-button>
+            </auth>
         </div>
 
         <div class="m-core">
@@ -324,4 +331,4 @@ export default {
 
 <style lang="less" scoped>
 
-</style>
+</style>