瀏覽代碼

标准清单,可切换标准库

MaiXinRong 7 年之前
父節點
當前提交
37cb98d815

+ 50 - 0
DataModules/BillsCompileDm.pas

@@ -90,6 +90,8 @@ type
 
     procedure ReorderChildrenCode(ANode: TsdIDTreeNode);
 
+    procedure RecursiveExportBillsJson(const AFileName: string);
+
     // 所有解锁的节点全部重新锁定
     procedure ReLockBaseData;
 
@@ -1283,4 +1285,52 @@ begin
   end;
 end;
 
+procedure TBillsCompileData.RecursiveExportBillsJson(
+  const AFileName: string);
+var
+  sgs: TStrings;
+
+  function GetNodeData(ANode: TBillsIDTreeNode; AOrder: Integer; AFullPath: string): string;
+  const
+    sBillsJson = '"id": %d, "pid": %d, "order": %d, "full_path": "%s", "level": %d, "isleaf" : %d, ' +
+                 '"code": "%s", "b_code": "%s", "name": "%s", "unit": "%s", ' +
+                 '%s';
+  begin
+    Result := Format(sBillsJson, [ANode.Rec.ID.AsInteger, ANode.Rec.ParentID.AsInteger, AOrder, AFullPath, ANode.Level, Integer(not ANode.HasChildren),
+         ANode.Rec.Code.AsString, ANode.Rec.B_Code.AsString, ANode.Rec.Name.AsString, ANode.Rec.Units.AsString, '"tender_id": 2']);
+  end;
+
+  procedure ExportNode(ANode: TsdIDTreeNode; AOrder: Integer; AParentPath: string);
+  var
+    sNodePath: string;
+  begin
+    if not Assigned(ANode) then Exit;
+
+    if AParentPath = '' then
+      sNodePath := IntToStr(ANode.ID)
+    else
+      sNodePath := AParentPath + '.' + IntToStr(ANode.ID);
+
+    sgs.Strings[sgs.Count - 1] := sgs.Strings[sgs.Count - 1] + '{';
+    sgs.Add(Format('  %s', [AnsiToUtf8(GetNodeData(TBillsIDTreeNode(ANode), AOrder, sNodePath))]));
+    sgs.Add('}');
+    if Assigned(ANode.NextNode) then
+      sgs.Strings[sgs.Count - 1] := sgs.Strings[sgs.Count - 1] + ',';
+      
+    ExportNode(ANode.FirstChild, 1, sNodePath);
+    ExportNode(ANode.NextSibling, AOrder + 1, AParentPath);
+  end;
+
+begin
+  sgs := TStringList.Create;
+  try
+    sgs.Add('var BillsData = [');
+    ExportNode(FBillsCompileTree.FirstNode, 1, '');
+    sgs.Strings[sgs.Count - 1] := sgs.Strings[sgs.Count - 1] + '];';
+    sgs.SaveToFile(AFileName);
+  finally
+    sgs.Free;
+  end;
+end;
+
 end.

+ 35 - 17
DataModules/StandardBillsDm.dfm

@@ -16,24 +16,42 @@ object StandardBillsData: TStandardBillsData
     FieldListData = {
       0101044E616D6506024944094669656C644E616D650602494408446174615479
       70650203084461746153697A6502040549734B6579080F4E65656450726F6365
-      73734E616D65090001044E616D650608506172656E744944094669656C644E61
-      6D650608506172656E7449440844617461547970650203084461746153697A65
-      02040549734B6579080F4E65656450726F636573734E616D65090001044E616D
-      6506064E6578744944094669656C644E616D6506064E65787449440844617461
-      547970650203084461746153697A6502040549734B6579080F4E65656450726F
-      636573734E616D65090001044E616D650604436F6465094669656C644E616D65
-      0604436F64650844617461547970650201084461746153697A6502320549734B
-      6579080F4E65656450726F636573734E616D65090001044E616D650606425F43
-      6F6465094669656C644E616D650606425F436F64650844617461547970650201
-      084461746153697A6502320549734B6579080F4E65656450726F636573734E61
-      6D65090001044E616D6506044E616D65094669656C644E616D6506044E616D65
-      0844617461547970650218084461746153697A6503C8000549734B6579080F4E
-      65656450726F636573734E616D65090001044E616D650604556E697409466965
-      6C644E616D650604556E69740844617461547970650218084461746153697A65
-      02140549734B6579080F4E65656450726F636573734E616D65090001044E616D
-      6506085374617469634944094669656C644E616D650608537461746963494408
+      73734E616D650909507265636973696F6E02000453697A6502000001044E616D
+      650608506172656E744944094669656C644E616D650608506172656E74494408
       44617461547970650203084461746153697A6502040549734B6579080F4E6565
-      6450726F636573734E616D65090000}
+      6450726F636573734E616D650909507265636973696F6E02000453697A650200
+      0001044E616D6506064E6578744944094669656C644E616D6506064E65787449
+      440844617461547970650203084461746153697A6502040549734B6579080F4E
+      65656450726F636573734E616D650909507265636973696F6E02000453697A65
+      02000001044E616D650604436F6465094669656C644E616D650604436F646508
+      44617461547970650201084461746153697A6502320549734B6579080F4E6565
+      6450726F636573734E616D650909507265636973696F6E02000453697A650200
+      0001044E616D650606425F436F6465094669656C644E616D650606425F436F64
+      650844617461547970650201084461746153697A6502320549734B6579080F4E
+      65656450726F636573734E616D650909507265636973696F6E02000453697A65
+      02000001044E616D6506044E616D65094669656C644E616D6506044E616D6508
+      44617461547970650218084461746153697A6503C8000549734B6579080F4E65
+      656450726F636573734E616D650909507265636973696F6E02000453697A6502
+      000001044E616D650604556E6974094669656C644E616D650604556E69740844
+      617461547970650218084461746153697A6502140549734B6579080F4E656564
+      50726F636573734E616D650909507265636973696F6E02000453697A65020000
+      01044E616D6506085374617469634944094669656C644E616D65060853746174
+      696349440844617461547970650203084461746153697A6502040549734B6579
+      080F4E65656450726F636573734E616D650909507265636973696F6E02000453
+      697A6502000001044E616D65060846756C6C50617468094669656C644E616D65
+      060846756C6C506174680844617461547970650218084461746153697A6503FF
+      000549734B6579080F4E65656450726F636573734E616D650909507265636973
+      696F6E02000453697A6502000001044E616D65060649734C656166094669656C
+      644E616D65060649734C6561660844617461547970650205084461746153697A
+      6502010549734B6579080F4E65656450726F636573734E616D65090950726563
+      6973696F6E02000453697A6502000001044E616D65060A42696C6C734F726465
+      72094669656C644E616D65060A42696C6C734F72646572084461746154797065
+      0203084461746153697A6502040549734B6579080F4E65656450726F63657373
+      4E616D650809507265636973696F6E02000453697A6502000001044E616D6506
+      0A42696C6C734C6576656C094669656C644E616D65060A42696C6C734C657665
+      6C0844617461547970650203084461746153697A6502040549734B6579080F4E
+      65656450726F636573734E616D650909507265636973696F6E02000453697A65
+      02000000}
   end
   object sdvStdBills: TsdDataView
     Active = False

