Prechádzať zdrojové kódy

报表模板管理。

Chenshilong 8 rokov pred
rodič
commit
74eda7dd12

+ 14 - 0
DataModules/PHPWebDm.pas

@@ -80,6 +80,8 @@ type
       var AOutRecords: TOVArr): Integer;
   public
     function SystemDateTime: TDateTime;
+    function Search(AURL: string; var AOutStrs: array of string): Integer; overload;
+    function Search(AURL: string; var AOutRecords: TOVArr): Integer; overload;
     function Search(AURL: string; AInFields, AInValues: array of string; var AOutStrs: array of string): Integer; overload;
     function Search(AURL: string; AInFields, AInValues: array of string; var AOutRecords: TOVArr): Integer; overload;
     function Search(AURL: string; AInFields, AInValues: array of string; var AOutStrs: array of string ; var AOutRecords: TOVArr): Integer; overload;
@@ -954,6 +956,18 @@ begin
   end;
 end;
 
+function TPHPWeb.Search(AURL: string; var AOutStrs: array of string): Integer;
+var vA: TOVArr;
+begin
+  Result := CustomSearch(AURL, [], [], 0, AOutStrs, vA);
+end;
+
+function TPHPWeb.Search(AURL: string; var AOutRecords: TOVArr): Integer;
+var vA: array of string;
+begin
+  Result := CustomSearch(AURL, [], [], 1, vA, AOutRecords);
+end;
+
 initialization
 
 finalization

+ 239 - 0
DataModules/ReportManagerDM.dfm

@@ -0,0 +1,239 @@
+object Reports: TReports
+  OldCreateOrder = False
+  OnCreate = DataModuleCreate
+  OnDestroy = DataModuleDestroy
+  Left = 765
+  Top = 357
+  Height = 283
+  Width = 280
+  object cdsOnline: TClientDataSet
+    Active = True
+    Aggregates = <>
+    FieldDefs = <
+      item
+        Name = 'ID'
+        DataType = ftInteger
+      end
+      item
+        Name = 'Category'
+        DataType = ftString
+        Size = 100
+      end
+      item
+        Name = 'Name'
+        DataType = ftString
+        Size = 100
+      end
+      item
+        Name = 'LocalVer'
+        DataType = ftString
+        Size = 20
+      end
+      item
+        Name = 'State'
+        DataType = ftString
+        Size = 10
+      end
+      item
+        Name = 'History'
+        DataType = ftString
+        Size = 10
+      end
+      item
+        Name = 'NewestVer'
+        DataType = ftString
+        Size = 20
+      end>
+    IndexDefs = <>
+    Params = <>
+    StoreDefs = True
+    Left = 112
+    Top = 16
+    Data = {
+      CC0000009619E0BD010000001800000007000000000003000000CC0002494404
+      000100000000000843617465676F727901004900000001000557494454480200
+      02006400044E616D650100490000000100055749445448020002006400084C6F
+      63616C5665720100490000000100055749445448020002001400055374617465
+      0100490000000100055749445448020002000A0007486973746F727901004900
+      00000100055749445448020002000A00094E6577657374566572010049000000
+      01000557494454480200020014000000}
+    object cdsOnlineID: TIntegerField
+      FieldName = 'ID'
+    end
+    object cdsOnlineCategory: TStringField
+      FieldName = 'Category'
+      Size = 100
+    end
+    object cdsOnlineName: TStringField
+      FieldName = 'Name'
+      Size = 100
+    end
+    object cdsOnlineVer: TStringField
+      FieldName = 'LocalVer'
+    end
+    object cdsOnlineState: TStringField
+      FieldName = 'State'
+      Size = 10
+    end
+    object cdsOnlineHistory: TStringField
+      FieldName = 'History'
+      Size = 10
+    end
+    object cdsOnlineNewest: TStringField
+      FieldName = 'NewestVer'
+    end
+  end
+  object cdsLocal: TClientDataSet
+    Active = True
+    Aggregates = <>
+    FieldDefs = <
+      item
+        Name = 'ID'
+        DataType = ftInteger
+      end
+      item
+        Name = 'Category'
+        DataType = ftString
+        Size = 100
+      end
+      item
+        Name = 'Name'
+        DataType = ftString
+        Size = 100
+      end
+      item
+        Name = 'LocalVer'
+        DataType = ftString
+        Size = 20
+      end
+      item
+        Name = 'State'
+        DataType = ftString
+        Size = 10
+      end
+      item
+        Name = 'History'
+        DataType = ftString
+        Size = 10
+      end
+      item
+        Name = 'NewestVer'
+        DataType = ftString
+        Size = 20
+      end>
+    IndexDefs = <>
+    Params = <>
+    StoreDefs = True
+    Left = 32
+    Top = 16
+    Data = {
+      CC0000009619E0BD010000001800000007000000000003000000CC0002494404
+      000100000000000843617465676F727901004900000001000557494454480200
+      02006400044E616D650100490000000100055749445448020002006400084C6F
+      63616C5665720100490000000100055749445448020002001400055374617465
+      0100490000000100055749445448020002000A0007486973746F727901004900
+      00000100055749445448020002000A00094E6577657374566572010049000000
+      01000557494454480200020014000000}
+    object cdsLocalID: TIntegerField
+      FieldName = 'ID'
+    end
+    object cdsLocalCategory: TStringField
+      FieldName = 'Category'
+      Size = 100
+    end
+    object cdsLocalName: TStringField
+      FieldName = 'Name'
+      Size = 100
+    end
+    object cdsLocalVer: TStringField
+      FieldName = 'LocalVer'
+    end
+    object cdsLocalState: TStringField
+      FieldName = 'State'
+      Size = 10
+    end
+    object cdsLocalHistory: TStringField
+      FieldName = 'History'
+      Size = 10
+    end
+    object cdsLocalNewest: TStringField
+      FieldName = 'NewestVer'
+    end
+  end
+  object cdsCustom: TClientDataSet
+    Active = True
+    Aggregates = <>
+    FieldDefs = <
+      item
+        Name = 'ID'
+        DataType = ftInteger
+      end
+      item
+        Name = 'Category'
+        DataType = ftString
+        Size = 100
+      end
+      item
+        Name = 'Name'
+        DataType = ftString
+        Size = 20
+      end
+      item
+        Name = 'LocalVer'
+        DataType = ftString
+        Size = 20
+      end
+      item
+        Name = 'State'
+        DataType = ftString
+        Size = 10
+      end
+      item
+        Name = 'History'
+        DataType = ftString
+        Size = 10
+      end
+      item
+        Name = 'NewestVer'
+        DataType = ftString
+        Size = 20
+      end>
+    IndexDefs = <>
+    Params = <>
+    StoreDefs = True
+    Left = 184
+    Top = 16
+    Data = {
+      CC0000009619E0BD010000001800000007000000000003000000CC0002494404
+      000100000000000843617465676F727901004900000001000557494454480200
+      02006400044E616D650100490000000100055749445448020002001400084C6F
+      63616C5665720100490000000100055749445448020002001400055374617465
+      0100490000000100055749445448020002000A0007486973746F727901004900
+      00000100055749445448020002000A00094E6577657374566572010049000000
+      01000557494454480200020014000000}
+    object cdsCustomID: TIntegerField
+      FieldName = 'ID'
+    end
+    object cdsCustomCategory: TStringField
+      FieldName = 'Category'
+      Size = 100
+    end
+    object cdsCustomName: TStringField
+      FieldName = 'Name'
+    end
+    object cdsCustomLocalVer: TStringField
+      FieldName = 'LocalVer'
+    end
+    object cdsCustomState: TStringField
+      FieldName = 'State'
+      Size = 10
+    end
+    object cdsCustomHistory: TStringField
+      FieldName = 'History'
+      Size = 10
+    end
+    object cdsCustomNewestVer: TStringField
+      FieldName = 'NewestVer'
+    end
+  end
+end

+ 779 - 0
DataModules/ReportManagerDM.pas

