diff --git a/projects/Platform/Api/Api/LayoutModel.cs b/projects/Platform/Api/Api/LayoutModel.cs index b73c5498..f7788b54 100644 --- a/projects/Platform/Api/Api/LayoutModel.cs +++ b/projects/Platform/Api/Api/LayoutModel.cs @@ -14,6 +14,7 @@ namespace Platform.Api public List Modules { get; set; } public List Organs { get; set; } public ClaimsIdentity User { get; set; } + public List Roles { get; set; } public Guid? CurrentOrganId { get; set; } } } \ No newline at end of file diff --git a/projects/Platform/Api/Api/SiteController.cs b/projects/Platform/Api/Api/SiteController.cs index 9320b33f..f79ebaef 100644 --- a/projects/Platform/Api/Api/SiteController.cs +++ b/projects/Platform/Api/Api/SiteController.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System; +using System.Collections.Generic; using System.Linq; using System.Security.Claims; @@ -26,9 +27,9 @@ namespace Platform.Api private readonly IRepository _buildingRepo; private readonly IRepository _statisticRepo; - public SiteController(ISettingService settingService, - IRepository userRepo, - IRepository appModuleRepo, + public SiteController(ISettingService settingService, + IRepository userRepo, + IRepository appModuleRepo, IRepository organUserRepo, IRepository areaRepo, IRepository organRepo, @@ -38,7 +39,7 @@ namespace Platform.Api this._settingService = settingService; this._userRepo = userRepo; this._appModuleRepo = appModuleRepo; - this._organUserRepo = organUserRepo; + this._organUserRepo = organUserRepo; this._areaRepo = areaRepo; this._organRepo = organRepo; this._buildingRepo = buildingRepo; @@ -60,6 +61,7 @@ namespace Platform.Api .Where(o => o.User.UserName == userName) .Select(o => o.Organ) .ToList(); + var organId = User.GetOrganId(); var model = new LayoutModel { Name = this._settingService.GetValue("name"), @@ -69,7 +71,15 @@ namespace Platform.Api Modules = modules, Organs = organs, CurrentOrganId = User.GetOrganId(), - User = User == null ? null : User.Identity as ClaimsIdentity + User = User == null ? null : User.Identity as ClaimsIdentity, + Roles = User == null + ? new List() + : this._organUserRepo.ReadOnlyTable() + .Where(o => o.User.UserName == userName) + .Where(o => o.OrganId == organId) + .SelectMany(o => o.UserRoles) + .Select(o => o.OrganRole.Name) + .ToList() }; if (platformUser != null && model.User != null) { diff --git a/projects/Platform/wwwroot/components/devices/camera.vue b/projects/Platform/wwwroot/components/devices/camera.vue index ff84ed68..ae9229bf 100644 --- a/projects/Platform/wwwroot/components/devices/camera.vue +++ b/projects/Platform/wwwroot/components/devices/camera.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/components/devices/collector.vue b/projects/Platform/wwwroot/components/devices/collector.vue index ae6802f6..ab6ceea6 100644 --- a/projects/Platform/wwwroot/components/devices/collector.vue +++ b/projects/Platform/wwwroot/components/devices/collector.vue @@ -4,7 +4,7 @@

{{device.displayName}}

-
+
diff --git a/projects/Platform/wwwroot/components/devices/control.vue b/projects/Platform/wwwroot/components/devices/control.vue index 076a2fa3..102624cb 100644 --- a/projects/Platform/wwwroot/components/devices/control.vue +++ b/projects/Platform/wwwroot/components/devices/control.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/components/devices/curtain.vue b/projects/Platform/wwwroot/components/devices/curtain.vue index a3a70832..9c93833b 100644 --- a/projects/Platform/wwwroot/components/devices/curtain.vue +++ b/projects/Platform/wwwroot/components/devices/curtain.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/components/devices/door.vue b/projects/Platform/wwwroot/components/devices/door.vue index 0f20f6ce..3493802e 100644 --- a/projects/Platform/wwwroot/components/devices/door.vue +++ b/projects/Platform/wwwroot/components/devices/door.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/components/devices/gateway.vue b/projects/Platform/wwwroot/components/devices/gateway.vue index 1f5dc50d..591f92d7 100644 --- a/projects/Platform/wwwroot/components/devices/gateway.vue +++ b/projects/Platform/wwwroot/components/devices/gateway.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/components/devices/lamp.vue b/projects/Platform/wwwroot/components/devices/lamp.vue index 6ab9c60f..f076dfb5 100644 --- a/projects/Platform/wwwroot/components/devices/lamp.vue +++ b/projects/Platform/wwwroot/components/devices/lamp.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/components/devices/plug.vue b/projects/Platform/wwwroot/components/devices/plug.vue index 7fd0046b..a768e394 100644 --- a/projects/Platform/wwwroot/components/devices/plug.vue +++ b/projects/Platform/wwwroot/components/devices/plug.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/components/devices/serialport.vue b/projects/Platform/wwwroot/components/devices/serialport.vue index d2e09800..97839beb 100644 --- a/projects/Platform/wwwroot/components/devices/serialport.vue +++ b/projects/Platform/wwwroot/components/devices/serialport.vue @@ -4,7 +4,7 @@

{{device.displayName}}

-
+
diff --git a/projects/Platform/wwwroot/components/devices/socket.vue b/projects/Platform/wwwroot/components/devices/socket.vue index d255b7ed..d3a9a52c 100644 --- a/projects/Platform/wwwroot/components/devices/socket.vue +++ b/projects/Platform/wwwroot/components/devices/socket.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/components/devices/switch1.vue b/projects/Platform/wwwroot/components/devices/switch1.vue index d255b7ed..d3a9a52c 100644 --- a/projects/Platform/wwwroot/components/devices/switch1.vue +++ b/projects/Platform/wwwroot/components/devices/switch1.vue @@ -6,7 +6,7 @@ -
+
diff --git a/projects/Platform/wwwroot/js/app.js b/projects/Platform/wwwroot/js/app.js index 84580e26..036c9328 100644 --- a/projects/Platform/wwwroot/js/app.js +++ b/projects/Platform/wwwroot/js/app.js @@ -140,6 +140,14 @@ function getIoTDataValue(device, name) { }; Vue.prototype.getIoTDataValue = getIoTDataValue; Vue.prototype.moment = moment; +Vue.prototype.hasDevicePermission = function () { + if (store.state.layout) { + if (Enumerable.from(store.state.layout.roles).any(o => o.indexOf('管理员')>-1)) { + return true; + } + } + return false; +} function getIoTDataUnit(device, name) { var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault(); if (data) {