+ 21 - 0
DataModules/StandardBillsDm.pas

@@ -22,6 +22,7 @@ type
     destructor Destroy; override;
 
     procedure Open(AConnection: TADOConnection);
+    procedure CalcCacheData(ANode:TsdIDTreeNode; AOrder: Integer; AParentPath: String);
 
     property BillsTree: TsdIDTree read FBillsTree;
   end;
@@ -32,6 +33,26 @@ implementation
 
 { TStandardBillsData }
 
+procedure TStandardBillsData.CalcCacheData(ANode: TsdIDTreeNode;
+  AOrder: Integer; AParentPath: String);
+var
+  sNodePath: string;
+begin
+  if not Assigned(ANode) then Exit;
+
+  ANode.Rec.ValueByName('BillsLevel').AsInteger := ANode.Level + 1;
+  ANode.Rec.ValueByName('BillsOrder').AsInteger := AOrder;
+  if AParentPath = '' then
+    sNodePath := IntToStr(ANode.ID)
+  else
+    sNodePath := AParentPath + '.' + IntToStr(ANode.ID);
+  ANode.Rec.ValueByName('FullPath').AsString := sNodePath;
+  ANode.Rec.ValueByName('IsLeaf').AsBoolean := not ANode.HasChildren;
+
+  CalcCacheData(ANode.FirstChild, 1, sNodePath);
+  CalcCacheData(ANode.NextSibling, AOrder + 1, AParentPath);
+end;
+
 constructor TStandardBillsData.Create(AOwner: TComponent);
 begin
   inherited;

+ 141 - 116
Forms/MainFrm.dfm

@@ -21,7 +21,7 @@ object MainForm: TMainForm
   object jtsProjects: TJimTabSet
     Left = 0
     Top = 49
-    Width = 734
+    Width = 742
     Height = 21
     Align = alTop
     BackgroundColor = clGradientInactiveCaption
@@ -45,8 +45,8 @@ object MainForm: TMainForm
   end
   object dxStatusBar: TdxStatusBar
     Left = 0
-    Top = 480
-    Width = 734
+    Top = 487
+    Width = 742
     Height = 20
     Panels = <
       item
@@ -78,12 +78,12 @@ object MainForm: TMainForm
     object dxStatusBarContainer2: TdxStatusBarContainerControl
       Left = 604
       Top = 2
-      Width = 128
+      Width = 136
       Height = 16
       object ProgressBar: TProgressBar
         Left = 0
         Top = 0
-        Width = 128
+        Width = 136
         Height = 16
         Align = alClient
         Max = 200
@@ -94,8 +94,8 @@ object MainForm: TMainForm
   object jpsMain: TJimPages
     Left = 0
     Top = 70
-    Width = 734
-    Height = 410
+    Width = 742
+    Height = 417
     ActivePage = jpsMainProjectsManager
     ActivePageIndex = 0
     Align = alClient
@@ -103,8 +103,8 @@ object MainForm: TMainForm
     object jpsMainProjectsManager: TJimPage
       Left = 0
       Top = 0
-      Width = 734
-      Height = 410
+      Width = 742
+      Height = 417
       TabName = 'ProjectsManager'
       Caption = 'ProjsMgr'
       object pnlUser: TPanel
@@ -201,8 +201,8 @@ object MainForm: TMainForm
     object jpsMainProjects: TJimPage
       Left = 0
       Top = 0
-      Width = 734
-      Height = 410
+      Width = 742
+      Height = 417
       TabName = 'Projects'
       Caption = 'Projects'
       object jpsProjects: TJimPages
@@ -220,7 +220,7 @@ object MainForm: TMainForm
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clWindowText
     Font.Height = -12
-    Font.Name = #24494#36719#38597#40657
+    Font.Name = 'Microsoft YaHei UI'
     Font.Style = []
     Bars = <
       item
