ProjectManagerFme.pas 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784
  1. unit ProjectManagerFme;
  2. interface
  3. uses
  4. ProjectManagerDm, ZhAPI,
  5. NewProjectFrm,
  6. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7. Dialogs, ZjGridDBA, ZJGrid, ComCtrls, ToolWin, ActnList,
  8. dxBar, sdGridDBA, sdGridTreeDBA, sdIDTree, CslJson, ExtCtrls,
  9. StdCtrls, sdDB, CslButton, OrderCheckerFme, Contnrs;
  10. type
  11. TStrArr = array of string;
  12. TProjectManagerFrame = class(TFrame)
  13. ToolBar: TToolBar;
  14. tobtnOpen: TToolButton;
  15. zgProjects: TZJGrid;
  16. tobtnDelete: TToolButton;
  17. ActionList1: TActionList;
  18. actnOpen: TAction;
  19. actnDelete: TAction;
  20. dxpmProjectManager: TdxBarPopupMenu;
  21. actnReceiveProject: TAction;
  22. stdProjects: TsdGridTreeDBA;
  23. actnNewProject: TAction;
  24. actnNewSubProject: TAction;
  25. actnNewTender: TAction;
  26. pnlTenderProperty: TPanel;
  27. sdTenderProperty: TsdGridDBA;
  28. sprProperty: TSplitter;
  29. tobtnRenane: TToolButton;
  30. actnRename: TAction;
  31. tobtnImport: TToolButton;
  32. tobtnExport: TToolButton;
  33. actnImport: TAction;
  34. actnExport: TAction;
  35. tobtn1: TToolButton;
  36. pnlWeb: TPanel;
  37. pnlProject: TPanel;
  38. shp2: TShape;
  39. shp1: TShape;
  40. shp3: TShape;
  41. shp4: TShape;
  42. pnlTenderTitle: TPanel;
  43. lblBidName: TLabel;
  44. pnlShadow: TPanel;
  45. pnlProgress: TPanel;
  46. lblPeriodTotal: TLabel;
  47. lblPeriodState: TLabel;
  48. lblProgress: TLabel;
  49. lblPeriod: TLabel;
  50. pnlBelongProject: TPanel;
  51. lblBelongProject: TLabel;
  52. lblProjName: TLabel;
  53. lblLeftHalfBracket: TLabel;
  54. lblOnwerCompany: TLabel;
  55. lblOnwerName: TLabel;
  56. pnlProjectType: TPanel;
  57. lblProjectType: TLabel;
  58. lblWebProjCtgyName: TLabel;
  59. zgTenderProperty: TZJGrid;
  60. actnOpenBackupFolder: TAction;
  61. sbChecker: TScrollBox;
  62. procedure actnOpenExecute(Sender: TObject);
  63. procedure actnDeleteExecute(Sender: TObject);
  64. procedure zgProjectsMouseDown(Sender: TObject; Button: TMouseButton;
  65. Shift: TShiftState; X, Y: Integer);
  66. procedure actnReceiveProjectExecute(Sender: TObject);
  67. procedure actnNewProjectExecute(Sender: TObject);
  68. procedure actnNewSubProjectExecute(Sender: TObject);
  69. procedure actnNewTenderExecute(Sender: TObject);
  70. procedure zgProjectsDrawCellText(ACanvas: TCanvas; const ARect: TRect;
  71. const ACoord: TPoint; AGrid: TZJGrid; const Text: String;
  72. var ADefaultDraw: Boolean);
  73. procedure actnNewSubProjectUpdate(Sender: TObject);
  74. procedure actnNewTenderUpdate(Sender: TObject);
  75. procedure zgProjectsCurrentChanged(Sender: TObject; Col, Row: Integer);
  76. procedure actnSubmitProjectUpdate(Sender: TObject);
  77. procedure actnReplyProjectUpdate(Sender: TObject);
  78. procedure actnRenameExecute(Sender: TObject);
  79. procedure actnOpenUpdate(Sender: TObject);
  80. procedure actnImportExecute(Sender: TObject);
  81. procedure actnExportExecute(Sender: TObject);
  82. procedure actnDeleteUpdate(Sender: TObject);
  83. procedure actnOpenBackupFolderExecute(Sender: TObject);
  84. procedure actnRenameUpdate(Sender: TObject);
  85. procedure zgProjectsShowHint(var HintStr: String; var CanShow: Boolean;
  86. var HintInfo: THintInfo; const ACoord: TPoint);
  87. private
  88. FProjectManagerData: TProjectManagerData;
  89. // Chenshilong,2016.03.24
  90. // 这部分线上和本地一致,无需区分
  91. FID: Integer; // 本地标段文件ID
  92. FWebID: Integer; // 关联服务器用的ID(服务器有自己的ID体系)
  93. FWebAuthorID: Integer; // 编制人
  94. FWebOwnerID: Integer; // 业主
  95. // 本地存储值、线上存储值。线上修改后,需要同步到本地
  96. FWebMD5_Local: string; // 本地存储的MD5
  97. FWebMD5_OnLine: string; // 线上存储的最新的MD5(下同)
  98. FWebBidName_Local: string; // 标段名 (当无法同线上取得联系时,本地需要用到该名称来提示)
  99. FWebBidName_OnLine: string;
  100. FWebFolder_OnLine: string; // 这个命名不妥,但很直观。线上的项目名称、项目类型概念跟本地颠倒,很混乱。
  101. FWebSubFolder_OnLine: string;
  102. FWebOwnerCompany: string;
  103. FWebOwnerRole: string;
  104. FWebOwnerName: string;
  105. FWebCheckStatusMy: TCheckStatus; // 登陆用户在当前项目中的工作状态。
  106. FWebCheckStatusProject: TCheckStatus; // 项目的审核状态。
  107. FOnLineCheckerBegin: Integer; // 线上审批的起始人。 010110111 起7止9。 0101101110 起0止0。
  108. FOnLineCheckerEnd: Integer; // 线上审批的截止人。
  109. FPhaseTotal: Integer;
  110. FPhaseNo: Integer;
  111. FCurPos: Integer; // 用来控制审核人的添加位置
  112. FCheckerList: TObjectList;
  113. function ReceiveFile(const AFileName: string; AFileMD5: string = ''; ANeedLock: Boolean = False): Boolean;
  114. function ImportFile(const AFileName: string; AFileMD5: string = ''): Boolean;
  115. procedure ConnectButtonWithAction;
  116. function GetImportProjectName(const AFileName: string; AParent: TsdIDTreeNode): string;
  117. function IsProject(ANode: TsdIDTreeNode): Boolean;
  118. function IsLeafProject(ANode: TsdIDTreeNode): Boolean;
  119. function IsUnEmptyLeafProject(ANode: TsdIDTreeNode): Boolean;
  120. function CheckOpened(ANode: TsdIDTreeNode): Boolean;
  121. procedure SetPropertyVisible(AVisible: Boolean);
  122. procedure ShowProjectInfoTopAndCheckers;
  123. // 网络上的目录结构,本地有则定位,没有则创建。
  124. procedure CheckWebFolders(AFolderID, ASubFolderID: Integer;
  125. AFolderName, ASubFolderName: string);
  126. // ANewBidName: 项目的最新标段名(取自服务器,有人改名了,本地的就变成旧的)
  127. procedure CheckBidName(AID: Integer; ANewBidName: string); overload;
  128. procedure CheckBidName(AUserID, AWebID: Integer; ANewBidName: string); overload;
  129. procedure ClearLocalValues;
  130. procedure GetLocalValues(ARec: TsdDataRecord); overload;
  131. // 用户ID、网络标段ID、Type=1可以定位一个标段。
  132. procedure GetLocalValues(AUserID, AWebID: Integer); overload;
  133. // 1 等待我审核的标段文件; 2 我参与的全部标段文件
  134. procedure DoBatchReceiveOnline(ARequestType: Integer);
  135. function LocalMD5(AUserID, AWebID: Integer): string;
  136. procedure BubbleSortProjects;
  137. // AReceiveKind: 1 接收; 2 导入
  138. function FileDownAndReceive(ADownURL: string; AReceiveKind: Integer): Boolean;
  139. // 线上审批的起止人
  140. procedure OnLineChecker(AAr: TOVArr; var ABegin, AEnd: Integer);
  141. public
  142. constructor Create(AOwner: TComponent); override;
  143. destructor Destroy; override;
  144. procedure DoBatchReceiveAllOnline;
  145. // AType: -2 繁忙; -1 正常读取; 0 第0期; 1 第1期。
  146. procedure ShowProjectInfoTop(AType: Integer = -1);
  147. function Rec(AProjectID: Integer): TsdDataRecord;
  148. function CurRec: TsdDataRecord;
  149. function CurRecAttachmentPath: string;
  150. function AttachmentFileCountsWithoutManageFile(ANode: TsdIDTreeNode): Integer;
  151. property ProjectCheckStatus: TCheckStatus read FWebCheckStatusProject;
  152. end;
  153. implementation
  154. uses
  155. MainFrm, UtilMethods, ProjectCommands, Globals, ConfigDoc, ConstUnit,
  156. WebNewTenderFrm, PHPWebDm, Math, mProgressFrm, ProgressHintFrm,
  157. ShellAPI;
  158. {$R *.dfm}
  159. procedure TProjectManagerFrame.ConnectButtonWithAction;
  160. begin
  161. SetDxBtnAction(actnNewProject, MainForm.dxbtnNewProject);
  162. SetDxBtnAction(actnNewSubProject, MainForm.dxbtnNewSubProject);
  163. SetDxBtnAction(actnNewTender, MainForm.dxbtnNewTender);
  164. SetDxBtnAction(actnOpen, MainForm.dxbtnOpenProject);
  165. SetDxBtnAction(actnDelete, MainForm.dxbtnDeleteProject);
  166. SetDxBtnAction(actnReceiveProject, MainForm.dxbtnReceiveProject);
  167. SetDxBtnAction(actnOpenBackupFolder, MainForm.dxbtnOpenBackupFolder);
  168. SetDxBtnAction(actnRename, MainForm.dxbtnRename);
  169. end;
  170. constructor TProjectManagerFrame.Create(AOwner: TComponent);
  171. begin
  172. inherited;
  173. FCheckerList := TObjectList.Create;
  174. FProjectManagerData := ProjectManager;
  175. FProjectManagerData.Open;
  176. stdProjects.IDTree := FProjectManagerData.ProjectsTree;
  177. sdTenderProperty.DataView := FProjectManagerData.sdvTenderProperty;
  178. ConnectButtonWithAction;
  179. SetPropertyVisible(False);
  180. sbChecker.Height := 0;
  181. if G_IsCloud then
  182. begin
  183. Application.HintPause := 200;
  184. Application.HintHidePause := 60000;
  185. tobtnImport.Visible := False;
  186. stdProjects.TreeOptions := stdProjects.TreeOptions - [aoAllowUpLevel, aoAllowDownLevel];
  187. stdProjects.Options := stdProjects.Options - [aoAllowUpMove, aoAllowDownMove];
  188. CreateProgress('正在从云端下载新项目');
  189. try
  190. actnReceiveProject.Execute;
  191. finally
  192. CloseProgress;
  193. end;
  194. end;
  195. end;
  196. function SearchFileOnline(AURL: string; var ADownURL, AFolder, ASubFolder, ABidName, AMD5Web, AError: string;
  197. var AFolderID, ASubFolderID: Integer): Integer;
  198. var vArr: TOVArr;
  199. begin
  200. Result := PHPWeb.Search(AURL, [''], [''], vArr);
  201. AError := '';
  202. if Result = 1 then
  203. begin
  204. if High(vArr) >= 0 then
  205. begin
  206. ADownURL := vArr[0, 0];
  207. AFolder := vArr[0, 2];
  208. ASubFolder := vArr[0, 3];
  209. AMD5Web := vArr[0, 1];
  210. AFolderID := StrToInt(vArr[0, 4]);
  211. ASubFolderID := StrToInt(vArr[0, 5]);
  212. ABidName := vArr[0, 6];
  213. end
  214. else
  215. Result := 10; // 返回10,表示无记录。用这个数字代表是否觉得怪异?没办法,0被占用了。
  216. end
  217. else if Result = 0 then
  218. AError := PHPWeb.PageError('标段更新数据失败')
  219. else if Result = -1 then
  220. AError := PHPWeb.NetError('标段更新数据失败');
  221. end;
  222. // 双击打开项目 TagB
  223. procedure TProjectManagerFrame.actnOpenExecute(Sender: TObject);
  224. var
  225. vSel: TsdIDTreeNode;
  226. vRec: TsdDataRecord;
  227. sHint: string;
  228. function CanOpen: Boolean;
  229. var
  230. sSearchURL, sDownURL,
  231. sMD5_UnLock, sError, sLocalFile: string;
  232. iSearch, iFolderID, iSubFolderID: Integer;
  233. function HasWebBidInfo(AWebID: Integer): Boolean;
  234. var vArr: array of string;
  235. iResult: Integer;
  236. begin
  237. sSearchURL := Format('%stender/get/%d/exist', [PHPWeb.MeasureURL, AWebID]);
  238. vArr := VarArrayOf(['id', 'name']);
  239. iResult := PHPWeb.Search(sSearchURL, [''], [''], vArr);
  240. if (iResult = 1) and (High(vArr) >= 0) then
  241. Result := True
  242. else
  243. Result := False;
  244. end;
  245. begin
  246. Result := False;
  247. // 先按正常接口找到最新的MD5码看是否需要更新
  248. sSearchURL := Format('%stender/get/%d/update', [PHPWeb.MeasureURL, FWebID]);
  249. iSearch := SearchFileOnline(sSearchURL, sDownURL, FWebFolder_OnLine, FWebSubFolder_OnLine, FWebBidName_OnLine, FWebMD5_OnLine, sError, iFolderID, iSubFolderID);
  250. if iSearch = 1 then
  251. begin
  252. try
  253. CheckWebFolders(iFolderID, iSubFolderID, FWebFolder_OnLine, FWebSubFolder_OnLine);
  254. CheckBidName(FID, FWebBidName_OnLine);
  255. finally
  256. if vSel <> nil then
  257. vSel.LocateInControl;
  258. end;
  259. // 打开前一定要先下载最新的标段文件(无论审核有没有通过)
  260. if FWebMD5_OnLine <> FWebMD5_Local then
  261. if not FileDownAndReceive(sDownURL, 1) then Exit;
  262. // 编制人且项目末通过
  263. if (FWebAuthorID = PHPWeb.UserID) and (FWebCheckStatusProject = csNotPass) then
  264. begin
  265. sHint := '本期计量审批不通过,你现在可以:' + #10#13 + '点击【是(Y)】重新开始本期计量,软件将打开本期上报时的数据,开始重新计量;' +
  266. #10#13 +'点击【否(N)】查看不通过计量,软件将打开本期最后审批的数据,重新打开标段' + '可再次打开本确认窗口。';
  267. if Application.MessageBox(PChar(sHint), '询问', MB_YESNO + MB_ICONQUESTION) = ID_Yes then
  268. begin
  269. sSearchURL := Format('%suser/create/%d/%d/new/audit', [PHPWeb.MeasureURL, FWebID, FPhaseNo]);
  270. case SearchFileOnline(sSearchURL, sDownURL, FWebFolder_OnLine, FWebSubFolder_OnLine, FWebBidName_OnLine, sMD5_UnLock, sError, iFolderID, iSubFolderID) of
  271. 1:
  272. begin
  273. if not FileDownAndReceive(sDownURL, 2) then Exit;
  274. end;
  275. 0, -1:
  276. begin
  277. sHint := sError + '(因网络出错,无法连接到云端以获取本期原报上传的无锁文件,无法重新开始本期,本次操作已取消。请重试。';
  278. Application.MessageBox(PChar(sHint), '警告', MB_OK + MB_ICONWARNING);
  279. Exit;
  280. end;
  281. end;
  282. end;
  283. end;
  284. end
  285. else if (iSearch = 10) then
  286. begin
  287. if not HasWebBidInfo(FWebID) then
  288. begin
  289. sHint :='该项目[' + FWebBidName_Local + ']在云端已被删除,点击"确定"后,可手动删除该项目。';
  290. Application.MessageBox(PChar(sHint), '提示', MB_OK + MB_ICONINFORMATION);
  291. Exit;
  292. end;
  293. end
  294. else if (iSearch = 0) or (iSearch = -1) then
  295. begin
  296. sHint := sError + '(因网络出错,无法检测[' + FWebBidName_Local + ']在云端是否有更新,本次操作已取消,请重试)。';
  297. Application.MessageBox(PChar(sHint), '警告', MB_OK + MB_ICONWARNING);
  298. Exit;
  299. end;
  300. Result := True;
  301. end;
  302. begin
  303. // 打开前先下载更新
  304. Screen.Cursor := crHourGlass;
  305. try
  306. vSel := stdProjects.IDTree.Selected;
  307. vRec := vSel.Rec;
  308. if G_IsCloud then
  309. begin
  310. GetLocalValues(CurRec);
  311. // 以下这段已经包含在MainForm.OpenProject(vRec)中了,但在调用这句之前,网络版要提前用一下。
  312. if MainForm.HasOpened(FID) then
  313. begin
  314. MainForm.LocateProject(FID);
  315. Exit;
  316. end;
  317. if not CanOpen then
  318. Exit;
  319. end;
  320. MainForm.OpenProject(vRec);
  321. if G_IsCloud then
  322. begin
  323. if not MainForm.CurProjectFrame.CheckFileAndCloudChekerList then
  324. begin
  325. sHint := '项目校验:“' + FWebBidName_OnLine + '”文件中的审核人和云端的审核人不一致,' +
  326. '禁止继续操作,项目即将关闭!请删除本地项目重新从云端获取,' +
  327. '重新获取后如果仍然存在同样的问题,请联系纵横服务人员以寻求帮助。';
  328. Application.MessageBox(PChar(sHint), '文件错误', MB_OK +MB_ICONWARNING);
  329. MainForm.actnCloseProject.Execute;
  330. Exit;
  331. end;
  332. end;
  333. finally
  334. Screen.Cursor := crDefault;
  335. end;
  336. end;
  337. procedure TProjectManagerFrame.actnDeleteExecute(Sender: TObject);
  338. begin
  339. if stdProjects.IDTree.Count = 0 then Exit;
  340. with stdProjects.IDTree.Selected.Rec do
  341. if QuestMessage(Format('确定要删除[%s]吗?', [ValueByName('Name').AsString])) then
  342. begin
  343. Screen.Cursor := crHourGlass;
  344. try
  345. FProjectManagerData.Delete;
  346. finally
  347. Screen.Cursor := crDefault;
  348. end;
  349. end;
  350. end;
  351. procedure TProjectManagerFrame.zgProjectsMouseDown(Sender: TObject;
  352. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  353. begin
  354. if Button = mbRight then
  355. dxpmProjectManager.PopupFromCursorPos
  356. else if (zgProjects.CurCol = 1) and (Button = mbLeft) and (ssDouble in Shift)
  357. and Assigned(stdProjects.IDTree.Selected) then
  358. begin
  359. if IsProject(stdProjects.IDTree.Selected) then
  360. stdProjects.IDTree.Selected.Expand
  361. else
  362. actnOpen.Execute;
  363. end;
  364. end;
  365. function TProjectManagerFrame.ReceiveFile(const AFileName: string; AFileMD5: string;
  366. ANeedLock: Boolean): Boolean;
  367. var
  368. Recevier: TReceiveProject;
  369. vNode: TsdIDTreeNode;
  370. begin
  371. Result := False;
  372. Recevier := TReceiveProject.Create(stdProjects.IDTree.Selected);
  373. try
  374. try
  375. if G_IsCloud then
  376. Recevier.Lock := ANeedLock;
  377. ProjectManager.RefreshSeedID;
  378. vNode := Recevier.Receive(AFileName);
  379. if G_IsCloud then
  380. begin
  381. vNode.Rec.BeginUpdate;
  382. vNode.Rec.ValueByName('WebMD5').AsString := AFileMD5;
  383. vNode.Rec.ValueByName('WebUserID').AsInteger := PHPWeb.UserID;
  384. vNode.Rec.EndUpdate;
  385. end;
  386. Result := True;
  387. except
  388. Result := False;
  389. end;
  390. finally
  391. case Recevier.MessageID of
  392. 0: vNode.LocateInControl;
  393. 1: ErrorMessage('当前标段处于打开状态,未能成功接收,请先关闭标段再次接收。');
  394. 2: ErrorMessage('下载数据与审核状态不一致,未能成功接收,请再次接收。');
  395. 3: ErrorMessage('升级数据失败,未能成功接收,请再次接收。');
  396. end;
  397. Recevier.Free;
  398. FProjectManagerData.Save;
  399. end;
  400. end;
  401. // 登录后自动扫描等待我审核的项目 TagC
  402. procedure TProjectManagerFrame.actnReceiveProjectExecute(Sender: TObject);
  403. procedure DoReceiveLocal;
  404. var
  405. sFileName: string;
  406. begin
  407. if SelectFile(sFileName, '.rmf;*.arf') then
  408. begin
  409. ShowProgressHint('正在接收项目并升级数据');
  410. try
  411. ReceiveFile(sFileName);
  412. finally
  413. CloseProgressHint;
  414. end;
  415. end;
  416. end;
  417. var OnCC: TZjCellNotifyEvent;
  418. begin
  419. Screen.Cursor := crHourGlass;
  420. try
  421. if G_IsCloud then
  422. begin
  423. OnCC := zgProjects.OnCurrentChanged;
  424. try
  425. zgProjects.OnCurrentChanged := nil;
  426. DoBatchReceiveOnline(1);
  427. if stdProjects.IDTree.FirstNode <> nil then
  428. stdProjects.IDTree.FirstNode.LocateInControl;
  429. finally
  430. zgProjects.OnCurrentChanged := OnCC;
  431. end;
  432. end
  433. else
  434. DoReceiveLocal;
  435. finally
  436. Screen.Cursor := crDefault;
  437. end;
  438. end;
  439. function TProjectManagerFrame.GetImportProjectName(
  440. const AFileName: string; AParent: TsdIDTreeNode): string;
  441. begin
  442. Result := ExtractSimpleFileName(AFileName);
  443. while FProjectManagerData.ExistProject(Result, AParent) do
  444. if not InputNewProjectName(Result, '导入', AParent) then Abort;
  445. end;
  446. procedure TProjectManagerFrame.actnNewProjectExecute(Sender: TObject);
  447. var
  448. sName: string;
  449. begin
  450. if G_IsCloud then Exit; // 云版线上与本地要保持同步,不允许本地新建
  451. if InputNewProjectName(sName, '新建', stdProjects.IDTree.Selected) then
  452. FProjectManagerData.InsertProject(sName, stdProjects.IDTree.Selected);
  453. end;
  454. procedure TProjectManagerFrame.actnNewSubProjectExecute(Sender: TObject);
  455. var
  456. sName: string;
  457. begin
  458. if G_IsCloud then Exit;
  459. if InputNewProjectName(sName, '新建', stdProjects.IDTree.Selected) then
  460. FProjectManagerData.InsertSubProject(sName, stdProjects.IDTree.Selected);
  461. end;
  462. procedure TProjectManagerFrame.actnNewTenderExecute(Sender: TObject);
  463. function AddAndOpenTender(const ATenderName: string): TsdIDTreeNode;
  464. begin
  465. Result := FProjectManagerData.InsertTender(ATenderName, stdProjects.IDTree.Selected);
  466. MainForm.OpenProject(Result.Rec);
  467. end;
  468. // 网络版新建标段 TagD
  469. procedure NewProjectWithOnline;
  470. var
  471. WebNewTenderForm: TWebNewTenderForm;
  472. sName, sKey, sURL: string;
  473. stnNew: TsdIDTreeNode;
  474. iID, iFolderID, iSubFolderID: Integer;
  475. vRec: TsdDataRecord;
  476. vArr: array of string;
  477. begin
  478. WebNewTenderForm := TWebNewTenderForm.Create(nil);
  479. try
  480. WebNewTenderForm.ShowModal;
  481. if WebNewTenderForm.ModalResult = mrOK then
  482. begin
  483. sKey := WebNewTenderForm.edtKey.Text;
  484. sName := WebNewTenderForm.edtTenderName.Text;
  485. // 同服务器取得联系
  486. iID := -1;
  487. vArr := VarArrayOf(['catid', 'name', 'company', 'phone', 'mobile', 'qq',
  488. 'pname', 'ptype', 'jobs', 'avatar', 'ownuid', 'pnameid', 'ptypeid']);
  489. sURL := Format('%s%d/%s/%s/creatmeasure', [PHPWeb.MeasureURL, PHPWeb.UserID, sName, sKey]); // AnsiToUtf8(sName)
  490. case PHPWeb.Search(sURL, [], [], vArr) of
  491. 1:
  492. begin
  493. iID := StrToInt(vArr[0]);
  494. iFolderID := StrToInt(vArr[11]);
  495. iSubFolderID := StrToInt(vArr[12]);
  496. CheckWebFolders(iFolderID, iSubFolderID, vArr[6], vArr[7]);
  497. end;
  498. 0:
  499. begin
  500. Application.MessageBox(PChar(PHPWeb.PageError('创建标段失败' + '[' + vArr[0] + ']')),
  501. '警告', MB_OK + MB_ICONWARNING);
  502. Exit;
  503. end;
  504. -1:
  505. begin
  506. Application.MessageBox(PChar(PHPWeb.NetError('创建标段失败')),
  507. '警告', MB_OK + MB_ICONWARNING);
  508. Exit;
  509. end;
  510. end;
  511. // 本地创建
  512. stnNew := FProjectManagerData.InsertTender(sName, stdProjects.IDTree.Selected);
  513. // 这里把Web获取的信息存储到项目管理里面。
  514. vRec := stnNew.Rec;
  515. vRec.BeginUpdate;
  516. vRec.ValueByName('WebID').AsInteger := iID;
  517. vRec.ValueByName('WebOwnerID').AsInteger := StrToInt(vArr[10]); // 业主
  518. vRec.ValueByName('WebAuthorID').AsInteger := PHPWeb.UserID; // 编制人
  519. vRec.ValueByName('WebUserID').AsInteger := PHPWeb.UserID; // 当前用户,用于只显示自己的项目
  520. vRec.ValueByName('WebKey').AsString := sKey;
  521. vRec.EndUpdate;
  522. GetLocalValues(vRec);
  523. FWebOwnerName := vArr[1];
  524. FWebOwnerCompany := vArr[2];
  525. FWebOwnerRole := vArr[8];
  526. FWebFolder_OnLine := vArr[6];
  527. FWebSubFolder_OnLine := vArr[7];
  528. // WebOwnerImage := vArr[9];
  529. // WebOwnerPhone := vArr[3];
  530. // WebOwnerMobile := vArr[4];
  531. // WebOwnerQQ := vArr[5];
  532. ShowProjectInfoTop(0);
  533. FProjectManagerData.Save;
  534. MainForm.OpenProject(vRec);
  535. end;
  536. finally
  537. WebNewTenderForm.Free;
  538. end;
  539. end;
  540. procedure NewProject;
  541. var
  542. sName: string;
  543. begin
  544. if InputNewProjectName(sName, '新建', stdProjects.IDTree.Selected) then
  545. AddAndOpenTender(sName);
  546. end;
  547. begin
  548. if G_IsCloud then
  549. NewProjectWithOnline
  550. else
  551. NewProject;
  552. end;
  553. procedure TProjectManagerFrame.zgProjectsDrawCellText(ACanvas: TCanvas;
  554. const ARect: TRect; const ACoord: TPoint; AGrid: TZJGrid;
  555. const Text: String; var ADefaultDraw: Boolean);
  556. procedure GetBitmap(AImage: TBitmap);
  557. begin
  558. with stdProjects.IDTree.Items[ACoord.Y - 1] do
  559. if Rec.ValueByName('Type').AsInteger = 0 then
  560. if Expanded and HasChildren then
  561. MainForm.Images.GetBitmap(34, AImage)
  562. else
  563. MainForm.Images.GetBitmap(34, AImage)
  564. else
  565. MainForm.Images.GetBitmap(11, AImage);
  566. end;
  567. const
  568. rIconWidth = 16;
  569. rIconHeight = 16;
  570. var
  571. Img: TBitmap;
  572. Cell: TZjCell;
  573. rImg: TRect;
  574. begin
  575. if (ACoord.X = 1) and (ACoord.Y > zgProjects.FixedRowCount - 1) then
  576. begin
  577. Cell := zgProjects.Cells[ACoord.X, ACoord.Y];
  578. Img := TBitmap.Create;
  579. try
  580. GetBitmap(Img);
  581. case Cell.Align of
  582. gaTopLeft, gaTopCenter, gaTopRight:
  583. rImg := Rect(ARect.Left + 2, ARect.Top, ARect.Left + rIconWidth, ARect.Top + rIconHeight);
  584. gaCenterLeft, gaCenterCenter, gaCenterRight:
  585. rImg := Rect(ARect.Left + 2, ARect.Top + (ARect.Bottom - ARect.Top - rIconHeight) div 2, ARect.Left + rIconWidth, ARect.Bottom - (ARect.Bottom - ARect.Top - rIconHeight) div 2);
  586. gaBottomLeft, gaBottomCenter, gaBottomRight:
  587. rImg := Rect(ARect.Left + 2, ARect.Bottom - rIconHeight, ARect.Left + rIconWidth, ARect.Bottom);
  588. end;
  589. ACanvas.StretchDraw(rImg, Img);
  590. WriteText(ACanvas, Rect(ARect.Left + rIconWidth, ARect.Top, ARect.Right, ARect.Bottom)
  591. , 2, 2, Text, Cell.Align, False);
  592. ADefaultDraw := False;
  593. finally
  594. Img.Free;
  595. end;
  596. end;
  597. end;
  598. procedure TProjectManagerFrame.actnNewSubProjectUpdate(Sender: TObject);
  599. begin
  600. TAction(Sender).Enabled := Assigned(stdProjects.IDTree.Selected)
  601. and IsProject(stdProjects.IDTree.Selected)
  602. and (not IsUnEmptyLeafProject(stdProjects.IDTree.Selected));
  603. end;
  604. procedure TProjectManagerFrame.actnNewTenderUpdate(Sender: TObject);
  605. var bCloud: Boolean;
  606. vNode: TsdIDTreeNode;
  607. begin
  608. bCloud := G_IsCloud;
  609. // 只有编制人才能创建新标段?逻辑先后有问题:编制人是在创建标段之后产生的。
  610. // 创建前,当前用户只是一个帐户,它是不是编制人末知,因为它还可以是其它角色。
  611. // 同一帐户在不同的标段可以作为不同的角色。
  612. if bCloud then
  613. begin
  614. TAction(Sender).Enabled := True;
  615. end
  616. else
  617. begin
  618. vNode := stdProjects.IDTree.Selected;
  619. TAction(Sender).Enabled := Assigned(vNode) and IsProject(vNode) and IsLeafProject(vNode);
  620. end;
  621. end;
  622. function TProjectManagerFrame.IsLeafProject(ANode: TsdIDTreeNode): Boolean;
  623. begin
  624. if ANode.HasChildren then
  625. Result := ANode.FirstChild.Rec.ValueByName('Type').AsInteger = 1
  626. else
  627. Result := ANode.Rec.ValueByName('Type').AsInteger = 0;
  628. end;
  629. function TProjectManagerFrame.IsProject(ANode: TsdIDTreeNode): Boolean;
  630. begin
  631. Result := ANode.Rec.ValueByName('Type').AsInteger = 0;
  632. end;
  633. function TProjectManagerFrame.IsUnEmptyLeafProject(
  634. ANode: TsdIDTreeNode): Boolean;
  635. begin
  636. Result := ANode.HasChildren and (ANode.Rec.ValueByName('Type').AsInteger = 1);
  637. end;
  638. procedure TProjectManagerFrame.SetPropertyVisible(AVisible: Boolean);
  639. begin
  640. // 单击刷新项目信息 TagA
  641. if G_IsCloud then
  642. begin
  643. if CurRec = nil then Exit;
  644. pnlTenderProperty.Visible := False;
  645. pnlWeb.Visible := AVisible;
  646. if AVisible then
  647. begin
  648. CreateProgress('云端读取项目信息');
  649. try
  650. ShowProjectInfoTopAndCheckers;
  651. finally
  652. CloseProgress;
  653. end;
  654. end;
  655. end
  656. else
  657. begin
  658. pnlWeb.Visible := False;
  659. pnlTenderProperty.Visible := AVisible;
  660. sprProperty.Visible := AVisible;
  661. end;
  662. end;
  663. procedure TProjectManagerFrame.zgProjectsCurrentChanged(Sender: TObject;
  664. Col, Row: Integer);
  665. begin
  666. if G_IsCloud then
  667. begin
  668. if CurRec <> nil then
  669. begin
  670. // 加这句后产生Bug:上报项目后,记录不曾移动,FID不变,不会刷新
  671. // if FID <> CurRec.ValueByName('ID').AsInteger then
  672. SetPropertyVisible(CurRec.ValueByName('Type').AsInteger = 1);
  673. // OnCurrentChanged取得的 CurRec.ValueByName() 值并不总是可靠,这里加保险。
  674. // 如调用locateInControl后,执行到这里取得的CurRec.ValueByName('ID')值还是上一条的。
  675. if (CurRec.ValueByName('Type').AsInteger = 1) and (not pnlWeb.Visible) then
  676. pnlWeb.Visible := True;
  677. end;
  678. end;
  679. end;
  680. procedure TProjectManagerFrame.actnSubmitProjectUpdate(Sender: TObject);
  681. begin
  682. TAction(Sender).Enabled := Assigned(stdProjects.IDTree.Selected)
  683. and (stdProjects.IDTree.Selected.Rec.ValueByName('Type').AsInteger = 1)
  684. and (stdProjects.IDTree.Selected.Rec.ValueByName('AuditStatus').AsInteger < iMaxStageCount-1);
  685. end;
  686. procedure TProjectManagerFrame.actnReplyProjectUpdate(Sender: TObject);
  687. begin
  688. TAction(Sender).Enabled := Assigned(stdProjects.IDTree.Selected)
  689. and (stdProjects.IDTree.Selected.Rec.ValueByName('Type').AsInteger = 1);
  690. end;
  691. procedure TProjectManagerFrame.actnRenameExecute(Sender: TObject);
  692. function CanRename(ARec: TsdDataRecord; const ANewName: string): Boolean;
  693. var
  694. sURL: string;
  695. iRename: Integer;
  696. vArr: array of string;
  697. begin
  698. Result := True;
  699. if not G_IsCloud then Exit;
  700. // 云版 重命名须确保同步服务器
  701. sURL := Format('%stender/%d/%s/update', [PHPWeb.MeasureURL, ARec.ValueByName('WebID').AsInteger, ANewName]);
  702. iRename := PHPWeb.Search(sURL, [], [], vArr);
  703. Result := iRename = 1;
  704. case iRename of
  705. 1: ShowMessage('新的标段名称已同步到服务器!');
  706. 0: Application.MessageBox(PChar(PHPWeb.PageError('重命名同步到云端失败' + '[' + vArr[0] + ']')),
  707. '警告', MB_OK + MB_ICONWARNING);
  708. -1: Application.MessageBox(PChar(PHPWeb.NetError('重命名同步到云端失败')),
  709. '警告', MB_OK + MB_ICONWARNING);
  710. end;
  711. end;
  712. var
  713. stnNode: TsdIDTreeNode;
  714. sName: string;
  715. begin
  716. stnNode := stdProjects.IDTree.Selected;
  717. sName := stnNode.Rec.ValueByName('Name').AsString;
  718. if not Assigned(OpenProjectManager.FindProjectData(stnNode.ID)) then
  719. begin
  720. if InputNewProjectName(sName, '重命名', stnNode.Parent, stnNode.ID) then
  721. begin
  722. if CanRename(stnNode.Rec, sName) then
  723. begin
  724. stnNode.Rec.ValueByName('Name').AsString := sName;
  725. ProjectManager.Save;
  726. end;
  727. end;
  728. end
  729. else
  730. ErrorMessage(Format('项目[%s]已经打开,无法重命名!', [sName]));
  731. end;
  732. procedure TProjectManagerFrame.actnOpenUpdate(Sender: TObject);
  733. begin
  734. TAction(Sender).Enabled := Assigned(stdProjects.IDTree.Selected)
  735. and (stdProjects.IDTree.Selected.Rec.ValueByName('Type').AsInteger = 1);
  736. end;
  737. procedure TProjectManagerFrame.actnImportExecute(Sender: TObject);
  738. procedure ImportTender(const AFileName, AProjectName: string);
  739. var
  740. Importor: TTenderImport;
  741. begin
  742. Importor := TTenderImport.Create(stdProjects.IDTree.Selected,
  743. AProjectName, AFileName);
  744. try
  745. Importor.Execute;
  746. finally
  747. Importor.Free;
  748. end;
  749. end;
  750. procedure ImportProject(const AFileName, AProjectName: string);
  751. var
  752. Importor: TProjectImport;
  753. begin
  754. Importor := TProjectImport.Create(stdProjects.IDTree.Selected,
  755. AProjectName, AFileName);
  756. try
  757. Importor.Execute;
  758. finally
  759. Importor.Free;
  760. end;
  761. end;
  762. var
  763. sFileName, sProjectName: string;
  764. begin
  765. if SelectFile(sFileName, '.mtf;*.mpf') then
  766. begin
  767. if SameText(ExtractFileExt(sFileName), '.mtf')
  768. and (stdProjects.IDTree.Selected.Rec.ValueByName('Type').AsInteger = 0) then
  769. sProjectName := GetImportProjectName(sFileName, stdProjects.IDTree.Selected)
  770. else
  771. sProjectName := GetImportProjectName(sFileName, stdProjects.IDTree.Selected.Parent);
  772. Screen.Cursor := crHourGlass;
  773. try
  774. if SameText(ExtractFileExt(sFileName), '.mtf') then
  775. ImportTender(sFileName, sProjectName)
  776. else
  777. ImportProject(sFileName, sProjectName);
  778. finally
  779. Screen.Cursor := crDefault;
  780. end;
  781. end;
  782. FProjectManagerData.Save;
  783. end;
  784. procedure TProjectManagerFrame.actnExportExecute(Sender: TObject);
  785. procedure ExportTender(ANode: TsdIDTreeNode);
  786. var
  787. Exportor: TTenderExport;
  788. sFileName, sHint: string;
  789. bExpAtch: Boolean;
  790. iCount: Integer;
  791. begin
  792. bExpAtch := False;
  793. sFileName := SupportManager.ConfigInfo.OutputPath + ANode.Rec.ValueByName('Name').AsString + '.mtf';
  794. if SaveFile(sFileName, '.mtf') then
  795. begin
  796. if FileExists(sFileName) and not QuestMessage(Format('存在同名文件“%s”,是否替换?', [ExtractFileName(sFileName)])) then
  797. Exit;
  798. Screen.Cursor := crHourGlass;
  799. try
  800. Exportor := TTenderExport.Create(ANode.Rec, sFileName);
  801. try
  802. { if not G_IsCloud then
  803. begin
  804. iCount := FileCount(CurRecAttachmentPath);
  805. if iCount > 1 then // 排除管理文件库
  806. begin
  807. sHint := Format('本标段包含 %d 个附件,是否将附件一起导出?', [iCount - 1]);
  808. bExpAtch := Application.MessageBox(PChar(sHint), '询问', MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2) = ID_Yes;
  809. end;
  810. end; } // FFFFF
  811. Exportor.Execute(bExpAtch);
  812. finally
  813. Exportor.Free;
  814. end;
  815. finally
  816. Screen.Cursor := crDefault;
  817. end;
  818. end;
  819. end;
  820. procedure ExportProject(ANode: TsdIDTreeNode);
  821. var
  822. Exportor: TProjectExport;
  823. sFileName, sHint: string;
  824. bExpAtch: Boolean;
  825. iCount: Integer;
  826. begin
  827. sFileName := SupportManager.ConfigInfo.OutputPath + ANode.Rec.ValueByName('Name').AsString + '.mpf';
  828. if SaveFile(sFileName, '.mpf') then
  829. begin
  830. if FileExists(sFileName) and not QuestMessage(Format('存在同名文件“%s”,是否替换?', [ExtractFileName(sFileName)])) then
  831. Exit;
  832. Screen.Cursor := crHourGlass;
  833. try
  834. bExpAtch := False;
  835. { if not G_IsCloud then
  836. begin
  837. iCount := AttachmentFileCountsWithoutManageFile(ANode);
  838. if iCount > 0 then
  839. begin
  840. sHint := Format('本建设项目共包含 %d 个附件,是否将附件一起导出?', [iCount]);
  841. bExpAtch := Application.MessageBox(PChar(sHint), '询问', MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2) = ID_Yes;
  842. end;
  843. end; } // FFFFF
  844. Exportor := TProjectExport.Create(ANode, sFileName, bExpAtch);
  845. try
  846. Exportor.Execute;
  847. finally
  848. Exportor.Free;
  849. end;
  850. finally
  851. Screen.Cursor := crDefault;
  852. end;
  853. end;
  854. end;
  855. var
  856. stnNode: TsdIDTreeNode;
  857. begin
  858. stnNode := stdProjects.IDTree.Selected;
  859. if stnNode.Rec.ValueByName('Type').AsInteger = 1 then
  860. begin
  861. ExportTender(stnNode);
  862. end
  863. else
  864. ExportProject(stnNode);
  865. end;
  866. procedure TProjectManagerFrame.actnDeleteUpdate(Sender: TObject);
  867. begin
  868. if Assigned(stdProjects.IDTree.Selected) then
  869. TAction(Sender).Enabled := not CheckOpened(stdProjects.IDTree.Selected);
  870. end;
  871. function TProjectManagerFrame.CheckOpened(ANode: TsdIDTreeNode): Boolean;
  872. var
  873. iChild: Integer;
  874. begin
  875. Result := False;
  876. if ANode.Rec.ValueByName('Type').AsInteger = 1 then
  877. Result := OpenProjectManager.ProjectIndex(ANode.ID) > -1
  878. else
  879. begin
  880. if not ANode.HasChildren then
  881. Result := False
  882. else
  883. begin
  884. for iChild := 0 to ANode.ChildCount - 1 do
  885. Result := Result or CheckOpened(ANode.ChildNodes[iChild]);
  886. end
  887. end;
  888. end;
  889. procedure TProjectManagerFrame.ShowProjectInfoTopAndCheckers;
  890. var
  891. vPSArr: TStrArr;
  892. vCArr: TOVArr; // Checkers
  893. vChecker: TOrderCheckerFrame;
  894. sPicPath, sURL: string;
  895. procedure AddChecker(AType: TCheckerFrameType; AArr: array of string);
  896. begin
  897. vChecker := TOrderCheckerFrame.Create(self);
  898. FCheckerList.Add(vChecker);
  899. vChecker.Owner := Self;
  900. sbChecker.VertScrollBar.Range := sbChecker.VertScrollBar.Range + vChecker.Height;
  901. sbChecker.Height := Min(sbChecker.Height + vChecker.Height, pnlWeb.Height - pnlProject.Height);
  902. vChecker.Parent := sbChecker;
  903. vChecker.Top := FCurPos;
  904. FCurPos := FCurPos + vChecker.Height;
  905. vChecker.Align := alTop;
  906. sPicPath := PHPWeb.UserPath + '1_' + AArr[0] + '.jpg';
  907. PHPWeb.DownFile(AArr[4], sPicPath);
  908. vChecker.Init(AType, StrToInt(AArr[0]), AArr[1], AArr[3],
  909. AArr[2], sPicPath, AArr[6], TCheckStatus(StrToInt(AArr[5])-1), AArr[8], StrToInt(AArr[7]));
  910. vChecker.Name := 'ProjectOrderFrame' + AArr[0];
  911. end;
  912. procedure RepairOrder;
  913. var k: Integer;
  914. begin
  915. for k := 0 to sbChecker.ControlCount - 1 do
  916. TOrderCheckerFrame(sbChecker.Controls[k]).Order := k + 1;
  917. end;
  918. procedure ShowProjectCheckers;
  919. var i, j, n: Integer;
  920. vOwner: array of string; // 业主信息
  921. begin
  922. FCheckerList.Clear;
  923. sbChecker.Height := 0;
  924. FCurPos := 0;
  925. n := Length(vCArr[Low(vCArr)]);
  926. SetLength(vOwner, n);
  927. sbChecker.VertScrollBar.Range := 0;
  928. for i := Low(vCArr) to High(vCArr) do
  929. begin
  930. if StrToInt(vCArr[i, 0]) = PHPWeb.UserID then
  931. FWebCheckStatusMy := TCheckStatus(StrToInt(vCArr[i, 5])-1);
  932. if StrToInt(vCArr[i, 0]) = FWebOwnerID then
  933. begin
  934. for j := 0 to n - 1 do
  935. vOwner[j] := vCArr[i, j];
  936. Continue;
  937. end;
  938. AddChecker(cftChecker, vCArr[i]);
  939. end;
  940. if vOwner[0] <> '' then
  941. AddChecker(cftOwner, vOwner);
  942. RepairOrder;
  943. OnLineChecker(vCArr, FOnLineCheckerBegin, FOnLineCheckerEnd);
  944. end;
  945. begin
  946. GetLocalValues(CurRec);
  947. if FWebID = 0 then Exit;
  948. SetLength(vPSArr, 8);
  949. sURL := Format('%smeasure/status/%d/get', [PHPWeb.MeasureURL, FWebID]);
  950. if PHPWeb.Search(sURL, [''], [''], 3, vPSArr, vCArr) = 1 then
  951. begin
  952. LockWindowUpdate(pnlWeb.Handle);
  953. try
  954. FPhaseNo := StrToInt(vPSArr[0]);
  955. FWebCheckStatusProject := TCheckStatus(StrToInt(vPSArr[1])-1);
  956. FPhaseTotal := StrToInt(vPSArr[2]);
  957. FWebFolder_OnLine := vPSArr[3];
  958. FWebSubFolder_OnLine := vPSArr[4];
  959. FWebOwnerName := vPSArr[5];
  960. FWebOwnerCompany := vPSArr[6];
  961. FWebOwnerRole := vPSArr[7];
  962. ShowProjectInfoTop;
  963. ShowProjectCheckers;
  964. finally
  965. LockWindowUpdate(0);
  966. end;
  967. end
  968. else
  969. begin
  970. FPhaseNo := 0;
  971. FWebCheckStatusProject := csNotBegin;
  972. FPhaseTotal := 0;
  973. FWebFolder_OnLine := '';
  974. FWebSubFolder_OnLine := '';
  975. FWebOwnerName := '';
  976. FWebOwnerCompany := '';
  977. FWebOwnerRole := '';
  978. ShowProjectInfoTop;
  979. sbChecker.Height := 0;
  980. end;
  981. end;
  982. procedure TProjectManagerFrame.ShowProjectInfoTop(AType: Integer);
  983. procedure ShowOwner;
  984. begin
  985. lblBidName.Caption := FWebBidName_Local;
  986. lblBidName.Update;
  987. lblProjName.Caption := FWebFolder_OnLine;
  988. lblProjName.Update;
  989. lblWebProjCtgyName.Caption := FWebSubFolder_OnLine;
  990. lblWebProjCtgyName.Update;
  991. lblOnwerName.Caption := FWebOwnerName;
  992. lblOnwerName.Update;
  993. lblOnwerCompany.Caption := Format('-%s)', [FWebOwnerCompany]);
  994. lblOnwerCompany.Update;
  995. lblOnwerCompany.Left := lblOnwerName.Left + lblOnwerName.Width;
  996. end;
  997. procedure ShowStatus(ANo: Integer; AState: TCheckStatus);
  998. begin
  999. lblPeriod.Caption := Format('第%d期', [ANo]);
  1000. lblPeriod.Update;
  1001. lblPeriodState.Caption := CheckStatusNames[AState];
  1002. lblPeriodState.Font.Color := CheckStatusColors[AState];
  1003. lblPeriodState.Update;
  1004. lblPeriodState.Left := lblPeriod.Left + lblPeriod.Width + 5;
  1005. lblPeriodTotal.Caption := Format('(共%d期)', [ANo]);
  1006. lblPeriodTotal.Update;
  1007. lblPeriodTotal.Left := lblPeriodState.Left + lblPeriodState.Width + 3;
  1008. end;
  1009. begin
  1010. GetLocalValues(CurRec);
  1011. case AType of
  1012. -2:
  1013. begin
  1014. lblPeriod.Caption := '正在从云端读取状态信息...';
  1015. lblPeriod.Update;
  1016. end;
  1017. -1:
  1018. begin
  1019. ShowOwner;
  1020. ShowStatus(FPhaseNo, FWebCheckStatusProject);
  1021. end;
  1022. 0:
  1023. begin
  1024. ShowOwner;
  1025. ShowStatus(0, csNotBegin);
  1026. end;
  1027. end;
  1028. end;
  1029. // 检查后,应该定位到最后一层目录,不应该回到原先的选择节点。否则从网络拉下来的项目无法组织正确的树结构。
  1030. procedure TProjectManagerFrame.CheckWebFolders(AFolderID, ASubFolderID: Integer;
  1031. AFolderName, ASubFolderName: string);
  1032. var
  1033. vTree: TsdIDTree;
  1034. vNode, vSubNode: TsdIDTreeNode;
  1035. i: Integer;
  1036. sName: string;
  1037. iUserID, iWebID, iWebFolderLevel: Integer;
  1038. bExist, bSubExist, bModified: Boolean;
  1039. begin
  1040. bExist := False;
  1041. bSubExist := False;
  1042. bModified := False;
  1043. vTree := stdProjects.IDTree;
  1044. for i := 0 to vTree.Count - 1 do
  1045. begin
  1046. vNode := vTree.Items[i];
  1047. sName := vNode.Rec.ValueByName('Name').AsString;
  1048. iUserID := vNode.Rec.ValueByName('WebUserID').AsInteger;
  1049. iWebID := vNode.Rec.ValueByName('WebID').AsInteger;
  1050. iWebFolderLevel := vNode.Rec.ValueByName('WebFolderLevel').AsInteger;
  1051. if (iWebID = AFolderID) and (iWebFolderLevel = G_WFL_ProjName) and (iUserID = PHPWeb.UserID) then
  1052. begin
  1053. bExist := True;
  1054. vNode.LocateInControl;
  1055. if not SameText(sName, AFolderName) then
  1056. begin
  1057. vNode.Rec.ValueByName('Name').AsString := AFolderName;
  1058. bModified := True;
  1059. end;
  1060. Break;
  1061. end;
  1062. end;
  1063. if not bExist then
  1064. begin
  1065. vNode := vTree.Items[0];
  1066. if Assigned(vNode) then
  1067. vNode.LocateInControl;
  1068. vNode := FProjectManagerData.InsertProject(AFolderName, stdProjects.IDTree.Selected, AFolderID, G_WFL_ProjName);
  1069. vNode.LocateInControl;
  1070. end;
  1071. for i := 0 to vNode.ChildCount - 1 do
  1072. begin
  1073. vSubNode := vNode.ChildNodes[i];
  1074. sName := vSubNode.Rec.ValueByName('Name').AsString;
  1075. iUserID := vSubNode.Rec.ValueByName('WebUserID').AsInteger;
  1076. iWebID := vSubNode.Rec.ValueByName('WebID').AsInteger;
  1077. iWebFolderLevel := vSubNode.Rec.ValueByName('WebFolderLevel').AsInteger;
  1078. if (iWebID = ASubFolderID) and (iWebFolderLevel = G_WFL_BidType) and (iUserID = PHPWeb.UserID) then
  1079. begin
  1080. bSubExist := True;
  1081. vSubNode.LocateInControl;
  1082. if not SameText(sName, ASubFolderName) then
  1083. begin
  1084. vSubNode.Rec.ValueByName('Name').AsString := ASubFolderName;
  1085. bModified := True;
  1086. end;
  1087. Break;
  1088. end;
  1089. end;
  1090. if not bSubExist then
  1091. begin
  1092. vNode.LocateInControl;
  1093. vNode := FProjectManagerData.InsertSubProject(ASubFolderName, stdProjects.IDTree.Selected, ASubFolderID, G_WFL_BidType);
  1094. vNode.LocateInControl;
  1095. end;
  1096. if bModified then
  1097. ProjectManager.Save;
  1098. end;
  1099. function TProjectManagerFrame.Rec(AProjectID: Integer): TsdDataRecord;
  1100. var i: Integer;
  1101. vTree: TsdIDTree;
  1102. begin
  1103. vTree := stdProjects.IDTree;
  1104. if vTree.Selected.Rec.ValueByName('ID').AsInteger = AProjectID then
  1105. begin
  1106. Result := stdProjects.IDTree.Selected.Rec;
  1107. Exit;
  1108. end;
  1109. for i := 0 to vTree.Count - 1 do
  1110. begin
  1111. if vTree.Items[i].Rec.ValueByName('ID').AsInteger = AProjectID then
  1112. begin
  1113. Result := vTree.Items[i].Rec;
  1114. vTree.Items[i].LocateInControl;
  1115. Break;
  1116. end;
  1117. end;
  1118. end;
  1119. destructor TProjectManagerFrame.Destroy;
  1120. begin
  1121. FCheckerList.Free;
  1122. inherited;
  1123. end;
  1124. procedure TProjectManagerFrame.DoBatchReceiveOnline(ARequestType: Integer);
  1125. var
  1126. sURL, sHint: string;
  1127. vArr: TOVArr;
  1128. i, iFolderID, iSubFolderID: Integer;
  1129. begin
  1130. // 查询等待我审核的标段文件,杰哥说分三种:①业主未审核 ②业主审核中 ③审核人审核中 (为什么加①?问杰哥)
  1131. case PHPWeb.Search(PHPWeb.MeasureURL + 'user/get/audit/project', ['audituid', 'RequestType'],
  1132. [IntToStr(PHPWeb.UserID), IntToStr(ARequestType)], vArr) of
  1133. 1:
  1134. begin
  1135. CreateProgress('正在从云端下载新项目');
  1136. try
  1137. for i := Low(vArr) to High(vArr) do
  1138. begin
  1139. sURL := vArr[i, 0];
  1140. FWebFolder_OnLine := vArr[i, 1];
  1141. FWebSubFolder_OnLine := vArr[i, 2];
  1142. FWebMD5_OnLine := vArr[i, 3];
  1143. FWebID := StrToInt(vArr[i, 5]);
  1144. iFolderID := StrToInt(vArr[i, 6]);
  1145. iSubFolderID := StrToInt(vArr[i, 7]);
  1146. FWebCheckStatusMy := TCheckStatus(StrToInt(vArr[i, 8])-1); // vArr[i, 4]项目审核状态;vArr[i, 8]当前登陆用户的审核状态
  1147. FWebAuthorID := StrToInt(vArr[i, 9]);
  1148. FWebBidName_OnLine := vArr[i, 10];
  1149. FWebMD5_Local := LocalMD5(PHPWeb.UserID, FWebID);
  1150. CheckWebFolders(iFolderID, iSubFolderID, FWebFolder_OnLine, FWebSubFolder_OnLine);
  1151. CheckBidName(PHPWeb.UserID, FWebID, FWebBidName_OnLine);
  1152. if FWebMD5_OnLine <> FWebMD5_Local then
  1153. if not FileDownAndReceive(sURL, 1) then Exit;
  1154. end;
  1155. BubbleSortProjects;
  1156. finally
  1157. CloseProgress;
  1158. end;
  1159. end;
  1160. 0, -1:
  1161. begin
  1162. sHint := '网络出错,无法查询云端项目的更新情况,请重试!';
  1163. Application.MessageBox(PChar(sHint), '警告', MB_OK + MB_ICONWARNING);
  1164. Exit;
  1165. end;
  1166. end;
  1167. end;
  1168. function TProjectManagerFrame.ImportFile(const AFileName: string; AFileMD5: string): Boolean;
  1169. var
  1170. vImport: TTenderImport;
  1171. vNode: TsdIDTreeNode;
  1172. begin
  1173. Result := False;
  1174. vNode := stdProjects.IDTree.Selected;
  1175. vImport := TTenderImport.Create(vNode, '', AFileName);
  1176. try
  1177. try
  1178. vImport.ImportToSelect;
  1179. vNode.LocateInControl;
  1180. Result := True;
  1181. except
  1182. Result := False;
  1183. end;
  1184. finally
  1185. vImport.Free;
  1186. vNode.Rec.BeginUpdate;
  1187. vNode.Rec.ValueByName('WebMD5').AsString := AFileMD5;
  1188. vNode.Rec.ValueByName('WebUserID').AsInteger := PHPWeb.UserID;
  1189. vNode.Rec.EndUpdate;
  1190. FProjectManagerData.Save;
  1191. end;
  1192. end;
  1193. procedure TProjectManagerFrame.actnOpenBackupFolderExecute(
  1194. Sender: TObject);
  1195. var
  1196. stnNode: TsdIDTreeNode;
  1197. begin
  1198. stnNode := stdProjects.IDTree.Selected;
  1199. if stnNode.Rec.ValueByName('BackupFolder').AsString = '' then
  1200. TipMessage('该项目暂无备份数据!')
  1201. else
  1202. ShellExecute(Handle, 'open', 'Explorer.exe',
  1203. PChar(FProjectManagerData.BackupPath(stnNode.ID)), nil, 1);
  1204. end;
  1205. procedure TProjectManagerFrame.actnRenameUpdate(Sender: TObject);
  1206. var
  1207. Rec: TsdDataRecord;
  1208. bNet: Boolean;
  1209. begin
  1210. if stdProjects.IDTree.Selected = nil then Exit;
  1211. Rec := stdProjects.IDTree.Selected.Rec;
  1212. if Rec = nil then Exit;
  1213. bNet := G_IsCloud;
  1214. if bNet then
  1215. begin
  1216. tobtnRenane.Enabled := (Rec.ValueByName('Type').AsInteger = 1) and
  1217. (Rec.ValueByName('WebAuthorID').AsInteger = PHPWeb.UserID);
  1218. end;
  1219. end;
  1220. procedure TProjectManagerFrame.CheckBidName(AID: Integer; ANewBidName: string);
  1221. var vNode: TsdIDTreeNode;
  1222. begin
  1223. vNode := stdProjects.IDTree.FindNode(AID);
  1224. if vNode = nil then Exit;
  1225. if vNode.Rec.ValueByName('Name').AsString <> ANewBidName then
  1226. begin
  1227. vNode.Rec.ValueByName('Name').AsString := ANewBidName;
  1228. ProjectManager.Save;
  1229. end;
  1230. end;
  1231. procedure TProjectManagerFrame.DoBatchReceiveAllOnline;
  1232. var
  1233. OnCC: TZjCellNotifyEvent;
  1234. begin
  1235. OnCC := zgProjects.OnCurrentChanged;
  1236. try
  1237. zgProjects.OnCurrentChanged := nil;
  1238. DoBatchReceiveOnline(2);
  1239. if stdProjects.IDTree.FirstNode <> nil then
  1240. stdProjects.IDTree.FirstNode.LocateInControl;
  1241. finally
  1242. zgProjects.OnCurrentChanged := OnCC;
  1243. end;
  1244. end;
  1245. procedure TProjectManagerFrame.GetLocalValues(ARec: TsdDataRecord);
  1246. begin
  1247. if not Assigned(ARec) then
  1248. begin
  1249. ClearLocalValues;
  1250. Exit;
  1251. end;
  1252. // 加这句后产生Bug:上报项目后,记录不曾移动,FID不变,不会刷新
  1253. // if ARec.ValueByName('ID').AsInteger <> FID then
  1254. begin
  1255. FID := ARec.ValueByName('ID').AsInteger;
  1256. FWebID := ARec.ValueByName('WebID').AsInteger;
  1257. FWebAuthorID := ARec.ValueByName('WebAuthorID').AsInteger;
  1258. FWebOwnerID := ARec.ValueByName('WebOwnerID').AsInteger;
  1259. FWebMD5_Local := ARec.ValueByName('WebMD5').AsString;
  1260. FWebBidName_Local := ARec.ValueByName('Name').AsString;
  1261. end;
  1262. end;
  1263. procedure TProjectManagerFrame.GetLocalValues(AUserID, AWebID: Integer);
  1264. var i: Integer;
  1265. vTree: TsdIDTree;
  1266. vRec: TsdDataRecord;
  1267. begin
  1268. ClearLocalValues; // 先清空,以防没找到。
  1269. if (CurRec <> nil) and
  1270. (CurRec.ValueByName('WebUserID').AsInteger = AUserID) and
  1271. (CurRec.ValueByName('WebID').AsInteger = AWebID) and
  1272. (CurRec.ValueByName('Type').AsInteger = 1) then
  1273. begin
  1274. GetLocalValues(vRec);
  1275. Exit;
  1276. end;
  1277. vTree := stdProjects.IDTree;
  1278. for i := 0 to vTree.Count - 1 do
  1279. begin
  1280. vRec := vTree.Items[i].Rec;
  1281. if (vRec.ValueByName('WebUserID').AsInteger = AUserID) and
  1282. (vRec.ValueByName('WebID').AsInteger = AWebID) and
  1283. (vRec.ValueByName('Type').AsInteger = 1) then
  1284. begin
  1285. GetLocalValues(vRec);
  1286. Break;
  1287. end;
  1288. end;
  1289. end;
  1290. procedure TProjectManagerFrame.ClearLocalValues;
  1291. begin
  1292. FID := -1;
  1293. FWebID := -1;
  1294. FWebAuthorID := -1;
  1295. FWebOwnerID := -1;
  1296. FWebMD5_Local := '';
  1297. FWebBidName_Local := '';
  1298. end;
  1299. function TProjectManagerFrame.LocalMD5(AUserID, AWebID: Integer): string;
  1300. var i: Integer;
  1301. vTree: TsdIDTree;
  1302. vRec: TsdDataRecord;
  1303. begin
  1304. Result := '本地无MD5码';
  1305. if (CurRec <> nil) and
  1306. (CurRec.ValueByName('WebUserID').AsInteger = AUserID) and
  1307. (CurRec.ValueByName('WebID').AsInteger = AWebID) and
  1308. (CurRec.ValueByName('Type').AsInteger = 1) then
  1309. begin
  1310. Result := vRec.ValueByName('WebMD5').AsString;
  1311. Exit;
  1312. end;
  1313. vTree := stdProjects.IDTree;
  1314. for i := 0 to vTree.Count - 1 do
  1315. begin
  1316. vRec := vTree.Items[i].Rec;
  1317. if (vRec.ValueByName('WebUserID').AsInteger = AUserID) and
  1318. (vRec.ValueByName('WebID').AsInteger = AWebID) and
  1319. (vRec.ValueByName('Type').AsInteger = 1) then
  1320. begin
  1321. Result := vRec.ValueByName('WebMD5').AsString;
  1322. Break;
  1323. end;
  1324. end;
  1325. end;
  1326. function TProjectManagerFrame.CurRec: TsdDataRecord;
  1327. begin
  1328. if stdProjects.IDTree.Selected = nil then
  1329. Result := nil
  1330. else
  1331. Result := stdProjects.IDTree.Selected.Rec;
  1332. end;
  1333. procedure TProjectManagerFrame.CheckBidName(AUserID, AWebID: Integer;
  1334. ANewBidName: string);
  1335. var i: Integer;
  1336. vTree: TsdIDTree;
  1337. vRec: TsdDataRecord;
  1338. begin
  1339. if (CurRec <> nil) and
  1340. (CurRec.ValueByName('WebUserID').AsInteger = AUserID) and
  1341. (CurRec.ValueByName('WebID').AsInteger = AWebID) and
  1342. (CurRec.ValueByName('Type').AsInteger = 1) then
  1343. begin
  1344. if (CurRec.ValueByName('Name').AsString <> ANewBidName) then
  1345. begin
  1346. CurRec.ValueByName('Name').AsString := ANewBidName;
  1347. ProjectManager.Save;
  1348. end;
  1349. Exit;
  1350. end;
  1351. vTree := stdProjects.IDTree;
  1352. for i := 0 to vTree.Count - 1 do
  1353. begin
  1354. vRec := vTree.Items[i].Rec;
  1355. if (vRec.ValueByName('WebUserID').AsInteger = AUserID) and
  1356. (vRec.ValueByName('WebID').AsInteger = AWebID) and
  1357. (vRec.ValueByName('Type').AsInteger = 1) then
  1358. begin
  1359. if vRec.ValueByName('Name').AsString <> ANewBidName then
  1360. begin
  1361. vRec.ValueByName('Name').AsString := ANewBidName;
  1362. ProjectManager.Save;
  1363. end;
  1364. Break;
  1365. end;
  1366. end;
  1367. end;
  1368. function TProjectManagerFrame.CurRecAttachmentPath: string;
  1369. begin
  1370. if G_IsCloud then
  1371. Result := PHPWeb.WebPath + 'Projects\' + CurRec.ValueByName('WebID').AsString + '\Attachment\'
  1372. else
  1373. Result := GetMyProjectsFilePath + 'Attachment\' + CurRec.ValueByName('FileName').AsString + '\';
  1374. end;
  1375. function TProjectManagerFrame.AttachmentFileCountsWithoutManageFile(ANode: TsdIDTreeNode): Integer;
  1376. function GetCount(ANode: TsdIDTreeNode): Integer;
  1377. var sPath: string;
  1378. begin
  1379. if not Assigned(ANode) then Exit;
  1380. Result := 0;
  1381. if ANode.Rec.ValueByName('Type').AsInteger = 0 then
  1382. Result := Result + 0
  1383. else
  1384. begin
  1385. sPath := GetMyProjectsFilePath + 'Attachment\' + ANode.Rec.ValueByName('FileName').AsString + '\';
  1386. Result := Result + FileCount(sPath) - 1;
  1387. end;
  1388. if Assigned(ANode.FirstChild) then
  1389. Result := Result + GetCount(ANode.FirstChild);
  1390. if Assigned(ANode.NextSibling) then
  1391. Result := Result + GetCount(ANode.NextSibling);
  1392. end;
  1393. begin
  1394. if not Assigned(ANode) then Exit;
  1395. if Assigned(ANode.FirstChild) then
  1396. Result := GetCount(ANode.FirstChild)
  1397. else
  1398. Result := 0;
  1399. end;
  1400. procedure TProjectManagerFrame.BubbleSortProjects;
  1401. // 不能排最顶层
  1402. procedure BubbleSort(ANode: TsdIDTreeNode);
  1403. var n, t, c, temp: Integer;
  1404. bSwap: Boolean;
  1405. vNode1, vNode2, vTempNode: TsdIDTreeNode;
  1406. begin
  1407. if ANode = nil then Exit;
  1408. // if ANode.Rec.ValueByName('WebFolderLevel').AsInteger = G_WFL_ProjName then Exit;
  1409. n := ANode.ChildCount;
  1410. for t := 1 to n - 1 do
  1411. begin
  1412. bSwap := False;
  1413. for c := 1 to (n - t) do
  1414. begin
  1415. vNode1 := ANode.ChildNodes[c - 1];
  1416. vNode2 := ANode.ChildNodes[c];
  1417. if AnsiCompareStr(vNode1.Rec.ValueByName('Name').AsString,
  1418. vNode2.Rec.ValueByName('Name').AsString) = 1 then
  1419. begin
  1420. vNode1.DownMove;
  1421. bSwap := True;
  1422. end;
  1423. end;
  1424. if bSwap = False then Break;
  1425. end;
  1426. if Assigned(ANode.FirstChild) then
  1427. BubbleSort(ANode.FirstChild);
  1428. if Assigned(ANode.NextSibling) then
  1429. BubbleSort(ANode.NextSibling);
  1430. end;
  1431. begin
  1432. BubbleSort(stdProjects.IDTree.FirstNode);
  1433. end;
  1434. procedure TProjectManagerFrame.zgProjectsShowHint(var HintStr: String;
  1435. var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
  1436. var
  1437. vCell: TZjCell;
  1438. vNode: TsdIDTreeNode;
  1439. iLevelWidth: Integer;
  1440. rText: TRect;
  1441. procedure CalcTextRect(var R: TRect);
  1442. var
  1443. DC: HDC;
  1444. iTextHeight: Integer;
  1445. begin
  1446. DC := CreateCompatibleDC(0);
  1447. try
  1448. SelectObject(DC, vCell.Font.Handle);
  1449. iTextHeight := DrawText(DC, PChar(vCell.Text), Length(vCell.Text), R, DT_SINGLELINE or DT_VCenter
  1450. or DT_NOCLIP or DT_CALCRECT);
  1451. finally
  1452. DeleteDC(DC);
  1453. end;
  1454. end;
  1455. begin
  1456. if (ACoord.Y < 1) and (ACoord.X <> 1) then Exit;
  1457. vCell := zgProjects.Cells[ACoord.X, ACoord.Y];
  1458. with HintInfo do
  1459. begin
  1460. vNode := stdProjects.IDTree.Items[ACoord.Y - 1];
  1461. if not Assigned(vNode) then Exit;
  1462. iLevelWidth := (vNode.Level + 1) * 20 + 16;
  1463. rText := CursorRect;
  1464. CalcTextRect(rText);
  1465. if (rText.Right - rText.Left + iLevelWidth > CursorRect.Right - CursorRect.Left) or
  1466. (rText.Right > ClientWidth) then
  1467. begin
  1468. CanShow := True;
  1469. HintStr := vCell.Text;
  1470. GetCursorPos(HintPos);
  1471. end;
  1472. end;
  1473. end;
  1474. function TProjectManagerFrame.FileDownAndReceive(ADownURL: string; AReceiveKind: Integer): Boolean;
  1475. var sLocalFile, sHint: string;
  1476. bLock, bCanImp, bIsOwner: Boolean;
  1477. vFileCheck: TTenderFileChecker;
  1478. begin
  1479. Result := False;
  1480. // 下载
  1481. sLocalFile := PHPWeb.UserPath + ExtractFileName(ADownURL);
  1482. if not PHPWeb.DownFile(ADownURL, sLocalFile) then
  1483. begin
  1484. if AReceiveKind = 1 then
  1485. sHint := Format('云端已找到[%s]的新文件,但由于网络原因下载失败!请重试!', [FWebBidName_Local])
  1486. else if AReceiveKind = 2 then
  1487. sHint := '云端已找到原报上传的无锁文件,但因网络出错无法下载,本次操作已取消。请重试!';
  1488. Application.MessageBox(PChar(sHint), '系统提醒', MB_OK + MB_ICONWARNING);
  1489. Exit;
  1490. end;
  1491. // 接收更新
  1492. if AReceiveKind = 1 then
  1493. begin
  1494. bLock := (FWebAuthorID = PHPWeb.UserID) or
  1495. ((FWebAuthorID <> PHPWeb.UserID) and (FWebCheckStatusMy <> csChecking));
  1496. bIsOwner := FWebOwnerID = PHPWeb.UserID;
  1497. if not ReceiveFile(sLocalFile, FWebMD5_OnLine, bLock) then
  1498. // if not ReceiveForLost(sLocalFile, FWebMD5_OnLine, bLock, FOnLineCheckerBegin, FOnLineCheckerEnd, bIsOwner) then
  1499. begin
  1500. sHint := Format('已从云端下载新的[%s]到本地[%s],但接收失败,请删除该项目然后重新从云端获取!', [FWebBidName_Local, sLocalFile]);
  1501. Application.MessageBox(PChar(sHint), '系统提醒', MB_OK + MB_ICONWARNING);
  1502. Exit;
  1503. end;
  1504. end
  1505. // 导入更新
  1506. else if AReceiveKind = 2 then
  1507. begin
  1508. // 有时无锁文件出错:包含了1审2审的数据。所以导入前须检测。
  1509. vFileCheck := TTenderFileChecker.Create;
  1510. try
  1511. // 有一期以上数据,且最新期数据审核状态为原报
  1512. bCanImp := vFileCheck.CheckFileValid(sLocalFile) and (vFileCheck.PhaseCount > 0) and (vFileCheck.AuditStatus = 0);
  1513. if not bCanImp then
  1514. begin
  1515. Application.MessageBox(PChar('已从云端下载原报上传的无锁文件到本地,但文件有错误,禁止导入!请致电纵横服务人员以获取帮助。'),
  1516. '警告', MB_OK + MB_ICONWARNING);
  1517. Exit;
  1518. end;
  1519. finally
  1520. vFileCheck.Free;
  1521. end;
  1522. {注意: 审核末通过的导入更新,这里的MD5码应取最终审核不通过项目的,否则会带来下载循环问题。
  1523. 问题描述:
  1524. ①编制人运行软件,双击项目,发现审核不通过,自动下载无锁文件,开始新一期,保存关闭。
  1525. ②编制人再次运行软件,双击项目,MD5码不同,自动下载旧的审核不通过文件,覆盖本地。
  1526. ③编制人再次运行软件,双击项目,发现审核不通过,重复①,循环....
  1527. 问:①那里下载无锁文件后不能改成新的MD5码吗?
  1528. 答:不能,因为审核人的项目会变成无锁文件,看不到不通过项目。MD5码只能在上传后更新。
  1529. 且编制人有个交互界面2种选择:a.下载更新不通过项目查看;b.下载更新无锁文件开始新一期。}
  1530. if not ImportFile(sLocalFile, FWebMD5_OnLine) then
  1531. begin
  1532. Application.MessageBox(PChar('已从云端下载原报上传的无锁文件到本地,但导入失败!请重试。'), '警告', MB_OK + MB_ICONWARNING);
  1533. Exit;
  1534. end;
  1535. end;
  1536. if FileExists(sLocalFile) then
  1537. DeleteFile(sLocalFile);
  1538. Result := True;
  1539. end;
  1540. // 为了跟PHP的数组兼容,这里限制数组的第一个元素是A[0](不能是A[1])
  1541. procedure TProjectManagerFrame.OnLineChecker(AAr: TOVArr; var ABegin,
  1542. AEnd: Integer);
  1543. var i, j, n: Integer;
  1544. vCS: TCheckStatus;
  1545. begin
  1546. ABegin := 0;
  1547. AEnd := 0;
  1548. n := -1;
  1549. for i := 0 to High(AAr) do
  1550. begin
  1551. vCS := TCheckStatus(StrToInt(AAr[i, 5])-1);
  1552. if vCS = csChecking then
  1553. begin
  1554. n := i; // 非常重要:传入的数组必须从第一个审核人到轮到工作中的那个人的前一个人
  1555. Break;
  1556. end;
  1557. end;
  1558. for i := n downto 0 do
  1559. begin
  1560. if AAr[i, 7] = '1' then // 接口返回的第7列是线上审批标记
  1561. begin
  1562. AEnd := i + 1;
  1563. Break;
  1564. end
  1565. else
  1566. Break;
  1567. end;
  1568. if AEnd = 0 then Exit;
  1569. i := i - 1;
  1570. if i < 0 then
  1571. begin
  1572. ABegin := 1;
  1573. Exit;
  1574. end;
  1575. for j := i downto 0 do
  1576. begin
  1577. if AAr[j, 7] = '0' then
  1578. begin
  1579. ABegin := j + 2;
  1580. Break;
  1581. end
  1582. else
  1583. begin
  1584. if j = 0 then
  1585. ABegin := 1;
  1586. end;
  1587. end;
  1588. end;
  1589. end.