Commit 5ce797a9 by jianshuqin

优化:组件功能

parent c23b2b82
...@@ -74,7 +74,6 @@ namespace Bailun.DC.Models.Component.DTO ...@@ -74,7 +74,6 @@ namespace Bailun.DC.Models.Component.DTO
/// <summary> /// <summary>
/// 列值 /// 列值
/// </summary> /// </summary>
[JsonIgnore]
public string ColumnValue { get; set; } public string ColumnValue { get; set; }
/// <summary> /// <summary>
...@@ -100,19 +99,16 @@ namespace Bailun.DC.Models.Component.DTO ...@@ -100,19 +99,16 @@ namespace Bailun.DC.Models.Component.DTO
/// <summary> /// <summary>
/// 数据值 /// 数据值
/// </summary> /// </summary>
[JsonIgnore]
public string DataValue { get; set; } public string DataValue { get; set; }
/// <summary> /// <summary>
/// 数据库:1: 数据中心, 2: 交易流水 /// 数据库:1: 数据中心, 2: 交易流水
/// </summary> /// </summary>
[JsonIgnore]
public DBEnum? DataDB { get; set; } public DBEnum? DataDB { get; set; }
/// <summary> /// <summary>
/// 数据默认排序SQL /// 数据默认排序SQL
/// </summary> /// </summary>
[JsonIgnore]
public string DataSortSql { get; set; } public string DataSortSql { get; set; }
/// <summary> /// <summary>
......
...@@ -21,24 +21,27 @@ namespace Bailun.DC.Services.Component ...@@ -21,24 +21,27 @@ namespace Bailun.DC.Services.Component
/// 获取查询组件 /// 获取查询组件
/// </summary> /// </summary>
/// <param name="code">编码</param> /// <param name="code">编码</param>
/// <param name="id">ID</param>
/// <returns></returns> /// <returns></returns>
public TableDTO Get(string code) public TableDTO Get(string code = null, string id = null)
{ {
TableDTO dto = default(TableDTO); TableDTO dto = default(TableDTO);
if (!string.IsNullOrWhiteSpace(code)) if (!string.IsNullOrWhiteSpace(code) || !string.IsNullOrWhiteSpace(id))
{ {
dc_component_table entity = default(dc_component_table); dc_component_table entity = default(dc_component_table);
using (var db = DB) using (var db = DB)
{ {
DynamicParameters sqlparam = new DynamicParameters(); DynamicParameters sqlparam = new DynamicParameters();
sqlparam.Add("id", id);
sqlparam.Add("code", code); sqlparam.Add("code", code);
entity = db.QueryFirstOrDefault<dc_component_table>("select * from dc_component_table where is_delete = 0 and code = @code", sqlparam); entity = db.QueryFirstOrDefault<dc_component_table>("select * from dc_component_table where is_delete = 0 and (id = @id or code = @code)", sqlparam);
} }
if (entity != null) if (entity != null)
{ {
dto = new TableDTO dto = new TableDTO
{ {
Id = entity.id,
Code = entity.code, Code = entity.code,
Name = entity.name, Name = entity.name,
MenuCode = entity.menu_code, MenuCode = entity.menu_code,
...@@ -69,6 +72,7 @@ namespace Bailun.DC.Services.Component ...@@ -69,6 +72,7 @@ namespace Bailun.DC.Services.Component
//列 //列
if (dto.ColumnType == ColumnTypeEnum.Config && !string.IsNullOrWhiteSpace(entity.column_value)) if (dto.ColumnType == ColumnTypeEnum.Config && !string.IsNullOrWhiteSpace(entity.column_value))
{ {
dto.ColumnValue = null;
dto.ListColumn = DeserializeCollection<dynamic>(entity.column_value); dto.ListColumn = DeserializeCollection<dynamic>(entity.column_value);
} }
if (dto.ListOperateControl?.Count() > 0) if (dto.ListOperateControl?.Count() > 0)
...@@ -481,7 +485,7 @@ namespace Bailun.DC.Services.Component ...@@ -481,7 +485,7 @@ namespace Bailun.DC.Services.Component
if (listColumn != null) if (listColumn != null)
{ {
//数据类型 //数据类型
DataTypeEnum?[] dataTypes = { DataTypeEnum.Table, DataTypeEnum.Sql }; DataTypeEnum?[] dataTypes = { DataTypeEnum.Table, DataTypeEnum.Sql };
//全部数据导出 //全部数据导出
queryFilter.CurrentPage = null; queryFilter.CurrentPage = null;
queryFilter.pageSize = null; queryFilter.pageSize = null;
...@@ -537,7 +541,7 @@ namespace Bailun.DC.Services.Component ...@@ -537,7 +541,7 @@ namespace Bailun.DC.Services.Component
is_show_sequence_column = dto.IsShowSequenceColumn, is_show_sequence_column = dto.IsShowSequenceColumn,
is_show_column_search = dto.IsShowColumnSearch, is_show_column_search = dto.IsShowColumnSearch,
column_type = dto.ColumnType, column_type = dto.ColumnType,
column_value = dto.ColumnValue, column_value = dto.ColumnType == ColumnTypeEnum.Config && dto.ListColumn?.Count() > 0 ? JsonConvert.SerializeObject(dto.ListColumn) : dto.ColumnValue,
data_type = dto.DataType, data_type = dto.DataType,
data_value = dto.DataValue, data_value = dto.DataValue,
data_db = dto.DataDB, data_db = dto.DataDB,
...@@ -733,16 +737,16 @@ namespace Bailun.DC.Services.Component ...@@ -733,16 +737,16 @@ namespace Bailun.DC.Services.Component
} }
else else
{ {
IList<dynamic> listColumn = default(IList<dynamic>); IEnumerable<dynamic> listColumn = default(IList<dynamic>);
if (entity.ColumnType == ColumnTypeEnum.Config) if (entity.ColumnType == ColumnTypeEnum.Config)
{ {
listColumn = DeserializeCollection<dynamic>(entity.ColumnValue).ToList(); listColumn = entity.ListColumn;
} }
else else
{ {
listColumn = this.GetListColumn(queryFilter); listColumn = this.GetListColumn(queryFilter, entity);
} }
if (listColumn?.Count > 0 && listColumn.Any(l => !string.IsNullOrWhiteSpace(l.Code) && l.OrderSort > 0)) if (listColumn?.Count() > 0 && listColumn.Any(l => !string.IsNullOrWhiteSpace(l.Code) && l.OrderSort > 0))
{ {
sql = string.Join(",", listColumn.Where(l => !string.IsNullOrWhiteSpace(l.Code) && l.OrderSort > 0).OrderBy(l => l.OrderSort).Select(l => $"`{l.Code}` {(l.Descending == true ? "desc" : "asc")}")); sql = string.Join(",", listColumn.Where(l => !string.IsNullOrWhiteSpace(l.Code) && l.OrderSort > 0).OrderBy(l => l.OrderSort).Select(l => $"`{l.Code}` {(l.Descending == true ? "desc" : "asc")}"));
} }
......
using Bailun.DC.Models.Component.DTO; using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Services.Component; using Bailun.DC.Services.Component;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System; using System;
using System.Linq;
using System.Collections.Generic;
namespace Bailun.DC.Web.Areas.Component.Controllers namespace Bailun.DC.Web.Areas.Component.Controllers
{ {
...@@ -15,12 +19,12 @@ namespace Bailun.DC.Web.Areas.Component.Controllers ...@@ -15,12 +19,12 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
[HttpGet] [HttpGet]
public JsonResult Get(string code = null) public JsonResult Get(string id = null, string code = null)
{ {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
try try
{ {
result.Data = new TableService().Get(code); result.Data = new TableService().Get(code, id);
result.Result = true; result.Result = true;
} }
catch (Exception ex) catch (Exception ex)
...@@ -28,7 +32,7 @@ namespace Bailun.DC.Web.Areas.Component.Controllers ...@@ -28,7 +32,7 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
result.Message = ex.Message; result.Message = ex.Message;
} }
return Json(result); return Json(result, new JsonSerializerSettings() { ContractResolver = new IgnoreJsonAttributesResolver(id), DefaultValueHandling = DefaultValueHandling.Include });
} }
[HttpPost] [HttpPost]
...@@ -143,5 +147,30 @@ namespace Bailun.DC.Web.Areas.Component.Controllers ...@@ -143,5 +147,30 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
return Json(result); return Json(result);
} }
private class IgnoreJsonAttributesResolver : DefaultContractResolver
{
private string Id { get; set; }
public IgnoreJsonAttributesResolver(string id)
{
this.Id = id;
}
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
this.NamingStrategy = new CamelCaseNamingStrategy();
IList<JsonProperty> props = base.CreateProperties(type, memberSerialization);
foreach (var prop in props)
{
string[] ignorePropertys = { "ColumnValue", "DataValue", "DataDB", "DataSortSql" };
if (string.IsNullOrWhiteSpace(this.Id) && ignorePropertys.Contains(prop.UnderlyingName))
{
prop.Ignored = true;
}
}
return props;
}
}
} }
} }
...@@ -77,3 +77,7 @@ ...@@ -77,3 +77,7 @@
.el-form-control .mt59 { .el-form-control .mt59 {
margin-left: 59px; margin-left: 59px;
} }
.el-form-control .el-textarea.el-input--small span {
height: 25px;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment