You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/Infrastructure/Views/Shared/Search.cshtml

55 lines
2.3 KiB

@{
var inputClass = "form-control";
var scope = ViewBag.ControllerScope as string;
}
@foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit))
{
var uihit = prop.TemplateHint ?? prop.DataTypeName;
var name = "query." + prop.PropertyName;
if(scope=="Organ"&&prop.PropertyName=="OrganId")
{
@Html.Hidden(prop.PropertyName)
continue;
}
if (prop.PropertyName == "Id" || prop.PropertyName == "DisplayOrder" || uihit == "ImageUrl" || uihit == "MultiSelectList")
{
continue;
}
else
{
<div class="col-12 col-sm-6 col-md-4 col-lg-3">
<div class="form-group row">
<label class="col-sm-3 col-form-label" for="@prop.PropertyName" data-ui="@uihit @prop.UnderlyingOrModelType">@prop.GetDisplayName():</label>
<div class="col-sm-9">
@if (prop.ModelType == typeof(string) ||
prop.UnderlyingOrModelType == typeof(Int32) ||
prop.UnderlyingOrModelType == typeof(Int64)||
prop.UnderlyingOrModelType == typeof(System.Single)||
prop.UnderlyingOrModelType == typeof(System.Double)||
prop.UnderlyingOrModelType == typeof(System.Decimal))
{
@Html.TextBox(prop.PropertyName, null, new { name=name,@class = inputClass })
}
else if(prop.IsNullableValueType&&prop.UnderlyingOrModelType == typeof(bool))
{
var items=new List<SelectListItem>(){new SelectListItem{ Value="true",Text="是"},new SelectListItem{Value="false",Text="否"}};
var list = new SelectList(items, "Value", "Text");
@Html.DropDownList(prop.PropertyName, list,"请选择", new { @class = inputClass })
}
else if(prop.IsNullableValueType&&prop.IsEnum)
{
var items=Enum.GetValues(prop.UnderlyingOrModelType).Cast<Enum>()
.Select(o => new SelectListItem { Value = o.GetValue().ToString(), Text = o.GetDisplayName() })
.ToList();
var list = new SelectList(items, "Value", "Text");
@Html.DropDownList(prop.PropertyName, list,"请选择", new { @class = inputClass })
}
else
{
@Html.Editor(prop.PropertyName, prop.DataTypeName ?? prop.TemplateHint, prop.AdditionalValues)
}
</div>
</div>
</div>
}
}