Browse Source

附件新需求。

Chenshilong 8 years ago
parent
commit
ea0a8d0757

+ 58 - 11
DataModules/PHPWebDm.pas

@@ -90,9 +90,12 @@ type
     function ConnectServer(AIP: string; var ACompanyName: string): Integer;  // 新装软件,先弹出设置IP窗口
     function UpDataFile(AUserID, ATenderID, APhaseNo: Integer; AFile, AMD5_JL: string;
       AIsSubmit: Boolean; var AResultStr: string; ACheckPassed: Boolean; ACheckerMemo: string): Boolean;
-    function UpAttachmentFile(AUperID, AWebID, ABillID: Integer; AFile,
-      ACategory, AMemo, APhaseName: string; var ANewFileName: string): Boolean;
-    function GetAttachmentFileList(AWebID: Integer; var vArr: TOVArr): Boolean;
+
+    function UpAttachment(AUperID, AWebID, ABillID, APhase: Integer; AFile, ACategory, AMemo: string; var ANewFileName: string): Boolean;
+    function UpAttachmentOnLine(AWebID, ABillID, APhase: Integer; AIDAry: array of  string): Boolean;
+    function DeleteAttachment(AFileID: Integer): Integer;
+    function GetAttachmentList(AWebID: Integer; var vArr: TOVArr): Boolean;
+
     function zip(AFileArr: array of string): string;
     function CheckZip(AZipFile: string; AFileCount: Integer): Boolean;   // 检测zip是否能够正确解压出所有文件。
     function TempName(ALength: Integer = 12): string;
@@ -107,7 +110,7 @@ type
     function PageError(AMid: string): string;
     function ExistInServer(AWebID: Integer): Boolean;
     function GetNameFromURLProtocol(AURLProtocol: string): string;
-    function DeleteAttachment(AFileID: Integer): Integer;
+
 
     property Account: string read FAccount write SetAccount;
     property UserID: Integer read FUserID write SetUserID;
@@ -602,8 +605,8 @@ begin
   end;
 end;
 
-function TPHPWeb.UpAttachmentFile(AUperID, AWebID, ABillID: Integer; AFile,
-  ACategory, AMemo, APhaseName: string; var ANewFileName: string): Boolean;
+function TPHPWeb.UpAttachment(AUperID, AWebID, ABillID, APhase: Integer; AFile,
+  ACategory, AMemo: string; var ANewFileName: string): Boolean;
 var
   vMPFDS: TIdMultiPartFormDataStream;
   sResult, sURL: string;
@@ -623,9 +626,9 @@ begin
     sURL := Format('%stender/attachment/%d/%d/upload', [FMeasureURL, AWebID, AUperID]);
     vMPFDS.AddFile('upitem', AFile, 'text/plain');
     vMPFDS.AddFormField('itemid', IntToStr(ABillID));
-    vMPFDS.AddFormField('Category', ACategory);
-    vMPFDS.AddFormField('Memo', ReplaceCharsForJson(AMemo));
-    vMPFDS.AddFormField('PhaseName', APhaseName);
+    vMPFDS.AddFormField('category', ACategory);
+    vMPFDS.AddFormField('memo', ReplaceCharsForJson(AMemo));
+    vMPFDS.AddFormField('phase', IntToStr(APhase));
 
     vMPFDS.Position := 0;
     try
@@ -656,7 +659,7 @@ begin
   end;
 end;
 
-function TPHPWeb.GetAttachmentFileList(AWebID: Integer; var vArr: TOVArr): Boolean;
+function TPHPWeb.GetAttachmentList(AWebID: Integer; var vArr: TOVArr): Boolean;
 var sURL: string;
 begin
   sURL := Format('%stender/attachment/%d/list', [FMeasureURL, AWebID]);
@@ -692,10 +695,54 @@ var sURL: string;
   vArr: array of string;
 begin
   vArr := VarArrayOf(['msg']);
-  sURL := Format('%stender/attachment/%d/list', [FMeasureURL, AFileID]);
+  sURL := Format('%stender/attachment/%d/del', [FMeasureURL, AFileID]);
   Result := Search(sURL, [], [], vArr);
 end;
 