@@ -0,0 +1,779 @@
+unit ReportManagerDM;
+
+interface
+
+uses
+  SysUtils, Classes, DB, DBClient, Contnrs, UtilMethods, Archiver;
+
+const
+  P6 = '4鲐;d煬0痤踿8镊<x伡垁Zx鷹?	�';    // 报表模板文件密码
+  PA6: array [0..31] of Byte =
+    ($34, $F6, $D8, $0C, $3B, $64, $9F, $AC, $30, $08, $F0, $EE, $DB, $80, $38, $C4,
+     $F7, $3C, $78, $81, $BC, $88, $80, $5A, $78, $FA, $97, $8D, $1E, $09, $FA, $FD);
+
+type
+  TChangeType = (ctAdd, ctEdit);
+
+  TReport = class(TObject)
+  private
+    FID: Integer;
+    FLocalVer: string;
+    FName: string;
+    FFileName: string;
+    FCategory: string;
+    FNewestVer: string;
+    FHistoryVer1: string;
+    FHistoryVer2: string;
+//    FHistoryURL2: string;
+//    FHistoryURL1: string;
+//    FNewestURL: string;
+    FHistoryMemo2: string;
+    FHistoryMemo1: string;
+    FNewestMemo: string;
+    FKey: string;
+    FArchiver: TArchiver;
+    FOwner: TObject;
+    FArea: string;
+    procedure SetID(const Value: Integer);
+    procedure SetLocalVer(const Value: string);
+    procedure SetFileName(const Value: string);
+    procedure SetName(const Value: string);
+    procedure SetCategory(const Value: string);
+    procedure SetNewestVer(const Value: string);
+    procedure SetHistoryVer1(const Value: string);
+    procedure SetHistoryVer2(const Value: string);
+//    procedure SetHistoryURL1(const Value: string);
+//    procedure SetHistoryURL2(const Value: string);
+//    procedure SetNewestURL(const Value: string);
+    procedure SetHistoryMemo1(const Value: string);
+    procedure SetHistoryMemo2(const Value: string);
+    procedure SetNewestMemo(const Value: string);
+    procedure ArchiverEnterCryptKey(Sender: TObject; var Key: String);
+    procedure ArchiverRequestCryptKey(Sender: TObject; var Key: String);
+    procedure SetOwner(const Value: TObject);
+    function GetPath: string;
+    procedure SetArea(const Value: string);
+  public
+    property ID: Integer read FID write SetID;
+    property LocalVer: string read FLocalVer write SetLocalVer;
+    property Path: string read GetPath;
+
+    property NewestVer: string read FNewestVer write SetNewestVer;        // 线上最新版本
+//    property NewestURL: string read FNewestURL write SetNewestURL;
+    property NewestMemo: string read FNewestMemo write SetNewestMemo;
+
+    property HistoryVer1: string read FHistoryVer1 write SetHistoryVer1;  // 线上历史版本次新
+//    property HistoryURL1: string read FHistoryURL1 write SetHistoryURL1;
+    property HistoryMemo1: string read FHistoryMemo1 write SetHistoryMemo1;
+
+    property HistoryVer2: string read FHistoryVer2 write SetHistoryVer2;  // 线上历史版本次次新
+//    property HistoryURL2: string read FHistoryURL2 write SetHistoryURL2;
+    property HistoryMemo2: string read FHistoryMemo2 write SetHistoryMemo2;
+//    property Name: string read FName write SetName;         // 文件头中的文件名,仅用于大报表界面显示
+    property Area: string read FArea write SetArea;         // 全国1,广东2,通用3
+    property Category: string read FCategory write SetCategory;
+    property FileName: string read FFileName write SetFileName;     // 硬盘上的物理文件名
+
+    property Owner: TObject read FOwner write SetOwner;
+
+    constructor Create;
+    destructor Destroy; override;
+    // AVer报表的版本号
+    function Update(AVer: string): Boolean;
+    function EncryptReport: Boolean;
+    procedure DecryptReport;
+    procedure GetHistoryVer;
+  end;
+
+  TReports = class(TDataModule)
+    cdsOnline: TClientDataSet;
+    cdsOnlineCategory: TStringField;
+    cdsOnlineName: TStringField;
+    cdsOnlineVer: TStringField;
+    cdsOnlineState: TStringField;
+    cdsOnlineHistory: TStringField;
+    cdsOnlineNewest: TStringField;
+    cdsOnlineID: TIntegerField;
+    cdsLocal: TClientDataSet;
+    cdsLocalID: TIntegerField;
+    cdsLocalCategory: TStringField;
+    cdsLocalName: TStringField;
+    cdsLocalVer: TStringField;
+    cdsLocalState: TStringField;
+    cdsLocalHistory: TStringField;
+    cdsLocalNewest: TStringField;
+    cdsCustom: TClientDataSet;
+    cdsCustomID: TIntegerField;
+    cdsCustomName: TStringField;
+    cdsCustomCategory: TStringField;
+    cdsCustomLocalVer: TStringField;
+    cdsCustomState: TStringField;
+    cdsCustomHistory: TStringField;
+    cdsCustomNewestVer: TStringField;
+    procedure DataModuleCreate(Sender: TObject);
+    procedure DataModuleDestroy(Sender: TObject);
+  private
+    { Private declarations }
+    FList: TObjectList;
+    FPath: string;
+    // AChangeType: 1增加 2修改
+    procedure ChangeRec(ACDS: TClientDataSet; AReport: TReport; AChangeType: TChangeType);
+  public
+    { Public declarations }
+    procedure Load;
+    function LoadCustom(ACode: string): Boolean;
+    procedure Refresh(AReport: TReport; ANeedAddLocal: Boolean);
+    procedure CategoryList(AList: TStrings);
+    procedure CancelFilterCategory;
+    procedure FilterCategory(ACategory: string);
+    function FindReprot(AID: Integer): TReport;
+
+    property Path: string read FPath;
+  end;
+
+
+
+implementation
+
+  uses Variants, ScFileArchiverConsts, ArchiverRoot, PHPWebDm, CslJson,
+    XMLDoc, XMLIntf, Windows, Math, Forms;
+
+var
+  Reports: TReports;
+
+{$R *.dfm}
+
+function ByteArrayToStr(AByteArray: array of Byte; ALength: Integer): string;
+begin
+  SetString(Result, PChar(@AByteArray[0]), ALength);
+end;
+
+{ TReport }
+
+constructor TReport.Create;
+begin
+  FArchiver := TArchiver.Create(nil);
+  FArchiver.Options := FArchiver.Options - [oOpenSingleSegment] + [oMaintainFileDirectory, oCrypt];
+  FArchiver.OnEnterCryptKey := ArchiverEnterCryptKey;
+  FArchiver.OnRequestCryptKey := ArchiverRequestCryptKey;
+end;
+
+destructor TReport.Destroy;
+begin
+  FArchiver.Free;
+  inherited;
+end;
+
+procedure TReport.SetCategory(const Value: string);
+begin
+  FCategory := Value;
+end;
+
+procedure TReport.SetFileName(const Value: string);
+begin
+  FFileName := Value;
+end;
+
+procedure TReport.SetID(const Value: Integer);
+begin
+  FID := Value;
+end;
+
+procedure TReport.SetName(const Value: string);
+begin
+  FName := Value;
+end;
+
+procedure TReport.SetLocalVer(const Value: string);
+begin
+  FLocalVer := Value;
+end;
+
+procedure TReport.SetNewestVer(const Value: string);
+begin
+  FNewestVer := Value;
+end;
+
+procedure TReports.DataModuleCreate(Sender: TObject);
+begin
+  FPath := ExtractFilePath(ParamStr(0)) + 'ReportTemplates\';
+  FList := TObjectList.Create;
+  
+  Load;
+end;
+
+procedure TReports.DataModuleDestroy(Sender: TObject);
+begin
+  FList.Free;
+end;
+
+procedure TReports.Load;
+
+  procedure ReadHead(AFile: string; var AHead: TScFile7Head);
+  var vFS: TFileStream;
+  begin
+    vFS := TFileStream.Create(AFile, fmOpenRead);
+    try
+//      vFS.Seek($00, soFromBeginning);
+      vFS.Read(AHead, SizeOf(AHead));
+    finally
+      vFS.Free;
+    end;
+  end;
+
+
+var
+  vReport: TReport;
+  SRec: TSearchRec;
+  iRetval, i, iID: Integer;
+  FOnlineAry, VersArr: TOVArr;
+  vHead7: TScFile7Head;
+  vSL: TStringList;
+  sProp, sURL, sIDs, sArea: string;
+begin
+  if FList.Count > 0 then
+    FList.Clear;
+
+  // 先读本地的
+  vSL := TStringList.Create;
+  iRetval := FindFirst(FPath + '*.srt', faAnyFile, sRec);
+  try
+    while iRetval = 0 do
+    begin
+      if (SRec.Attr and faDirectory) = 0 then
+      begin
+        ReadHead(FPath + SRec.Name, vHead7);
+        SetString(sProp, vHead7.ReportProperties, 256);
+        if sProp <> '' then
+        begin
+          vSL.Text := sProp;
+        end;
+
+        vReport := TReport.Create;
+        vReport.Owner := Self;
+        vReport.ID := StrToInt(vSL.Values['报表ID']);
+        vReport.Category := vSL.Values['分类名称'];
+        vReport.FileName := SRec.Name;
+        vReport.LocalVer := vSL.Values['版本'];
+        FList.Add(vReport);
+      end;
+      iRetval := FindNext(SRec);
+    end;
+
+  finally
+    SysUtils.FindClose(SRec);
+    vSL.Free;
+  end;
+
+  // 对比线上最新版本号,看是否需更新
+  if FList.Count > 0 then
+  begin
+    cdsLocal.DisableControls;
+    cdsLocal.First;
+    while cdsLocal.RecordCount > 0 do
+      cdsLocal.Delete;
+
+    try
+      for i := 0 to FList.Count - 1 do
+      sIDs := sIDs + ',' + IntToStr(TRePort(FList[i]).ID);
+
+      Delete(sIDs, 1, 1);
+      sURL := 'http://jlzfbb.com/api/report/update/get';
+
+      case PHPWeb.Search(sURL, ['idlist'], [sIDs], VersArr) of
+        1:
+        begin
+          for i := 0 to Length(VersArr) - 1 do
+          begin
+            iID := StrToInt(VersArr[i, 0]);
+            vReport := FindReprot(iID);
+            if vReport <> nil then
+              vReport.NewestVer := VersArr[i, 1];
+            ChangeRec(cdsLocal, vReport, ctAdd);
+          end;
+        end
+        else
+        begin
+          Application.MessageBox(PChar('报表更新检测失败,请检查网络!') , '提示', MB_OK + MB_ICONWARNING);
+          Exit;
+        end;
+      end;
+    finally
+      cdsLocal.First;
+      cdsLocal.EnableControls;
+    end;
+  end;
+
+  // 再读线上的。接口返回值为:
+  {areacate:"1"
+  catename:"结算表/子表"
+  edittime:"20170707114000"
+  itemid:"0"
+  reportid:"9"
+  reportname:"通用表3"   }
+  {$IFDEF _mGuangDong}
+     sArea := '2';   // 广东
+  {$ELSE}
+     sArea := '1';   // 全国
+  {$ENDIF}
+  PHPWeb.Search('http://jlzfbb.com/api/getreportmsg', ['areacate'], [sArea], FOnlineAry);
+  if Length(FOnlineAry) > 0 then
+  begin
+    cdsOnline.DisableControls;
+    cdsOnline.First;
+    while cdsOnline.RecordCount > 0 do
+      cdsOnline.Delete;
+
+    try
+      for i := Low(FOnlineAry) to High(FOnlineAry) do
+      begin
+        iID := StrToInt(FOnlineAry[i, 0]);
+        vReport := FindReprot(iID);
+
+        // 线上有,本地无
+        if vReport = nil then
+        begin
+          vReport := TReport.Create;
+          vReport.Owner := Self;
+          vReport.ID := iID;
+          vReport.Area := FOnlineAry[i, 2];
+          vReport.Category := FOnlineAry[i, 5];
+          vReport.FileName := CheckExt(FOnlineAry[i, 1], '.srt');
+          vReport.LocalVer := '';
+          vReport.NewestVer := FOnlineAry[i, 3];
+          FList.Add(vReport);
+        end;
+
+        ChangeRec(cdsOnline, vReport, ctAdd);
+      end;
+    finally
+      cdsOnline.First;
+      cdsOnline.EnableControls;
+    end;
+  end;
+end;
+
+procedure TReports.CategoryList(AList: TStrings);
+var sCgy: string;
+  i: Integer;
+begin
+  AList.Clear;
+  AList.Add('按类别筛选');
+  for i := 0 to FList.Count - 1 do
+  begin
+    sCgy := TReport(FList[i]).Category;
+    if AList.IndexOf(sCgy) < 0 then
+      AList.Add(sCgy);
+  end;
+end;
+
+procedure TReports.CancelFilterCategory;
+begin
+  cdsOnline.Filtered := False;
+end;
+
+procedure TReports.FilterCategory(ACategory: string);
+begin
+  cdsOnline.Filter := Format('Category=''%s''', [ACategory]);
+  cdsOnline.Filtered := True;
+end;
+
+procedure TReport.SetHistoryVer1(const Value: string);
+begin
+  FHistoryVer1 := Value;
+end;
+
+procedure TReport.SetHistoryVer2(const Value: string);
+begin
+  FHistoryVer2 := Value;
+end;
+
+//procedure TReport.SetHistoryURL1(const Value: string);
+//begin
+//  FHistoryURL1 := Value;
+//end;
+//
+//procedure TReport.SetHistoryURL2(const Value: string);
+//begin
+//  FHistoryURL2 := Value;
+//end;
+//
+//procedure TReport.SetNewestURL(const Value: string);
+//begin
+//  FNewestURL := Value;
+//end;
+
+function TReports.FindReprot(AID: Integer): TReport;
+var i: Integer;
+  vReport: TReport;
+begin
+  Result := nil;
+  for i := 0 to FList.Count - 1 do
+  begin
+    vReport := TReport(FList[i]);
+    if vReport.ID = AID then
+    begin
+      Result := vReport;
+      Break;
+    end;
+  end;
+end;
+
+procedure TReport.SetHistoryMemo1(const Value: string);
+begin
+  FHistoryMemo1 := Value;
+end;
+
+procedure TReport.SetHistoryMemo2(const Value: string);
+begin
+  FHistoryMemo2 := Value;
+end;
+
+procedure TReport.SetNewestMemo(const Value: string);
+begin
+  FNewestMemo := Value;
+end;
+
+function TReport.Update(AVer: string): Boolean;
+var vArr: array of string;
+  sURL, sLocalFile: string;
+  ANeedAddLocal: Boolean;
+begin
+  Result := False;
+  vArr := VarArrayOf(['downloadurl']);
+  sURL := Format('http://jlzfbb.com/api/downloadurl/%d/%s', [FID, AVer]);
+  PHPWeb.Search(sURL, vArr);
+  sLocalFile := Path + CheckExt(FFileName, '.xml');
+
+  if PHPweb.DownFile(vArr[0], sLocalFile) then
+  begin
+    if EncryptReport then
+    begin
+      ANeedAddLocal := FLocalVer = '';
+      FLocalVer := AVer;
+      TReports(FOwner).Refresh(Self, ANeedAddLocal);
+      Result := True;
+    end;
+  end
+  else
+    Application.MessageBox(PChar('报表文件下载失败,请重试!') , '提示', MB_OK + MB_ICONWARNING);
+end;
+
+
+function TReport.EncryptReport: Boolean;
+
+  function GetReportPropertyFromXML(AFile: string): string;
+  var
+    I: Integer;
+    xmlDoc: IXMLDocument;
+    xmlNode: IXMLNode;
+    slstProperties: TStringList;
+  begin
+    slstProperties := TStringList.Create;
+    xmlDoc := TXMLDocument.Create(nil) as IXMLDocument;
+    try
+      xmlDoc.LoadFromFile(AFile);
+      xmlNode := xmlDoc.DocumentElement;
+      if xmlNode <> nil then
+      begin
+        for I := 0 to xmlNode.AttributeNodes.Count - 1 do
+        begin
+          slstProperties.Values[xmlNode.AttributeNodes[I].NodeName] := xmlNode.AttributeNodes[I].NodeValue;
+        end;
+      end;
+      Result := slstProperties.Text;
+    finally
+      slstProperties.Free;
+    end;
+  end;
+
+  procedure WriteReportProp(AFile: string; AProp: string);
+  var vHead7: TScFile7Head;
+    sTemp: string;
+    I: Integer;
+    vFS, vTempFS: TFileStream;
+  begin
+    ZeroMemory(@vHead7, Sizeof(TScFile7Head));
+    vHead7.ProductName := 'SmartCost';
+    vHead7.ProductVersion := '8.0';
+    vHead7.FileType := 6;
+    vHead7.ProjectFileType := 0;
+    vHead7.IsSysFile := True;
+    vHead7.ReadOnly := False;
+    vHead7.HasPassword := False;
+    vHead7.Password := '';
+    vHead7.FileVersion := '1.0.0.1';
+    if AProp <> '' then
+      StrPLCopy(@(vHead7.ReportProperties[0]), AProp, Length(AProp));
+
+    ZeroMemory(@(vHead7.Reserve[0]), Length(vHead7.Reserve));
+    for I := 0 to Length(vHead7.RandomData) - 1 do
+      vHead7.RandomData[I] := Char(RandomRange(0, 255));
+    vFS := TFileStream.Create(AFile, fmOpenReadWrite);
+    sTemp := ExtractFilePath(AFile) + TempName(16);
+    vTempFS := TFileStream.Create(sTemp, fmCreate);
+    try
+      vTempFS.Seek($00, soFromBeginning);
+      vTempFS.Write(vHead7, Sizeof(TScFile7Head));
+      vTempFS.CopyFrom(vFS, vFS.Size);
+    finally
+      vTempFS.Free;
+      vFS.Free;
+      CopyFile(PChar(sTemp), PCHar(AFile), False);
+      DeleteFile(PChar(sTemp));
+    end;
+  end;
+
+var sSource, sXMLProp, sTargetFile, sTempFile: string;
+begin
+  Result := False;
+  sSource := Path + CheckExt(FileName, '.xml');
+  if not FileExists(sSource) then
+    Exit;
+
+  try
+    try
+      FKey := ByteArrayToStr(PA6, Length(PA6));
+      sXMLProp := GetReportPropertyFromXML(sSource);
+
+      sTargetFile := CheckExt(sSource, '.srt');
+      if FileExists(sTargetFile) then
+        DeleteFile(PChar(sTargetFile));
+
+      FileSetAttr(sSource, 0);
+      sTempFile := sSource + '.~temp~';
+      CopyFile(PChar(sSource), PChar(sTempFile), False);
+
+      FArchiver.FileName := sTargetFile;
+      FArchiver.OpenNew;
+      FArchiver.AddFile(sTempFile);
+      FArchiver.Close;
+
+      WriteReportProp(sTargetFile, sXMLProp);
+      Result := True;
+    except
+      Application.MessageBox(PChar('报表文件损坏,加密失败无法使用,请重试!') , '提示', MB_OK + MB_ICONWARNING);
+    end;
+  finally
+    DeleteFile(PChar(sTempFile));
+    DeleteFile(PChar(sSource));
+  end;
+end;
+
+procedure TReport.ArchiverEnterCryptKey(Sender: TObject; var Key: String);
+begin
+  Key := FKey;
+end;
+
+procedure TReport.ArchiverRequestCryptKey(Sender: TObject;
+  var Key: String);
+begin
+  Key := FKey;
+end;
+
+procedure TReport.DecryptReport;
+var
+  sSource, sTemp, sDcyt: string;
+  TF, TS: TFileStream;
+  idx: Integer;
+  IsEmpty: Boolean;
+begin
+  sSource := Path + FileName;
+  if not FileExists(sSource) then
+    Exit;
+  FKey := ByteArrayToStr(PA6, Length(PA6));
+  sDcyt := ChangeFileExt(sSource, '.xml');
+  sTemp := Path + 'TempReport.~temp~';
+
+  FileSetAttr(sSource, 0);
+
+  TS := TFileStream.Create(sSource, fmOpenRead);
+  TF := TFileStream.Create(sTemp, fmCreate);
+  try
+    TS.Position := SizeOf(TScFile7Head);
+    TF.CopyFrom(TS, TS.Size - SizeOf(TScFile7Head));
+  finally
+    TS.Free;
+    TF.Free;
+  end;
+
+  try
+    FArchiver.FileName := sTemp;
+    FArchiver.Open;
+    FArchiver.EnumerateFiles;
+    if FArchiver.FileCount <=0 then
+      raise Exception.Create('读取文件出错!');
+    idx := FArchiver.FileCount - 1;
+
+    with FArchiver.Header do
+      IsEmpty := (ArchiveInfo.FileCount + SegmentInfo.FileCount) = 0;
+
+    if IsEmpty or (idx <= -1) then
+      raise Exception.Create('文件中没有数据!');
+
+    try
+      with FArchiver.Files[idx].FileEntry do
+        FArchiver.ExtractFileTo(Segment, Offset, ArchiveInfo.CompressedSize, sDcyt);
+    except
+      raise;
+    end;
+  finally
+    FArchiver.Close;
+    DeleteFile(PChar(sTemp));
+    DeleteFile(PChar(sSource));
+  end;
+end;
+
+procedure TReports.Refresh(AReport: TReport; ANeedAddLocal: Boolean);
+begin
+  if ANeedAddLocal then
+    ChangeRec(cdsLocal, AReport, ctAdd)
+  else
+    ChangeRec(cdsLocal, AReport, ctEdit);
+
+  ChangeRec(cdsOnline, AReport, ctEdit);
+  ChangeRec(cdsCustom, AReport, ctEdit);
+end;
+
+procedure TReport.SetOwner(const Value: TObject);
+begin
+  FOwner := Value;
+end;
+
+function TReport.GetPath: string;
+begin
+  Result := TReports(FOwner).Path;
+end;
+
+procedure TReports.ChangeRec(ACDS: TClientDataSet; AReport: TReport; AChangeType: TChangeType);
+begin
+  if AChangeType = ctAdd then
+    ACDS.Append
+  else if AChangeType = ctEdit then
+  begin
+    if ACDS.Locate('ID', AReport.ID, []) then
+      ACDS.Edit
+    else
+      Exit;
+  end;
+
+  ACDS.FieldByName('ID').AsInteger := AReport.ID;
+  ACDS.FieldByName('Category').AsString := AReport.Category;
+  ACDS.FieldByName('Name').AsString := AReport.FileName;
+  ACDS.FieldByName('LocalVer').AsString := AReport.LocalVer;
+  ACDS.FieldByName('NewestVer').AsString := AReport.NewestVer;
+
+  if AReport.LocalVer = '' then
+    ACDS.FieldByName('State').AsString := '下载'
+  else
+  begin
+    if SameText(AReport.LocalVer, AReport.NewestVer) then
+      ACDS.FieldByName('State').AsString := '已下载'
+    else
+      ACDS.FieldByName('State').AsString := '更新';
+  end;
+
+  ACDS.FieldByName('History').AsString := '查看';
+  ACDS.Post;
+end;
+
+procedure TReport.GetHistoryVer;
+var vArr: TOVArr;
+  sURL, sLocalFile: string;
+begin
+  sURL := Format('http://jlzfbb.com/api/getversionmsg/%d', [FID]);
+  PHPWeb.Search(sURL, vArr);
+
+  try
+    if Length(vArr) > 0 then
+    begin
+      FNewestVer := vArr[0, 0];
+      FNewestMemo := ReplaceChars(vArr[0, 1]);
+//      FNewestURL := vArr[0, 2];
+    end;
+
+    if Length(vArr) > 1 then
+    begin
+      FHistoryVer1 := vArr[1, 0];
+      FHistoryMemo1 := ReplaceChars(vArr[1, 1]);
+//      FHistoryURL1 := vArr[1, 2];
+    end;
+
+    if Length(vArr) > 2 then
+    begin
+      FHistoryVer2 := vArr[2, 0];
+      FHistoryMemo2 := ReplaceChars(vArr[2, 1]);
+//      FHistoryURL2 := vArr[2, 2];
+    end;
+  except
+    Application.MessageBox('报表文件有错误!', '提示', MB_OK + MB_ICONWARNING);
+  end;
+end;
+
+function TReports.LoadCustom(ACode: string): Boolean;
+var FOnlineAry: TOVArr;
+  i, iID: Integer;
+  vReport: TReport;
+begin
+  Result := False;
+
+//  cds1.Append;
+//  cds1ID.AsInteger := 1;
+//  cds1Category.AsString := '定制';
+//  cds1Name.AsString := 'xxxxxxxxxxx';
+//  cds1.Post;
+//
+//  cds1.Append;
+//  cds1ID.AsInteger := 2;
+//  cds1Category.AsString := '定制';
+//  cds1Name.AsString := 'BBBBBBBBBBBB';
+//  cds1.Post;
+//
+//  Result := True;
+//  exit;
+
+  PHPWeb.Search('http://jlzfbb.com/api/getreportmsg', ['itemcode'], [ACode], FOnlineAry);
+  if Length(FOnlineAry) > 0 then
+  begin
+    cdsCustom.DisableControls;
+    cdsCustom.First;
+    while cdsCustom.RecordCount > 0 do
+      cdsCustom.Delete;
+
+    try
+      for i := Low(FOnlineAry) to High(FOnlineAry) do
+      begin
+        iID := StrToInt(FOnlineAry[i, 0]);
+        vReport := FindReprot(iID);
+
+        // 线上有,本地无
+        if vReport = nil then
+        begin
+          vReport := TReport.Create;
+          vReport.Owner := Self;
+          vReport.ID := iID;
+          vReport.Category := FOnlineAry[i, 3];
+          vReport.FileName := FOnlineAry[i, 1];
+          vReport.LocalVer := '';
+          vReport.NewestVer := FOnlineAry[i, 2];
+          FList.Add(vReport);
+        end;
+
+        ChangeRec(cdsCustom, vReport, ctAdd);
+      end;
+      Result := True;
+    finally
+      cdsCustom.First;
+      cdsCustom.EnableControls;
+    end;
+  end
+  else
+    Application.MessageBox('没有找到该领取码的定制报表!', '提示', MB_OK + MB_ICONINFORMATION);
+end;
+
+procedure TReport.SetArea(const Value: string);
+begin
+  FArea := Value;
+end;
+
+end.

