diff --git a/projects/IoT.Shared/Application/Models/EditDataModel.cs b/projects/IoT.Shared/Application/Models/EditDataModel.cs index 71f3036b..a1717b43 100644 --- a/projects/IoT.Shared/Application/Models/EditDataModel.cs +++ b/projects/IoT.Shared/Application/Models/EditDataModel.cs @@ -10,45 +10,48 @@ namespace IoT.Shared.Application.Models public class EditDataModel : EditModel { [Display(Name = "节点")] - [ReadOnly(true)] + [ReadOnlyForEdit] [SelectList] public Guid? NodeId { get; set; } [Display(Name = "设备")] - [ReadOnly(true)] + [ReadOnlyForEdit] [SelectList] public Guid? DeviceId { get; set; } [Display(Name = "键")] - [ReadOnly(true)] + [ReadOnlyForEdit] + [Required(ErrorMessage = nameof(RequiredAttribute))] public string Key { get; set; } [Display(Name = "值")] public string Value { get; set; } [Display(Name = "名称")] - [ReadOnly(true)] + [ReadOnlyForEdit] + [Required(ErrorMessage = nameof(RequiredAttribute))] public string Name { get; set; } [Display(Name = "类型")] - [ReadOnly(true)] + [ReadOnlyForEdit] [Required(ErrorMessage = nameof(RequiredAttribute))] public IoTDataType? Type { get; set; } [Display(Name = "单位")] - [ReadOnly(true)] + [ReadOnlyForEdit] public string Unit { get; set; } [Display(Name = "描述")] - [ReadOnly(true)] + [ReadOnlyForEdit] public string Description { get; set; } [Display(Name = "时间戳")] - [ReadOnly(true)] + [ReadOnlyForEdit] + [Required(ErrorMessage = nameof(RequiredAttribute))] public long? Timestamp { get; set; } [Display(Name = "隐藏")] - [ReadOnly(true)] + [ReadOnlyForEdit] public bool? Hidden { get; set; } } } diff --git a/projects/IoT.Shared/Application/Models/EditDeviceModel.cs b/projects/IoT.Shared/Application/Models/EditDeviceModel.cs index 59bf524f..4d9daf44 100644 --- a/projects/IoT.Shared/Application/Models/EditDeviceModel.cs +++ b/projects/IoT.Shared/Application/Models/EditDeviceModel.cs @@ -8,19 +8,19 @@ namespace IoT.Shared.Application.Models [Display(Name = "设备")] public class EditDeviceModel : EditModel { - [ReadOnly(true)] + [ReadOnlyForEdit] [Display(Name = "产品")] [SelectList] [Required(ErrorMessage = nameof(RequiredAttribute))] public Guid? ProductId { get; set; } - [ReadOnly(true)] + [ReadOnlyForEdit] [SelectList] [Display(Name = "节点")] [Required(ErrorMessage = nameof(RequiredAttribute))] public Guid? NodeId { get; set; } - [ReadOnly(true)] + [ReadOnlyForEdit] [Display(Name = "名称")] [Required(ErrorMessage = nameof(RequiredAttribute))] public string Name { get; set; } @@ -45,7 +45,7 @@ namespace IoT.Shared.Application.Models [Display(Name = "密码")] public string Password { get; set; } - [ReadOnly(true)] + [ReadOnlyForEdit] [Display(Name = "编号")] [Required(ErrorMessage = nameof(RequiredAttribute))] public string Number { get; set; } @@ -53,12 +53,12 @@ namespace IoT.Shared.Application.Models [Display(Name = "图标")] public string Icon { get; set; } - [ReadOnly(true)] + [ReadOnlyForEdit] [Display(Name = "在线状态")] public bool? IsOnline { get; set; } [Display(Name = "连接Id")] - [ReadOnly(true)] + [ReadOnlyForEdit] public string ConnectId { get; set; } [Display(Name = "序号")] diff --git a/projects/IoT.Shared/Application/Models/EditLiveRecordModel.cs b/projects/IoT.Shared/Application/Models/EditLiveRecordModel.cs index ff188b9b..f23e9b37 100644 --- a/projects/IoT.Shared/Application/Models/EditLiveRecordModel.cs +++ b/projects/IoT.Shared/Application/Models/EditLiveRecordModel.cs @@ -8,12 +8,12 @@ namespace IoT.Shared.Application.Models public class EditLiveRecordModel : EditModel { [Display(Name = "设备编号")] - [ReadOnly(true)] + [ReadOnlyForEdit] [Required(ErrorMessage = nameof(RequiredAttribute))] public string DeviceNumber { get; set; } [Display(Name = "设备名称")] - [ReadOnly(true)] + [ReadOnlyForEdit] [Required(ErrorMessage = nameof(RequiredAttribute))] public string DeviceName { get; set; } @@ -22,7 +22,7 @@ namespace IoT.Shared.Application.Models public string Name { get; set; } [Display(Name = "文件")] - [ReadOnly(true)] + [ReadOnlyForEdit] [Required(ErrorMessage = nameof(RequiredAttribute))] public string Value { get; set; } } diff --git a/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTDataController.cs b/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTDataController.cs index 0dd91437..6f7733da 100644 --- a/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTDataController.cs +++ b/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTDataController.cs @@ -41,8 +41,6 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls public override IQueryable Query(PagedListModel model, IQueryable query) { - //ViewData.SelectList(o => model.Query.NodeId, () => this._ajax.GetNodeSelectList(model.Query.NodeId)); - ViewData.SelectList(o => model.Query.DeviceId, () => this._ajax.GetIoTDevice(model.Query.NodeId.Value, model.Query.DeviceId), model.Query.NodeId.HasValue); return query.WhereIf(model.Query.NodeId.HasValue, o => o.Device.NodeId == model.Query.NodeId.Value) .WhereIf(model.Query.DeviceId.HasValue, o => o.DeviceId == model.Query.DeviceId.Value) .WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name)) @@ -65,10 +63,11 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls public override void ToEditModel(IoTData entity, EditDataModel model) { + model.NodeId = entity?.Device?.NodeId; ViewData.SelectList(o => model.NodeId, () => this._ajax.GetIoTGateway(model.NodeId).SelectList()); if(model.NodeId.HasValue) { - ViewData.SelectList(o => model.DeviceId, () => this._ajax.GetIoTDevice(model.NodeId.Value, model.DeviceId), model.NodeId.HasValue); + ViewData.SelectList(o => model.DeviceId, () => this._ajax.GetIoTDevice(model.NodeId.Value, model.DeviceId).SelectList()); } } diff --git a/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTDeviceController.cs b/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTDeviceController.cs index bcef0e5c..b28c0e36 100644 --- a/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTDeviceController.cs +++ b/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTDeviceController.cs @@ -7,7 +7,6 @@ using IoT.Shared.Application.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Primitives; using System; using System.Linq; diff --git a/projects/IoT.Shared/Controllers/AjaxBaseController.cs b/projects/IoT.Shared/Controllers/AjaxBaseController.cs index 971f67c5..cf8bb033 100644 --- a/projects/IoT.Shared/Controllers/AjaxBaseController.cs +++ b/projects/IoT.Shared/Controllers/AjaxBaseController.cs @@ -76,7 +76,7 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls return new JsonResult(new SelectList(list, "Id", "Name", selected)); } - public SelectList GetIoTDevice(Guid parentId, Guid? selected = null) + public JsonResult GetIoTDevice(Guid parentId, Guid? selected = null) { using var scope = this._services.CreateScope(); var repo = scope.ServiceProvider.GetRequiredService>(); @@ -84,7 +84,7 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls .Where(o => o.NodeId == parentId) .Select(o => new { o.Id, o.Name }) .ToList(); - return new SelectList(list, "Id", "Name", selected); + return new JsonResult(new SelectList(list, "Id", "Name", selected)); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/projects/IoTNode/Areas/IoTCenter/Controllers/AjaxController.cs b/projects/IoTNode/Areas/IoTCenter/Controllers/AjaxController.cs index 39f04211..d6dc06e2 100644 --- a/projects/IoTNode/Areas/IoTCenter/Controllers/AjaxController.cs +++ b/projects/IoTNode/Areas/IoTCenter/Controllers/AjaxController.cs @@ -1,11 +1,12 @@ -using Microsoft.AspNetCore.Mvc; +using IoT.Shared.Areas.IoTCenter.Controlls; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System; namespace Platform.Areas.IoTCenter.Controllers { [Area("IoTCenter")] - public class AjaxController : IoT.Shared.Areas.IoTCenter.Controlls.AjaxBaseController + public class AjaxController : AjaxBaseController { public AjaxController(IServiceProvider services, ILogger logger) diff --git a/projects/Platform/Application/Models/EditUserInfoModel.cs b/projects/Platform/Application/Models/EditUserInfoModel.cs index bd5e9ef5..0f00b8f9 100644 --- a/projects/Platform/Application/Models/EditUserInfoModel.cs +++ b/projects/Platform/Application/Models/EditUserInfoModel.cs @@ -10,7 +10,7 @@ namespace IoT.Shared.Application.Models public class EditUserInfoModel : EditModel { [Display(Name = "用户名")] - [ReadOnly(true)] + [ReadOnlyForEdit] public string UserName { get; set; } [MaxLength(24, ErrorMessage = "{0}最大长度为{1}")] diff --git a/projects/Platform/Areas/IoTCenter/Controllers/OrganSceneTiggerController.cs b/projects/Platform/Areas/IoTCenter/Controllers/OrganSceneTiggerController.cs index fb036411..e89325d0 100644 --- a/projects/Platform/Areas/IoTCenter/Controllers/OrganSceneTiggerController.cs +++ b/projects/Platform/Areas/IoTCenter/Controllers/OrganSceneTiggerController.cs @@ -57,7 +57,7 @@ namespace Platform.Areas.IoTCenter.Controllers ViewData.SelectList(o => model.OrganId, () => this._ajax.GetOrgan(model.OrganId).SelectList()); ViewData.SelectList(o => model.NodeId, () => this._ajax.GetIoTGateway(model.NodeId).SelectList(), model.OrganId.HasValue); ViewData.SelectList(o => model.OrganSceneId, () => this._ajax.GetOrganSceneSelectList(model.OrganId.Value, model.OrganSceneId), model.OrganId.HasValue); - ViewData.SelectList(o => model.DeviceId, () => this._ajax.GetIoTDevice(model.NodeId.Value), model.NodeId.HasValue); + ViewData.SelectList(o => model.DeviceId, () => this._ajax.GetIoTDevice(model.NodeId.Value, model.DeviceId).SelectList()); ViewData.SelectList(o => model.DataId, () => this._ajax.GetDataSelectList(model.DeviceId.Value), model.DeviceId.HasValue); }