更新列表设置字段长度

dev
cjy 2 weeks ago
parent f7953cf8b2
commit 5c2a50b5e5

@ -0,0 +1,83 @@
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Code.Dtos
{
/// <summary>
/// 设置表格列宽度
/// </summary>
public class UpdateColumnFieldReq
{
public long PermissionId { get; set; }
public int ColumnNo { get; set; }
public string Field { get; set; }
public int Width { get; set; }
}
/// <summary>
/// 列设置内容
/// </summary>
public class ColumnSetContent {
/// <summary>
///
/// </summary>
public List<Columns> Columns { get; set; }
}
public class Columns
{
/// <summary>
/// 委托编号
/// </summary>
public string Label { get; set; }
/// <summary>
///
/// </summary>
public string Value { get; set; }
/// <summary>
///
/// </summary>
public string DataIndex { get; set; }
/// <summary>
/// 委托编号
/// </summary>
public string Title { get; set; }
/// <summary>
///
/// </summary>
public bool Sorter { get; set; }
/// <summary>
///
/// </summary>
public int Width { get; set; }
/// <summary>
///
/// </summary>
public bool DefaultHidden { get; set; }
/// <summary>
///
/// </summary>
public bool Resizable { get; set; }
/// <summary>
///
/// </summary>
public string Align { get; set; }
/// <summary>
///
/// </summary>
public string Key { get; set; }
/// <summary>
///
/// </summary>
public bool Ellipsis { get; set; }
}
}

@ -46,4 +46,11 @@ public interface IColumnSetService
/// <returns></returns> /// <returns></returns>
public DataResult BatchDelColumnSet(IdModel req); public DataResult BatchDelColumnSet(IdModel req);
/// <summary>
/// 更新列表设置字段长度
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult> UpdateColumnSetField(UpdateColumnFieldReq req);
} }

@ -6,8 +6,11 @@ using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos; using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Code.Interface; using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Sys.Dtos;
using Mapster; using Mapster;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using SqlSugar; using SqlSugar;
namespace DS.WMS.Core.Code.Method namespace DS.WMS.Core.Code.Method
{ {
@ -94,6 +97,50 @@ namespace DS.WMS.Core.Code.Method
.First(); .First();
return DataResult<ColumnSetRes>.Success(data, MultiLanguageConst.DataQuerySuccess); return DataResult<ColumnSetRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
} }
/// <summary>
/// 更新列表设置字段长度
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult> UpdateColumnSetField(UpdateColumnFieldReq req) {
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var columnSet = await tenantDb.Queryable<CodeColumnSet>()
.Where(x => x.PermissionId == req.PermissionId && x.ColumnNo == req.ColumnNo && x.CreateBy == long.Parse(user.UserId) && x.Status == StatusEnum.Enable)
.FirstAsync();
if (columnSet.IsNull())
{
return DataResult.Failed("列表字段设置不存在!");
}
var content = JsonConvert.DeserializeObject<ColumnSetContent>(columnSet.Content);
if (content.IsNull() || content.Columns.Count == 0 ) {
return DataResult.Failed("列表字段设置内容不存在!");
}
var columns = content.Columns;
var column = columns.Where(x=>x.DataIndex == req.Field).FirstOrDefault();
if (column.IsNull()) {
return DataResult.Failed("列表字段不存在!");
}
foreach (var item in columns)
{
if (item.DataIndex == req.Field)
{
item.Width = req.Width;
}
}
var columnStr = JsonConvert.SerializeObject(columns);
columnSet.Content = columnStr;
await tenantDb.Updateable(columnSet).UpdateColumns(x=> new { x.Content }).ExecuteCommandAsync();
return DataResult.Success;
}
/// <summary> /// <summary>
/// 列表 /// 列表
/// </summary> /// </summary>

@ -87,4 +87,17 @@ public class ColumnSetController : ApiController
var res = _invokeService.BatchDelColumnSet(req); var res = _invokeService.BatchDelColumnSet(req);
return res; return res;
} }
/// <summary>
/// 更新列表设置字段长度
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("UpdateColumnSetField")]
public async Task<DataResult> UpdateColumnSetField([FromBody] UpdateColumnFieldReq req)
{
var res = await _invokeService.UpdateColumnSetField(req);
return res;
}
} }
Loading…
Cancel
Save