public static AutoTable Convert(string fullName) { var objectCache = Ioc.Resolve <IObjectCache>(); return(objectCache.GetOrSet(() => { var type = fullName.GetTypeByFullName(); var classDescription = fullName.GetClassDescription(); if (classDescription == null) { return null; } var classPropertyAttribute = classDescription.ClassPropertyAttribute; var auto = new AutoTable { Key = fullName, Name = classPropertyAttribute.Name, ApiUrl = GetApiUrl(type), Icon = classPropertyAttribute.Icon }; #region 如果不包含操作按钮,则不显示操作这一列 // 如果不包含操作按钮,则不显示操作这一列 auto.TableActions = GetActions(type, classPropertyAttribute); // 操作链接 if (auto.TableActions != null && auto.TableActions.Any(r => r.ActionType == TableActionType.ColumnAction)) { // 构建字段 var actionColumn = new TableColumn { Label = "操作", Prop = "action" }; auto.Columns.Add(actionColumn); } #endregion 如果不包含操作按钮,则不显示操作这一列 #region 列相关的字段操作 var propertys = classDescription.Propertys; foreach (var item in propertys) { if (item.FieldAttribute != null && item.FieldAttribute.ListShow) { if (item.Name == "Id") { continue; } var tableColumn = new TableColumn { Label = item.DisplayAttribute?.Name, Prop = item.Property.Name.ToFristLower(), Width = item.FieldAttribute.Width }; tableColumn = GetType(tableColumn, item.Property, item.FieldAttribute); if (!item.FieldAttribute.Width.IsNullOrEmpty()) { tableColumn.Width = item.FieldAttribute.Width; } auto.Columns.Add(tableColumn); } } #endregion 列相关的字段操作 auto.SearchOptions = GetSearchOptions(propertys); // 搜索相关链接 auto.Tabs = GetTabs(propertys); // Tabs导航 return auto; }, fullName + "AutoTable").Value); }
public static AutoTable Convert(string fullName) { var objectCache = Ioc.Resolve <IObjectCache>(); return(objectCache.GetOrSet(() => { var type = fullName.GetTypeByFullName(); var classDescription = fullName.GetClassDescription(); if (classDescription == null) { return null; } var classPropertyAttribute = classDescription.ClassPropertyAttribute; var auto = new AutoTable { Type = fullName, }; auto.Border = new Border(classPropertyAttribute); #region 如果不包含操作按钮,则不显示操作这一列 if (classPropertyAttribute.IsTableAction) { // 如果不包含操作按钮,则不显示操作这一列 auto.TableActions = GetActions(type, classPropertyAttribute); // 操作链接 } if (auto.TableActions != null && auto.TableActions.Any(r => r.ActionType == TableActionType.ColumnAction)) { // 构建字段 var actionColumn = new AutoTableColumn { Label = "操作", Prop = "action", }; actionColumn.Style.ColumnStyle = ColumnStyle.Action; actionColumn.Style.Width = "105"; auto.Columns.Add(actionColumn); } #endregion 如果不包含操作按钮,则不显示操作这一列 #region 列相关的字段操作 var propertys = classDescription.Propertys; int decimalIndex = 0; foreach (var item in propertys) { if (item.FieldAttribute != null && item.FieldAttribute.ListShow) { if (item.Name == "Id") { continue; } var tableColumn = new AutoTableColumn { Label = item.DisplayAttribute?.Name, Prop = item.Property.Name.ToFristLower(), }; tableColumn = GetType(type, tableColumn, item.Property, item.FieldAttribute, ref decimalIndex); auto.Columns.Add(tableColumn); } } #endregion 列相关的字段操作 auto.SearchOptions = GetSearchOptions(propertys); // 搜索相关链接 auto.Tabs = GetTabs(propertys); // Tabs导航 auto.Columns = HanderWidth(auto.Columns); // 宽度处理 return auto; }, fullName + "AutoTable").Value); }