@@ -364,10 +364,22 @@ object MainForm: TMainForm
       end>
     CanCustomize = False
     Categories.Strings = (
-      #40664#35748)
+      #26174#31034#33267
+      #21491#38190'-'#23548#20837#23548#20986
+      #40664#35748
+      #25991#20214'-'#23548#20837#23548#20986
+      #24635#20998#21253)
     Categories.ItemsVisibles = (
+      2
+      2
+      2
+      2
       2)
     Categories.Visibles = (
+      True
+      True
+      True
+      True
       True)
     Images = Images
     PopupMenuLinks = <>
@@ -383,7 +395,7 @@ object MainForm: TMainForm
       0)
     object dxsiFile: TdxBarSubItem
       Caption = #25991#20214'(&F)'
-      Category = 0
+      Category = 2
       Visible = ivAlways
       ItemLinks = <
         item
@@ -421,11 +433,15 @@ object MainForm: TMainForm
         item
           Item = dxbtnImportSubTenderGather
           Visible = True
+        end
+        item
+          Item = dxbtnExportBillsJson
+          Visible = True
         end>
     end
     object dxsiEdit: TdxBarSubItem
       Caption = #32534#36753'(&E)'
-      Category = 0
+      Category = 2
       Visible = ivAlways
       ItemLinks = <
         item
@@ -469,7 +485,7 @@ object MainForm: TMainForm
     end
     object dxsiHelp: TdxBarSubItem
       Caption = #24110#21161'(&H)'
-      Category = 0
+      Category = 2
       Visible = ivAlways
       ItemLinks = <
         item
@@ -493,186 +509,186 @@ object MainForm: TMainForm
     end
     object dxbtnCopy: TdxBarButton
       Action = ZjGridCopy
-      Category = 0
+      Category = 2
     end
     object dxbtnPaste: TdxBarButton
       Action = ZjGridPaste
-      Category = 0
+      Category = 2
     end
     object dxbtnCut: TdxBarButton
       Action = ZjGridCut
-      Category = 0
+      Category = 2
     end
     object dxbtnInsert: TdxBarButton
       Action = ZjDbaInsert
-      Category = 0
+      Category = 2
     end
     object dxbtnDelete: TdxBarButton
       Action = ZjDbaDelete
-      Category = 0
+      Category = 2
     end
     object dxbtnUpMove: TdxBarButton
       Action = ZjDbaUpMove
-      Category = 0
+      Category = 2
     end
     object dxbtnDownMove: TdxBarButton
       Action = ZjDbaDownMove
-      Category = 0
+      Category = 2
     end
     object dxbtnUpLevel: TdxBarButton
       Action = ZjTreeDbaUpLevel
-      Category = 0
+      Category = 2
     end
     object dxbtnDownLevel: TdxBarButton
       Action = ZjTreeDbaDownLevel
-      Category = 0
+      Category = 2
     end
     object dxbtnAuthorizeDog: TdxBarButton
       Caption = #20135#21697#27880#20876
-      Category = 0
+      Category = 2
       Hint = #20135#21697#27880#20876
       Visible = ivAlways
       OnClick = dxbtnAuthorizeDogClick
     end
     object dxbtnAbout: TdxBarButton
       Caption = #20851#20110
-      Category = 0
+      Category = 2
       Hint = #20851#20110
       Visible = ivAlways
       OnClick = dxbtnAboutClick
     end
     object dxbtnNewProject: TdxBarButton
       Caption = #26032#24314#25991#20214#22841
-      Category = 0
+      Category = 2
       Hint = #26032#24314
       Visible = ivAlways
       ImageIndex = 11
     end
     object dxbtnOpenProject: TdxBarButton
       Caption = #25171#24320#39033#30446
-      Category = 0
+      Category = 2
       Hint = #25171#24320
       Visible = ivAlways
       ImageIndex = 3
     end
     object dxbtnDeleteProject: TdxBarButton
       Caption = #21024#38500#39033#30446
-      Category = 0
+      Category = 2
       Hint = #21024#38500
       Visible = ivAlways
       ImageIndex = 6
     end
     object dxbtnCloseProject: TdxBarButton
       Action = actnCloseProject
-      Category = 0
+      Category = 2
     end
     object dxbtnNewPhase: TdxBarButton
       Action = actnNewPhase
-      Category = 0
+      Category = 2
     end
     object dxbtnCalculateLedger: TdxBarButton
       Caption = #21488#36134#35745#31639
-      Category = 0
+      Category = 2
       Hint = #21488#36134#35745#31639
       Visible = ivAlways
       ImageIndex = 15
     end
     object dxbtnProjectProperties: TdxBarButton
       Action = actnProjectProperties
-      Category = 0
+      Category = 2
     end
     object dxbtnSaveProject: TdxBarButton
       Action = actnSaveProject
-      Category = 0
+      Category = 2
     end
     object dxbtnRemapedPaste: TdxBarButton
       Action = ZjGridRemapedPaste
-      Category = 0
+      Category = 2
     end
     object dxbtnImportExcel: TdxBarButton
       Action = actnImportExcel
-      Category = 0
+      Category = 3
     end
     object dxbtnNewAudit: TdxBarButton
       Action = actnNewAudit
-      Category = 0
+      Category = 2
       Hint = #26032#22686#23457#26680
     end
     object dxbtnCopyBillsBlock: TdxBarButton
       Caption = #22797#21046#25972#22359
-      Category = 0
+      Category = 2
       Hint = #22797#21046#25972#22359
       Visible = ivAlways
     end
     object dxbtnFinalAudit: TdxBarButton
       Caption = #35774#20026#32456#23457
-      Category = 0
+      Category = 2
       Hint = #35774#20026#32456#23457
       Visible = ivAlways
     end
     object dxbtnSubmitProject: TdxBarButton
       Caption = #19978#25253#35745#37327#25991#20214
