Browse Source

BillsGather -- DetailGcl: Locate Bills in Measure

MaiXinRong 8 years ago
parent
commit
568214b63b

+ 2 - 1
Forms/BatchInsertBillsFrm.dfm

@@ -100,7 +100,7 @@ object BatchInsertBillsForm: TBatchInsertBillsForm
           Width = 474
           Height = 166
           OptionsEx = []
-          ColCount = 8
+          ColCount = 9
           ShowGridLine = False
           DefaultColWidth = 50
           DefaultFixedColWidth = 25
@@ -215,6 +215,7 @@ object BatchInsertBillsForm: TBatchInsertBillsForm
           LabelPosition = lpLeft
           MaxLength = 255
           TabOrder = 1
+          Visible = False
         end
         object udBeginCode: TUpDown
           Left = 137

+ 47 - 32
Forms/BatchInsertBillsFrm.pas

@@ -84,6 +84,17 @@ uses
 
 {$R *.dfm}
 
+const
+  iBwNameCol = 1;
+  iBwDrawingCodeCol = 2;
+  iBwBillsQtyCol = 3;
+
+  iGclCodeCol = 1;
+  iGclNameCol = 2;
+  iGclUnitsCol = 3;
+  iGclPriceCol = 4;
+  iGclDrawingCodeCol = 5;
+
 procedure AddLeafBills(ABillsCompileData: TBillsCompileData; AInsertType: TInsertType);
 var
   InsertBillsForm: TBatchInsertBillsForm;
@@ -110,8 +121,8 @@ begin
   with stnNode.Rec do
   begin
     ValueByName('Code').AsString := GetXmjCode(ARow);{ReplaceLastNum(leBeginCode.Text, ARow);}
-    ValueByName('Name').AsString := zgPosition.Cells[1, ARow].Text;
-    ValueByName('DrawingCode').AsString := leDrawingCode.Text;
+    ValueByName('Name').AsString := zgPosition.Cells[iBwNameCol, ARow].Text;
+    ValueByName('DrawingCode').AsString := zgPosition.Cells[iBwDrawingCodeCol, ARow].Text;
   end;
 
   AddBillsNodes(ARow, stnNode);
@@ -193,13 +204,16 @@ end;
 
 procedure TBatchInsertBillsForm.ResetPositionGridHead;
 var
-  iCol: Integer;
+  iCol, iColDiff: Integer;
 begin
-  zgPosition.Cells[1, 0].Text := '窒弇';
-  zgPosition.ColWidths[1] := 120;
-  for iCol := 2 to zgPosition.ColCount - 1 do
+  zgPosition.Cells[iBwNameCol, 0].Text := '窒弇';
+  zgPosition.ColWidths[iBwNameCol] := 100;
+  zgPosition.Cells[iBwDrawingCodeCol, 0].Text := '芞(聊)瘍';
+  zgPosition.ColWidths[iBwDrawingCodeCol] := 100;
+  iColDiff := iBwBillsQtyCol - 1;
+  for iCol := iBwBillsQtyCol to zgPosition.ColCount - 1 do
   begin
-    zgPosition.Cells[iCol, 0].Text := 'ラ等' + IntToStr(iCol - 1);
+    zgPosition.Cells[iCol, 0].Text := 'ラ等' + IntToStr(iCol - iColDiff);
     zgPosition.ColWidths[iCol] := 50;
   end;
 end;
@@ -247,17 +261,17 @@ var
 begin
   if (zgBills.Cells[1, ARow].Text = '') or
      (zgPosition.Cells[ARow + 1, AQtyRow].Text = '') or
-     not TryStrToFloat(zgPosition.Cells[ARow + 1, AQtyRow].Text, fQuantity) then Exit;
+     not TryStrToFloat(zgPosition.Cells[ARow + iBwBillsQtyCol - 1, AQtyRow].Text, fQuantity) then Exit;
 
   stnNode := FBillsCompileData.BillsCompileTree.Add(AParent.ID, -1);
   with stnNode.Rec do
   begin
