浏览代码

刚上传完的附件立即编辑,编辑无法提交问题。

Chenshilong 8 年之前
父节点
当前提交
a11488a907
共有 7 个文件被更改,包括 40 次插入36 次删除
  1. 0 17
      DataModules/PHPWebDm.dfm
  2. 30 12
      DataModules/PHPWebDm.pas
  3. 2 2
      Dprs/CSL/Measure_Cloud.dof
  4. 2 1
      Dprs/CSL/Measure_Cloud.dpr
  5. 二进制
      Dprs/CSL/Measure_Cloud.res
  6. 2 2
      Forms/LoginFrm.pas
  7. 4 2
      Forms/UpFileFrame.pas

+ 0 - 17
DataModules/PHPWebDm.dfm

@@ -5,21 +5,4 @@ object PHPWeb: TPHPWeb
   Top = 216
   Height = 226
   Width = 281
-  object IdHTTP: TIdHTTP
-    MaxLineAction = maException
-    ReadTimeout = 0
-    AllowCookies = True
-    ProxyParams.BasicAuthentication = False
-    ProxyParams.ProxyPort = 0
-    Request.ContentLength = -1
-    Request.ContentRangeEnd = 0
-    Request.ContentRangeStart = 0
-    Request.ContentType = 'text/html'
-    Request.Accept = 'text/html, */*'
-    Request.BasicAuthentication = False
-    Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
-    HTTPOptions = [hoForceEncodeParams]
-    Left = 64
-    Top = 48
-  end
 end

+ 30 - 12
DataModules/PHPWebDm.pas

@@ -20,7 +20,6 @@ type
   TLoginType = (ltCon, ltDisCon, ltLoginFail, ltUpdate, ltIncomplete);
 
   TPHPWeb = class(TDataModule)
-    IdHTTP: TIdHTTP;
     procedure DataModuleCreate(Sender: TObject);
   private
     // 远程服务器上时间
@@ -91,7 +90,7 @@ type
     function UpDataFile(AUserID, ATenderID, APhaseNo: Integer; AFile, AMD5_JL: string;
       AIsSubmit: Boolean; var AResultStr: string; ACheckPassed: Boolean; ACheckerMemo: string): Boolean;
 
-    function UpAttachment(AUperID, AWebID, ABillID, APhase: Integer; AFile, ACategory, AMemo: string; var ANewFileName: string): Boolean;
+    function UpAttachment(AUperID, AWebID, ABillID, APhase: Integer; AFile, ACategory, AMemo: string; var ANewFileName, AFileID: 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;
@@ -143,7 +142,7 @@ implementation
 
 uses
   MD5Unit, IdMultipartFormData, VCLUnZip, VCLZip,
-  IniFiles, Forms, UtilMethods, Variants, ConstUnit{, Controls, Windows};
+  IniFiles, Forms, UtilMethods, Variants, ConstUnit, ScUtils;{, Controls, Windows}
 
 var g_PHPWeb: TPHPWeb;
 
@@ -292,6 +291,7 @@ var
   sResult, sURL: string;
   J: TCslJson;
   sZipMD5: string;
+  vIdHttp: TIdHTTP;
 begin
   Result := False;
 
@@ -328,12 +328,13 @@ begin
 
     IdDataStream.Position := 0;
     try
-      sResult := IdHTTP.Post(sURL, IdDataStream);
+      sResult := vIdHTTP.Post(sURL, IdDataStream);
     except
       Abort;
     end;
   finally
     IdDataStream.Free;
+    vIdHttp.Free;
     DeleteFile(AFile);
   end;
 
@@ -406,13 +407,14 @@ var
   vStream: TMemoryStream;
   iFlag: Integer;
   bOK: Boolean;
+  vIdHTTP: TIdHTTP;
 
   procedure SafeDownFile(ASourceURL: string; var ALocalFile: string);
   begin
     Inc(iFlag);
     bOK := False;
     try
-      IdHTTP.Get(ASourceURL, vStream);
+      vIdHTTP.Get(ASourceURL, vStream);
       vStream.SaveToFile(ALocalFile);
       bOK := True;
     except
@@ -431,6 +433,7 @@ begin
     DeleteFile(ALocalFile);
 
   vStream := TMemoryStream.Create;
+  vIdHTTP := TIdHTTP.Create(nil);
   try
     while (not bOK) and (iFlag < 3) do   // 尝试3次
       SafeDownFile(ASourceURL, ALocalFile);
@@ -438,6 +441,7 @@ begin
     Result := bOK;
   finally
     vStream.Free;
+    vIdHTTP.Free;
   end;
 end;
 
@@ -450,22 +454,23 @@ var
   ssResponse: TStringStream;
   bDone: Boolean;
   vJson: TCslJson;
+  vIdHTTP: TIdHTTP;
 begin
   Result := -1;
   postList := TStringList.Create;
   ssResponse := TStringStream.Create('');
+  vIdHTTP := TIdHTTP.Create(nil);
   try
     try
       for i := Low(AInFields) to High(AInFields) do
         postList.Add(Format('%s=%s', [AInFields[i], AInValues[i]]));
-
-      IdHTTP.Post(AURL, postList, ssResponse);
+      vIdHTTP.Post(AURL, postList, ssResponse);
       bDone := True;
     except
       bDone := False;
     end;
 
-    if (bDone) and (Pos('200 OK', IdHTTP.ResponseText) <> 0) then   // 网络已通
+    if (bDone) and (Pos('200 OK', vIdHTTP.ResponseText) <> 0) then   // 网络已通
     begin
       vJson := TCslJson.Create;
       try
@@ -527,6 +532,7 @@ begin
   finally
     postList.Free;
     ssResponse.Free;
+    vIdHTTP.Free;
   end;
 end;
 
@@ -606,12 +612,13 @@ begin
 end;
 
 function TPHPWeb.UpAttachment(AUperID, AWebID, ABillID, APhase: Integer; AFile,
-  ACategory, AMemo: string; var ANewFileName: string): Boolean;
+  ACategory, AMemo: string; var ANewFileName, AFileID: string): Boolean;
 var
   vMPFDS: TIdMultiPartFormDataStream;
   sResult, sURL: string;
   J: TCslJson;
   vArr: array of string;
