feat: 优化初始化缓存及控件功能

This commit is contained in:
cyf
2026-08-14 20:33:43 +08:00
parent 222ae3c08a
commit f665688d0b
27 changed files with 505 additions and 106 deletions
+42 -1
View File
@@ -24,8 +24,9 @@ namespace Lskj.Control.Model
/// <summary>
/// 表格拖拽到树结构
/// </summary>
public class GridDragTree
public class GridDragTree : IDisposable
{
private bool _disposed;
/// <summary>
/// 拖动位置
/// </summary>
@@ -59,6 +60,46 @@ namespace Lskj.Control.Model
this._treeView.AllowDrop = true;
this._treeView.DragOver += new DragEventHandler(treeView_DragOver);
this._treeView.DragDrop += new DragEventHandler(treeView_DragDrop);
if (this._gridView.GridControl != null)
{
this._gridView.GridControl.Disposed += OnOwnerDisposed;
}
this._treeView.Disposed += OnOwnerDisposed;
}
private void OnOwnerDisposed(object sender, EventArgs e)
{
Dispose();
}
/// <summary>
/// 模块关闭时解除源表格和目标树的拖拽事件。
/// </summary>
public void Dispose()
{
if (_disposed) return;
_disposed = true;
if (_gridView != null)
{
_gridView.MouseDown -= gridView_MouseDown;
_gridView.MouseMove -= gridView_MouseMove;
if (_gridView.GridControl != null)
{
_gridView.GridControl.Disposed -= OnOwnerDisposed;
}
}
if (_treeView != null)
{
_treeView.DragOver -= treeView_DragOver;
_treeView.DragDrop -= treeView_DragDrop;
_treeView.Disposed -= OnOwnerDisposed;
}
OnDragComplete = null;
_hitInfo = null;
_gridView = null;
_treeView = null;
}
+1 -1
View File
@@ -950,7 +950,7 @@ namespace Lskj.Control.Model
{
try
{
if (!BaseImpl.HasExistsColumn(ResourceKeys.SettingTableName, ""))
if (!BaseImpl.HasExistsColumn(ResourceKeys.SettingTableName, "IfFixColumn"))
{
BaseImpl.ExecSqlValue("alter table " + ResourceKeys.SettingTableName + " add IfFixColumn bit");
}
@@ -114,6 +114,7 @@ namespace Lskj.Control.Model.MenuStrip
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
@@ -137,6 +137,7 @@ namespace Lskj.Control.Model
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
@@ -147,6 +147,7 @@ namespace Lskj.Control.Model.MenuStrip
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
+33 -11
View File
@@ -133,6 +133,10 @@ namespace Lskj.Control.Model
public DataRow CurrentData;
public ModuleModel SystemModel;
/// <summary>
/// 外部已查询的MRP操作按钮数据;为空时保持原查询逻辑。
/// </summary>
public DataTable MrpClickMenus;
/// <summary>
/// 下拉框、搜索框控件对象
/// </summary>
public List<ControlModel> mControlList = new List<ControlModel>();
@@ -899,10 +903,13 @@ namespace Lskj.Control.Model
return controlModel;
}));
}
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
if (MrpClickMenus == null)
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
}
return true;
}));
}
@@ -1042,7 +1049,17 @@ namespace Lskj.Control.Model
}
if (dynamicModel != null && !string.IsNullOrEmpty(dynamicModel.ModuleCode))
{
if (!dataCaches.GetValue(parent, "SysModel", out ModuleModel moduleModel))
ModuleModel moduleModel = null;
if (SystemModel != null && string.Equals(SystemModel.ModeCode, dynamicModel.ModuleCode, StringComparison.OrdinalIgnoreCase))
{
moduleModel = SystemModel;
}
if (moduleModel == null && dataCaches.GetValue(parent, "SysModel", out ModuleModel cacheModuleModel) &&
cacheModuleModel != null && string.Equals(cacheModuleModel.ModeCode, dynamicModel.ModuleCode, StringComparison.OrdinalIgnoreCase))
{
moduleModel = cacheModuleModel;
}
if (moduleModel == null)
{
moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(dynamicModel.ModuleCode));
}
@@ -1060,13 +1077,14 @@ namespace Lskj.Control.Model
btnCondSearch.Click += new EventHandler(OnBtnCondSearchClick);
}
}
DataTable rightDt = null;
if (dynamicModel != null)
DataTable rightDt = MrpClickMenus;
if (rightDt == null && dynamicModel != null)
{
if (!dataCaches.GetValue(this, "RightDtGridRightMenus", out rightDt))
{
rightDt = BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}
MrpClickMenus = rightDt;
}
if (rightDt != null && rightDt.Rows.Count > 0)
{
@@ -1220,13 +1238,14 @@ namespace Lskj.Control.Model
_popupMenu.Name = "pm_search";
CreateSearchScheme();
}
DataTable rightDt = null;
if (dynamicModel != null)
DataTable rightDt = MrpClickMenus;
if (rightDt == null && dynamicModel != null)
{
if (!dynamicModel.DataCaches.GetValue(this, "RightDtGridRightMenus", out rightDt))
{
rightDt = BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}
MrpClickMenus = rightDt;
}
if (rightDt != null && rightDt.Rows.Count > 0)
{
@@ -1295,10 +1314,13 @@ namespace Lskj.Control.Model
return controlModel;
}));
}
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
if (MrpClickMenus == null)
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
}
return true;
}));
}