+ 2 - 2
Dprs/CSL/Measure_Cloud.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MinorVer=1
 Release=3
-Build=1130
+Build=1133
 Debug=0
 PreRelease=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化云版
-FileVersion=3.1.3.1130
+FileVersion=3.1.3.1133
 InternalName=
 LegalCopyright=
 LegalTrademarks=

+ 4 - 1
Dprs/CSL/Measure_Cloud.dpr

@@ -225,7 +225,10 @@ uses
   SignReports in '..\..\Units\SignReports.pas',
   TemplateManagerHelper in '..\..\Units\TemplateManagerHelper.pas',
   RenameSignReportFrm in '..\..\Forms\RenameSignReportFrm.pas' {RenameSignReportForm},
-  rmWeiWuZjjlGatherDm in '..\..\DataModules\ReportMemoryDm\rmWeiWuZjjlGatherDm.pas' {rmWeiWuZjjlGatherData: TDataModule};
+  rmWeiWuZjjlGatherDm in '..\..\DataModules\ReportMemoryDm\rmWeiWuZjjlGatherDm.pas' {rmWeiWuZjjlGatherData: TDataModule},
+  ReportHistoryFrm in '..\..\Forms\ReportHistoryFrm.pas' {ReportHistoryForm},
+  ReportManagerFrm in '..\..\Forms\ReportManagerFrm.pas' {ReportManagerForm},
+  ReportManagerDM in '..\..\DataModules\ReportManagerDM.pas' {Reports: TDataModule};
 
 {$R *.res}
 