+  vIdHTTP: TIdHTTP;
 begin
   Result := False;
 
@@ -622,9 +629,18 @@ begin
   end;
 
   vMPFDS := TIdMultiPartFormDataStream.Create;
+  vIdHTTP := TIdHTTP.Create(nil);
   try
     sURL := Format('%stender/attachment/%d/%d/upload', [FMeasureURL, AWebID, AUperID]);
-    vMPFDS.AddFile('upitem', AFile, 'text/plain');
+
+    // 如果文件已被打开,这里会报错。
+    try
+      vMPFDS.AddFile('upitem', AFile, 'text/plain');
+    except
+      MessageHint(0, '当前文件处于打开状态,请关闭文件,重新上传。');
+      Exit;
+    end;
+
     vMPFDS.AddFormField('itemid', IntToStr(ABillID));
     vMPFDS.AddFormField('category', ACategory);
     vMPFDS.AddFormField('memo', ReplaceCharsForJson(AMemo));
@@ -632,12 +648,13 @@ begin
 
     vMPFDS.Position := 0;
     try
-      sResult := IdHTTP.Post(sURL, vMPFDS);
+      sResult := vIdHTTP.Post(sURL, vMPFDS);
     except
       Abort;
     end;
   finally
     vMPFDS.Free;
+    vIdHTTP.Free;
   end;
 
   J := TCslJson.Create;
@@ -646,9 +663,10 @@ begin
     if SameText(J.Value['status'], 'true') then
     begin
       Result := True;
-      vArr := VarArrayOf(['onlinefilename']);
+      vArr := VarArrayOf(['onlinefilename', 'imnid']);
       J.ChildValues('iteminfo', vArr);
       ANewFileName := vArr[0];
+      AFileID := vArr[1];
     end
     else
     begin

+ 2 - 2
Dprs/CSL/Measure_Cloud.dof

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

+ 2 - 1
Dprs/CSL/Measure_Cloud.dpr

@@ -203,7 +203,8 @@ uses
   DealBillsExcelImport in '..\..\Units\DealBillsExcelImport.pas',
   ExcelImport_Bills in '..\..\Units\ExcelImport_Bills.pas',
   ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas',
-  UpFileSelectOnLineFrm in '..\..\Forms\UpFileSelectOnLineFrm.pas' {UpFileSelectOnLineForm};
+  UpFileSelectOnLineFrm in '..\..\Forms\UpFileSelectOnLineFrm.pas' {UpFileSelectOnLineForm},
+  ScReportHelperUnit in '..\..\..\SmartCost\Reports\UI\ScReportHelperUnit.pas';
 
 {$R *.res}
 

二进制
Dprs/CSL/Measure_Cloud.res


+ 2 - 2
Forms/LoginFrm.pas

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

+ 4 - 2
Forms/UpFileFrame.pas

@@ -127,7 +127,7 @@ begin
 end;
 
 procedure TUpFileView.btnUpClick(Sender: TObject);
-var sWebName, sPhase: string;
+var sWebName, sPhase, sID: string;
 begin
   Screen.Cursor := crHourGlass;
   try
@@ -145,11 +145,13 @@ begin
     if G_IsCloud then
     begin
       if PHPWeb.UpAttachment(PHPWeb.UserID, TProjectData(FProjectData).WebID, Data.BillID, Data.Phase,
-        Data.OrgFile, Data.Category, Data.Memo, sWebName) then
+        Data.OrgFile, Data.Category, Data.Memo, sWebName, sID) then
       begin
   //      TUpFileManageView(Owner).Rec.ValueByName('HasAttachment').AsBoolean := True;
         CopyFile(PChar(Data.OrgFile), PChar(Data.LocalFile), False);
         Data.Status := ufsNormal;
+        Data.ID := StrToInt(sID);
+        FrameClick(Sender);
       end
       else
       begin