+function TPHPWeb.UpAttachmentOnLine(AWebID, ABillID, APhase: Integer; AIDAry: array of string): Boolean;
+//var
+//  vMPFDS: TIdMultiPartFormDataStream;
+//  sResult, sURL: string;
+//  J: TCslJson;
+//  vArr: array of string;
+begin
+{  Result := False;
+
+  vMPFDS := TIdMultiPartFormDataStream.Create;
+  try
+    sURL := Format('%stender/attachment/%d/%d/upload', [FMeasureURL, AWebID, PHPWeb.UserID]);
+    vMPFDS.AddFormField('itemid', IntToStr(ABillID));
+    vMPFDS.AddFormField('phase', IntToStr(APhase));
+
+    vMPFDS.Position := 0;
+    try
+      sResult := IdHTTP.Post(sURL, vMPFDS);
+    except
+      Abort;
+    end;
+  finally
+    vMPFDS.Free;
+  end;
+
+  J := TCslJson.Create;
+  try
+    J.Text := Utf8ToAnsi(sResult);
+    if SameText(J.Value['status'], 'true') then
+    begin
+      Result := True;
+      vArr := VarArrayOf(['onlinefilename']);
+      J.ChildValues('iteminfo', vArr);
+      ANewFileName := vArr[0];
+    end
+    else
+    begin
+      Result := False;
+    end;
+  finally
+    J.Free;
+  end;  }
+end;
+
 initialization
 
 finalization

+ 2 - 2
Dprs/CSL/Measure_Cloud.dof

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

+ 3 - 2
Dprs/CSL/Measure_Cloud.dpr

@@ -202,7 +202,8 @@ uses
   CalcData in '..\..\Units\CalcData.pas',
   DealBillsExcelImport in '..\..\Units\DealBillsExcelImport.pas',
   ExcelImport_Bills in '..\..\Units\ExcelImport_Bills.pas',
-  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas';
+  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas',
+  UpFileSelectOnLineFrm in '..\..\Forms\UpFileSelectOnLineFrm.pas' {UpFileSelectOnLineForm};
 
 {$R *.res}
 
@@ -281,7 +282,7 @@ begin
     if CheckDogExists then
     begin
       Application.CreateForm(TMainForm, MainForm);
-    end;
+  end;
     Application.Run;
   end;
 

BIN
Dprs/CSL/Measure_Cloud.res


+ 2 - 2
Forms/LoginFrm.pas

@@ -164,8 +164,8 @@ begin
 
   if G_IsTest then
   begin
-    cbUser.Text := 'ww9zl';
-    edtPW.Text := 'ww9zl';
+    cbUser.Text := '1971614655@qq.com';
+    edtPW.Text := '357134933..';
   end;
 end;
 

+ 3 - 2
Forms/UpFileFrame.dfm

@@ -62,7 +62,8 @@ object UpFileView: TUpFileView
       Top = 0
       Width = 28
       Height = 30