BIN
Dprs/CSL/Measure_Cloud.res


+ 105 - 0
Forms/ReportHistoryFrm.dfm

@@ -0,0 +1,105 @@
+object ReportHistoryForm: TReportHistoryForm
+  Left = 445
+  Top = 436
+  ActiveControl = mmMemo
+  BorderStyle = bsDialog
+  Caption = #21382#21490#29256#26412
+  ClientHeight = 284
+  ClientWidth = 450
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -13
+  Font.Name = #23435#20307
+  Font.Style = []
+  OldCreateOrder = False
+  Position = poScreenCenter
+  PixelsPerInch = 96
+  TextHeight = 13
+  object Label1: TLabel
+    Left = 8
+    Top = 8
+    Width = 80
+    Height = 20
+    Caption = #21382#21490#29256#26412
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -20
+    Font.Name = #23435#20307
+    Font.Style = []
+    ParentFont = False
+  end
+  object Label2: TLabel
+    Left = 8
+    Top = 32
+    Width = 260
+    Height = 19
+    Caption = #25105#20204#26368#22810#20165#25552#20379#19977#20010#21382#21490#29256#26412#20379#20320#19979#36733#20351#29992#12290
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = 6250335
+    Font.Height = -13
+    Font.Name = #24494#36719#38597#40657
+    Font.Style = []
+    ParentFont = False
+  end
+  object lblReportName: TLabel
+    Left = 8
+    Top = 60
+    Width = 92
+    Height = 19
+    Caption = 'lblReportName'
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -13
+    Font.Name = #24494#36719#38597#40657
+    Font.Style = []
+    ParentFont = False
+  end
+  object tcHistory: TTabControl
+    Left = 8
+    Top = 84
+    Width = 433
+    Height = 194
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -13
+    Font.Name = #24494#36719#38597#40657
+    Font.Style = []
+    ParentFont = False
+    TabOrder = 0
+    Tabs.Strings = (
+      '2016-08-01'
+      '2016-08-02'
+      '2016-08-03')
+    TabIndex = 0
+    TabStop = False
+    OnChange = tcHistoryChange
+    object btnDown: TSpeedButton
+      Left = 118
+      Top = 157
+      Width = 163
+      Height = 30
+      Caption = #19979#36733#27492#29256#26412
+      Font.Charset = DEFAULT_CHARSET
+      Font.Color = clBlue
+      Font.Height = -13
+      Font.Name = #24494#36719#38597#40657
+      Font.Style = []
+      ParentFont = False
+      OnClick = btnDownClick
+    end
+    object mmMemo: TMemo
+      Left = 4
+      Top = 30
+      Width = 425
+      Height = 122
+      TabStop = False
+      Align = alTop
+      Lines.Strings = (
+        #35828#26126)
+      ReadOnly = True
+      ScrollBars = ssVertical
+      TabOrder = 0
+    end
+  end
+end

+ 89 - 0
Forms/ReportHistoryFrm.pas

@@ -0,0 +1,89 @@
+unit ReportHistoryFrm;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, ComCtrls, StdCtrls, Buttons, ReportManagerDM,
+  cxLookAndFeelPainters, cxButtons;
+
+type
+  TReportHistoryForm = class(TForm)
+    Label1: TLabel;
+    Label2: TLabel;
+    lblReportName: TLabel;
+    tcHistory: TTabControl;
+    mmMemo: TMemo;
+    btnDown: TSpeedButton;
+    procedure tcHistoryChange(Sender: TObject);
+    procedure btnDownClick(Sender: TObject);
+  private
+    FReport: TReport;
+    procedure SetReport(const Value: TReport);
+    { Private declarations }
+  public
+    { Public declarations }
+    constructor Create(AReport: TReport);
+    procedure Init;
+    property Report: TReport read FReport write SetReport;
+  end;
+
+implementation
+
+{$R *.dfm}
+
+procedure TReportHistoryForm.tcHistoryChange(Sender: TObject);
+begin
+  case tcHistory.TabIndex of
+    0: mmMemo.Text := FReport.NewestMemo;
+    1: mmMemo.Text := FReport.HistoryMemo1;
+    2: mmMemo.Text := FReport.HistoryMemo2;
+  end;
+  btnDown.Enabled := (tcHistory.Tabs[tcHistory.TabIndex] <> '') and (tcHistory.Tabs[tcHistory.TabIndex] <> FReport.LocalVer);
+
+  if (tcHistory.Tabs[tcHistory.TabIndex] <> '') and (tcHistory.Tabs[tcHistory.TabIndex] = FReport.LocalVer) then
+    btnDown.Caption := '正在使用'
+  else
+    btnDown.Caption := '下载此版本';
+end;
+
+constructor TReportHistoryForm.Create(AReport: TReport);
+begin
+  inherited create(nil);
+  FReport := AReport;
+  Init;
+end;
+
+procedure TReportHistoryForm.SetReport(const Value: TReport);
+begin
+  FReport := Value;
+end;
+
+procedure TReportHistoryForm.Init;
+begin
+  lblReportName.Caption := FReport.FileName;
+  lblReportName.Update;
+
+
+
+  tcHistory.Tabs[0] := FReport.NewestVer;
+  tcHistory.Tabs[1] := FReport.HistoryVer1;
+  tcHistory.Tabs[2] := FReport.HistoryVer2;
+  tcHistory.OnChange(nil);
+end;
+
+procedure TReportHistoryForm.btnDownClick(Sender: TObject);
+begin
+  if FReport.Update(tcHistory.Tabs[tcHistory.TabIndex]) then
+  begin
+    btnDown.Caption := '正在使用';
+    btnDown.Enabled := False;
+  end
+  else
+  begin
+    btnDown.Caption := '下载此版本';
+    btnDown.Enabled := True;
+  end;
+end;
+
+end.

+ 656 - 0
Forms/ReportManagerFrm.dfm

@@ -0,0 +1,656 @@
+object ReportManagerForm: TReportManagerForm
+  Left = 679
+  Top = 296
+  BorderStyle = bsDialog
+  Caption = #25253#34920#27169#26495
+  ClientHeight = 442
+  ClientWidth = 809
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -13
+  Font.Name = #23435#20307
+  Font.Style = []
+  OldCreateOrder = False
+  Position = poScreenCenter
+  OnCreate = FormCreate
+  OnDestroy = FormDestroy
+  PixelsPerInch = 96
+  TextHeight = 13
+  object pcReport: TPageControl
+    Left = 0
+    Top = 0
+    Width = 809
+    Height = 442
+    ActivePage = tsLocal
+    Align = alClient
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -24
+    Font.Name = #24494#36719#38597#40657
+    Font.Style = [fsBold]
+    ParentFont = False
+    TabHeight = 50
+    TabOrder = 0
+    OnChange = pcReportChange
+    object tsLocal: TTabSheet
+      Caption = '  '#26412#22320#25253#34920'  '
+      Font.Charset = DEFAULT_CHARSET
+      Font.Color = clWindowText
+      Font.Height = -19
+      Font.Name = #23435#20307
+      Font.Style = []
+      ParentFont = False
+      object zgLoacl: TZJGrid
+        Left = 0
+        Top = 0
+        Width = 801
+        Height = 382
+        Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+        OptionsEx = []
+        ColCount = 7
+        RowCount = 1
+        ShowGridLine = False
+        DefaultColWidth = 73
+        DefaultFixedColWidth = 30
+        DefaultFixedRowHeight = 29
+        DefaultRowHeight = 30
+        Selection.AlphaBlend = False
+        Selection.TransparentColor = False
+        FrozenCol = 0
+        FrozenRow = 0
+        OnCellGetFont = zgLoaclCellGetFont
+        OnMouseDown = zgLoaclMouseDown
+        Font.Charset = DEFAULT_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #24494#36719#38597#40657
+        Font.Style = []
+        ParentFont = False
+        Align = alClient
+      end
+      object pnlHint: TPanel
+        Left = 0
+        Top = 0
+        Width = 801
+        Height = 382
+        Align = alClient
+        BevelOuter = bvNone
+        Caption = #26412#22320#36824#27809#26377#25253#34920#65292#35831#20351#29992#8220#32447#19978#25253#34920#24211#8221#19979#36733#25253#34920
+        Font.Charset = DEFAULT_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -27
+        Font.Name = #24494#36719#38597#40657
+        Font.Style = [fsBold]
+        ParentFont = False
+        TabOrder = 1
+      end
+    end
+    object tsOnline: TTabSheet
+      Caption = '  '#32447#19978#25253#34920#24211'  '
+      ImageIndex = 1
+      object Panel1: TPanel
+        Left = 0
+        Top = 0
+        Width = 801
+        Height = 37
+        Align = alTop
+        BevelOuter = bvNone
+        TabOrder = 0
+        object cbCategory: TComboBox
+          Left = 0
+          Top = 4
+          Width = 273
+          Height = 27
+          Style = csDropDownList
+          Font.Charset = DEFAULT_CHARSET
+          Font.Color = clWindowText
+          Font.Height = -13
+          Font.Name = #24494#36719#38597#40657
+          Font.Style = []
+          ItemHeight = 19
+          ParentFont = False
+          TabOrder = 0
+          TabStop = False
+          OnChange = cbCategoryChange
+        end
+      end
+      object zgOnline: TZJGrid
+        Left = 0
+        Top = 36
+        Width = 801
+        Height = 346
+        Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+        OptionsEx = []
+        ColCount = 7
+        RowCount = 1
+        ShowGridLine = False
+        DefaultColWidth = 73
+        DefaultFixedColWidth = 30
+        DefaultFixedRowHeight = 29
+        DefaultRowHeight = 30
+        Selection.AlphaBlend = False
+        Selection.TransparentColor = False
+        FrozenCol = 0
+        FrozenRow = 0
+        OnCellGetFont = zgOnlineCellGetFont
+        OnMouseDown = zgOnlineMouseDown
+        Font.Charset = DEFAULT_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #24494#36719#38597#40657
+        Font.Style = []
+        ParentFont = False
+        Align = alBottom
+      end
+    end
+    object tsCustom: TTabSheet
+      Caption = '  '#23450#21046#25253#34920'  '
+      ImageIndex = 2
+      object pnlCustom: TPanel
+        Left = 0
+        Top = 0
+        Width = 801
+        Height = 382
+        Align = alClient
+        BevelOuter = bvNone
+        Caption = 'pnlCustom'
+        TabOrder = 1
+        object zgCustom: TZJGrid
+          Left = 0
+          Top = 0
+          Width = 801
+          Height = 382
+          Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+          OptionsEx = []
+          ColCount = 7
+          RowCount = 1
+          ShowGridLine = False
+          DefaultColWidth = 73
+          DefaultFixedColWidth = 30
+          DefaultFixedRowHeight = 29
+          DefaultRowHeight = 30
+          Selection.AlphaBlend = False
+          Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
+          OnCellGetFont = zgCustomCellGetFont
+          OnMouseDown = zgCustomMouseDown
+          Font.Charset = DEFAULT_CHARSET
+          Font.Color = clWindowText
+          Font.Height = -12
+          Font.Name = #24494#36719#38597#40657
+          Font.Style = []
+          ParentFont = False
+          Align = alClient
+        end
+      end
+      object pnlInputCode: TPanel
+        Left = 0
+        Top = 0
+        Width = 801
+        Height = 382
+        Align = alClient
+        BevelOuter = bvNone
+        TabOrder = 0
+        object Label2: TLabel
+          Left = 176
+          Top = 170
+          Width = 455
+          Height = 19
+          Caption = #26356#22810#20851#20110#8220#23450#21046#25253#34920#8221#21644#8220#25253#34920#39046#21462#30721#8221#30340#35814#24773#21487#20197#32852#31995#30456#20851#32437#27178#38144#21806#24037#31243#24072#12290
+          Font.Charset = DEFAULT_CHARSET
+          Font.Color = clWindowText
+          Font.Height = -13
+          Font.Name = #24494#36719#38597#40657
+          Font.Style = []
+          ParentFont = False
+        end
+        object Label1: TLabel
+          Left = 176
+          Top = 93
+          Width = 195
+          Height = 19
+          Caption = #36755#20837#8220#25253#34920#39046#21462#30721#8221#33719#21462#23450#21046#25253#34920
+          Font.Charset = DEFAULT_CHARSET
+          Font.Color = clWindowText
+          Font.Height = -13
+          Font.Name = #24494#36719#38597#40657
+          Font.Style = []
+          ParentFont = False
+        end
+        object edtCode: TEdit
+          Left = 176
+          Top = 114
+          Width = 324
+          Height = 48
+          Font.Charset = DEFAULT_CHARSET
+          Font.Color = clBlue
+          Font.Height = -40
+          Font.Name = #23435#20307
+          Font.Style = [fsBold]
+          ParentFont = False
+          TabOrder = 0
+        end
+        object btnGet: TcxButton
+          Left = 502
+          Top = 97
+          Width = 121
+          Height = 65
+          Cursor = crHandPoint
+          Caption = #39046#21462
+          Font.Charset = DEFAULT_CHARSET
+          Font.Color = clWindowText
+          Font.Height = -27
+          Font.Name = #24494#36719#38597#40657
+          Font.Style = [fsBold]
+          ParentFont = False
+          TabOrder = 1
+          OnClick = btnGetClick
+          Colors.Default = clWindow
+          Colors.Normal = clWindow
+          Colors.Pressed = clHotLight
+        end
+      end
+    end
+  end
+  object zaLocal: TZjGridDBA
+    Columns = <
+      item
+        Title.Caption = #31867#21035
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Category'
+        Width = 120
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #25253#34920#21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Name'
+        Width = 290
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#22320#29256#26412
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'LocalVer'
+        Width = 93
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26368#26032#26356#26032
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'NewestVer'
+        Width = 93
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #29366#24577
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'State'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21382#21490#29256#26412
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'History'
+        Width = 65
+        ReadOnly = True
+      end
+      item
+        Title.Caption = 'ID'
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'ID'
+        Visible = False
+        ReadOnly = False
+      end>
+    Grid = zgLoacl
+    ExtendRowCount = 0
+    Left = 644
+    Top = 72
+  end
+  object zaOnline: TZjGridDBA
+    Columns = <
+      item
+        Title.Caption = #31867#21035
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Category'
+        Width = 120
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #25253#34920#21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Name'
+        Width = 290
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#22320#29256#26412
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'LocalVer'
+        Width = 93
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26368#26032#26356#26032
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'NewestVer'
+        Width = 93
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #29366#24577
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'State'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21382#21490#29256#26412
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'History'
+        Width = 65
+        ReadOnly = True
+      end
+      item
+        Title.Caption = 'ID'
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'ID'
+        Visible = False
+        ReadOnly = False
+      end>
+    Grid = zgOnline
+    ExtendRowCount = 0
+    Left = 676
+    Top = 72
+  end
+  object zaCustom: TZjGridDBA
+    Columns = <
+      item
+        Title.Caption = #31867#21035
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Category'
+        Width = 120
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #25253#34920#21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Name'
+        Width = 290
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#22320#29256#26412
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'LocalVer'
+        Width = 93
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26368#26032#26356#26032
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'NewestVer'
+        Width = 93
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #29366#24577
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'State'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21382#21490#29256#26412
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'History'
+        Width = 65
+        ReadOnly = True
+      end
+      item
+        Title.Caption = 'ID'
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'ID'
+        Visible = False
+        ReadOnly = False
+      end>
+    Grid = zgCustom
+    ExtendRowCount = 0
+    Left = 732
+    Top = 72
+  end
+end

+ 212 - 0
Forms/ReportManagerFrm.pas

@@ -0,0 +1,212 @@
+unit ReportManagerFrm;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, ComCtrls, DB, DBClient, ZJGrid, StdCtrls, ExtCtrls, ZjGridDBA,
+  cxLookAndFeelPainters, cxButtons;
+
+type
+  TReportManagerForm = class(TForm)
+    pcReport: TPageControl;
+    tsLocal: TTabSheet;
+    tsOnline: TTabSheet;
+    tsCustom: TTabSheet;
+    zgLoacl: TZJGrid;
+    Panel1: TPanel;
+    cbCategory: TComboBox;
+    pnlInputCode: TPanel;
+    edtCode: TEdit;
+    Label2: TLabel;
+    zaLocal: TZjGridDBA;
+    Label1: TLabel;
+    zgOnline: TZJGrid;
+    zaOnline: TZjGridDBA;
+    btnGet: TcxButton;
+    pnlCustom: TPanel;
+    pnlHint: TPanel;
+    zgCustom: TZJGrid;
+    zaCustom: TZjGridDBA;
+    procedure FormCreate(Sender: TObject);
+    procedure FormDestroy(Sender: TObject);
+    procedure zgLoaclCellGetFont(Sender: TObject; ACoord: TPoint;
+      AFont: TFont);
+    procedure zgOnlineCellGetFont(Sender: TObject; ACoord: TPoint;
+      AFont: TFont);
+    procedure zgLoaclMouseDown(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: Integer);
+    procedure zgOnlineMouseDown(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: Integer);
+    procedure cbCategoryChange(Sender: TObject);
+    procedure btnGetClick(Sender: TObject);
+    procedure zgCustomCellGetFont(Sender: TObject; ACoord: TPoint;
+      AFont: TFont);
+    procedure zgCustomMouseDown(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: Integer);
+    procedure pcReportChange(Sender: TObject);
+  private
+    { Private declarations }
+    FReports: TObject;
+    function CurValue(AGridDBA: TZjGridDBA; FieldName: string): Variant;
+    function Col(AGridDBA: TZjGridDBA; FieldName: string): Integer;
+    procedure GridGetFont(Sender: TObject; ACoord: TPoint; AFont: TFont; AGrid: TZjGrid; AGridDBA: TZjGridDBA);
+    procedure GridMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer; AGrid: TZjGrid; AGridDBA: TZjGridDBA);
+  public
+    { Public declarations }
+  end;
+
+
+implementation
+
+uses ReportManagerDM, ReportHistoryFrm;
+
+{$R *.dfm}
+
+function TReportManagerForm.Col(AGridDBA: TZjGridDBA; FieldName: string): Integer;
+begin
+  Result := AGridDBA.ColumnIndex(FieldName) + 1;
+end;
+
+function TReportManagerForm.CurValue(AGridDBA: TZjGridDBA; FieldName: string): Variant;
+begin
+  Result := AGridDBA.DataSet.FieldByName(FieldName).AsVariant;
+end;
+
+procedure TReportManagerForm.FormCreate(Sender: TObject);
+begin
+  FReports := TReports.Create(nil);
+  zaLocal.DataSet := TReports(FReports).cdsLocal;
+  zaLocal.Grid := zgLoacl;
+  zaOnline.DataSet := TReports(FReports).cdsOnline;
+  zaOnline.Grid := zgOnline;
+  zaCustom.DataSet := TReports(FReports).cdsCustom;
+  zaCustom.Grid := zgCustom;
+
+  pnlHint.Visible := zaLocal.DataSet.RecordCount = 0;
+  TReports(FReports).CategoryList(cbCategory.Items);
+  cbCategory.ItemIndex := 0;
+  pcReport.ActivePage := tsLocal;
+end;
+
+procedure TReportManagerForm.FormDestroy(Sender: TObject);
+begin
+  FReports.Free;
+end;
+
+procedure TReportManagerForm.GridGetFont(Sender: TObject; ACoord: TPoint;
+  AFont: TFont; AGrid: TZjGrid; AGridDBA: TZjGridDBA);
+var
+  OldActiveRecd: Integer;
+begin
+  if ACoord.X = Col(AGridDBA, 'State') then
+  begin
+    if AGridDBA.ChangeActiveRecord(ACoord.Y - AGrid.FixedRowCount, OldActiveRecd)then
+    begin
+      try
+        if (CurValue(AGridDBA, 'State') = '¸üÐÂ') or (CurValue(AGridDBA, 'State') = 'ÏÂÔØ') then
+          AFont.Color := clBlue;
+      finally
+        AGridDBA.ChangeActiveRecord(OldActiveRecd, OldActiveRecd);
+      end;
+    end;
+  end
+  else if ACoord.X = Col(AGridDBA, 'History') then
+    AFont.Color := clBlue;
+end;
+
+procedure TReportManagerForm.GridMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer; AGrid: TZjGrid;
+  AGridDBA: TZjGridDBA);
+var
+  vForm: TReportHistoryForm;
+  vReport: TReport;
+  iID: Integer;
+begin
+  if CurValue(AGridDBA, 'ID') = null then Exit;
+
+  Screen.Cursor := crHourGlass;
+  try
+    iID := CurValue(AGridDBA, 'ID');
+    vReport := TReports(FReports).FindReprot(iID);
+
+    if AGrid.CurCol = Col(AGridDBA, 'State') then
+    begin
+      if not SameText(vReport.LocalVer, vReport.NewestVer) then
+        vReport.Update(vReport.NewestVer);
+    end
+    else if AGrid.CurCol = Col(AGridDBA, 'History') then
+    begin
+      vReport.GetHistoryVer;
+      vForm := TReportHistoryForm.Create(vReport);
+      try
+        vForm.ShowModal;
+      finally
+        vForm.Free;
+      end;
+    end;
+  finally
+    Screen.Cursor := crDefault;
+  end;
+end;
+
+procedure TReportManagerForm.zgLoaclCellGetFont(Sender: TObject;
+  ACoord: TPoint; AFont: TFont);
+begin
+  GridGetFont(Sender, ACoord, AFont, zgLoacl, zaLocal);
+end;
+
+procedure TReportManagerForm.zgOnlineCellGetFont(Sender: TObject;
+  ACoord: TPoint; AFont: TFont);
+begin
+  GridGetFont(Sender, ACoord, AFont, zgOnline, zaOnline);
+end;
+
+procedure TReportManagerForm.zgLoaclMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+begin
+  GridMouseDown(Sender, Button, Shift, X, Y, zgLoacl, zaLocal);
+end;
+
+procedure TReportManagerForm.zgOnlineMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+begin
+  GridMouseDown(Sender, Button, Shift, X, Y, zgOnline, zaOnline);
+end;
+
+procedure TReportManagerForm.cbCategoryChange(Sender: TObject);
+begin
+  if cbCategory.ItemIndex = 0 then
+    TReports(FReports).CancelFilterCategory
+  else
+    TReports(FReports).FilterCategory(cbCategory.Text);
+end;
+
+procedure TReportManagerForm.btnGetClick(Sender: TObject);
+begin
+  if Trim(edtCode.Text) = '' then Exit;
+  if TReports(FReports).LoadCustom(Trim(edtCode.Text)) then
+  begin
+    pnlInputCode.Visible := False;
+  end;
+end;
+
+procedure TReportManagerForm.zgCustomCellGetFont(Sender: TObject;
+  ACoord: TPoint; AFont: TFont);
+begin
+  GridGetFont(Sender, ACoord, AFont, zgCustom, zaCustom);
+end;
+
+procedure TReportManagerForm.zgCustomMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+begin
+  GridMouseDown(Sender, Button, Shift, X, Y, zgCustom, zaCustom);
+end;
+
+procedure TReportManagerForm.pcReportChange(Sender: TObject);
+begin
+  if pcReport.ActivePage = tsLocal then
+    pnlHint.Visible := zaLocal.DataSet.RecordCount = 0;
+end;
+
+end.

