Former-commit-id: c181872a59e5ee8f7ae7e168f5d9edab10ad67c6
Former-commit-id: 09fb3a5a8cc2764d0119b9dce959a8cdd2d98b18
1.0
wanggang 5 years ago
parent 63aa6a8979
commit bad856647d

@ -71,9 +71,13 @@
{
continue;
}
if(scope=="Organ"&&item.Name=="OrganId")
if (item.CustomAttributes.Any(o => o.AttributeType == typeof(SkipListAttribute)))
{
continue;
continue;
}
if (scope=="Organ"&&item.Name=="OrganId")
{
continue;
}
<th style="white-space: nowrap;">@item.GetDisplayName()</th>
}

@ -1,6 +1,7 @@
@using System.Reflection
@using Microsoft.AspNetCore.Mvc.Controllers
@using Infrastructure.Web.Mvc
@using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
@{
var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope;
var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit).ToList();
@ -14,7 +15,11 @@
Html.Hidden(prop.PropertyName);
continue;
}
if (prop.PropertyName == "Id" || prop.PropertyName == "DisplayOrder" || prop.PropertyName == "Cron" || uihit == "ImageUrl" || uihit == "MultiSelectList" || uihit=="ImageUrl")
if ((prop as DefaultModelMetadata).Attributes.Attributes.Any(o => o.GetType() == typeof(SkipSearchAttribute)))
{
continue;
}
if (prop.PropertyName == "Id" || prop.PropertyName == "DisplayOrder" || prop.PropertyName == "Cron" || uihit == "ImageUrl" || uihit == "MultiSelectList" || uihit == "ImageUrl")
{
continue;
}

@ -1,6 +1,7 @@
@using System.Reflection
@using Microsoft.AspNetCore.Mvc.Controllers
@using Infrastructure.Web.Mvc
@using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
@{
var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope;
var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !pm.HideSurroundingHtml && !pm.IsComplexType && !pm.IsCollectionType);
@ -8,10 +9,15 @@
@{
foreach (var prop in props)
{
var metadata = prop as DefaultModelMetadata;
if (scope != null && scope == ControllerScopeType.Organ && prop.PropertyName == "OrganId")
{
continue;
}
if (metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(SkipListAttribute)))
{
continue;
}
var templateName = prop.DataTypeName ?? prop.TemplateHint ?? (prop.ModelType == typeof(string) ? typeof(string).Name : null);
<td style="white-space: nowrap;text-overflow:ellipsis;overflow: hidden;max-width:10em;" data-ext="@templateName">
@Html.Display(prop.PropertyName, templateName)

@ -0,0 +1,6 @@
namespace System.ComponentModel.DataAnnotations
{
public class SkipListAttribute : Attribute
{
}
}

@ -0,0 +1,6 @@
namespace System.ComponentModel.DataAnnotations
{
public class SkipSearchAttribute : Attribute
{
}
}

@ -10,7 +10,7 @@ namespace IoT.Shared.Application.Models
[ReadOnlyForEdit]
[Display(Name = "产品")]
[SelectList]
public Guid? ProductId { get; set; }
public Guid? IoTProductId { get; set; }
[ReadOnlyForEdit]
[SelectList]
@ -40,6 +40,8 @@ namespace IoT.Shared.Application.Models
[Display(Name = "用户名")]
public string UserName { get; set; }
[SkipSearch]
[SkipList]
[Display(Name = "密码")]
public string Password { get; set; }
@ -48,6 +50,7 @@ namespace IoT.Shared.Application.Models
[Required(ErrorMessage = nameof(RequiredAttribute))]
public string Number { get; set; }
[SkipSearch]
[Display(Name = "图标")]
public string Icon { get; set; }
@ -55,6 +58,8 @@ namespace IoT.Shared.Application.Models
[Display(Name = "在线状态")]
public bool? IsOnline { get; set; }
[SkipSearch]
[SkipList]
[Display(Name = "连接Id")]
[ReadOnlyForEdit]
public string ConnectId { get; set; }

@ -25,6 +25,7 @@ namespace IoT.Shared.Application.Models
[ReadOnlyForEdit]
public string Path { get; set; }
[SkipList]
[Display(Name = "ApiJson")]
[DataType(DataType.MultilineText)]
[ReadOnlyForEdit]

@ -35,17 +35,14 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
{
return query
.WhereIf(model.Query.IoTGatewayId.HasValue, o => o.IoTGatewayId == model.Query.IoTGatewayId.Value)
.WhereIf(model.Query.ProductId.HasValue, o => o.IoTProductId == model.Query.ProductId.Value)
.WhereIf(model.Query.IoTProductId.HasValue, o => o.IoTProductId == model.Query.IoTProductId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.WhereIf(!string.IsNullOrEmpty(model.Query.DisplayName), o => o.DisplayName.Contains(model.Query.DisplayName))
.WhereIf(!string.IsNullOrEmpty(model.Query.Gateway), o => o.Gateway.Contains(model.Query.Gateway))
.WhereIf(!string.IsNullOrEmpty(model.Query.Tag), o => o.Tag.Contains(model.Query.Tag))
.WhereIf(!string.IsNullOrEmpty(model.Query.Ip), o => o.Ip.Contains(model.Query.Ip))
.WhereIf(!string.IsNullOrEmpty(model.Query.UserName), o => o.UserName.Contains(model.Query.UserName))
.WhereIf(!string.IsNullOrEmpty(model.Query.Password), o => o.Password.Contains(model.Query.Password))
.WhereIf(!string.IsNullOrEmpty(model.Query.Number), o => o.Number.Contains(model.Query.Number))
.WhereIf(!string.IsNullOrEmpty(model.Query.Icon), o => o.Icon.Contains(model.Query.Icon))
.WhereIf(!string.IsNullOrEmpty(model.Query.ConnectId), o => o.ConnectId.Contains(model.Query.ConnectId))
.WhereIf(model.Query.IsOnline.HasValue, o => o.IsOnline == model.Query.IsOnline.Value)
.WhereIf(model.Query.Disabled.HasValue, o => o.Disabled == model.Query.Disabled.Value);
}
@ -53,13 +50,13 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
public override void ToDisplayModel(IoTDevice entity, EditIoTDeviceModel model)
{
ViewData.Add(model.IoTGatewayId, entity?.IoTGateway?.Name);
ViewData.Add(model.ProductId, entity?.IoTProduct?.Name);
ViewData.Add(model.IoTProductId, entity?.IoTProduct?.Name);
}
public override void ToEditModel(IoTDevice entity, EditIoTDeviceModel model)
{
ViewData.SelectList(o => model.IoTGatewayId, () => this._ajax.GetIoTGateway(model.IoTGatewayId).SelectList());
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetIoTProduct(model.ProductId).SelectList());
ViewData.SelectList(o => model.IoTProductId, () => this._ajax.GetIoTProduct(model.IoTProductId).SelectList());
}
}
}