-      Category = 0
+      Category = 2
       Hint = #19978#25253#35745#37327#25991#20214
       Visible = ivAlways
     end
     object dxbtnReceiveProject: TdxBarButton
       Caption = #25509#25910#25253#23457'\'#25209#22797#25991#20214
-      Category = 0
+      Category = 2
       Hint = #25509#25910#25253#23457'\'#25209#22797#25991#20214
       Visible = ivAlways
     end
     object dxbtnReplyProject: TdxBarButton
       Caption = #25209#22797#32456#23457#25991#20214
-      Category = 0
+      Category = 2
       Hint = #25209#22797#32456#23457#25991#20214
       Visible = ivAlways
     end
     object dxbtnAcceptProject: TdxBarButton
       Caption = #25509#25910#25209#22797#25991#20214
-      Category = 0
+      Category = 2
       Hint = #25509#25910#25209#22797#25991#20214
       Visible = ivAlways
     end
     object dxbtnCalculateAll: TdxBarButton
       Caption = #20840#37096#35745#31639
-      Category = 0
+      Category = 2
       Hint = #20840#37096#35745#31639
       Visible = ivAlways
       ImageIndex = 15
     end
     object dxbtnNewSubProject: TdxBarButton
       Caption = #26032#24314#23376#25991#20214#22841
-      Category = 0
+      Category = 2
       Hint = #26032#24314#23376#25991#20214#22841
       Visible = ivAlways
       ImageIndex = 11
     end
     object dxbtnNewTender: TdxBarButton
       Caption = #26032#24314#26631#27573
-      Category = 0
+      Category = 2
       Hint = #26032#24314#26631#27573
       Visible = ivAlways
       ImageIndex = 11
     end
     object dxbtnOptions: TdxBarButton
       Action = actnOptions
-      Category = 0
+      Category = 2
     end
     object dxbtnCalculatePhasePay: TdxBarButton
       Caption = #35745#31639#26412#26399#21512#21516#25903#20184
-      Category = 0
+      Category = 2
       Hint = #35745#31639#26412#26399#21512#21516#25903#20184
       Visible = ivAlways
       ImageIndex = 15
     end
     object dxbtnSubmit: TdxBarButton
       Action = actnSubmit
-      Category = 0
+      Category = 2
     end
     object dxbtnReply: TdxBarButton
       Action = actnReply
-      Category = 0
+      Category = 2
     end
     object dxbtnFirstLevel: TdxBarButton
       Caption = #31532#19968#23618
@@ -718,24 +734,24 @@ object MainForm: TMainForm
     end
     object dxbtnExportGridToExcel: TdxBarButton
       Caption = #23548#20986#34920#26684#25968#25454
-      Category = 0
+      Category = 1
       Hint = #23548#20986#34920#26684#25968#25454
       Visible = ivAlways
       ImageIndex = 13
     end
     object dxbtnRefresh: TdxBarButton
       Caption = #21047#26032
-      Category = 0
+      Category = 2
       Hint = #21047#26032
       Visible = ivAlways
     end
     object dxbtnUnlockInfo: TdxBarButton
       Action = actnUnlockInfo
-      Category = 0
+      Category = 2
     end
     object dxUser: TdxBarSubItem
       Caption = 'User'
-      Category = 0
+      Category = 2
       Visible = ivAlways
       ImageIndex = 48
       ItemLinks = <
@@ -759,14 +775,14 @@ object MainForm: TMainForm
     end
     object dxUserContainer: TdxBarControlContainerItem
       Caption = 'User'#23481#22120
-      Category = 0
+      Category = 2
       Hint = 'User'#23481#22120
       Visible = ivAlways
       Control = pnlUser
     end
     object dxLoginCloud: TdxBarButton
       Caption = #30331#24405#35745#37327#25903#20184#20113#31471
-      Category = 0
+      Category = 2
       Hint = #30331#24405#35745#37327#25903#20184#20113#31471
       Visible = ivAlways
       ImageIndex = 50
@@ -774,7 +790,7 @@ object MainForm: TMainForm
     end
     object dxManageAccount: TdxBarButton
       Caption = #31649#29702#25105#30340#36890#34892#24080#21495
-      Category = 0
+      Category = 2
       Hint = #31649#29702#25105#30340#36890#34892#24080#21495
       Visible = ivAlways
       ImageIndex = 51
@@ -782,29 +798,29 @@ object MainForm: TMainForm
     end
     object dxbtnBatchAddChild: TdxBarButton
       Caption = #25209#37327#25554#20837#23376#39033
-      Category = 0
+      Category = 2
       Hint = #25209#37327#25554#20837#23376#39033
       Visible = ivAlways
     end
     object dxbtnBatchAddNext: TdxBarButton
       Caption = #25209#37327#25554#20837#21518#39033
-      Category = 0
+      Category = 2
       Hint = #25209#37327#25554#20837#21518#39033
       Visible = ivAlways
     end
     object dxbtnReorderChildrenCode: TdxBarButton
       Caption = #39034#24207#37325#25490#23376#39033#32534#21495
-      Category = 0
+      Category = 2
       Hint = #39034#24207#37325#25490#23376#39033#32534#21495
       Visible = ivAlways
     end
     object dxbtnImportBillsPrice: TdxBarButton
       Action = actnImportBillsPrice
-      Category = 0
+      Category = 3
     end
     object dxsiImportExcel: TdxBarSubItem
       Caption = #23548#20837'Excel'
-      Category = 0
+      Category = 3
       Visible = ivAlways
       ItemLinks = <
         item
@@ -822,17 +838,17 @@ object MainForm: TMainForm
     end
     object dxbtnImportDealBills: TdxBarButton
       Action = actnImportDealBills
