lishuangjiang@potevio.com пре 1 година
родитељ
комит
20847cba66

+ 1 - 0
src/components/common/props/crudProps.ts

@@ -118,4 +118,5 @@ export const crudProps = {
   funProps: Object,
   tableProps: Object,
   formProps: Object,
+  addBtn:propTypes.bool.def(false),
 }

+ 2 - 1
src/components/common/yt-crud.vue

@@ -13,6 +13,7 @@
     <yt-table-fun
       v-bind="bind.funBind"
       v-loading="loading"
+      :addBtn="addBtn"
       :multipleSelection="multipleSelection"
       :limit="pageParams.pageSize"
       @change-all="changeAll"
@@ -153,7 +154,7 @@ const changeAll = (e) => {
 const onSuccess = (obj: any) => {
   emits('saveFun', obj)
 }
-
+const addBtn = ref(props.addBtn)
 // 传给列表需要的参数
 const queryParams = ref(props.query)
 const search = (params: any) => {

+ 1 - 1
src/components/common/yt-table-fun.vue

@@ -4,7 +4,7 @@
       <el-row justify="space-between" style="margin-bottom: 0;">
         <el-row :gutter="gutter" align="middle" class="mb8">
           <el-col :span="span" v-if="addBtn">
-            <el-button v-bind="addBind" type="primary" icon="Plus" @click="emits('handleAdd')">{{ addBtnText }}</el-button>
+            <el-button v-bind="addBind" type="primary" icon="Plus" @click="emits('handleAdd')" >{{ addBtnText }}</el-button>
           </el-col>
           <el-col :span="span" v-if="exportBtn">
             <el-button v-bind="exportBind" plain @click="emits('handleExport')">

+ 16 - 0
src/utils/auth.ts

@@ -1,3 +1,5 @@
+import useUserStore from "@/store/modules/user";
+
 const TokenKey = 'Admin-Token'
 
 const tokenStorage = useStorage<null | string>(TokenKey, null)
@@ -7,3 +9,17 @@ export const getToken = () => tokenStorage.value
 export const setToken = (token: string) => (tokenStorage.value = token)
 
 export const removeToken = () => (tokenStorage.value = null)
+
+export const hasPermission = (permission:string)=>{
+  const permissions = useUserStore().permissions
+  const permissionDatas = permission
+  const all_permission = '*:*:*'
+
+  const hasPermission = permissions.some((permission) => {
+    return all_permission === permission || permissionDatas.includes(permission)
+  })
+  if (!hasPermission) {
+    return false
+  }
+  return true
+}

+ 3 - 0
src/views/iot/equipment/categories/index.vue

@@ -8,6 +8,7 @@
       v-model:query="state.query"
       :total="state.total"
       :loading="state.loading"
+      :addBtn = "hasPermission('iot:category:add')"
       :tableProps=" {
         selection: false,
         viewBtn: false,
@@ -23,10 +24,12 @@
 
 <script lang="ts" setup>
 import { IColumn } from '@/components/common/types/tableCommon'
+import useUserStore from '@/store/modules/user'
 
 import YtCrud from '@/components/common/yt-crud.vue'
 import { deleteCategories, getCategoriesList, saveCategories } from '../api/categories.api'
 import { ICategoriesVO } from '../api/categories.api'
+import { hasPermission } from '@/utils/auth'
 
 const column: IColumn[] = [{
   label: 'id',

+ 3 - 1
src/views/iot/equipment/devices/list.vue

@@ -24,6 +24,7 @@
       @delFun="handleDelete"
       @saveFun="onSave"
       @openBeforeFun="openBeforeFun"
+      :addBtn = "hasPermission('iot:device:add')"
     >
       <template #rightToolbar>
         <el-radio-group v-model="layoutType">
@@ -82,7 +83,7 @@
                 @click="showChidrenDevices(item)"
                 >子设备</el-button
               >
-              <el-button class="cu-btn" type="primary" icon="EditPen" plain @click="crudRef.handleUpdate(item)">编辑</el-button>
+              <el-button class="cu-btn" type="primary" icon="EditPen" plain @click="crudRef.handleUpdate(item)" >编辑</el-button>
               <el-button class="cu-btn" type="warning" icon="View" plain @click="handleView(item)">详情</el-button>
               <el-divider direction="vertical" />
               <el-popconfirm title="是否确认删除?" @confirm="handleDelete(item)">
@@ -139,6 +140,7 @@ import ChildrenDialog from './modules/childrenDialog.vue'
 import YtCrud from '@/components/common/yt-crud.vue'
 import { ElPopconfirm } from 'element-plus'
 import StatusTag from '@/components/StatusTag/index.vue'
+import { hasPermission } from '@/utils/auth'
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance
 const state = reactive({

+ 8 - 5
src/views/iot/equipment/products/index.vue

@@ -4,6 +4,7 @@
       ref="crudRef"
       :data="data"
       :column="column"
+      :addBtn = "hasPermission('iot:product:add')"
       v-model:page="state.page"
       v-model:query="state.query"
       :total="state.total"
@@ -11,7 +12,8 @@
       :tableProps=" {
         selection: true,
         viewBtn: true,
-        delBtn: true,
+        editBtn: hasPermission('iot:product:edit'),
+        delBtn: hasPermission('iot:product:remove'),
         customTable: layoutType === 'card',
         menuSlot: true,
         menuWidth: 300,
@@ -64,13 +66,13 @@
               </div>
             </div>
             <div class="btn-group">
-              <el-button class="cu-btn" type="primary" icon="EditPen" plain @click="crudRef.handleUpdate(item)">编辑</el-button>
+              <el-button class="cu-btn" type="primary" icon="EditPen" plain @click="crudRef.handleUpdate(item)"  v-show = "hasPermission('iot:product:edit')">编辑</el-button>
               <el-button class="cu-btn" type="warning" icon="View" plain @click="crudRef.handleView(item)">详情</el-button>
               <el-button class="cu-btn" type="success" icon="ScaleToOriginal" plain @click="openObjectModel(item)">物模型</el-button>
-              <el-divider direction="vertical" />
-              <el-popconfirm title="是否确认删除?" @confirm="handleDel(item)">
+              <el-divider direction="vertical" v-show = "hasPermission('iot:product:remove')"/>
+              <el-popconfirm title="是否确认删除?" @confirm="handleDel(item)"  >
                 <template #reference>
-                  <el-button type="danger" icon="Delete" plain />
+                  <el-button type="danger" icon="Delete" plain  v-show = "hasPermission('iot:product:remove')"/>
                 </template>
               </el-popconfirm>
             </div>
@@ -106,6 +108,7 @@ import YtCrud from '@/components/common/yt-crud.vue'
 import { getProductsList, saveProducts, IProductsVO, deleteProduct } from '../api/products.api'
 import { getCategoriesAll } from '../api/categories.api'
 import { ElDivider } from 'element-plus'
+import { hasPermission } from '@/utils/auth'
 
 const crudRef = ref()
 const nodeTypeOptions =  [

+ 2 - 1
src/views/iot/equipment/products/modules/functionConfig.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="function-config">
-    <yt-table-fun @handle-add="handleAdd">
+    <yt-table-fun @handle-add="handleAdd" :addBtn ="hasPermission('iot:product:edit')">
       <yt-table
         :selection="false"
         :page-hide="true"
@@ -31,6 +31,7 @@ import FunctionDetail from './modeuls/functionDetail.vue'
 import YtTableFun from '@/components/common/yt-table-fun.vue'
 import YtTable from '@/components/common/yt-table'
 import { useEmitt } from '@/hooks/web/useEmitt'
+import { hasPermission } from '@/utils/auth'
 
 const { emitter } = useEmitt()
 

+ 2 - 1
src/views/iot/equipment/products/modules/modelNumberConfig.vue

@@ -1,5 +1,5 @@
 <template>
-  <yt-table-fun @handle-add="handleAdd">
+  <yt-table-fun @handle-add="handleAdd" :addBtn ="hasPermission('iot:product:edit')">
     <yt-table
       :selection="false"
       :page-hide="true"
@@ -30,6 +30,7 @@ import { getProductModelList, deleteProductModel } from '../../api/products.api'
 import ModelNumberDetail from './modeuls/modelNumberDetail.vue'
 import YtTableFun from '@/components/common/yt-table-fun.vue'
 import YtTable from '@/components/common/yt-table'
+import { hasPermission } from '@/utils/auth'
 
 const props = defineProps({
   id: propTypes.string.def(''),

+ 2 - 0
src/views/iot/ruleEngine/ruleSys/index.vue

@@ -7,6 +7,7 @@
       :column="column"
       :loading="state.loading"
       :total="state.total"
+      :addBtn = "hasPermission('iot:rule:eidt')"
       v-model:page="state.page"
       v-model:query="state.query"
       @on-load="getData"
@@ -61,6 +62,7 @@ import Filtera from './modules/filtera.vue'
 import Output from './modules/output.vue'
 import LogDialog from '../modules/logDialog.vue'
 import YtCrud from '@/components/common/yt-crud.vue'
+import { hasPermission } from '@/utils/auth'
 
 // 查看日志
 const logDialogRef = ref()

+ 2 - 0
src/views/iot/ruleEngine/scheduledTask/index.vue

@@ -3,6 +3,7 @@
     <yt-crud
       ref="crudRef"
       :data="data"
+      :addBtn = "hasPermission('iot:task:edit')"
       :table-props="{
         delBtn: false,
         menuSlot: true,
@@ -87,6 +88,7 @@ import CrontabBox from '@/components/Crontab/index.vue'
 import LogDialog from '../modules/logDialog.vue'
 import YtCrud from '@/components/common/yt-crud.vue'
 import optput from '../ruleSys/modules/output.vue'
+import { hasPermission } from '@/utils/auth'
 // 查看日志
 const logDialogRef = ref()
 const handleViewLog = (id: string) => {

+ 5 - 1
src/views/system/dept/index.vue

@@ -22,8 +22,11 @@
     <el-card shadow="never">
       <template #header>
         <el-row :gutter="10">
+<!--          <el-col :span="1.5">-->
+<!--            <el-button type="primary" plain icon="Plus" @click="handleAdd()" v-hasPermi="['system:dept:add']">新增 </el-button>-->
+<!--          </el-col>-->
           <el-col :span="1.5">
-            <el-button type="primary" plain icon="Plus" @click="handleAdd()" v-hasPermi="['system:dept:add']">新增 </el-button>
+            <el-button type="primary" plain icon="Plus" @click="handleAdd()"  v-if="checkPermi['system:dept:add']">新增 </el-button>
           </el-col>
           <el-col :span="1.5">
             <el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button>
@@ -197,6 +200,7 @@ const { queryParams, form, rules } = toRefs<PageData<DeptForm, DeptQuery>>(data)
 
 /** 查询菜单列表 */
 const getList = async () => {
+  // console.log("#######################"+ checkPermi['system:dept:add'])
   loading.value = true
   const res = await listDept(queryParams.value)
   const data = proxy?.handleTree<DeptVO>(res.data, 'id')