-    ValueByName('B_Code').AsString := zgBills.Cells[1, ARow].Text;
-    ValueByName('Name').AsString := zgBills.Cells[2, ARow].Text;
-    ValueByName('Units').AsString := zgBills.Cells[3, ARow].Text;
-    ValueByName('Price').AsFloat := StrToFloatDef(zgBills.Cells[4, ARow].Text, 0);
-    ValueByName('OrgQuantity').AsFloat := StrToFloatDef(zgPosition.Cells[ARow + 1, AQtyRow].Text, 0);
-    ValueByName('DrawingCode').AsString := zgBills.Cells[5, ARow].Text;
+    ValueByName('B_Code').AsString := zgBills.Cells[iGclCodeCol, ARow].Text;
+    ValueByName('Name').AsString := zgBills.Cells[iGclNameCol, ARow].Text;
+    ValueByName('Units').AsString := zgBills.Cells[iGclUnitsCol, ARow].Text;
+    ValueByName('Price').AsFloat := StrToFloatDef(zgBills.Cells[iGclPriceCol, ARow].Text, 0);
+    ValueByName('OrgQuantity').AsFloat := StrToFloatDef(zgPosition.Cells[ARow + iBwBillsQtyCol - 1, AQtyRow].Text, 0);
+    ValueByName('DrawingCode').AsString := zgBills.Cells[iGclDrawingCodeCol, ARow].Text;
   end;
 end;
 
@@ -265,15 +279,15 @@ procedure TBatchInsertBillsForm.ResetBillsGridHead;
 var
   iRow: Integer;
 begin
-  zgBills.Cells[1, 0].Text := '晤瘍';
+  zgBills.Cells[iGclCodeCol, 0].Text := '晤瘍';
   zgBills.ColWidths[1] := 80;
-  zgBills.Cells[2, 0].Text := '靡備';
+  zgBills.Cells[iGclNameCol, 0].Text := '靡備';
   zgBills.ColWidths[2] := 120;
-  zgBills.Cells[3, 0].Text := '等弇';
+  zgBills.Cells[iGclUnitsCol, 0].Text := '等弇';
   zgBills.ColWidths[3] := 60;
-  zgBills.Cells[4, 0].Text := '等歎';
+  zgBills.Cells[iGclPriceCol, 0].Text := '等歎';
   zgBills.ColWidths[4] := 60;
-  zgBills.Cells[5, 0].Text := '芞(聊)瘍';
+  zgBills.Cells[iGclDrawingCodeCol, 0].Text := '芞(聊)瘍';
   zgBills.ColWidths[5] := 60;
   for iRow := 1 to zgBills.RowCount - 1 do
     zgBills.Cells[0, iRow].Text := 'ラ等' + IntToStr(iRow);
@@ -345,23 +359,23 @@ begin
       Rec := sddBills.Locate('B_Code', sB_Code);
     if Assigned(Rec) then
     begin
-      zgBills.Cells[2, Row].Text := Rec.ValueByName('Name').AsString;
-      zgBills.Cells[2, Row].Align := gaCenterLeft;
-      zgBills.Cells[3, Row].Text := Rec.ValueByName('Units').AsString;
-      zgBills.Cells[3, Row].Align := gaCenterCenter;
-      zgBills.Cells[3, Row].Font.Name := 'smartSimSun';
-      zgBills.Cells[4, Row].Text := Rec.ValueByName('Price').AsString;
-      zgBills.Cells[4, Row].Align := gaCenterRight;
-      zgBills.Cells[5, Row].Align := gaCenterLeft;
+      zgBills.Cells[iGclNameCol, Row].Text := Rec.ValueByName('Name').AsString;
+      zgBills.Cells[iGclNameCol, Row].Align := gaCenterLeft;
+      zgBills.Cells[iGclUnitsCol, Row].Text := Rec.ValueByName('Units').AsString;
+      zgBills.Cells[iGclUnitsCol, Row].Align := gaCenterCenter;
+      zgBills.Cells[iGclPriceCol, Row].Font.Name := 'smartSimSun';
+      zgBills.Cells[iGclPriceCol, Row].Text := Rec.ValueByName('Price').AsString;
+      zgBills.Cells[iGclPriceCol, Row].Align := gaCenterRight;
+      zgBills.Cells[iGclDrawingCodeCol, Row].Align := gaCenterLeft;
     end;
   end