-      Category = 0
+      Category = 3
     end
     object dxbtnBatchReplaceBillsInfo: TdxBarButton
       Caption = #25209#37327#26367#25442#28165#21333#20449#24687
-      Category = 0
+      Category = 2
       Hint = #25209#37327#26367#25442#28165#21333#20449#24687
       Visible = ivAlways
     end
     object dxsiExportExcel: TdxBarSubItem
       Caption = #23548#20986'Excel'
-      Category = 0
+      Category = 3
       Visible = ivAlways
       ItemLinks = <
         item
@@ -846,7 +862,7 @@ object MainForm: TMainForm
     end
     object dxbtnExportExcel: TdxBarButton
       Action = actnExportExcel
-      Category = 0
+      Category = 3
     end
     object dxbtnCurPhase: TdxBarButton
       Caption = #21482#26174#31034#26412#26399
@@ -856,7 +872,7 @@ object MainForm: TMainForm
     end
     object dxSync: TdxBarButton
       Caption = #21516#27493#26356#26032#25105#21442#19982#30340#20840#37096#39033#30446
-      Category = 0
+      Category = 2
       Hint = #21516#27493#26356#26032#25105#21442#19982#30340#20840#37096#39033#30446
       Visible = ivAlways
       ImageIndex = 52
@@ -864,55 +880,55 @@ object MainForm: TMainForm
     end
     object dxbtnBatchWritePos_Reason: TdxBarButton
       Caption = #19968#38190#22635#21517#31216#33267#21407#22240
-      Category = 0
+      Category = 2
       Hint = #19968#38190#22635#21517#31216#33267#21407#22240
       Visible = ivAlways
     end
     object dxbtnExportCloudTenderFile: TdxBarButton
       Action = actnExportCloudTenderFile
-      Category = 0
+      Category = 3
     end
     object dxtbnImportCloudTenderFile: TdxBarButton
       Action = actnImportCloudTenderFile
-      Category = 0
+      Category = 2
     end
     object dxbtnCheckAndClear: TdxBarButton
       Caption = #26816#26597#28165#29702
-      Category = 0
+      Category = 2
       Hint = #26816#26597#28165#29702
       Visible = ivAlways
     end
     object dxbtnModifyDealBills: TdxBarButton
       Caption = #20462#25913#31614#32422#28165#21333
-      Category = 0
+      Category = 2
       Hint = #39035#20808#35299#38145#26041#21487#20462#25913
       Visible = ivAlways
     end
     object dxbtnLocateBills: TdxBarButton
       Caption = #23450#20301#33267#21488#36134
-      Category = 0
+      Category = 2
       Hint = #23450#20301#33267#21488#36134
       Visible = ivAlways
     end
     object dxbtnOpenBackupFolder: TdxBarButton
       Caption = #26597#30475#22791#20221#25968#25454
-      Category = 0
+      Category = 2
       Hint = #26597#30475#22791#20221#25968#25454
       Visible = ivAlways
     end
     object dxbtnSetBookmark: TdxBarButton
       Caption = #35774#32622'/'#21462#28040#20070#31614
-      Category = 0
+      Category = 2
       Hint = #35774#32622'/'#21462#28040#20070#31614
       Visible = ivAlways
     end
     object dxbtnExportFxBillsExcel: TdxBarButton
       Action = actnExportFxBillsExcel
-      Category = 0
+      Category = 3
     end
     object dxseBatchInsert: TdxBarSpinEdit
       Caption = #25209#37327#25554#20837
-      Category = 0
+      Category = 2
       Hint = #25209#37327#25554#20837
       Visible = ivAlways
       OnKeyDown = dxseBatchInsertKeyDown
@@ -924,26 +940,26 @@ object MainForm: TMainForm
     end
     object dxbtnRename: TdxBarButton
       Caption = #37325#21629#21517
-      Category = 0
+      Category = 2
       Hint = #37325#21629#21517
       Visible = ivAlways
       ImageIndex = 18
     end
     object dxbtnImportGclBillsToXmj: TdxBarButton
       Caption = #23548#20837#24037#31243#37327#28165#21333#33267#39033#30446#33410
-      Category = 0
+      Category = 1
       Hint = #23548#20837#24037#31243#37327#28165#21333#33267#39033#30446#33410
       Visible = ivAlways
     end
     object dxbtnChangeDealBillsMode: TdxBarButton
       Caption = #20999#25442#33267'XX'#27169#24335
-      Category = 0
+      Category = 2
       Hint = #20999#25442#33267'XX'#27169#24335
       Visible = ivAlways
     end
     object dxsiExpandTo: TdxBarSubItem
       Caption = #26174#31034#33267'...'
-      Category = 0
+      Category = 2
       Visible = ivAlways
       ItemLinks = <
         item
@@ -977,37 +993,37 @@ object MainForm: TMainForm
     end
     object dxbtnLocateBookmark: TdxBarButton
       Caption = #23450#20301
-      Category = 0
+      Category = 2
       Hint = #23450#20301
       Visible = ivAlways
     end
     object dxbtnImportPlaneFxBillsToXmj: TdxBarButton
       Caption = #23548#20837#21488#36134'('#24179#38754#32467#26500')'#33267#39033#30446#33410
-      Category = 0
+      Category = 1
       Hint = #23548#20837#21488#36134'('#24179#38754#32467#26500')'#33267#39033#30446#33410
       Visible = ivAlways
     end
     object dxbtnSetDealPayPlan: TdxBarButton
       Caption = #35774#32622#35745#25552#26399#38480