-      Hint = #25991#20214#24050#19979#36733#65292#28857#20987#25171#24320#25991#20214
+      Hint = #22312#32447#39044#35272
+      Visible = False
       Layout = pbsImageLeft
       Spacing = 4
       ImageNormal.Data = {
@@ -348,7 +349,7 @@ object UpFileView: TUpFileView
       Top = 0
       Width = 23
       Height = 30
-      Hint = #28857#20987#25171#24320#25991#20214#25152#22312#30340#25991#20214#22841
+      Hint = #32447#19978#31227#38500
       Layout = pbsImageLeft
       Spacing = 4
       ImageNormal.Data = {

+ 5 - 3
Forms/UpFileFrame.pas

@@ -144,8 +144,8 @@ begin
 
     if G_IsCloud then
     begin
-      if PHPWeb.UpAttachmentFile(PHPWeb.UserID, TProjectData(FProjectData).WebID, Data.BillID,
-        Data.OrgFile, Data.Category, Data.Memo, IntToStr(Data.Phase), sWebName) then
+      if PHPWeb.UpAttachment(PHPWeb.UserID, TProjectData(FProjectData).WebID, Data.BillID, Data.Phase,
+        Data.OrgFile, Data.Category, Data.Memo, sWebName) then
       begin
   //      TUpFileManageView(Owner).Rec.ValueByName('HasAttachment').AsBoolean := True;
         CopyFile(PChar(Data.OrgFile), PChar(Data.LocalFile), False);
@@ -215,7 +215,7 @@ begin
     ufsNormal:
     begin
       pnlOrder.Visible := False;
-      pnlPlay.Visible := FileExists(Data.LocalFile);
+      pnlPlay.Visible := True;
       lblInfo.Visible := True;
       lblInfo.Font.Color := clBlack;
       lblInfo.Caption := Data.UperName;
@@ -262,6 +262,8 @@ end;
 
 procedure TUpFileView.btnDeleteClick(Sender: TObject);
 begin
+  if Application.MessageBox('确定要在线上移除该附件吗?', '询问', MB_YESNO + MB_ICONQUESTION) = ID_No then
+    Exit;
   TUpFileManageView(Owner).DeleteViewAndData(Self, True);
   //ShellExecute(Handle, nil, PChar('explorer.exe'), PChar('/e,/select,' + Data.LocalFile), nil, SW_Show);
 end;

+ 5 - 1
Forms/UpFileManageFrame.dfm

@@ -445,7 +445,7 @@ object UpFileManageView: TUpFileManageView
       Width = 51
       Height = 24
       Font.Charset = DEFAULT_CHARSET
-      Font.Color = 46336
+      Font.Color = clBlue
       Font.Height = -13
       Font.Name = #24494#36719#38597#40657
       Font.Style = []
@@ -478,6 +478,7 @@ object UpFileManageView: TUpFileManageView
         401CF38041C7A81B89D445293D26EA85C23123A93F012797324CF856D3B70000
         000049454E44AE426082}
       ButtonStyle = pbsFlat
+      Enabled = False
       OnClick = btnDownClick
     end
     object Shape4: TShape
@@ -715,6 +716,7 @@ object UpFileManageView: TUpFileManageView
     Top = 16
   end
   object pmUp: TPopupMenu
+    AutoHotkeys = maManual
     Left = 144
     Top = 8
     object miLocalUp: TMenuItem
@@ -723,6 +725,8 @@ object UpFileManageView: TUpFileManageView
     end
     object miServerUp: TMenuItem
       Caption = #20174#39033#30446#25991#20214#36873#25321
+      Visible = False
+      OnClick = miServerUpClick
     end
   end
 end

+ 28 - 3
Forms/UpFileManageFrame.pas

@@ -56,6 +56,7 @@ type
     procedure tDelViewTimer(Sender: TObject);
     procedure btnDownClick(Sender: TObject);
     procedure miLocalUpClick(Sender: TObject);
+    procedure miServerUpClick(Sender: TObject);
   private
     FDetailIsEdit: Boolean;
     FSelected: TUpFileView;
@@ -100,7 +101,7 @@ type
 implementation
 
 uses PHPWebDm, ProjectData, IdGlobal, ProjectFme, ConstUnit, MainFrm,
-  BillsMeasureDm, UtilMethods;
+  BillsMeasureDm, UtilMethods, UpFileSelectOnLineFrm;
 
 
 {$R *.dfm}
@@ -118,6 +119,8 @@ begin
   lblUpTime.Caption := '';
   lblCategory.Caption := '';
   mmMemo.Clear;
+  btnEdit.Enabled := False;
+  btnDown.Enabled := False;
 end;
 
 procedure TUpFileManageView.DetailIntoEditStatus;
@@ -187,7 +190,8 @@ begin
     mmMemo.Text := vFile.Memo;
   end;
 
-  btnEdit.Enabled := (edtFileName.Text <> '') and TProjectData(FProjectData).CurUserIsAuthor;
+  btnEdit.Enabled := (edtFileName.Text <> '') and (PHPWeb.UserID = vFile.UperID); // TProjectData(FProjectData).CurUserIsAuthor;
+  btnDown.Enabled := (edtFileName.Text <> '');
 end;
 
 procedure TUpFileManageView.RefreshOtherFileFrames;
@@ -311,8 +315,11 @@ begin
   tDelView.Enabled := False;
   vUpFile := WaitForDelete.Data;
   if FDeleteAttachmentOnLine then
-    if PHPWeb.DeleteAttachment(vUpFile.ID) <> 1 then    
+    if PHPWeb.DeleteAttachment(vUpFile.ID) <> 1 then
+    begin
+      Application.MessageBox('线上附件移除失败,请重试!', '警告', MB_OK + MB_ICONWARNING);
       Exit;
+    end;
   WaitForDelete.Free;
   Datas.Delete(vUpFile);
 end;
@@ -342,6 +349,7 @@ begin
 
   svDlg := TSaveDialog.Create(nil);
   svDlg.InitialDir := ExtractFilePath(Application.ExeName) + 'UserData\';
+  svDlg.FileName := Selected.Data.DisplayName;
 
   try
     if svDlg.Execute then
@@ -488,4 +496,21 @@ begin
   SelectUpFile;
 end;
 
+procedure TUpFileManageView.miServerUpClick(Sender: TObject);
+var
+  vForm: TUpFileSelectOnLineForm;
+begin
+  vForm := TUpFileSelectOnLineForm.Create(nil);
+  try
+    vForm.InitData(FDatas.List);
+    if vForm.ModalResult = mrOK then
+    begin
+      vForm.UpOnlineFiles;
+    end;
+  finally
+    vForm.Free;
+  end;
+
+end;
+
 end.

+ 169 - 0
Forms/UpFileSelectOnLineFrm.dfm

@@ -0,0 +1,169 @@
+object UpFileSelectOnLineForm: TUpFileSelectOnLineForm
+  Left = 1121
+  Top = 282
+  BorderStyle = bsDialog
+  Caption = #32447#19978#36873#25321#38468#20214
+  ClientHeight = 467
+  ClientWidth = 631
+  Color = clBtnFace
+  Font.Charset = ANSI_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -13
+  Font.Name = #24494#36719#38597#40657
+  Font.Style = []
+  OldCreateOrder = False
+  Position = poMainFormCenter
+  PixelsPerInch = 96
+  TextHeight = 19
+  object ZJGrid1: TZJGrid
+    Left = 5
+    Top = 5
+    Width = 621
+    Height = 428
+    Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+    OptionsEx = []
+    ColCount = 4
+    RowCount = 2
+    ShowGridLine = False
+    DefaultColWidth = 70
+    DefaultFixedColWidth = 30
+    Selection.AlphaBlend = False
+    Selection.TransparentColor = False
+    FrozenCol = 0
+    FrozenRow = 0
+    Font.Charset = ANSI_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -13
+    Font.Name = #23435#20307
+    Font.Style = []
+    ParentFont = False
+  end
+  object btnOK: TButton
+    Left = 470
+    Top = 437
+    Width = 75
+    Height = 25
+    Caption = #30830#23450
+    ModalResult = 1
+    TabOrder = 1
+  end
+  object btnCancel: TButton
+    Left = 550
+    Top = 437
+    Width = 75
+    Height = 25
+    Caption = #21462#28040
+    ModalResult = 2
+    TabOrder = 2
+  end
+  object ZjGridDBA1: TZjGridDBA
+    Columns = <
+      item
+        Title.Caption = #38468#20214#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 = 400
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #19978#20256#32773
+        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 = 'Uper'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #36873#25321
+        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 = 'Select'
+        Width = 50
+        ReadOnly = False
+      end>
+    DataSet = cdsFiles
+    Grid = ZJGrid1
+    ExtendRowCount = 1
+    Options = [aoAllowEdit, aoAutoInsert, aoAllowUpMove, aoAllowDownMove]
+    Left = 384
+    Top = 88
+  end
+  object cdsFiles: TClientDataSet
+    Active = True
+    Aggregates = <>
+    FieldDefs = <
+      item
+        Name = 'ID'
+        DataType = ftString
+        Size = 20
+      end
+      item
+        Name = 'Name'
+        DataType = ftString
+        Size = 255
+      end
+      item
+        Name = 'Uper'
+        DataType = ftString
+        Size = 20
+      end
+      item
+        Name = 'Select'
+        DataType = ftBoolean
+      end>
+    IndexDefs = <>
+    FetchOnDemand = False
+    Params = <>
+    StoreDefs = True
+    Left = 416
+    Top = 88
+    Data = {
+      720000009619E0BD010000001800000004000000000003000000720002494401
+      00490000000100055749445448020002001400044E616D650200490000000100
+      05574944544802000200FF000455706572010049000000010005574944544802
+      00020014000653656C65637402000300000000000000}
+    object cdsFilesID: TStringField
+      FieldName = 'ID'
+    end
+    object cdsFilesName: TStringField
+      FieldName = 'Name'
+      Size = 255
+    end
+    object cdsFilesUper: TStringField
+      FieldName = 'Uper'
+    end
+    object cdsFilesSelect: TBooleanField
+      FieldName = 'Select'
+    end
+  end
+end

+ 77 - 0
Forms/UpFileSelectOnLineFrm.pas

@@ -0,0 +1,77 @@
+unit UpFileSelectOnLineFrm;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, StdCtrls, DB, DBClient, ZjGridDBA, ZJGrid;
+
+type
+  TUpFileSelectOnLineForm = class(TForm)
+    ZJGrid1: TZJGrid;
+    ZjGridDBA1: TZjGridDBA;
+    cdsFiles: TClientDataSet;
+    btnOK: TButton;
+    btnCancel: TButton;
+    cdsFilesID: TStringField;
+    cdsFilesName: TStringField;
+    cdsFilesUper: TStringField;
+    cdsFilesSelect: TBooleanField;
+  private
+    { Private declarations }
+  public
+    { Public declarations }
+    procedure InitData(AList: TList);
+    procedure UpOnlineFiles;
+  end;
+
+implementation
+
+uses UpFileManageUnit, Math, PHPWebDm;
+
+{$R *.dfm}
+
+{ TUpFileSelectOnLineForm }
+
+procedure TUpFileSelectOnLineForm.InitData(AList: TList);
+var i: Integer;
+  vFile: TUpFile;
+begin
+  if AList.Count = 0 then Exit;
+
+  if cdsFiles.RecordCount > 0 then
+    cdsFiles.EmptyDataSet;
+
+  for i := 0 to AList.Count - 1 do
+  begin
+    vFile := TUpFile(AList[i]);
+    cdsFiles.Append;
+    cdsFilesID.AsInteger := vFile.ID;
+    cdsFilesName.AsString := vFile.DisplayName;
+    cdsFilesUper.AsString := vFile.UperName;
+    cdsFiles.Post;
+  end;
+end;
+
+procedure TUpFileSelectOnLineForm.UpOnlineFiles;
+var L: Integer;
+  vA: array of string;
+begin
+  if cdsFiles.RecordCount = 0 then Exit;
+  L := 0;
+  cdsFiles.First;
+  while not cdsfiles.Eof do
+  begin
+    if cdsFilesSelect.AsBoolean = True then
+    begin
+      Inc(L);
+      SetLength(vA, L);
+      vA[L - 1] := cdsFilesID.AsString;
+    end;
+    cdsFiles.Next;
+  end;
+//  if L > 0 then       AAAAA
+//    PHPWeb.UpAttachment(PHPWeb.UserID, );
+end;
+
+end.

+ 3 - 2
Units/UpFileManageUnit.pas

@@ -120,6 +120,7 @@ type
     property Count: Integer read GetCount;
     property ProjectData: TObject read FProjectData write SetProjectData;
     property Path: string read FPath;
+    property List: TList read FList;
   end;
 
 
@@ -267,7 +268,7 @@ var vArrFile: TOVArr;
 begin
   if G_IsCloud then
   begin
-    if PHPWeb.GetAttachmentFileList(TProjectData(FProjectData).WebID, vArrFile) then
+    if PHPWeb.GetAttachmentList(TProjectData(FProjectData).WebID, vArrFile) then
     begin
       for i := Low(vArrFile) to High(vArrFile) do
       begin
@@ -276,13 +277,13 @@ begin
         vFile.DownURL := vArrFile[i, 0];
         vFile.DisplayName := vArrFile[i, 1];
         vFile.LocalFile := FPath + vArrFile[i, 1];
-        vFile.Phase := StrToInt(vArrFile[i, 2]);
         vFile.UperName := vArrFile[i, 3];
         vFile.Category := vArrFile[i, 5];
         vFile.Memo := vArrFile[i, 6];
         vFile.UperID := StrToInt(vArrFile[i, 7]);
         vFile.UpTime := vArrFile[i, 8];
         vFile.ID := StrToInt(vArrFile[i, 9]);
+        vFile.Phase := StrToInt(vArrFile[i, 10]);     // vArrFile[i, 2] ÎļþÀ©Õ¹Ãû
         vFile.WebID := TProjectData(FProjectData).WebID;
         vFile.Status := ufsNormal;
       end;