|
@@ -3,7 +3,7 @@ unit ColVisibleManager;
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
- Classes, sdGridDBA, ZhAPI;
|
|
|
+ Classes, sdGridDBA, ZhAPI, sdGridTreeDBA;
|
|
|
|
|
|
type
|
|
|
TColVisible = class
|
|
@@ -28,6 +28,9 @@ type
|
|
|
FBGLCode: Boolean;
|
|
|
FAlias: Boolean;
|
|
|
FDesign: Boolean;
|
|
|
+ FApprovalCode: Boolean;
|
|
|
+ FIsGatherZJJL: Boolean;
|
|
|
+ function GetVisible: Boolean;
|
|
|
public
|
|
|
constructor Create(ACol: TsdGridColumn); override;
|
|
|
|
|
@@ -37,36 +40,54 @@ type
|
|
|
property BGLCode: Boolean read FBGLCode write FBGLCode;
|
|
|
property Design: Boolean read FDesign write FDesign;
|
|
|
property Alias: Boolean read FAlias write FAlias;
|
|
|
+ property ApprovalCode: Boolean read FApprovalCode write FApprovalCode;
|
|
|
+ property IsGatherZJJL: Boolean read FIsGatherZJJL write FIsGatherZJJL;
|
|
|
+
|
|
|
+ property Visible: Boolean read GetVisible;
|
|
|
end;
|
|
|
|
|
|
TColVisibleManager = class
|
|
|
private
|
|
|
FColVisibles: TList;
|
|
|
+ function GetColVisible(AIndex: Integer): TColVisible;
|
|
|
protected
|
|
|
function CreateColVisible(ACol: TsdGridColumn): TColVisible; virtual;
|
|
|
public
|
|
|
constructor Create(ACols: TsdGridColumnList);
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
- procedure RefreshVisible;
|
|
|
+ procedure RefreshVisible; virtual;
|
|
|
|
|
|
procedure ShowGridCol(AShow: Boolean; ABeginCol, AEndCol: Integer);
|
|
|
+
|
|
|
+ property ColVisible[AIndex: Integer]: TColVisible read GetColVisible;
|
|
|
end;
|
|
|
|
|
|
TBM_ColVisibleManager = class(TColVisibleManager)
|
|
|
+ private
|
|
|
+ FGridFixedColCount: Integer;
|
|
|
+ FOrgTreeCol: Integer;
|
|
|
+ FGridTreeDBA: TsdGridTreeDBA;
|
|
|
protected
|
|
|
function CreateColVisible(ACol: TsdGridColumn): TColVisible; override;
|
|
|
public
|
|
|
+ constructor Create(AGridTreeDBA: TsdGridTreeDBA);
|
|
|
+
|
|
|
procedure ShowPriceChange(AShow: Boolean);
|
|
|
procedure ShowBGLCode(AShow: Boolean);
|
|
|
procedure ShowDesign(AShow: Boolean);
|
|
|
procedure ShowAlias(AShow: Boolean);
|
|
|
procedure ShowApprovalCode(AShow: Boolean);
|
|
|
+ procedure ShowIsGather(AShow: Boolean);
|
|
|
+
|
|
|
+ procedure RefreshVisible; override;
|
|
|
+
|
|
|
+ property GridTreeDBA: TsdGridTreeDBA read FGridTreeDBA;
|
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
-uses SysUtils;
|
|
|
+uses SysUtils, ZJGrid;
|
|
|
|
|
|
{ TColVisible }
|
|
|
|
|
@@ -91,11 +112,18 @@ begin
|
|
|
FBGLCode := True;
|
|
|
FDesign := True;
|
|
|
FAlias := True;
|
|
|
+ FApprovalCode := True;
|
|
|
+ FIsGatherZJJL := True;
|
|
|
+end;
|
|
|
+
|
|
|
+function TBM_ColVisible.GetVisible: Boolean;
|
|
|
+begin
|
|
|
+ Result := FCustom and FPriceChange and FBGLCode and FDesign and FAlias and FApprovalCode and FIsGatherZJJL;
|
|
|
end;
|
|
|
|
|
|
procedure TBM_ColVisible.RefreshVisible;
|
|
|
begin
|
|
|
- FDBACol.Visible := FCustom and FPriceChange and FBGLCode and FDesign and FAlias;
|
|
|
+ FDBACol.Visible := FCustom and FPriceChange and FBGLCode and FDesign and FAlias and FApprovalCode and FIsGatherZJJL;
|
|
|
end;
|
|
|
|
|
|
{ TColVisibleManager }
|
|
@@ -126,6 +154,11 @@ begin
|
|
|
inherited;
|
|
|
end;
|
|
|
|
|
|
+function TColVisibleManager.GetColVisible(AIndex: Integer): TColVisible;
|
|
|
+begin
|
|
|
+ Result := TColVisible(FColVisibles[AIndex]);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TColVisibleManager.RefreshVisible;
|
|
|
var
|
|
|
iCol: Integer;
|
|
@@ -161,12 +194,56 @@ end;
|
|
|
|
|
|
{ TBM_ColVisibleManager }
|
|
|
|
|
|
+constructor TBM_ColVisibleManager.Create(AGridTreeDBA: TsdGridTreeDBA);
|
|
|
+begin
|
|
|
+ inherited Create(AGridTreeDBA.Columns);
|
|
|
+ FGridTreeDBA := AGridTreeDBA;
|
|
|
+ FOrgTreeCol := AGridTreeDBA.TreeCellCol;
|
|
|
+ if Assigned(AGridTreeDBA.Grid) then
|
|
|
+ FGridFixedColCount := AGridTreeDBA.Grid.FixedColCount
|
|
|
+ else
|
|
|
+ FGridFixedColCount := 1;
|
|
|
+end;
|
|
|
+
|
|
|
function TBM_ColVisibleManager.CreateColVisible(
|
|
|
ACol: TsdGridColumn): TColVisible;
|
|
|
begin
|
|
|
Result := TBM_ColVisible.Create(ACol);
|
|
|
end;
|
|
|
|
|
|
+procedure TBM_ColVisibleManager.RefreshVisible;
|
|
|
+var
|
|
|
+ i, iCount: Integer;
|
|
|
+ vGrid: TZJGrid;
|
|
|
+begin
|
|
|
+ (*
|
|
|
+ iCount := 0;
|
|
|
+ for i := 0 to FOrgTreeCol - FGridFixedColCount do
|
|
|
+ begin
|
|
|
+ if TBM_ColVisible(ColVisible[i]).Visible then
|
|
|
+ Inc(iCount);
|
|
|
+ end;
|
|
|
+ FGridTreeDBA.TreeCellCol := FGridFixedColCount + iCount - 1;
|
|
|
+ *)
|
|
|
+ inherited;
|
|
|
+ iCount := 0;
|
|
|
+ for i := 0 to FOrgTreeCol - FGridFixedColCount do
|
|
|
+ begin
|
|
|
+ if TBM_ColVisible(ColVisible[i]).Visible then
|
|
|
+ Inc(iCount);
|
|
|
+ end;
|
|
|
+ if FGridTreeDBA.TreeCellCol <> FGridFixedColCount + iCount - 1 then
|
|
|
+ begin
|
|
|
+ vGrid := FGridTreeDBA.Grid;
|
|
|
+ FGridTreeDBA.Grid := nil;
|
|
|
+ vGrid.BeginUpdate;
|
|
|
+ vGrid.CellClass.Cols[FGridTreeDBA.TreeCellCol] := vGrid.CellClass.DefaultCellClass;
|
|
|
+ FGridTreeDBA.TreeCellCol := FGridFixedColCount + iCount - 1;
|
|
|
+ FGridTreeDBA.Grid := vGrid;
|
|
|
+ vGrid.EndUpdate;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TBM_ColVisibleManager.ShowAlias(AShow: Boolean);
|
|
|
var
|
|
|
iCol: Integer;
|
|
@@ -190,7 +267,7 @@ begin
|
|
|
begin
|
|
|
vCol := TBM_ColVisible(FColVisibles.Items[iCol]);
|
|
|
if SameText('ApprovalCode', vCol.DBACol.FieldName) then
|
|
|
- vCol.FAlias := AShow;
|
|
|
+ vCol.FApprovalCode := AShow;
|
|
|
end;
|
|
|
RefreshVisible;
|
|
|
end;
|
|
@@ -231,6 +308,20 @@ begin
|
|
|
RefreshVisible;
|
|
|
end;
|
|
|
|
|
|
+procedure TBM_ColVisibleManager.ShowIsGather(AShow: Boolean);
|
|
|
+var
|
|
|
+ iCol: Integer;
|
|
|
+ vCol: TBM_ColVisible;
|
|
|
+begin
|
|
|
+ for iCol := 0 to FColVisibles.Count - 1 do
|
|
|
+ begin
|
|
|
+ vCol := TBM_ColVisible(FColVisibles.Items[iCol]);
|
|
|
+ if SameText('IsGatherZJJL', vCol.DBACol.FieldName) then
|
|
|
+ vCol.FIsGatherZJJL := AShow;
|
|
|
+ end;
|
|
|
+ RefreshVisible;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TBM_ColVisibleManager.ShowPriceChange(AShow: Boolean);
|
|
|
var
|
|
|
iCol: Integer;
|