+ 2 - 2
Forms/ReportsFrm.dfm

@@ -159,8 +159,8 @@ object ReportsForm: TReportsForm
           object tbImportSrt: TToolButton
             Left = 0
             Top = 0
-            Hint = #23548#20837#25253#34920#27169#26495
-            Caption = #23548#20837#27169#26495
+            Hint = #25253#34920#27169#26495
+            Caption = #25253#34920#27169#26495
             ImageIndex = 5
             ParentShowHint = False
             ShowHint = True

+ 16 - 1
Forms/ReportsFrm.pas

@@ -177,7 +177,7 @@ implementation
 uses
   UtilMethods, Math, Globals, ZhAPI, ReportAdjustFrm,
   Contnrs, mEncryptUnit, Printers, WinSpool, MainFrm, ConstUnit,
-  GclBillsGatherModel, ReportPdfHelper;
+  GclBillsGatherModel, ReportPdfHelper, ReportManagerFrm;
 
 {$R *.dfm}
 
@@ -670,6 +670,7 @@ begin
     Result := AddClassNode(nil, ANode.ClassNum + '.' + ANode.ClassName);
 end;
 
+{ 启用报表模板管理器,报表导入功能取消。
 procedure TReportsForm.tbImportSrtClick(Sender: TObject);
 
   procedure ImportReportTemplate(const AFileName: string);
@@ -710,8 +711,22 @@ begin
   finally
     sgsFiles.Free;
   end;
+end; }
+
+procedure TReportsForm.tbImportSrtClick(Sender: TObject);
+var vRDForm: TReportManagerForm;
+begin
+  Screen.Cursor := crHourGlass;
+  vRDForm := TReportManagerForm.Create(nil);
+  try
+    vRDForm.ShowModal;
+  finally
+    vRDForm.Free;
+    Screen.Cursor := crDefault;
+  end;
 end;
 
