dedsudiyu vor 4 Monaten
Ursprung
Commit
e6f0f457e8
3 geänderte Dateien mit 34 neuen und 4 gelöschten Zeilen
  1. 1 0
      pages/views/login/login.vue
  2. 4 4
      pages_manage/views/laboratory/iotControl.vue
  3. 29 0
      utils/index.js

+ 1 - 0
pages/views/login/login.vue

@@ -162,6 +162,7 @@
 				if (data.code == 200) {
 					uni.setStorageSync('permissions', data.data.data)
 					uni.setStorageSync('controlsRestrict', data.data.roleKeys ? data.data.roleKeys : [])
+					uni.setStorageSync('user', data.data.userInfo)
 				}
 			},
 			switchClick() {

+ 4 - 4
pages_manage/views/laboratory/iotControl.vue

@@ -55,7 +55,7 @@
 
 <script>
 	import {
-		controlsRestrictVerify
+		itoOrVideoLimits
 	} from '@/utils/index'
 	import $mqtt from '@/utils/mqtt.min.js';
 	import {
@@ -107,7 +107,7 @@
 			//物联控制设备
 			deviceTypeFun(item) {
 				if (item.type == 'video') {
-					if (!controlsRestrictVerify('subVideo')) {
+					if (!itoOrVideoLimits(this.newData.adminId)) {
 						uni.showToast({
 							title: '没有相关操作权限,请联系管理员',
 							icon: "none",
@@ -118,7 +118,7 @@
 					}
 					this.$parent.goVideoPage();
 				} else {
-					if (!controlsRestrictVerify('subHardwareControl')) {
+					if (!itoOrVideoLimits(this.newData.adminId)) {
 						uni.showToast({
 							title: '没有相关操作权限,请联系管理员',
 							icon: "none",
@@ -137,7 +137,7 @@
 				}
 			},
 			buttonClick(type, row, status) {
-				if (!controlsRestrictVerify('subHardwareControl')) {
+				if (!itoOrVideoLimits(this.newData.adminId)) {
 					uni.showToast({
 						title: '没有相关操作权限,请联系管理员',
 						icon: "none",

+ 29 - 0
utils/index.js

@@ -21,4 +21,33 @@ export function pageRestrictVerify(str) {
   }else{
     return false
   }
+}
+
+/*            硬件控制与视频监控权限验证(校级管理员/院级管理员/实验室管理员)
+  subAdminId          传入的实验室管理员ID
+  schoolId            校级管理员身份ID
+  collegeId           院级管理员身份ID
+  userInfo.position   当前用户身份ID (系统用户为NULL)
+  userInfo.userId     当前用户userID
+*/
+export function itoOrVideoLimits(subAdminId) {
+  console.log('subAdminId',subAdminId)
+  let userInfo = uni.getStorageSync('user');
+  let schoolId = '1815293314666532865';
+  let collegeId = '1815336278075838465';
+  if(userInfo.position == null){
+    //如果是管理员(系统用户)
+    return true
+  }else if(userInfo.position == schoolId || userInfo.position == collegeId){
+    //如果是校级管理员/院级管理员
+    return true
+  }else if(userInfo.userId == subAdminId){
+    //如果当前用户userId 与 管理员ID相等
+    return true
+  }else{
+    return false
+  }
+
+
+
 }