Browse Source

权限管理

zouzs 1 week ago
parent
commit
701dc7121d
3 changed files with 35 additions and 12 deletions
  1. 15 5
      src/views/ipAccount/index.vue
  2. 15 5
      src/views/ipInterface/index.vue
  3. 5 2
      src/views/ipInterfaceCall/index.vue

+ 15 - 5
src/views/ipAccount/index.vue

@@ -18,7 +18,12 @@
     >
       <template #table-title>
         <el-row class="button-row">
-          <el-button size="default" type="success" @click="handleCreate">
+          <el-button
+            v-perms="'ipAccount:index:add'"
+            size="default"
+            type="success"
+            @click="handleCreate"
+          >
             新增
           </el-button>
         </el-row>
@@ -43,7 +48,7 @@
 </template>
 
 <script lang="ts" setup>
-import { computed, reactive, ref, toRefs } from "vue";
+import { computed, reactive, ref, resolveDirective, toRefs } from "vue";
 import type { FormRules } from "element-plus";
 import { ElMessage, ElMessageBox } from "element-plus";
 import {
@@ -268,6 +273,8 @@ const handleClose = () => {
 
 const { buttons } = useTable();
 
+const perms = resolveDirective("perms");
+
 buttons.value = [
   {
     // 修改
@@ -281,7 +288,8 @@ buttons.value = [
       form.value = params.row;
       state.isCreate = false;
       state.dialogVisible = true;
-    }
+    },
+    directives: [[perms, "ipAccount:index:edit"]]
   },
   {
     // 修改
@@ -317,7 +325,8 @@ buttons.value = [
       });
       // 路由跳转
       router.push({ name: "IpAccountInterface", query: params });
-    }
+    },
+    directives: [[perms, "ipAccount:index:interface"]]
   },
   {
     // 删除
@@ -343,7 +352,8 @@ buttons.value = [
       } catch (e) {
         ElMessage.error("删除失败");
       }
-    }
+    },
+    directives: [[perms, "ipAccount:index:remove"]]
   }
 ];
 

+ 15 - 5
src/views/ipInterface/index.vue

@@ -18,7 +18,12 @@
     >
       <template #table-title>
         <el-row class="button-row">
-          <el-button size="default" type="success" @click="handleCreate">
+          <el-button
+            v-perms="'ipInterface:index:add'"
+            size="default"
+            type="success"
+            @click="handleCreate"
+          >
             新增
           </el-button>
         </el-row>
@@ -55,7 +60,7 @@
 </template>
 
 <script lang="ts" setup>
-import { computed, reactive, ref, toRefs } from "vue";
+import { computed, reactive, ref, resolveDirective, toRefs } from "vue";
 import type { FormRules } from "element-plus";
 import { ElMessage, ElMessageBox } from "element-plus";
 import {
@@ -351,6 +356,8 @@ const normalizeParams = (params: Record<string, any>) => {
 
 const { buttons } = useTable();
 
+const perms = resolveDirective("perms");
+
 buttons.value = [
   {
     // 修改
@@ -365,7 +372,8 @@ buttons.value = [
       Object.assign(form.value, normalizeParams(params.row));
       state.isCreate = false;
       state.dialogVisible = true;
-    }
+    },
+    directives: [[perms, "ipInterface:index:edit"]]
   },
   {
     // 修改
@@ -381,7 +389,8 @@ buttons.value = [
       descriptionsData.value = {
         interfaceConfig: val.row.interfaceConfig
       };
-    }
+    },
+    directives: [[perms, "ipInterface:index:detail"]]
   },
   {
     // 删除
@@ -407,7 +416,8 @@ buttons.value = [
       } catch (e) {
         ElMessage.error("删除失败");
       }
-    }
+    },
+    directives: [[perms, "ipInterface:index:remove"]]
   }
 ];
 

+ 5 - 2
src/views/ipInterfaceCall/index.vue

@@ -20,7 +20,7 @@
 </template>
 
 <script lang="ts" setup>
-import { computed, ref } from "vue";
+import { computed, ref, resolveDirective } from "vue";
 import {
   type FieldValues,
   type PlusColumn,
@@ -110,6 +110,8 @@ const tableConfig: PlusColumn[] = [
 
 const { buttons } = useTable();
 
+const perms = resolveDirective("perms");
+
 buttons.value = [
   {
     // 修改
@@ -141,7 +143,8 @@ buttons.value = [
       });
       // 路由跳转
       router.push({ name: "IpInterfaceCallDetail", query: params });
-    }
+    },
+    directives: [[perms, "ipInterfaceCall:index:detail"]]
   }
 ];
 </script>