-      Category = 0
+      Category = 2
       Hint = #35774#32622#35745#25552#26399#38480
       Visible = ivAlways
     end
     object dxbtnAddDetailGLs: TdxBarButton
       Caption = #26032#22686#35843#24046#24037#26009
-      Category = 0
+      Category = 2
       Hint = #26032#22686#35843#24046#24037#26009
       Visible = ivAlways
     end
     object dxbtnAllPeg: TdxBarButton
       Caption = #21482#26174#31034#26729#21495'('#39033#30446#33410')'
-      Category = 0
+      Category = 2
       Hint = #21482#26174#31034#26729#21495'('#39033#30446#33410')'
       Visible = ivAlways
     end
     object dxsiData: TdxBarSubItem
       Caption = #25968#25454'(D)'
-      Category = 0
+      Category = 2
       Visible = ivAlways
       ItemLinks = <
         item
@@ -1021,172 +1037,176 @@ object MainForm: TMainForm
     end
     object dxbtnTenderPartition: TdxBarButton
       Caption = #26631#27573#21010#20998
-      Category = 0
+      Category = 2
       Hint = #26631#27573#21010#20998
       Visible = ivAlways
       OnClick = dxbtnTenderPartitionClick
     end
     object dxbtnCopyDetailGls: TdxBarButton
       Caption = #22797#21046#35843#24046#24037#26009
-      Category = 0
+      Category = 2
       Hint = #22797#21046#35843#24046#24037#26009
       Visible = ivAlways
       ImageIndex = 4
     end
     object dxbtnApplyToSameBills: TdxBarButton
       Caption = #24212#29992#35843#24046#24037#26009#33267#30456#21516#28165#21333
-      Category = 0
+      Category = 2
       Hint = #24212#29992#35843#24046#24037#26009#33267#30456#21516#28165#21333
       Visible = ivAlways
     end
     object dxbtnCalculatePriceMargin: TdxBarButton
       Caption = #20215#24046#35745#31639
-      Category = 0
+      Category = 2
       Hint = #20215#24046#35745#31639
       Visible = ivAlways
       ImageIndex = 15
     end
     object dxbtnFxZJJL: TdxBarButton
       Caption = '0'#21495#21488#36134#26684#24335
-      Category = 0
+      Category = 2
       Hint = '0'#21495#21488#36134#26684#24335
       Visible = ivAlways
     end
     object dxbtnGclZJJL: TdxBarButton
       Caption = #24635#37327#25511#21046#26684#24335
-      Category = 0
+      Category = 2
       Hint = #24635#37327#25511#21046#26684#24335
       Visible = ivAlways
     end
     object dxbtnInsertCol: TdxBarButton
       Caption = #26032#22686#19968#21015
-      Category = 0
+      Category = 2
       Hint = #26032#22686#19968#21015
       Visible = ivAlways
     end
     object dxbtnHidden: TdxBarButton
       Caption = #38544#34255
-      Category = 0
+      Category = 2
       Hint = #38544#34255
       Visible = ivAlways
     end
     object dxbtnCancelHidden: TdxBarButton
       Caption = #21462#28040#38544#34255
-      Category = 0
+      Category = 2
       Hint = #21462#28040#38544#34255
       Visible = ivAlways
     end
     object dxbtnImportDmf: TdxBarButton
       Action = actnImportDmf
-      Category = 0
+      Category = 3
     end
     object dxbtnCanCalc: TdxBarButton
       Caption = #20572#29992'/'#21551#29992
-      Category = 0
+      Category = 2
       Hint = #20572#29992'/'#21551#29992
       Visible = ivAlways
     end
     object dxbtnWithoutCalcCurPay: TdxBarButton
       Caption = #19981#21442#19982#26412#26399#24212#20184#35745#31639
-      Category = 0
+      Category = 2
       Hint = #19981#21442#19982#26412#26399#24212#20184#35745#31639
       Visible = ivAlways
     end
     object dxbtnSignOnline: TdxBarButton
       Caption = #29983#25104#22312#32447#31614#32626
-      Category = 0
+      Category = 2
       Hint = #29983#25104#22312#32447#31614#32626
       Visible = ivAlways
     end
     object dxbtnExportTpExcel: TdxBarButton
       Caption = 'New Item'
-      Category = 0
+      Category = 2
       Hint = 'New Item'
       Visible = ivAlways
     end
     object dxbtnHelpCenter: TdxBarButton
       Caption = #24110#21161#20013#24515
-      Category = 0
+      Category = 2
       Hint = #24110#21161#20013#24515
       Visible = ivAlways
       OnClick = dxbtnHelpCenterClick
     end
     object dxbtnLocateMeasureBills: TdxBarButton
       Caption = #23450#20301#33267#35745#37327#21488#36134
-      Category = 0
+      Category = 2
       Hint = #23450#20301#33267#35745#37327#21488#36134
       Visible = ivAlways
     end
     object dxbtnGuest: TdxBarButton
       Caption = #28155#21152#20851#27880#20154
-      Category = 0
+      Category = 2
       Hint = #28155#21152#20851#27880#20154
       Visible = ivAlways
     end
     object dxbtnLocateZJJL: TdxBarButton
       Caption = #23450#20301#33267#20013#38388#35745#37327
-      Category = 0
+      Category = 2
       Hint = #23450#20301#33267#20013#38388#35745#37327
       Visible = ivAlways
     end
     object dxbtnEpure: TdxBarButton
       Caption = #25554#20837#35745#37327#33609#22270
-      Category = 0
+      Category = 2
       Hint = #25554#20837#35745#37327#33609#22270
       Visible = ivAlways
     end
     object dxbtnLocateCompileBills: TdxBarButton
       Caption = #23450#20301#33267#21488#36134#20998#35299