+
 procedure TReportsForm.tbDeleteSrtClick(Sender: TObject);
 var
   vTemplateNode: TTemplateNode;

+ 18 - 1
Frames/ProjectFme.pas

@@ -210,7 +210,7 @@ uses
   PhaseData, BGLDm, MainFrm, ZhAPI, SearchDm, PHPWebDm, ActiveX,
   ConstUnit, MD5Unit, sdIDTree, sdDB, mProgressFrm, ConditionalDefines,
   ProjectCommands, ProjectProperty, CheckerMemoFrm, BillsMeasureDm,
-  ProgressHintFrm, mProgressProFrm;
+  ProgressHintFrm, mProgressProFrm, ReportManagerFrm;
 
 {$R *.dfm}
 
@@ -559,7 +559,24 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
   *)
 
   procedure DisplayReports;
+  var vRDForm: TReportManagerForm;
+    sPath: string;
   begin
+    if G_IsCloud then
+    begin
+      sPath := ExtractFilePath(ParamStr(0)) + 'ReportTemplates\';
+      if FileCount(sPath, '.srt') = 0 then
+      begin
+        Screen.Cursor := crHourGlass;
+        vRDForm := TReportManagerForm.Create(nil);
+        try
+          vRDForm.ShowModal;
+        finally
+          vRDForm.Free;
+          Screen.Cursor := crDefault;
+        end;
+      end;
+    end;
     // ×¼±¸Êý¾Ý
     if Item.Tag = xbiReport.Tag then
       FProjectData.CopyPhaseData;

