From 5c2a50b5e5abd18ec2e2909b173324a3be975520 Mon Sep 17 00:00:00 2001 From: cjy Date: Mon, 11 Nov 2024 17:14:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=97=E8=A1=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=AD=97=E6=AE=B5=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Code/Dtos/UpdateColumnFieldReq.cs | 83 +++++++++++++++++++ .../Code/Interface/IColumnSetService.cs | 7 ++ .../Code/Method/ColumnSetService.cs | 47 +++++++++++ .../Controllers/ColumnSetController.cs | 13 +++ 4 files changed, 150 insertions(+) create mode 100644 ds-wms-service/DS.WMS.Core/Code/Dtos/UpdateColumnFieldReq.cs diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/UpdateColumnFieldReq.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/UpdateColumnFieldReq.cs new file mode 100644 index 00000000..a3415838 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/UpdateColumnFieldReq.cs @@ -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 +{ + /// + /// 设置表格列宽度 + /// + public class UpdateColumnFieldReq + { + + public long PermissionId { get; set; } + + public int ColumnNo { get; set; } + + public string Field { get; set; } + + public int Width { get; set; } + } + + /// + /// 列设置内容 + /// + public class ColumnSetContent { + + /// + /// + /// + public List Columns { get; set; } + } + + public class Columns + { + /// + /// 委托编号 + /// + public string Label { get; set; } + /// + /// + /// + public string Value { get; set; } + /// + /// + /// + public string DataIndex { get; set; } + /// + /// 委托编号 + /// + public string Title { get; set; } + /// + /// + /// + public bool Sorter { get; set; } + /// + /// + /// + public int Width { get; set; } + /// + /// + /// + public bool DefaultHidden { get; set; } + /// + /// + /// + public bool Resizable { get; set; } + /// + /// + /// + public string Align { get; set; } + /// + /// + /// + public string Key { get; set; } + /// + /// + /// + public bool Ellipsis { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/IColumnSetService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/IColumnSetService.cs index c90bfa27..43ae89ea 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Interface/IColumnSetService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/IColumnSetService.cs @@ -46,4 +46,11 @@ public interface IColumnSetService /// public DataResult BatchDelColumnSet(IdModel req); + /// + /// 更新列表设置字段长度 + /// + /// + /// + public Task UpdateColumnSetField(UpdateColumnFieldReq req); + } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/ColumnSetService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/ColumnSetService.cs index cf621eb4..9bfa8287 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Method/ColumnSetService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Method/ColumnSetService.cs @@ -6,8 +6,11 @@ using DS.Module.UserModule; using DS.WMS.Core.Code.Dtos; using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Code.Interface; +using DS.WMS.Core.Invoice.Dtos; +using DS.WMS.Core.Sys.Dtos; using Mapster; using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; using SqlSugar; namespace DS.WMS.Core.Code.Method { @@ -94,6 +97,50 @@ namespace DS.WMS.Core.Code.Method .First(); return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess); } + /// + /// 更新列表设置字段长度 + /// + /// + /// + public async Task UpdateColumnSetField(UpdateColumnFieldReq req) { + + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + var columnSet = await tenantDb.Queryable() + .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(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; + } + /// /// 列表 /// diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/ColumnSetController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/ColumnSetController.cs index 505ae07d..dc2abc5e 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/ColumnSetController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/ColumnSetController.cs @@ -87,4 +87,17 @@ public class ColumnSetController : ApiController var res = _invokeService.BatchDelColumnSet(req); return res; } + + /// + /// 更新列表设置字段长度 + /// + /// + /// + [HttpPost] + [Route("UpdateColumnSetField")] + public async Task UpdateColumnSetField([FromBody] UpdateColumnFieldReq req) + { + var res = await _invokeService.UpdateColumnSetField(req); + return res; + } } \ No newline at end of file