Quellcode durchsuchen

1. 台账分解,新增计量汇总列,开始计量后,需解锁后方可编辑
2. 计量台账界面,计量汇总列,只读

MaiXinRong vor 7 Jahren
Ursprung
Commit
912f6ea07d

+ 3 - 0
DataModules/BillsCompileDm.dfm

@@ -97,6 +97,9 @@ object BillsCompileData: TBillsCompileData
       end
       item
         FieldName = 'ApprovalCode'
+      end
+      item
+        FieldName = 'IsGatherZJJL'
       end>
     AfterAddRecord = sdvBillsCompileAfterAddRecord
     BeforeValueChange = sdvBillsCompileBeforeValueChange

+ 86 - 0
DataModules/BillsCompileDm.pas

@@ -294,6 +294,68 @@ end;
 
 procedure TBillsCompileData.sdvBillsCompileBeforeValueChange(
   AValue: TsdValue; const NewValue: Variant; var Allow: Boolean);
+  
+  function CheckParentExist(ANode: TBillsIDTreeNode): Boolean;
+  var
+    vParent: TBillsIDTreeNode;
+  begin
+    Result := False;
+    vParent := TBillsIDTreeNode(ANode.Parent);
+    while Assigned(vParent) and not Result do
+    begin
+      if vParent.Rec.IsGatherZJJL.AsBoolean then
+        Result := True;
+      vParent := TBillsIDTreeNode(vParent.Parent);
+    end;
+  end;
+
+  procedure CancelParentCheck(ANode: TBillsIDTreeNode);
+  var
+    vParent: TBillsIDTreeNode;
+  begin
+    vParent := TBillsIDTreeNode(ANode.Parent);
+    while Assigned(vParent) do
+    begin
+      if vParent.Rec.IsGatherZJJL.AsBoolean then
+        vParent.Rec.IsGatherZJJL.AsBoolean := False;
+      vParent := TBillsIDTreeNode(vParent.Parent);
+    end;
+  end;
+
+  function CheckChildrenExist(ANode: TBillsIDTreeNode): Boolean;
+  var
+    iChild: Integer;
+    vChild: TBillsIDTreeNode;
+  begin
+    Result := False;
+    for iChild := 0 to ANode.ChildCount - 1 do
+    begin
+      vChild := TBillsIDTreeNode(ANode.ChildNodes[iChild]);
+      if vChild.Rec.IsGatherZJJL.AsBoolean or CheckChildrenExist(vChild) then
+      begin
+        Result := True;
+        Break;
+      end;
+    end;
+  end;
+
+  procedure CancelChildrenCheck(ANode: TBillsIDTreeNode);
+  var
+    iChild: Integer;
+    vChild: TBillsIDTreeNode;
+  begin
+    for iChild := 0 to ANode.ChildCount - 1 do
+    begin
+      vChild := TBillsIDTreeNode(ANode.ChildNodes[iChild]);
+      if vChild.Rec.IsGatherZJJL.AsBoolean then
+        vChild.Rec.IsGatherZJJL.AsBoolean := False
+      else
+        CancelChildrenCheck(vChild);
+    end;
+  end;
+
+var
+  vNode: TBillsIDTreeNode;
 begin
   if SameText(AValue.FieldName, 'OrgQuantity') or
       SameText(AValue.FieldName, 'MisQuantity') or
@@ -306,6 +368,30 @@ begin
     TBillsRecord(AValue.Owner).CacheOrgTP := AValue.Owner.ValueByName('OrgTotalPrice').AsFloat;
     TBillsRecord(AValue.Owner).CacheMisTP := AValue.Owner.ValueByName('MisTotalPrice').AsFloat;
     TBillsRecord(AValue.Owner).CacheOthTP := AValue.Owner.ValueByName('OthTotalPrice').AsFloat;
+  end
+  else if SameText(AValue.FieldName, 'IsGatherZJJL') then
+  begin
+    Allow := TProjectData(FProjectData).CanUnlockInfo;
+    if Allow then
+    begin  
+      vNode := TBillsIDTreeNode(BillsCompileTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger));
+      if CheckParentExist(vNode) then
+      begin
+        if QuestMessage('父项已勾选,继续将取消父项勾选。') then
+          CancelParentCheck(vNode)
+        else
+          Allow := False;
+      end
+      else if CheckChildrenExist(vNode) then
+      begin
+        if QuestMessage('子项已勾选,继续将取消子项勾选。') then
+          CancelChildrenCheck(vNode)
+        else
+          Allow := False;
+      end;
+    end
+    else
+      WarningMessage('开始计量后,计量台账列不可编辑,如需修改,请先解锁。');
   end;
 end;
 

+ 22 - 1
Frames/BillsCompileFme.dfm

@@ -53,7 +53,7 @@ object BillsCompileFrame: TBillsCompileFrame
       Height = 376
       Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection, goShowTreeLine]
       OptionsEx = []
-      ColCount = 24
+      ColCount = 25
       RowCount = 7
       FixedRowCount = 3
       ShowGridLine = False
@@ -174,6 +174,26 @@ object BillsCompileFrame: TBillsCompileFrame
   object stdBillsCompile: TsdGridTreeDBA
     Columns = <
       item
+        Title.Caption = #35745#37327#27719#24635
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 3
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        EditType = sgeCheckBox
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'IsGatherZJJL'
+        Width = 35
+        ReadOnly = False
+      end
+      item
         Title.Caption = #39033#30446#33410#32534#21495
         Title.CaptionAcrossCols = '1'
         Title.CaptionAcrossRows = 3
@@ -740,6 +760,7 @@ object BillsCompileFrame: TBillsCompileFrame
     Grid = zgBillsCompile
     ExtendRowCount = 3
     AutoExpand = False
+    TreeCellCol = 2
     KeyFieldName = 'ID'
     ParentFieldName = 'ParentID'
     NextSiblingFieldName = 'NextSiblingID'

+ 2 - 0
Frames/BillsCompileFme.pas

@@ -231,7 +231,9 @@ begin
   FBillsCompileData := ABillsCompileData;
   stdBillsCompile.IDTree := FBillsCompileData.BillsCompileTree;
   with TProjectData(FBillsCompileData.ProjectData) do
+  begin
     stdBillsCompile.Column('LockedInfo').ReadOnly := ProjProperties.PhaseCount > 0;
+  end;
   zgBillsCompile.OnExpandMouseDown := ExpandMouseDown;
 end;
 

+ 1 - 1
Frames/BillsMeasureFme.dfm

@@ -147,7 +147,7 @@ object BillsMeasureFrame: TBillsMeasureFrame
         Font.Style = []
         FieldName = 'IsGatherZJJL'
         Width = 35
-        ReadOnly = False
+        ReadOnly = True
       end
       item
         Title.Caption = #39033#30446#33410#32534#21495