+ 1 - 1
Frames/ProjectManagerFme.pas

@@ -1630,7 +1630,7 @@ function TProjectManagerFrame.AttachmentFileCountsWithoutManageFile(ANode: TsdID
     else
     begin
       sPath := GetMyProjectsFilePath + 'Attachment\' + ANode.Rec.ValueByName('FileName').AsString + '\';
-      Result := Result + FileCount(sPath) - 1;
+      Result := Result + FileCount(sPath, '.*') - 1;
     end;
 
     if Assigned(ANode.FirstChild) then

+ 80 - 8
Units/UtilMethods.pas

@@ -109,18 +109,23 @@ type
 
   procedure AppendTestLog(const AFileName, ALog: string);
 
-  // Add by chenshilong, 2014-04-11
+  // From here, Add by chenshilong, 2014-04-11
   function GetVersion(APartCount: Integer = 4): string;
   function ExtractFileNameWithoutExt(const AFileName: string): string;
-  function ShortText(AText: string; AWidth: Integer): string;                     // 文本缩略显示
+  function ShortText(AText: string; AWidth: Integer): string;                   // 文本缩略显示
   function CustomWidthText(AText: string; AWidth: Integer): string;
-  function ReplaceCharsForJson(AText: string): string;                                  // 替换Json文本中的特殊字符
-  function RecoverCharsFromJson(AText: string): string;                             // 下载得到的Json文本恢复成用户需要的文本
+  function ReplaceCharsForJson(AText: string): string;                          // 替换Json文本中的特殊字符
+  function RecoverCharsFromJson(AText: string): string;                         // 下载得到的Json文本恢复成用户需要的文本
   procedure FindFiles(APath, AExtName: string; AFileList: TStrings);
   function DeleteFolder(const FolderStr: string): Boolean;
   function HasExt(const AFileName: string): Boolean;
   function CopyFolder(const SrcFolder, DstFolder: string): Boolean;
-  function FileCount(APath: string): Integer;
+  function FileCount(APath, AExt: string): Integer;
+  function ChangeExt(AFile, ANewExt: string): string;
+  function CheckExt(AName, AExt: string): string;
+  function TempName(ALength: Integer): string;
+  function URLFileName(AURL: string): string;
+  function ReplaceChars(AStr: string): string;
 
 implementation
 
@@ -1330,15 +1335,15 @@ begin
   Result     := SHFileOperation(fos) <> 0;
 end;
 
-function FileCount(APath: string): Integer;
+function FileCount(APath, AExt: string): Integer;
 var
   vSR: TSearchRec;
   iRetval: Integer;
   vSL: TStringList;
 begin
   vSL := TStringList.Create;
-  iRetval := FindFirst(APath + '*.*', faAnyFile, vSR);
-  try 
+  iRetval := FindFirst(APath + '*' + AExt, faAnyFile, vSR);
+  try
     while iRetval = 0 do
     begin
       if (vSR.Attr and faDirectory) = 0 then
@@ -1352,4 +1357,71 @@ begin
   end;
 end;
 
+
+function ChangeExt(AFile, ANewExt: string): string;
+var i, iPos: Integer;
+begin
+  for i := Length(AFile) Downto 1 do
+  begin
+    if AFile[i] = '.' then
+    begin
+      iPos := i;
+      Break;
+    end;
+  end;
+  Result := Copy(AFile, 1, iPos - 1) + ANewExt;
+end;
+
+function CheckExt(AName, AExt: string): string;
+var bHasExt: Boolean;
+begin
+  bHasExt := ExtractFileExt(AName) <> '';
+  if not bHasExt then
+    Result := AName + AExt
+  else
+  begin
+    if (UpperCase(ExtractFileExt(AName)) <> AExt) then
+      Result := ChangeExt(AName, AExt)
+    else
+      Result := AName;
+  end;
+end;
+
+function TempName(ALength: Integer): string;
+const 
+  CodedBuf: array[0..35] of Char = ('0', '1', '2', '3', '4', '5',
+  '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 
+  'J', 'K', 'L', 'M', 'N',
+'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 
+  'W', 'X', 'Y', 'Z');
+begin
+  Result := '';
+  Randomize;
+  while Length(Result) < ALength do
+    Result := Result + CodedBuf[Random(36)];
+end;
+
+function URLFileName(AURL: string): string;
+var
+  i: integer;
+  s: string;
+begin
+  s := AURL;
+  i := Pos('/', s);
+  while i <> 0 do
+  begin
+    Delete(s, 1, i);
+    i := Pos('/', s);
+  end;
+  Result := s;
+end;
+
+function ReplaceChars(AStr: string): string;
+var s: string;
+begin
+  s := Trim(AStr);
+  s := StringReplace(s, '\r\n', #$D#$A, [rfReplaceAll]);
+  Result := s;
+end;
+
 end.