Browse Source

计量台账,隐藏显示计量汇总列

MaiXinRong 7 years ago
parent
commit
928cdce644
3 changed files with 112 additions and 7 deletions
  1. 14 1
      Frames/BillsMeasureFme.pas
  2. 2 1
      Frames/ProjectFme.pas
  3. 96 5
      Units/ColVisibleManager.pas

+ 14 - 1
Frames/BillsMeasureFme.pas

@@ -70,6 +70,7 @@ type
     FOnAfterSetBookmark: TBookmarkRefreshEvent;
     FShowAlias: Boolean;
     FShowApprovalCode: Boolean;
+    FShowIsGather: Boolean;
 
     FColVisibleManager: TBM_ColVisibleManager;
     FOnLocateZJJL: TLocateZJJLEvent;
@@ -100,6 +101,7 @@ type
     procedure SetShowDesignQuantity(const Value: Boolean);
     procedure SetShowAlias(const Value: Boolean);
     procedure SetShowApprovalCode(const Value: Boolean);
+    procedure SetShowIsGather(const Value: Boolean);
   public
     constructor Create(AProjectFrame: TFrame; ABillsMeasureData: TBillsMeasureData);
     destructor Destroy; override;
@@ -115,6 +117,7 @@ type
     property ShowDesignQuantity: Boolean read FShowDesignQuantity write SetShowDesignQuantity;
     property ShowAlias: Boolean read FShowAlias write SetShowAlias;
     property ShowApprovalCode: Boolean read FShowApprovalCode write SetShowApprovalCode;
+    property ShowIsGather: Boolean read FShowIsGather write SetShowIsGather;
 
     property OnAfterSetBookmark: TBookmarkRefreshEvent read FOnAfterSetBookmark write FOnAfterSetBookmark;
     property OnLocateZJJL: TLocateZJJLEvent read FOnLocateZJJL write FOnLocateZJJL;
@@ -139,7 +142,7 @@ begin
   stdBillsMeasure.IDTree := FBillsMeasureData.BillsMeasureTree;
   zgBillsMeasure.OnExpandMouseDown := ExpandMouseDown;
 
-  FColVisibleManager := TBM_ColVisibleManager.Create(stdBillsMeasure.Columns);
+  FColVisibleManager := TBM_ColVisibleManager.Create(stdBillsMeasure);
 end;
 
 destructor TBillsMeasureFrame.Destroy;
@@ -445,6 +448,10 @@ begin
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
       and (Key in [67, 99]) then // 'c', 'C'
     actnCalculateAll.Execute;
+
+  if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
+      and (Key in [66, 98]) then
+    ShowIsGather := not ShowIsGather;
 end;
 
 procedure TBillsMeasureFrame.actnSetStageBookmarkExecute(Sender: TObject);
@@ -788,4 +795,10 @@ begin
   FColVisibleManager.ShowApprovalCode(FShowApprovalCode);
 end;
 
+procedure TBillsMeasureFrame.SetShowIsGather(const Value: Boolean);
+begin
+  FShowIsGather := Value;
+  FColVisibleManager.ShowIsGather(FShowIsGather);
+end;
+
 end.

+ 2 - 1
Frames/ProjectFme.pas

@@ -702,7 +702,8 @@ begin
   FBillsMeasureFrame.ShowBGLCode := FProjectData.ProjProperties.ShowBGLCode;
   FBillsMeasureFrame.ShowDesignQuantity := FProjectData.ProjProperties.ShowDesignQuantity;
   FBillsMeasureFrame.ShowAlias := FProjectData.ProjProperties.ShowAlias;
-  FBillsMeasureFrame.ShowApprovalCode := FProjectData.ProjProperties.ShowApprovalCode;
+  FBillsMeasureFrame.ShowApprovalCode := FProjectData.ProjProperties.ShowApprovalCode; 
+  FBillsMeasureFrame.ShowIsGather := True;
   AlignControl(FBillsMeasureFrame, jpsMainBillsMeasure, alClient);
 end;
 

+ 96 - 5
Units/ColVisibleManager.pas

@@ -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;