feat: 更新业务、控件及单据功能
This commit is contained in:
@@ -181,6 +181,24 @@ namespace Lskj.Control
|
||||
protected GridView CurrentOperGridView = null;
|
||||
public List<string> ImageList = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 外部设置的右键菜单数据,用于创建每行操作列。
|
||||
/// </summary>
|
||||
private DataTable rightMenuButtonTable;
|
||||
private bool gridColumnsInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// 新版模块选择框缓存。同一关联模块的单选和多选界面分别复用。
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, FrmModelLookUp2> selectReturnModelLookUpCache =
|
||||
new Dictionary<string, FrmModelLookUp2>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// 新版模块选择框显示数据缓存。同一轮列初始化中,相同关联模块只加载一次显示数据。
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, DataTable> selectReturnDisplaySourceCache =
|
||||
new Dictionary<string, DataTable>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
protected bool mLoading = false;
|
||||
protected Timer mTimer = new Timer();
|
||||
/// <summary>
|
||||
@@ -482,6 +500,7 @@ namespace Lskj.Control
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
|
||||
InitializeComponent();
|
||||
this.Disposed += OnGridControlExDisposed;
|
||||
|
||||
// 自定义选中区域方式
|
||||
this.gridView.CustomDrawRowIndicator += new RowIndicatorCustomDrawEventHandler(OnGridViewCustomDrawRowIndicator);
|
||||
@@ -997,6 +1016,8 @@ namespace Lskj.Control
|
||||
|
||||
if (!string.IsNullOrEmpty(model.SqlSource) && !ControlType.IsNotLoadData(model.FieldType))
|
||||
{
|
||||
if (ControlType.LabTreeType == model.FieldType && IsSpecModel) return;//如果是树节点,并且是PubSpec模块就直接跳出
|
||||
|
||||
Task<DataTable> sourceTask = new Task<DataTable>(() =>
|
||||
{
|
||||
DataTable dataTable = new DataTable();
|
||||
@@ -1386,8 +1407,10 @@ namespace Lskj.Control
|
||||
this.mLoading = false;
|
||||
this.InitGridColumsTab = table;
|
||||
this.CustomColumKey = customColumKey;
|
||||
this.gridColumnsInitialized = false;
|
||||
this.GridView.Columns.Clear();
|
||||
this.ColumnList.Clear();
|
||||
this.selectReturnDisplaySourceCache.Clear();
|
||||
if (table == null) return;
|
||||
this.gridView.BeginUpdate();
|
||||
for (int i = 0; i < table.Rows.Count; i++)
|
||||
@@ -1463,19 +1486,8 @@ namespace Lskj.Control
|
||||
|
||||
}
|
||||
|
||||
//创建右键菜单列
|
||||
if (!dataCaches.GetValue(this, "RightMenuBtn", out DataTable rightMentTab))
|
||||
{
|
||||
if (this.Model != null)
|
||||
{
|
||||
rightMentTab = BaseModuleImpl.GetBaseGridRightMenus(this.Model.ModuleCode);
|
||||
}
|
||||
}
|
||||
//左侧如果配置表格,也和出现和主表一样的操作列。先限制为左侧固定不加载(要加载的话要获取左侧的fieldKey)
|
||||
if (this.Model != null && BaseModuleImpl.IsGridViewRightMenuBtnEdit(rightMentTab) && !customColumKey.Contains("BaseLeftGridView_"))
|
||||
{
|
||||
this.InitRightMenuBtnEdit();
|
||||
}
|
||||
this.gridColumnsInitialized = true;
|
||||
this.TryInitRightMenuBtnEdit(false);
|
||||
if (!dataCaches.GetValue(this, "CustomColumnByDatabase", out DataTable customTable))
|
||||
{
|
||||
customTable = this.gridView.GetCustomColumnByDatabase(this.CustomColumKey);
|
||||
@@ -1677,6 +1689,7 @@ namespace Lskj.Control
|
||||
this.CustomColumKey = customColumKey;
|
||||
this.GridView.Columns.Clear();
|
||||
this.ColumnList.Clear();
|
||||
this.selectReturnDisplaySourceCache.Clear();
|
||||
if (table == null) return;
|
||||
for (int i = 0; i < table.Rows.Count; i++)
|
||||
{
|
||||
@@ -1769,8 +1782,10 @@ namespace Lskj.Control
|
||||
this.mLoading = false;
|
||||
this.InitGridColumsTab = table;
|
||||
this.CustomColumKey = customColumKey;
|
||||
this.gridColumnsInitialized = false;
|
||||
this.GridView.Columns.Clear();
|
||||
this.ColumnList.Clear();
|
||||
this.selectReturnDisplaySourceCache.Clear();
|
||||
if (table == null) return;
|
||||
|
||||
Console.WriteLine(DateTime.Now);
|
||||
@@ -1887,32 +1902,15 @@ namespace Lskj.Control
|
||||
}
|
||||
}
|
||||
|
||||
if (Model != null)
|
||||
{
|
||||
if (!Model.DataCaches.GetValue(this, "RightMenuBtn", out DataTable rightMentTab))
|
||||
{
|
||||
if (this.Model != null)
|
||||
{
|
||||
rightMentTab = BaseModuleImpl.GetBaseGridRightMenus(this.Model.ModuleCode);
|
||||
}
|
||||
}
|
||||
//左侧如果配置表格,也和出现和主表一样的操作列。先限制为左侧固定不加载(要加载的话要获取左侧的fieldKey)
|
||||
if (this.Model != null && BaseModuleImpl.IsGridViewRightMenuBtnEdit(rightMentTab) && !customColumKey.Contains("BaseLeftGridView_"))
|
||||
{
|
||||
this.InitRightMenuBtnEdit();
|
||||
}
|
||||
}
|
||||
this.gridColumnsInitialized = true;
|
||||
this.TryInitRightMenuBtnEdit(false);
|
||||
|
||||
if (Model != null && !Model.DataCaches.GetValue(this, "CustomColumnByDatabase", out DataTable customTable))
|
||||
DataTable customTable;
|
||||
if (Model == null || !Model.DataCaches.GetValue(this, "CustomColumnByDatabase", out customTable))
|
||||
{
|
||||
customTable = this.gridView.GetCustomColumnByDatabase(this.CustomColumKey);
|
||||
this.SetCustomColumns(customTable);
|
||||
}
|
||||
else
|
||||
{
|
||||
DataTable customTableNew = this.gridView.GetCustomColumnByDatabase(this.CustomColumKey);
|
||||
this.SetCustomColumns(customTableNew);
|
||||
}
|
||||
this.SetCustomColumns(customTable);
|
||||
|
||||
|
||||
|
||||
@@ -1937,20 +1935,10 @@ namespace Lskj.Control
|
||||
/// <param name="customColumKey"></param>
|
||||
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic, string customColumKey = "")
|
||||
{
|
||||
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
|
||||
//Task<bool> existsSettingTableTask = cachesDic.AddTask(this, "HasExistsSettingTable", new Task<bool>(() =>
|
||||
//{
|
||||
// return BaseImpl.HasExistsTable(ResourceKeys.SettingTableName);
|
||||
//}));
|
||||
Task<DataTable> setBaseGridRightMenusTask = cachesDic.AddTask(this, "RightMenuBtn", new Task<DataTable>(() =>
|
||||
{
|
||||
DataTable dataTable = null;
|
||||
if (dynamicModelTask != null)
|
||||
{
|
||||
dataTable = BaseModuleImpl.GetBaseGridRightMenus(dynamicModelTask.Result.ModuleCode);
|
||||
}
|
||||
return dataTable;
|
||||
}));
|
||||
Task<DataTable> customColumnByDatabaseTask = cachesDic.AddTask(this, "CustomColumnByDatabase", new Task<DataTable>(() =>
|
||||
{
|
||||
return this.GridView.GetCustomColumnByDatabase(customColumKey);
|
||||
@@ -3747,9 +3735,26 @@ namespace Lskj.Control
|
||||
else if (columnEdit is RepositoryItemCheckedComboBoxEdit)
|
||||
{
|
||||
RepositoryItemCheckedComboBoxEdit rccbe = columnEdit as RepositoryItemCheckedComboBoxEdit;
|
||||
FrmModelLookUp modelLookUp = rccbe.Buttons[1].Tag as FrmModelLookUp;
|
||||
if (!modelLookUp.SingleChoiceMode) moduleReturnCheck = true;
|
||||
table = rccbe.DataSource as DataTable;
|
||||
|
||||
if (rccbe.Buttons[1].Tag is FrmModelLookUp)
|
||||
{
|
||||
FrmModelLookUp modelLookUp = rccbe.Buttons[1].Tag as FrmModelLookUp;
|
||||
if (!modelLookUp.SingleChoiceMode) moduleReturnCheck = true;
|
||||
table = rccbe.DataSource as DataTable;
|
||||
}
|
||||
else if (rccbe.Buttons[1].Tag is FrmModelLookUp2)
|
||||
{
|
||||
FrmModelLookUp2 modelLookUp = rccbe.Buttons[1].Tag as FrmModelLookUp2;
|
||||
if (!modelLookUp.SingleChoiceMode) moduleReturnCheck = true;
|
||||
table = rccbe.DataSource as DataTable;
|
||||
}
|
||||
else if (rccbe.Buttons[1].Tag is FrmLookUp)
|
||||
{
|
||||
FrmLookUp frmLookUp = rccbe.Buttons[1].Tag as FrmLookUp;
|
||||
table = frmLookUp.DataSource as DataTable;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (table != null && table.Rows.Count > 0 && table.Columns.Count > 0)
|
||||
{
|
||||
@@ -5119,7 +5124,52 @@ namespace Lskj.Control
|
||||
|
||||
}
|
||||
|
||||
private void InitRightMenuBtnEdit()
|
||||
/// <summary>
|
||||
/// 保存外部传入的右键数据,并在表格列就绪后创建操作列。
|
||||
/// </summary>
|
||||
internal void SetRightMenuButtonTable(DataTable table)
|
||||
{
|
||||
// 树表格和多表头表格原来不在此处创建操作列,维持原有行为。
|
||||
if (this is TreeGridControlEx || this is BandedGridControlEx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.rightMenuButtonTable = table;
|
||||
this.TryInitRightMenuBtnEdit(true);
|
||||
}
|
||||
|
||||
private void TryInitRightMenuBtnEdit(bool rebuild)
|
||||
{
|
||||
if (!this.gridColumnsInitialized || this.Model == null ||
|
||||
this.CustomColumKey.Contains("BaseLeftGridView_"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GridColumn oldColumn = this.gridView.Columns.ColumnByFieldName("RightMenuBtnEdit");
|
||||
bool showButtonColumn = BaseModuleImpl.IsGridViewRightMenuBtnEdit(this.rightMenuButtonTable);
|
||||
if (!showButtonColumn)
|
||||
{
|
||||
if (oldColumn != null) this.gridView.Columns.Remove(oldColumn);
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldColumn != null)
|
||||
{
|
||||
if (!rebuild) return;
|
||||
this.gridView.Columns.Remove(oldColumn);
|
||||
}
|
||||
|
||||
this.InitRightMenuBtnEdit(this.rightMenuButtonTable);
|
||||
DataTable dataSource = this.gridControl.DataSource as DataTable;
|
||||
if (dataSource != null && !dataSource.Columns.Contains("RightMenuBtnEdit"))
|
||||
{
|
||||
dataSource.Columns.Add("RightMenuBtnEdit");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitRightMenuBtnEdit(DataTable rightMenuTab)
|
||||
{
|
||||
GridColumn gridColumn = new GridColumn();
|
||||
gridColumn.FieldName = "RightMenuBtnEdit";
|
||||
@@ -5136,7 +5186,6 @@ namespace Lskj.Control
|
||||
ItemButtonEdit.ButtonsStyle = BorderStyles.UltraFlat;
|
||||
ItemButtonEdit.BorderStyle = BorderStyles.NoBorder;
|
||||
ItemButtonEdit.ButtonClick += new ButtonPressedEventHandler(OnItemButtonEdit_ButtonClick);
|
||||
DataTable rightMenuTab = BaseModuleImpl.GetBaseGridRightMenus(this.Model.ModuleCode);
|
||||
int ColumnWidth = 0;
|
||||
if (rightMenuTab.Columns.Contains("IcoName"))
|
||||
{
|
||||
@@ -5287,14 +5336,13 @@ namespace Lskj.Control
|
||||
/// </summary>
|
||||
private void InitSelectReturnIdNew(GridColumn gridColumn, GridColumnModel model)
|
||||
{
|
||||
FrmModelLookUp2 modelLookUp = new FrmModelLookUp2(model.addModuleld, model.IsRadio);
|
||||
modelLookUp.ConfigureColumnMode = model.ConfigureColumnMode;
|
||||
modelLookUp.ValueField = model.ValueMember;
|
||||
modelLookUp.TextField = model.TextMember;
|
||||
modelLookUp.SourceSQL = model.SqlSource;
|
||||
modelLookUp.IsType = model.FieldType;
|
||||
modelLookUp.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember;
|
||||
modelLookUp.Tag = model;
|
||||
// 只读列保留原有显示编辑器,但不初始化关联模块选择窗口。
|
||||
FrmModelLookUp2 modelLookUp = null;
|
||||
if (model.Edit)
|
||||
{
|
||||
modelLookUp = GetSelectReturnModelLookUp(model);
|
||||
ConfigureSelectReturnModelLookUp(modelLookUp, model);
|
||||
}
|
||||
|
||||
RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit();
|
||||
btnEdit.NullText = "";
|
||||
@@ -5306,8 +5354,7 @@ namespace Lskj.Control
|
||||
|
||||
if (model.ModuleFrameDisplayText && model.FieldType == ControlType.LabSelectReturnIdNew)
|
||||
{
|
||||
DataTable dataTable = MainImpl.GetDataTableResult(modelLookUp.SysModel.MenuSql);
|
||||
btnEdit.DataSource = dataTable;
|
||||
btnEdit.DataSource = GetSelectReturnDisplaySource(model, modelLookUp);
|
||||
}
|
||||
|
||||
|
||||
@@ -5315,9 +5362,12 @@ namespace Lskj.Control
|
||||
btnEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) });
|
||||
|
||||
btnEdit.Tag = model;
|
||||
btnEdit.Buttons[1].Tag = modelLookUp;
|
||||
btnEdit.ButtonClick += new ButtonPressedEventHandler(OnModuleChoiceNew);
|
||||
btnEdit.KeyDown += BtnEdit_KeyDown;
|
||||
if (model.Edit)
|
||||
{
|
||||
btnEdit.Buttons[1].Tag = modelLookUp;
|
||||
btnEdit.ButtonClick += new ButtonPressedEventHandler(OnModuleChoiceNew);
|
||||
btnEdit.KeyDown += BtnEdit_KeyDown;
|
||||
}
|
||||
gridControl.RepositoryItems.Add(btnEdit);
|
||||
gridColumn.OptionsColumn.ReadOnly = true;
|
||||
gridColumn.ColumnEdit = btnEdit;
|
||||
@@ -5326,6 +5376,83 @@ namespace Lskj.Control
|
||||
this.mControlList.Add(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取新版模块选择窗口。同一关联模块按单选、多选模式分别复用。
|
||||
/// </summary>
|
||||
/// <param name="model">当前表格列配置。</param>
|
||||
/// <returns>与当前模块及选择模式匹配的模块选择窗口。</returns>
|
||||
private FrmModelLookUp2 GetSelectReturnModelLookUp(GridColumnModel model)
|
||||
{
|
||||
string cacheKey = string.Format("{0}|{1}", model.addModuleld ?? string.Empty, model.IsRadio ? "Single" : "Multiple");
|
||||
if (!selectReturnModelLookUpCache.TryGetValue(cacheKey, out FrmModelLookUp2 modelLookUp) || modelLookUp.IsDisposed)
|
||||
{
|
||||
modelLookUp = new FrmModelLookUp2(model.addModuleld, model.IsRadio);
|
||||
selectReturnModelLookUpCache[cacheKey] = modelLookUp;
|
||||
}
|
||||
|
||||
return modelLookUp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取新版模块返回ID列的显示数据,用于将保存的ID显示为对应文本。
|
||||
/// </summary>
|
||||
/// <param name="model">当前表格列配置。</param>
|
||||
/// <param name="modelLookUp">可编辑列已创建的模块选择窗口;只读列传入空值。</param>
|
||||
/// <returns>关联模块的数据源。</returns>
|
||||
private DataTable GetSelectReturnDisplaySource(GridColumnModel model, FrmModelLookUp2 modelLookUp)
|
||||
{
|
||||
string cacheKey = model.addModuleld ?? string.Empty;
|
||||
if (selectReturnDisplaySourceCache.TryGetValue(cacheKey, out DataTable dataTable))
|
||||
{
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
string sourceSql = modelLookUp?.SysModel?.MenuSql;
|
||||
if (string.IsNullOrWhiteSpace(sourceSql))
|
||||
{
|
||||
DataRow moduleRow = MainImpl.GetSystemdllTab(model.addModuleld);
|
||||
sourceSql = moduleRow?["SQL"] + "";
|
||||
}
|
||||
|
||||
dataTable = string.IsNullOrWhiteSpace(sourceSql) ? null : MainImpl.GetDataTableResult(sourceSql);
|
||||
selectReturnDisplaySourceCache[cacheKey] = dataTable;
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将当前列的字段映射及返回配置应用到复用的模块选择窗口。
|
||||
/// </summary>
|
||||
/// <param name="modelLookUp">模块选择窗口。</param>
|
||||
/// <param name="model">当前表格列配置。</param>
|
||||
private static void ConfigureSelectReturnModelLookUp(FrmModelLookUp2 modelLookUp, GridColumnModel model)
|
||||
{
|
||||
modelLookUp.ConfigureColumnMode = model.ConfigureColumnMode;
|
||||
modelLookUp.ValueField = model.ValueMember;
|
||||
modelLookUp.TextField = model.TextMember;
|
||||
modelLookUp.SourceSQL = model.SqlSource;
|
||||
modelLookUp.IsType = model.FieldType;
|
||||
modelLookUp.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember;
|
||||
modelLookUp.Tag = model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 表格控件销毁时释放缓存的模块选择窗口及显示数据。
|
||||
/// </summary>
|
||||
/// <param name="sender">事件源。</param>
|
||||
/// <param name="e">事件参数。</param>
|
||||
private void OnGridControlExDisposed(object sender, EventArgs e)
|
||||
{
|
||||
foreach (FrmModelLookUp2 modelLookUp in selectReturnModelLookUpCache.Values.Distinct())
|
||||
{
|
||||
if (modelLookUp != null && !modelLookUp.IsDisposed)
|
||||
{
|
||||
modelLookUp.Dispose();
|
||||
}
|
||||
}
|
||||
selectReturnModelLookUpCache.Clear();
|
||||
selectReturnDisplaySourceCache.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:创建 模块返回行 </para>
|
||||
/// <para>创建人:曹屹峰</para>
|
||||
@@ -6258,10 +6385,9 @@ namespace Lskj.Control
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (model.FieldType == 160 || model.FieldType == 161)
|
||||
if ((model.FieldType == 160 || model.FieldType == 161) &&
|
||||
col.ColumnEdit is RepositoryItemCheckedComboBoxEdit)
|
||||
{
|
||||
RepositoryItemCheckedComboBoxEdit rccbe = col.ColumnEdit as RepositoryItemCheckedComboBoxEdit;
|
||||
FrmModelLookUp2 modelLookUp = rccbe.Buttons[1].Tag as FrmModelLookUp2;
|
||||
value = ModuleReturnVerify(model, col.ColumnEdit, cellValue, out IsTextEqualValue);
|
||||
//// 避免下拉框值替换失败提示错误
|
||||
if (model != null && !IsTextEqualValue && cellValue == value + "")
|
||||
@@ -6496,10 +6622,9 @@ namespace Lskj.Control
|
||||
}
|
||||
|
||||
}
|
||||
if (model.FieldType == 160 || model.FieldType == 161)
|
||||
if ((model.FieldType == 160 || model.FieldType == 161) &&
|
||||
col.ColumnEdit is RepositoryItemCheckedComboBoxEdit)
|
||||
{
|
||||
RepositoryItemCheckedComboBoxEdit rccbe = col.ColumnEdit as RepositoryItemCheckedComboBoxEdit;
|
||||
FrmModelLookUp2 modelLookUp = rccbe.Buttons[1].Tag as FrmModelLookUp2;
|
||||
value = ModuleReturnVerify(model, col.ColumnEdit, cellValue, out IsTextEqualValue);
|
||||
//// 避免下拉框值替换失败提示错误
|
||||
if (model != null && !IsTextEqualValue && cellValue == value + "")
|
||||
@@ -7667,8 +7792,15 @@ namespace Lskj.Control
|
||||
{
|
||||
CheckedComboBoxEdit btnEdit = (CheckedComboBoxEdit)sender;
|
||||
FrmModelLookUp2 modelLookUp = e.Button.Tag as FrmModelLookUp2;
|
||||
GridColumnModel model = btnEdit.Properties.Tag as GridColumnModel;
|
||||
if (model == null) return;
|
||||
|
||||
GridColumnModel model = modelLookUp.Tag as GridColumnModel;
|
||||
if (modelLookUp == null || modelLookUp.IsDisposed)
|
||||
{
|
||||
modelLookUp = GetSelectReturnModelLookUp(model);
|
||||
e.Button.Tag = modelLookUp;
|
||||
}
|
||||
ConfigureSelectReturnModelLookUp(modelLookUp, model);
|
||||
modelLookUp.EditText = btnEdit.Text;
|
||||
modelLookUp.CurrentOperColumnKey = Model.ModuleCode + "_" + model.FieldName;
|
||||
modelLookUp.EditText = btnEdit.Text;
|
||||
|
||||
Reference in New Issue
Block a user