@ -60,6 +60,10 @@
{
continue;
}
if (item.CustomAttributes.Any(o => o.AttributeType == typeof(SkipListAttribute)))
{
continue;
}
if (scope == "Organ" && item.Name == "OrganId")
{
continue;

@ -20,7 +20,7 @@ namespace Platform.Application.Models.IoTCenter
[Display(Name = "分类")]
[ReadOnlyForEdit]
[SelectList(nameof(ProductId), nameof(AjaxController.GetIoTProductByCategory))]
[SelectList(nameof(IoTProductId), nameof(AjaxController.GetIoTProductByCategory))]
public Guid? CategoryId { get; set; }
}
}

@ -54,17 +54,14 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
.WhereIf(model.Query.BuildingId.HasValue, o => o.IoTGateway.BuildingId == model.Query.BuildingId.Value)
.WhereIf(model.Query.IoTGatewayId.HasValue, o => o.IoTGatewayId == model.Query.IoTGatewayId.Value)
.WhereIf(model.Query.CategoryId.HasValue, o => o.IoTProduct.IoTProductCategoryId == model.Query.CategoryId.Value)
.WhereIf(model.Query.ProductId.HasValue, o => o.IoTProductId == model.Query.ProductId.Value)
.WhereIf(model.Query.IoTProductId.HasValue, o => o.IoTProductId == model.Query.IoTProductId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.WhereIf(!string.IsNullOrEmpty(model.Query.DisplayName), o => o.DisplayName.Contains(model.Query.DisplayName))
.WhereIf(!string.IsNullOrEmpty(model.Query.Gateway), o => o.Gateway.Contains(model.Query.Gateway))
.WhereIf(!string.IsNullOrEmpty(model.Query.Tag), o => o.Tag.Contains(model.Query.Tag))
.WhereIf(!string.IsNullOrEmpty(model.Query.Ip), o => o.Ip.Contains(model.Query.Ip))
.WhereIf(!string.IsNullOrEmpty(model.Query.UserName), o => o.UserName.Contains(model.Query.UserName))
.WhereIf(!string.IsNullOrEmpty(model.Query.Password), o => o.Password.Contains(model.Query.Password))
.WhereIf(!string.IsNullOrEmpty(model.Query.Number), o => o.Number.Contains(model.Query.Number))
.WhereIf(!string.IsNullOrEmpty(model.Query.Icon), o => o.Icon.Contains(model.Query.Icon))
.WhereIf(!string.IsNullOrEmpty(model.Query.ConnectId), o => o.ConnectId.Contains(model.Query.ConnectId))
.WhereIf(model.Query.IsOnline.HasValue, o => o.IsOnline == model.Query.IsOnline.Value)
.WhereIf(model.Query.Disabled.HasValue, o => o.Disabled == model.Query.Disabled.Value);
}
@ -108,9 +105,9 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
.FirstOrDefault(o => o.Id == model.CategoryId.Value)?.GetDisplayName();
ViewData.Add(model.CategoryId, name);
}
if (model.ProductId.HasValue)
if (model.IoTProductId.HasValue)
{
ViewData.Add(model.ProductId, entity.IoTProduct.Name);
ViewData.Add(model.IoTProductId, entity.IoTProduct.Name);
}
if (model.IoTGatewayId.HasValue)
{
@ -123,7 +120,7 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
ViewData.SelectList(o => model.OrganId, () => this._ajax.GetOrgan(model.OrganId).SelectList());
ViewData.SelectList(o => model.BuildingId, () => this._ajax.GetBuilding(model.OrganId.Value, model.BuildingId).SelectList(), model.OrganId.HasValue);
ViewData.SelectList(o => model.CategoryId, () => this._ajax.GetIoTProductCategory(model.CategoryId).SelectList());
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetIoTProductByCategory(model.CategoryId.Value, model.ProductId).SelectList(), model.CategoryId.HasValue);
ViewData.SelectList(o => model.IoTProductId, () => this._ajax.GetIoTProductByCategory(model.CategoryId.Value, model.IoTProductId).SelectList(), model.CategoryId.HasValue);
}
public override string GetNodeNumber(EditPlatformIoTDeviceModel model)

Loading…
Cancel
Save