-  else if (Col = 4) and (Row > 0) then
+  else if (Col = iGclPriceCol) and (Row > 0) then
   begin
     zgBills.Cells[Col, Row].Value := PriceRoundTo(
         StrToFloatDef(zgBills.Cells[Col, Row].Text, 0));
     zgBills.Cells[Col, Row].Align := gaCenterRight;
   end
-  else if (Col = 5) and (Row > 0) then
+  else if (Col = iGclDrawingCodeCol) and (Row > 0) then
     zgBills.Cells[Col, Row].Align := gaCenterLeft;
 end;
 
@@ -405,7 +419,7 @@ procedure TBatchInsertBillsForm.zgPositionCellTextChanged(Sender: TObject;
 var
   value: Double;
 begin
-  if (Col > 1) and (Row > 0) then
+  if (Col >= iBwBillsQtyCol) and (Row > 0) then
   begin
     if (TryStrToFloat(zgPosition.Cells[Col, Row].Text, value)) then
     begin
@@ -425,9 +439,10 @@ end;
 procedure TBatchInsertBillsForm.actnInsertColExecute(Sender: TObject);
 begin
   zgPosition.ColCount := zgPosition.ColCount + 1;
-  zgPosition.Cells[zgPosition.ColCount-1, 0].Text := 'ラ等' + IntToStr(zgPosition.ColCount -1 - 1);
+  zgPosition.Cells[zgPosition.ColCount-1, 0].Text := 'ラ等' + IntToStr(zgPosition.ColCount - iBwBillsQtyCol);
   zgPosition.ColWidths[zgPosition.ColCount-1] := 50;
-  zgBills.RowCount := zgPosition.ColCount - 1;
+
+  zgBills.RowCount := zgPosition.ColCount - (iBwBillsQtyCol - 1);
   zgBills.Cells[0, zgBills.RowCount-1].Text := 'ラ等' + IntToStr(zgBills.RowCount-1);
 end;
 

+ 6 - 0
Forms/MainFrm.dfm

@@ -1095,6 +1095,12 @@ object MainForm: TMainForm
       Visible = ivAlways
       OnClick = dxbtnHelpCenterClick
     end
+    object dxbtnLocateMeasureBills: TdxBarButton
+      Caption = #23450#20301#33267#35745#37327#21488#36134
+      Category = 0
+      Hint = #23450#20301#33267#35745#37327#21488#36134
+      Visible = ivAlways
+    end
   end
   object Images: TImageList
     DrawingStyle = dsTransparent

+ 1 - 0
Forms/MainFrm.pas

@@ -163,6 +163,7 @@ type
     dxbtnSignOnline: TdxBarButton;
     dxbtnExportTpExcel: TdxBarButton;
     dxbtnHelpCenter: TdxBarButton;
+    dxbtnLocateMeasureBills: TdxBarButton;
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure jtsProjectsChange(Sender: TObject; NewTab: Integer;

+ 22 - 0
Frames/BillsGatherFme.dfm

@@ -138,6 +138,7 @@ object BillsGatherFrame: TBillsGatherFrame
           Selection.TransparentColor = False
           FrozenCol = 0
           FrozenRow = 0
+          OnMouseDown = zgDetailGclMouseDown
           Align = alClient
         end
       end
@@ -1236,4 +1237,25 @@ object BillsGatherFrame: TBillsGatherFrame
     Left = 224
     Top = 104
   end
+  object dxpmDetailGcl: TdxBarPopupMenu
+    BarManager = MainForm.dxBarManager
+    ItemLinks = <
+      item
+        Item = MainForm.dxbtnLocateMeasureBills
+        Visible = True
+      end>
+    UseOwnFont = False
+    OnPopup = dxpmDetailGclPopup
+    Left = 160
+    Top = 496
+  end
+  object alBillsGather: TActionList
+    Left = 288
+    Top = 104
+    object actnLocateMeasureBills: TAction
+      Caption = #23450#20301#33267#35745#37327#21488#36134
+      OnExecute = actnLocateMeasureBillsExecute
+      OnUpdate = actnLocateMeasureBillsUpdate
+    end
+  end
 end

+ 39 - 2
Frames/BillsGatherFme.pas

@@ -6,9 +6,11 @@ uses
   BillsGatherDm, Globals, sdDB,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
   Dialogs, ZJGrid, ExtCtrls, ZjGridDBA, ZjGridTreeDBA, ComCtrls, ToolWin,
-  XPMenu, sdGridDBA, JimPages;
+  XPMenu, sdGridDBA, JimPages, dxBar, ActnList;
 
 type
+  TLocateBillsEvent = procedure (AID: Integer) of object;
+
   TBillsGatherFrame = class(TFrame)
     pnlBillsGather: TPanel;
     zgGclBills: TZJGrid;
@@ -31,13 +33,22 @@ type
     zgDetailBGL: TZJGrid;
     zgDetailDeal: TZJGrid;
     saGclBills: TsdGridDBA;
+    dxpmDetailGcl: TdxBarPopupMenu;
+    alBillsGather: TActionList;
+    actnLocateMeasureBills: TAction;
     procedure zgGclBillsCellGetColor(Sender: TObject; ACoord: TPoint;
       var AColor: TColor);
     procedure tobtnDetailGclClick(Sender: TObject);
+    procedure dxpmDetailGclPopup(Sender: TObject);
+    procedure actnLocateMeasureBillsExecute(Sender: TObject);
+    procedure actnLocateMeasureBillsUpdate(Sender: TObject);
+    procedure zgDetailGclMouseDown(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: Integer);
   private
     FBillsGatherData: TBillsGatherData;
     FShowPhaseData: Boolean;
     FShowPriceChange: Boolean;
+    FOnLocateMeasureBills: TLocateBillsEvent;
 
     procedure SetColumnVisible(const AColumn: string; AVisible: Boolean);
 
@@ -51,12 +62,14 @@ type
 
     property ShowPriceChange: Boolean read FShowPriceChange write SetShowPriceChange;
     property ShowPhaseData: Boolean read FShowPhaseData write SetShowPhaseData;
+
+    property OnLocateMeasureBills: TLocateBillsEvent read FOnLocateMeasureBills write FOnLocateMeasureBills;
   end;
 
 implementation
 
 uses
-  ProjectData, UtilMethods, CalcDecimal;
+  ProjectData, UtilMethods, CalcDecimal, MainFrm;
 
 {$R *.dfm}
 
@@ -188,4 +201,28 @@ begin
   tobtnDetailBGL.Down := tobtnDetailBGL.Tag = TToolButton(Sender).Tag;
 end;
 
+procedure TBillsGatherFrame.dxpmDetailGclPopup(Sender: TObject);
+begin
+  SetDxBtnAction(actnLocateMeasureBills, MainForm.dxbtnLocateMeasureBills);
+end;
+
+procedure TBillsGatherFrame.actnLocateMeasureBillsExecute(Sender: TObject);
+begin
+  if Assigned(saDetailGcl.DataView.Current) and Assigned(FOnLocateMeasureBills) then
+    FOnLocateMeasureBills(saDetailGcl.DataView.Current.ValueByName('RelaBillsID').AsInteger);
+end;
+
+procedure TBillsGatherFrame.actnLocateMeasureBillsUpdate(Sender: TObject);
+begin
+  TAction(Sender).Enabled := Assigned(saDetailGcl.DataView.Current) and Assigned(FOnLocateMeasureBills);
+end;
+
+procedure TBillsGatherFrame.zgDetailGclMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+begin
+  if Button = mbRight then
+    dxpmDetailGcl.PopupFromCursorPos;
+end;
+
 end.
+

+ 114 - 2
Frames/ProjectFme.pas

@@ -136,6 +136,11 @@ type
     // 刷新各界面只读、显示等
     procedure RefreshProjectState;
 
+    // Change Main View
+    procedure BeforeChangeView(APageIndex: Integer);
+    procedure AfterChangeView(APageIndex: Integer);
+    procedure ChangeView(APageIndex: Integer);
+
     procedure AdjustFramesDisplay;
 
     procedure SaveLog(AStr: string);
@@ -178,6 +183,8 @@ type
     procedure RepairAudits;
     function CheckFileAndCloudChekerList: Boolean;
 
+    procedure LocateMeasureBills(AID: Integer);
+
     property ProjectData: TProjectData read FProjectData;
 
     property BillsCompileFrame: TBillsCompileFrame read FBillsCompileFrame;
@@ -536,6 +543,7 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
     end;
   end;
 
+  (*
   procedure ChangeView;
   begin
     BeforeChangeView;
@@ -545,6 +553,7 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
     end;
     AfterChangeView;
   end;
+  *)
 
   procedure DisplayReports;
   begin
@@ -598,7 +607,7 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
       dxsbViewControl.SelectedItem := dxsbViewControl.ActiveGroup.Items[jpsMain.ActivePageIndex];
       Abort;
     end;
-    ChangeView;
+    ChangeView(Item.Tag);
   end;
 
 var
@@ -609,7 +618,7 @@ begin
   bCloseCompare := (Item.Tag in [0..3, 5]) and (jpsMain.ActivePageIndex = 4);
 
   case Item.Tag of
-    0..2, 5: ChangeView;
+    0..2, 5: ChangeView(Item.Tag);
     3: DisplayPriceMargin;
     4: DisplayCompare;
     6: DisplayReports;
@@ -649,6 +658,7 @@ begin
   AlignControl(FBillsGatherFrame, jpsMainBillsGather, alClient);
   FBillsGatherFrame.ShowPriceChange := FProjectData.ProjProperties.ShowPriceChange;
   FBillsGatherFrame.ShowPhaseData := FProjectData.ProjProperties.PhaseCount > 0;
+  FBillsGatherFrame.OnLocateMeasureBills := LocateMeasureBills;
 end;
 
 procedure TProjectFrame.dxpmExpandBillsPopup(Sender: TObject);
@@ -1485,4 +1495,106 @@ begin
   pnlProjectCheckStatus.Update;
 end;
 
+procedure TProjectFrame.LocateMeasureBills(AID: Integer);
+var
+  vNode: TsdIDTreeNode;
+begin
+  dxsbViewControl.SelectedItem := dxsbViewControl.Groups[0].Items[xbiBillsMeasure.Tag];
+  ChangeView(xbiBillsMeasure.Tag);
+  with FProjectData.BillsMeasureData do
+  begin
+    vNode := BillsMeasureTree.FindNode(AID);
+    if Assigned(vNode) then
+      sdvBillsMeasure.LocateInControl(vNode.Rec);
+  end;
+end;
+
+procedure TProjectFrame.ChangeView(APageIndex: Integer);
+begin
+  BeforeChangeView(APageIndex);
+  case APageIndex of
+    0, 2: jpsMain.ActivePageIndex := APageIndex;
+    1, 3, 5: if CheckMeasureEdition then jpsMain.ActivePageIndex := APageIndex;
+  end;
+  AfterChangeView(APageIndex);
+end;
+
+procedure TProjectFrame.AfterChangeView(APageIndex: Integer);
+begin
+  // 仅计量台账界面可以选择计量期
+  pnlPhaseSelect.Visible := APageIndex = xbiBillsMeasure.Tag;
+  // 台账分解、计量台账、审核比较 可使用"显示至"功能
+  tbExpand.Visible := (APageIndex = xbiBillsCompile.Tag)
+                   or (APageIndex = xbiBillsMeasure.Tag)
+                   or (APageIndex = xbiStageCompare.Tag);
+  // 右侧按钮是否显示
+  tbToolsButton.Visible := (APageIndex = xbiBillsCompile.Tag)
+                        or (APageIndex = xbiBillsMeasure.Tag);
+  tobtnBGL.Visible := APageIndex = xbiBillsMeasure.Tag;
+  tobtnZJJL.Visible := APageIndex = xbiBillsMeasure.Tag;
+  // 控制整个按钮工具栏显示,
+  pnlToolBar.Visible := pnlPhaseSelect.Visible or tbExpand.Visible or tbToolsButton.Visible;
+  // 根据当前View控制右侧按钮是否按下,右侧工具窗是否弹开
+  jpsAssistant.ActivePageIndex := jpsMain.ActivePage.Tag;
+  sbtnExpend.Tag := jpsMain.ActivePage.Tag;
+  ControlAssistantButtonsDown(jpsMain.ActivePage.Tag);
+  SetAssistantViewVisible(jpsMain.ActivePage.Tag <> -1);
+  SetImageOfsbtnExpend(jpsMain.ActivePage.Tag <> -1);
+  // 0号台账与计量台账的书签不同
+  if APageIndex = xbiBillsCompile.Tag then
+    FBookmarkFrame.BMType := bmtCompile
+  else if APageIndex = xbiBillsMeasure.Tag then
+    FBookmarkFrame.BMType := bmtMeasure;
+  // 0号台账与计量台账的查找定位不同
+  if APageIndex = xbiBillsCompile.Tag then
+    FSearchFrame.LocateType := ltCompile
+  else if APageIndex = xbiBillsMeasure.Tag then
+    FSearchFrame.LocateType := ltMeasure;
+  // 切换至清单汇总,须重新汇总
+  if APageIndex = xbiBillsGather.Tag then
+    BillsGatherFrame.RefreshBills;
+  // 切换至材料调差,须重新汇总展示调差清单
+  if APageIndex = xbiPriceMargin.Tag then
+    PriceMarginFrame.RefreshBills;
+
+  if G_IsCloud then
+  begin
+    if (APageIndex = xbiBillsCompile.Tag) or (APageIndex = xbiBillsMeasure.Tag) then
+      CheckUpFile;
+
+    tobtnUpFile.Visible := APageIndex = xbiBillsMeasure.Tag;
+    if (tobtnUpFile.Visible = False) and (jpsAssistant.ActivePage = jpsAssistantUpFile) then
+      jpsAssistant.ActivePage := jpsAssistantStandardBills;
+  end;
+end;
+
+procedure TProjectFrame.BeforeChangeView(APageIndex: Integer);
+begin
+  if G_IsCloud then
+  begin
+    tobtnShowChecker.Visible := ProjectData.PhaseIndex > 0;
+    tobtnShowChecker.Enabled := (APageIndex = xbiBillsMeasure.Tag);
+
+    ButtonControl_NewPhase;
+
+    if APageIndex = xbiBillsCompile.Tag then
+    begin
+      if tobtnShowChecker.Down then
+      begin
+        tobtnShowChecker.Down := False;
+        tobtnShowChecker.Click;
+        tobtnStandardBills.Down := True;
+        tobtnStandardBills.Click;
+        tobtnStandardBills.Down := False;
+        tobtnStandardBills.Click;
+      end;
+    end;
+  end;
+  // 记录台账分解、计量台账等的右侧展开情况
+  if jpsAssistant.Visible then
+    jpsMain.ActivePage.Tag := jpsAssistant.ActivePageIndex
+  else
+    jpsMain.ActivePage.Tag := -1;
+end;
+
 end.