-      Category = 0
+      Category = 2
       Hint = #23450#20301#33267#21488#36134#20998#35299
       Visible = ivAlways
     end
     object dxbtnGclGatherZJJL: TdxBarButton
       Caption = #35745#37327#27719#24635#26684#24335
-      Category = 0
+      Category = 2
       Hint = #35745#37327#27719#24635#26684#24335
       Visible = ivAlways
     end
     object dxbtnExportSumBaseFile: TdxBarButton
       Action = actnExportSumBaseFile
-      Category = 0
+      Category = 4
       Hint = #23548#20986#24635#21253#22522#20934#25991#20214
     end
     object dxbtnGatherSubTender: TdxBarButton
       Caption = #20998#21253#26631#27573#27719#24635
-      Category = 0
+      Category = 2
       Hint = #20998#21253#26631#27573#27719#24635
       Visible = ivAlways
       OnClick = dxbtnGatherSubTenderClick
     end
     object dxbtnExportTenderError: TdxBarButton
       Caption = #23548#20986#21333#26631#27573#38169#35823#20449#24687
-      Category = 0
+      Category = 4
       Hint = #23548#20986#21333#26631#27573#38169#35823#20449#24687
       Visible = ivAlways
     end
     object dxbtnExportAllError: TdxBarButton
       Caption = #23548#20986#20840#37096#38169#35823#20449#24687
-      Category = 0
+      Category = 4
       Hint = #23548#20986#20840#37096#38169#35823#20449#24687
       Visible = ivAlways
     end
     object dxbtnExportStgResultExcel: TdxBarButton
       Caption = #23548#20986#20998#21253#27719#24635#32467#26524
-      Category = 0
+      Category = 4
       Hint = #23548#20986#20998#21253#27719#24635#32467#26524
       Visible = ivAlways
       ImageIndex = 13
     end
     object dxbtnExportStgResult: TdxBarButton
       Caption = #23548#20986#20998#21253#27719#24635#32467#26524
-      Category = 0
+      Category = 4
       Hint = #23548#20986#20998#21253#27719#24635#32467#26524
       Visible = ivAlways
     end
     object dxbtnImportSubTenderGather: TdxBarButton
       Action = actnImportSubTenderGather
-      Category = 0
+      Category = 4
+    end
+    object dxbtnExportBillsJson: TdxBarButton
+      Action = actnExportBillsJson
+      Category = 3
     end
   end
   object Images: TImageList
@@ -3373,6 +3393,11 @@ object MainForm: TMainForm
       OnExecute = actnImportSubTenderGatherExecute
       OnUpdate = actnImportSubTenderGatherUpdate
     end
+    object actnExportBillsJson: TAction
+      Caption = #23548#20986#28165#21333'Json'#25968#25454
+      OnExecute = actnExportBillsJsonExecute
+      OnUpdate = actnCloseProjectUpdate
+    end
   end
   object dxpmTabSet: TdxBarPopupMenu
     BarManager = dxBarManager

+ 11 - 0
Forms/MainFrm.pas

@@ -178,6 +178,8 @@ type
     dxbtnExportStgResult: TdxBarButton;
     dxbtnImportSubTenderGather: TdxBarButton;
     actnImportSubTenderGather: TAction;
+    dxbtnExportBillsJson: TdxBarButton;
+    actnExportBillsJson: TAction;
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure jtsProjectsChange(Sender: TObject; NewTab: Integer;
@@ -227,6 +229,7 @@ type
     procedure dxbtnGatherSubTenderClick(Sender: TObject);
     procedure actnImportSubTenderGatherExecute(Sender: TObject);
     procedure actnImportSubTenderGatherUpdate(Sender: TObject);
+    procedure actnExportBillsJsonExecute(Sender: TObject);
   private
     FProjectManagerFrame: TProjectManagerFrame;
     FProjectFrames: TList;
@@ -952,4 +955,12 @@ begin
     and (CurProjectFrame.ProjectData.PhaseData.StageCount <= 1);
 end;
 
+procedure TMainForm.actnExportBillsJsonExecute(Sender: TObject);
+var
+  sFileName: string;
+begin
+  if SaveFile(sFileName, '.json') then
+    CurProjectFrame.ProjectData.BillsCompileData.RecursiveExportBillsJson(sFileName);
+end;
+
 end.

+ 6 - 0
Frames/StandardBillsFme.dfm

@@ -63,6 +63,7 @@ object StandardBillsFrame: TStandardBillsFrame
         FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
         FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00}
       ParentFont = False
+      OnClick = spbtnLibsClick
     end
     object edtLibName: TEdit
       Left = 1
@@ -231,4 +232,9 @@ object StandardBillsFrame: TStandardBillsFrame
     Left = 136
     Top = 80
   end
+  object odLib: TOpenDialog
+    Options = [ofHideReadOnly, ofNoChangeDir, ofEnableSizing]
+    Left = 32
+    Top = 80
+  end
 end

+ 50 - 2
Frames/StandardBillsFme.pas

@@ -21,9 +21,11 @@ type
     dxpmStandardBills: TdxBarPopupMenu;
     actnInsertBillsFromLib: TAction;
     stdBills: TsdGridTreeDBA;
+    odLib: TOpenDialog;
     procedure actnInsertBillsFromLibExecute(Sender: TObject);
     procedure zgBillsMouseDown(Sender: TObject; Button: TMouseButton;
       Shift: TShiftState; X, Y: Integer);
+    procedure spbtnLibsClick(Sender: TObject);
   private
     FStandardLibs: TStandardLibs;
     FBillsType: TBillsType;
@@ -43,7 +45,7 @@ type
 implementation
 
 uses
-  SupportUnit, Globals;
+  SupportUnit, Globals, ConditionalDefines, UtilMethods;
 
 {$R *.dfm}
 
@@ -98,7 +100,7 @@ end;
 procedure TStandardBillsFrame.zgBillsMouseDown(Sender: TObject;
   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
 begin
-  if Button = mbRight then
+  if (Button = mbRight) and (_IsDebugView) then
     dxpmStandardBills.PopupFromCursorPos
   else if (Button = mbLeft) and (ssDouble in Shift) then
     actnInsertBillsFromLib.Execute;
@@ -112,4 +114,50 @@ begin
       AddBillsFromLib(stdBills.IDTree.Selected, BillsType);
 end;
 
+procedure TStandardBillsFrame.spbtnLibsClick(Sender: TObject);
+
+  procedure ChangeStandardBills(const sFileName: string);
+  begin
+    case FBillsType of
+      btXm: SupportManager.ConfigInfo.StandardXmLib := ExtractFileName(odLib.FileName);
+      btGcl: SupportManager.ConfigInfo.StandardGclLib := ExtractFileName(odLib.FileName);
+    end;
+    Screen.Cursor := crHourGlass;
+    try
+      ConnectStandardLib;
+    finally
+      Screen.Cursor := crDefault;
+    end;
+  end;
+
+var
+  sLibPath, sSelectLib, sNewLib: string;
+  vLib: TStandardLib;
+begin
+  case FBillsType of
+    btXm: sLibPath := ExtractFileDir(FStandardLibs.StandardXmLib.FileName);
+    btGcl: sLibPath := ExtractFileDir(FStandardLibs.StandardGclLib.FileName);
+  end;
+  if odLib.Execute then
+  begin
+    sSelectLib := odLib.FileName;
+    if ExtractFileDir(sSelectLib) <> sLibPath then
+    begin
+      sNewLib := sLibPath + '\' + ExtractFileName(sSelectLib);
+      if FileExists(sNewLib) then
+      begin
+        if QuestMessageYesNo('选择的标准清单不在默认路径下,默认路径下存在同名标准清单,仅可打开默认路径下的标准清单,是否继续?') then
+          ChangeStandardBills(sNewLib);
+      end
+      else if QuestMessageYesNo('选择的标准清单不在默认路径下,是否复制到默认路径下并打开?') then
+      begin
+        CopyFile(PChar(sSelectLib), PChar(sNewLib), false);
+        ChangeStandardBills(sNewLib);
+      end;
+    end
+    else
+      ChangeStandardBills(sSelectLib);
+  end;
+end;
+
 end.

+ 10 - 0
Units/DataBaseTables.pas

@@ -25,6 +25,16 @@ type
 //  (FieldName: ; FieldType: ; Size: ; Precision: 0; NotNull: ; PrimaryKey: ; ForceUpdate: )
 
 const
+  {StandBills}
+  {BillsTree}
+  SBillsTree = 'BillsTree';
+  tdBillsTree: array [0..3] of TScFieldDef =(
+    (FieldName: 'BillsOrder'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'BillsLevel'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'FullPath'; FieldType: ftString; Size: 255; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'IsLeaf'; FieldType: ftBoolean; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
   {ProjectManagerData}
   {ÏîÄ¿¹ÜÀí}
   SProjectsInfo = 'ProjectsInfo';

+ 25 - 0
Units/StandardLib.pas

@@ -18,6 +18,7 @@ type
     destructor Destroy; override;
 
     procedure Open(const AFileName: string);
+    procedure SaveSaasData;
 
     property FileName: string read GetFileName;
     property LibName: string read GetLibName;
@@ -29,6 +30,9 @@ implementation
 
 { TStandardLib }
 
+uses
+  UpdateDataBase;
+
 constructor TStandardLib.Create;
 begin
   FLibConnection := TCommonConnection.Create;
@@ -53,9 +57,30 @@ begin
 end;
 
 procedure TStandardLib.Open(const AFileName: string);
+
+  procedure Update;
+  var
+    Updater: TStandBillsUpdateDB;
+  begin
+    Updater := TStandBillsUpdateDB.Create;
+    try
+      Updater.Update(FLibConnection);
+    finally
+      Updater.Free;
+    end;
+  end;
+
 begin
   FLibConnection.Open(AFileName);
+  Update;
   FStandardBillsData.Open(FLibConnection.Connection);
+  SaveSaasData;
+end;
+
+procedure TStandardLib.SaveSaasData;
+begin
+  FStandardBillsData.CalcCacheData(StandardBillsData.BillsTree.FirstNode, 1, '');
+  FStandardBillsData.sddStdBills.Save;
 end;
 
 end.

+ 23 - 0
Units/UpdateDataBase.pas

@@ -43,6 +43,11 @@ type
     procedure AddAuditData(AConnection: TADOConnection; AIndex: Integer);
   end;
 
+  TStandBillsUpdateDB = class
+  public
+    procedure Update(AConnection: TConnection);
+  end;
+
 implementation
 
 { TUpdateDB }
@@ -208,4 +213,22 @@ begin
   end;
 end;
 
+{ TStandBillsUpdateDB }
+
+procedure TStandBillsUpdateDB.Update(AConnection: TConnection);
+var
+  Updater: TScUpdater;
+  iIndex: Integer;
+begin
+  Updater := TScUpdater.Create;
+  try
+    Updater.ForceUpdate := True;
+    Updater.Open('', AConnection.Connection, '', '');
+    Updater.AddTableDef(SBillsTree, @tdBillsTree, Length(tdBillsTree), False, False);
+    Updater.ExcuteUpdate;
+  finally
+    Updater.Free;
+  end;
+end;
+
 end.