ProjectFme.pas 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  1. unit ProjectFme;
  2. interface
  3. uses
  4. BillsCompileFme, BillsMeasureFme, PhaseCompareFme, DealPaymentFme,
  5. BillsGatherFme, ZJJLFme, BGLFme, ReportsFrm, SearchFme, BookmarkFme,
  6. ProjectData, UtilMethods, Globals, mEncryptEditions, DealBillsFme,
  7. PriceMarginFme,
  8. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  9. Dialogs, ImgList, XPMenu, Buttons, ComCtrls, ToolWin, ExtCtrls, JimPages,
  10. StdCtrls, JimCombos, dxsbar, ActnList, dxBar, OrderCheckerFme, CheckerFme,
  11. CslButton, UpFileManageFrame, UpFileManageUnit;
  12. type
  13. TProjectFrame = class(TFrame)
  14. xpm: TXPMenu;
  15. ilstExpend: TImageList;
  16. pnlViewControl: TPanel;
  17. pnlView: TPanel;
  18. pnlToolBar: TPanel;
  19. tbToolsButton: TToolBar;
  20. tobtnStandardBills: TToolButton;
  21. tobtnDealPayment: TToolButton;
  22. tobtnSearch: TToolButton;
  23. sbtnExpend: TSpeedButton;
  24. tbXmjBills: TToolBar;
  25. tbExpand: TToolButton;
  26. tbSeparator: TToolButton;
  27. sprAssistant: TSplitter;
  28. jpsAssistant: TJimPages;
  29. jpsAssistantDealPayment: TJimPage;
  30. jpsAssistantSearch: TJimPage;
  31. dxsbViewControl: TdxSideBar;
  32. dxsbsViewControl: TdxSideBarStore;
  33. xbiBillsCompile: TdxStoredSideItem;
  34. jpsAssistantStandardBills: TJimPage;
  35. jpsMain: TJimPages;
  36. jpsMainBillsMeasure: TJimPage;
  37. xbiBillsGather: TdxStoredSideItem;
  38. jpsMainBillsGather: TJimPage;
  39. ilstLarge: TImageList;
  40. ilstSmall: TImageList;
  41. xbiStageCompare: TdxStoredSideItem;
  42. xbiCompleteDegree: TdxStoredSideItem;
  43. xbiReport: TdxStoredSideItem;
  44. jpsMainStageCompare: TJimPage;
  45. tobtnZJJL: TToolButton;
  46. tobtnBGL: TToolButton;
  47. jpsAssistantZJJL: TJimPage;
  48. jpsAssistantBGL: TJimPage;
  49. dxpmExpandBills: TdxBarPopupMenu;
  50. alProject: TActionList;
  51. actnFirstLevel: TAction;
  52. actnSecondLevel: TAction;
  53. actnThirdLevel: TAction;
  54. actnFourthLevel: TAction;
  55. actnFifthLevel: TAction;
  56. actnAllLevel: TAction;
  57. actnAllXmj: TAction;
  58. xbiBillsMeasure: TdxStoredSideItem;
  59. jpsMainBillsCompile: TJimPage;
  60. pnlPhaseSelect: TPanel;
  61. jcbAudit: TJimComboBox;
  62. jcbPhase: TJimComboBox;
  63. tobtnShowChecker: TToolButton;
  64. jpsAssistantChecker: TJimPage;
  65. btnSubmit: TCslButton;
  66. btnPass: TCslButton;
  67. btnNotPass: TCslButton;
  68. pnlNewPhase: TPanel;
  69. btnNewPhase: TCslButton;
  70. pnlProjectCheckStatus: TPanel;
  71. actnCurPhase: TAction;
  72. tobtnBookmark: TToolButton;
  73. jpsAssistantBookmark: TJimPage;
  74. jpsAssistantUpFile: TJimPage;
  75. tobtnUpFile: TToolButton;
  76. jpsAssistantDealBills: TJimPage;
  77. tobtnDealBills: TToolButton;
  78. actnAllPeg: TAction;
  79. jpsMainPriceMargin: TJimPage;
  80. xbiPriceMargin: TdxStoredSideItem;
  81. procedure tobtnStandardBillsClick(Sender: TObject);
  82. procedure jcbPhaseChanged(Sender: TObject);
  83. procedure sbtnExpendClick(Sender: TObject);
  84. procedure jcbAuditChanged(Sender: TObject);
  85. procedure dxsbViewControlItemClick(Sender: TObject;
  86. Item: TdxSideBarItem);
  87. procedure dxpmExpandBillsPopup(Sender: TObject);
  88. procedure actnFirstLevelExecute(Sender: TObject);
  89. procedure tbExpandClick(Sender: TObject);
  90. procedure actnAllXmjExecute(Sender: TObject);
  91. procedure btnSubmitClick(Sender: TObject);
  92. procedure btnPassClick(Sender: TObject);
  93. procedure btnNotPassClick(Sender: TObject);
  94. procedure btnNewPhaseClick(Sender: TObject);
  95. procedure actnCurPhaseExecute(Sender: TObject);
  96. procedure tobtnUpFileClick(Sender: TObject);
  97. procedure jpsAssistantActivePageChanged(Sender: TObject);
  98. procedure actnAllPegExecute(Sender: TObject);
  99. private
  100. FProjectData: TProjectData;
  101. FBillsCompileFrame: TBillsCompileFrame;
  102. FBillsMeasureFrame: TBillsMeasureFrame;
  103. FBillsGatherFrame: TBillsGatherFrame;
  104. FPriceMarginFrame: TPriceMarginFrame;
  105. FPhaseCompareFrame: TPhaseCompareFrame;
  106. FCheckerFrame: TCheckerFrame;
  107. FDealPaymentFrame: TDealPaymentFrame;
  108. FZJJLFrame: TZJJLFrame;
  109. FBGLFrame: TBGLFrame;
  110. FSearchFrame: TSearchFrame;
  111. FBookmarkFrame: TBookmarkFrame;
  112. FUpFileManageView: TUpFileManageView;
  113. FDealBillsFrame: TDealBillsFrame;
  114. procedure CreateBillsFrame;
  115. procedure CreateDealPaymentFrame;
  116. procedure CreateBillsGatherFrame;
  117. procedure CreatePriceMarginFrame;
  118. procedure CreateCheckerFrame;
  119. procedure CreateUpFile;
  120. procedure CreateFrames;
  121. procedure InitialForVersions;
  122. procedure OpenCompare;
  123. procedure CloseCompare;
  124. // 刷新各界面只读、显示等
  125. procedure RefreshProjectState;
  126. procedure AdjustFramesDisplay;
  127. procedure SaveLog(AStr: string);
  128. procedure ExpandNodeTo(ALevel: Integer);
  129. procedure ExpandAllXmj;
  130. procedure ExpandCurPhase;
  131. procedure SetAssistantViewVisible(AVisible: Boolean);
  132. procedure SetImageOfsbtnExpend(AExpend: Boolean);
  133. procedure ControlAssistantButtonsDown(ATag: Integer);
  134. procedure ExpandBookmarkFrame(AExpandFrame: Boolean);
  135. procedure UpToWeb(ACheckPassed: Boolean);
  136. function CheckersHint: string;
  137. procedure SetUpFileManageView(const Value: TUpFileManageView);
  138. procedure CheckUpFile;
  139. public
  140. constructor Create(AProjectData: TProjectData);
  141. destructor Destroy; override;
  142. procedure ResetAssistantView;
  143. procedure GeneratePhaseChooseList;
  144. procedure GenerateStageChooseList;
  145. procedure CreateNewPhase;
  146. procedure CreateNewAudit;
  147. procedure RefreshColumnDisplay;
  148. function CheckCanReport: Boolean;
  149. procedure UnLockData;
  150. procedure ReLockData;
  151. function IsUped: Boolean;
  152. procedure ButtonControl_UpToWeb;
  153. procedure ButtonControl_NewPhase;
  154. procedure RepairAudits;
  155. function CheckFileAndCloudChekerList: Boolean;
  156. property ProjectData: TProjectData read FProjectData;
  157. property BillsCompileFrame: TBillsCompileFrame read FBillsCompileFrame;
  158. property BillsMeasureFrame: TBillsMeasureFrame read FBillsMeasureFrame;
  159. property BillsGatherFrame: TBillsGatherFrame read FBillsGatherFrame;
  160. property PriceMarginFrame: TPriceMarginFrame read FPriceMarginFrame;
  161. property CheckerFrame: TCheckerFrame read FCheckerFrame;
  162. property UpFileManageView: TUpFileManageView read FUpFileManageView write SetUpFileManageView;
  163. property DealPaymentFrame: TDealPaymentFrame read FDealPaymentFrame;
  164. property ZJJLFrame: TZJJLFrame read FZJJLFrame;
  165. property BGLFrame: TBGLFrame read FBGLFrame;
  166. property SearchFrame: TSearchFrame read FSearchFrame;
  167. property BookmarkFrame: TBookmarkFrame read FBookmarkFrame;
  168. property DealBillsFrame: TDealBillsFrame read FDealBillsFrame;
  169. end;
  170. implementation
  171. uses
  172. PhaseData, BGLDm, MainFrm, ZhAPI, SearchDm, PHPWebDm, ActiveX,
  173. ConstUnit, MD5Unit, sdIDTree, sdDB, mProgressFrm, ConditionalDefines,
  174. ProjectCommands, ProjectProperty, CheckerMemoFrm, BillsMeasureDm,
  175. ProgressHintFrm, mProgressProFrm;
  176. {$R *.dfm}
  177. { TProjectFrame }
  178. procedure TProjectFrame.AdjustFramesDisplay;
  179. begin
  180. jpsAssistant.Width := 395;
  181. SetAssistantViewVisible(False);
  182. end;
  183. procedure TProjectFrame.ControlAssistantButtonsDown(ATag: Integer);
  184. begin
  185. tobtnStandardBills.Down := ATag = tobtnStandardBills.Tag;
  186. tobtnDealPayment.Down := ATag = tobtnDealPayment.Tag;
  187. tobtnSearch.Down := ATag = tobtnSearch.Tag;
  188. tobtnZJJL.Down := ATag = tobtnZJJL.Tag;
  189. tobtnBGL.Down := ATag = tobtnBGL.Tag;
  190. tobtnShowChecker.Down := ATag = tobtnShowChecker.Tag;
  191. tobtnUpFile.Down := ATag = tobtnUpFile.Tag;
  192. tobtnBookmark.Down := ATag = tobtnBookmark.Tag;
  193. end;
  194. constructor TProjectFrame.Create(AProjectData: TProjectData);
  195. begin
  196. inherited Create(nil);
  197. FProjectData := AProjectData;
  198. ResetAssistantView;
  199. AdjustFramesDisplay;
  200. CreateFrames;
  201. RefreshProjectState;
  202. GeneratePhaseChooseList;
  203. GenerateStageChooseList;
  204. dxsbViewControl.SelectedItem := dxsbViewControl.ActiveGroup.Items.Items[0];
  205. InitialForVersions;
  206. CreateUpFile;
  207. if G_IsCloud then
  208. begin
  209. // 0号台帐无审核人,网络读取会出错。所以只有在有计量的情况下才创建审核人
  210. if (ProjectData.PhaseIndex > 0) then
  211. begin
  212. tobtnShowChecker.Visible := True;
  213. CreateCheckerFrame;
  214. end;
  215. ButtonControl_NewPhase;
  216. ButtonControl_UpToWeb;
  217. RepairAudits;
  218. end;
  219. end;
  220. destructor TProjectFrame.Destroy;
  221. begin
  222. FBookmarkFrame.Free;
  223. FZJJLFrame.Free;
  224. FBillsGatherFrame.Free;
  225. FDealPaymentFrame.Free;
  226. FBillsCompileFrame.Free;
  227. FBillsMeasureFrame.Free;
  228. FUpFileManageView.Free;
  229. SupportManager.ClearAssistantViewParent;
  230. inherited;
  231. end;
  232. procedure TProjectFrame.ResetAssistantView;
  233. begin
  234. AlignControl(SupportManager.StandardLibsFrame, jpsAssistantStandardBills, alClient);
  235. end;
  236. procedure TProjectFrame.SetAssistantViewVisible(AVisible: Boolean);
  237. begin
  238. jpsAssistant.Visible := AVisible;
  239. sprAssistant.Visible := AVisible;
  240. end;
  241. procedure TProjectFrame.SetImageOfsbtnExpend(AExpend: Boolean);
  242. begin
  243. sbtnExpend.Glyph := nil;
  244. ilstExpend.GetBitmap(Integer(AExpend), sbtnExpend.Glyph);
  245. end;
  246. procedure TProjectFrame.tobtnStandardBillsClick(Sender: TObject);
  247. begin
  248. with TToolButton(Sender) do
  249. begin
  250. if Down then
  251. begin
  252. jpsAssistant.ActivePageIndex := Tag;
  253. sbtnExpend.Tag := Tag;
  254. ControlAssistantButtonsDown(Tag);
  255. jpsMain.ActivePage.Tag := Tag;
  256. end;
  257. SetAssistantViewVisible(Down);
  258. SetImageOfsbtnExpend(Down);
  259. end;
  260. end;
  261. procedure TProjectFrame.GeneratePhaseChooseList;
  262. var
  263. iIndex: Integer;
  264. begin
  265. jcbPhase.Items.Clear;
  266. for iIndex := 1 to FProjectData.ProjProperties.PhaseCount do
  267. jcbPhase.Items.Add(Format(' 第 %d 期数据', [iIndex]));
  268. jcbPhase.ItemIndex := jcbPhase.Items.Count - 1;
  269. jcbPhase.Enabled := jcbPhase.Items.Count > 0;
  270. tobtnZJJL.Enabled := jcbPhase.Enabled;
  271. tobtnBGL.Enabled := jcbPhase.Enabled;
  272. end;
  273. procedure TProjectFrame.jcbPhaseChanged(Sender: TObject);
  274. begin
  275. if ProjectData.PhaseIndex = jcbPhase.ItemIndex + 1 then Exit;
  276. FProjectData.PhaseIndex := jcbPhase.ItemIndex + 1;
  277. GenerateStageChooseList;
  278. RefreshProjectState;
  279. if Assigned(FZJJLFrame) then
  280. begin
  281. FZJJLFrame.DataReadOnly := FProjectData.PhaseData.StageDataReadOnly;
  282. FZJJLFrame.ResetFrameLink(FProjectData.PhaseData.ZJJLData);
  283. end;
  284. if G_IsCloud then
  285. begin
  286. if Assigned(FCheckerFrame) then
  287. begin
  288. FCheckerFrame.Init;
  289. RepairAudits;
  290. end;
  291. ButtonControl_UpToWeb;
  292. end;
  293. end;
  294. procedure TProjectFrame.CreateNewPhase;
  295. var
  296. iBef: Integer;
  297. vArr: array of string;
  298. begin
  299. if QuestMessage('请检查合同支付的初始值,新增一期计量将锁定当前全部的清单数据,是否继续?') then
  300. begin
  301. // 网络版创建第二期、第三期等跟第一期有所不同:
  302. // 创建前,先发送信号给服务器,服务器自动根据第一期生成第二期的审核人列表。
  303. // 有了这个列表程序才能正常接下来的业务。
  304. if G_IsCloud then
  305. begin
  306. iBef := FProjectData.ProjProperties.PhaseCount;
  307. if iBef >= 1 then
  308. begin
  309. vArr := VarArrayOf(['msg']);
  310. if PHPWeb.Search(PHPWeb.MeasureURL + 'phaseno/userlist/create',
  311. ['tenderid', 'phaseno'], [IntToStr(FProjectData.WebID),
  312. IntToStr(iBef + 1)], vArr) <> 1 then
  313. begin
  314. Application.MessageBox(Pchar('云端自动创建本期审核人列表出错,请重新尝试!'), '警告', MB_OK + MB_ICONWARNING);
  315. Exit;
  316. end;
  317. end;
  318. end;
  319. FProjectData.CreateNewPhase;
  320. tobtnDealPayment.Enabled := True;
  321. tobtnZJJL.Enabled := True;
  322. tobtnBGL.Enabled := True;
  323. jcbPhase.Enabled := True;
  324. jcbAudit.Enabled := True;
  325. jcbPhase.Items.Add(Format(' 第 %d 期数据', [jcbPhase.Items.Count + 1]));
  326. jcbPhase.ItemIndex := jcbPhase.Items.Count - 1;
  327. FProjectData.CopyPreData;
  328. RefreshProjectState;
  329. if G_IsCloud then
  330. begin
  331. if Assigned(CheckerFrame) then
  332. CheckerFrame.Free;
  333. CreateCheckerFrame;
  334. tobtnShowChecker.Visible := True;
  335. tobtnShowChecker.Enabled := True;
  336. ButtonControl_NewPhase;
  337. ButtonControl_UpToWeb;
  338. end;
  339. end;
  340. end;
  341. procedure TProjectFrame.sbtnExpendClick(Sender: TObject);
  342. var
  343. bExpend: Boolean;
  344. begin
  345. bExpend := not jpsAssistant.Visible;
  346. jpsAssistant.ActivePageIndex := TSpeedButton(Sender).Tag;
  347. SetAssistantViewVisible(bExpend);
  348. SetImageOfsbtnExpend(bExpend);
  349. if bExpend then
  350. begin
  351. ControlAssistantButtonsDown(jpsAssistant.ActivePageIndex);
  352. jpsMain.ActivePage.Tag := jpsAssistant.ActivePageIndex;
  353. end
  354. else
  355. begin
  356. ControlAssistantButtonsDown(-1);
  357. jpsMain.ActivePage.Tag := -1;
  358. end;
  359. if G_IsCloud then
  360. CheckUpFile;
  361. end;
  362. procedure TProjectFrame.CreateNewAudit;
  363. begin
  364. FProjectData.PhaseData.CreateNewAuditData;
  365. jcbAudit.Items.Add(Format(' %d 审', [FProjectData.PhaseData.StageCount - 1]));
  366. if jcbAudit.ItemIndex <> jcbAudit.Items.Count - 1 then
  367. jcbAudit.ItemIndex := jcbAudit.Items.Count - 1
  368. else
  369. FProjectData.ResetPhaseDataLink;
  370. end;
  371. procedure TProjectFrame.GenerateStageChooseList;
  372. var
  373. iIndex: Integer;
  374. begin
  375. jcbAudit.Items.Clear;
  376. if not FProjectData.PhaseData.Active then Exit;
  377. for iIndex := 0 to FProjectData.PhaseData.AuditCount do
  378. begin
  379. if iIndex = 0 then
  380. jcbAudit.Items.Add(' 原报')
  381. else
  382. jcbAudit.Items.Add(Format(' %d 审', [iIndex]));
  383. end;
  384. if jcbAudit.ItemIndex <> jcbAudit.Items.Count - 1 then
  385. jcbAudit.ItemIndex := jcbAudit.Items.Count - 1
  386. else
  387. FProjectData.ResetPhaseDataLink;
  388. jcbAudit.Enabled := jcbAudit.Items.Count > 0;
  389. end;
  390. procedure TProjectFrame.jcbAuditChanged(Sender: TObject);
  391. begin
  392. if FProjectData.PhaseData.StageIndex = jcbAudit.ItemIndex then Exit;
  393. FProjectData.StageIndex := jcbAudit.ItemIndex;
  394. RefreshProjectState;
  395. end;
  396. procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
  397. Item: TdxSideBarItem);
  398. procedure BeforeChangeView;
  399. begin
  400. if G_IsCloud then
  401. begin
  402. tobtnShowChecker.Visible := ProjectData.PhaseIndex > 0;
  403. tobtnShowChecker.Enabled := (Item.Tag = xbiBillsMeasure.Tag);
  404. ButtonControl_NewPhase;
  405. if Item.Tag = xbiBillsCompile.Tag then
  406. begin
  407. if tobtnShowChecker.Down then
  408. begin
  409. tobtnShowChecker.Down := False;
  410. tobtnShowChecker.Click;
  411. tobtnStandardBills.Down := True;
  412. tobtnStandardBills.Click;
  413. tobtnStandardBills.Down := False;
  414. tobtnStandardBills.Click;
  415. end;
  416. end;
  417. end;
  418. // 记录台账分解、计量台账等的右侧展开情况
  419. if jpsAssistant.Visible then
  420. jpsMain.ActivePage.Tag := jpsAssistant.ActivePageIndex
  421. else
  422. jpsMain.ActivePage.Tag := -1;
  423. end;
  424. procedure AfterChangeView;
  425. begin
  426. // 仅计量台账界面可以选择计量期
  427. pnlPhaseSelect.Visible := Item.Tag = xbiBillsMeasure.Tag;
  428. // 台账分解、计量台账、审核比较 可使用"显示至"功能
  429. tbExpand.Visible := (Item.Tag = xbiBillsCompile.Tag)
  430. or (Item.Tag = xbiBillsMeasure.Tag)
  431. or (Item.Tag = xbiStageCompare.Tag);
  432. // 右侧按钮是否显示
  433. tbToolsButton.Visible := (Item.Tag = xbiBillsCompile.Tag)
  434. or (Item.Tag = xbiBillsMeasure.Tag);
  435. tobtnBGL.Visible := Item.Tag = xbiBillsMeasure.Tag;
  436. tobtnZJJL.Visible := Item.Tag = xbiBillsMeasure.Tag;
  437. // 控制整个按钮工具栏显示,
  438. pnlToolBar.Visible := pnlPhaseSelect.Visible or tbExpand.Visible or tbToolsButton.Visible;
  439. // 根据当前View控制右侧按钮是否按下,右侧工具窗是否弹开
  440. jpsAssistant.ActivePageIndex := jpsMain.ActivePage.Tag;
  441. sbtnExpend.Tag := jpsMain.ActivePage.Tag;
  442. ControlAssistantButtonsDown(jpsMain.ActivePage.Tag);
  443. SetAssistantViewVisible(jpsMain.ActivePage.Tag <> -1);
  444. SetImageOfsbtnExpend(jpsMain.ActivePage.Tag <> -1);
  445. // 0号台账与计量台账的书签不同
  446. if Item.Tag = xbiBillsCompile.Tag then
  447. FBookmarkFrame.BMType := bmtCompile
  448. else if Item.Tag = xbiBillsMeasure.Tag then
  449. FBookmarkFrame.BMType := bmtMeasure;
  450. // 0号台账与计量台账的查找定位不同
  451. if Item.Tag = xbiBillsCompile.Tag then
  452. FSearchFrame.LocateType := ltCompile
  453. else if Item.Tag = xbiBillsMeasure.Tag then
  454. FSearchFrame.LocateType := ltMeasure;
  455. // 切换至清单汇总,须重新汇总
  456. if Item.Tag = xbiBillsGather.Tag then
  457. BillsGatherFrame.RefreshBills;
  458. // 切换至材料调差,须重新汇总展示调差清单
  459. if Item.Tag = xbiPriceMargin.Tag then
  460. PriceMarginFrame.RefreshBills;
  461. if G_IsCloud then
  462. if (Item.Tag = xbiBillsCompile.Tag) or (Item.Tag = xbiBillsMeasure.Tag) then
  463. CheckUpFile;
  464. tobtnUpFile.Enabled := Item.Tag = xbiBillsMeasure.Tag;
  465. if (tobtnUpFile.Enabled = False) and (jpsAssistant.ActivePage = jpsAssistantUpFile) then
  466. jpsAssistant.ActivePage := jpsAssistantStandardBills;
  467. end;
  468. procedure ChangeView;
  469. begin
  470. BeforeChangeView;
  471. case Item.Tag of
  472. 0, 2: jpsMain.ActivePageIndex := Item.Tag;
  473. 1, 3: if CheckMeasureEdition then jpsMain.ActivePageIndex := Item.Tag;
  474. end;
  475. AfterChangeView;
  476. end;
  477. procedure DisplayReports;
  478. begin
  479. // 准备数据
  480. if Item.Tag = xbiReport.Tag then
  481. FProjectData.CopyPhaseData;
  482. // 显示报表界面
  483. DisplayReportsForm(FProjectData);
  484. dxsbViewControl.SelectedItem := dxsbViewControl.ActiveGroup.Items[jpsMain.ActivePageIndex];
  485. end;
  486. procedure DisplayCompare;
  487. begin
  488. if FProjectData.ProjProperties.PhaseCount = 0 then
  489. begin
  490. ErrorMessage('当前项目未开始计量,暂无审核比较数据!');
  491. dxsbViewControl.SelectedItem := dxsbViewControl.ActiveGroup.Items[jpsMain.ActivePageIndex];
  492. Abort;
  493. end;
  494. ShowProgressHint('正在准备审核比较数据,请稍候...');
  495. Screen.Cursor := crHourGlass;
  496. try
  497. BeforeChangeView;
  498. if CheckMeasureEdition then
  499. begin
  500. OpenCompare;
  501. jpsMain.ActivePageIndex := Item.Tag;
  502. end;
  503. AfterChangeView;
  504. finally
  505. Screen.Cursor := crDefault;
  506. CloseProgressHint;
  507. end;
  508. end;
  509. procedure DisplayPriceMargin;
  510. var
  511. vPM_Node: TsdIDTreeNode;
  512. begin
  513. vPM_Node := FProjectData.BillsCompileData.BillsCompileTree.FindNode(iPriceMarginID);
  514. if not Assigned(vPM_Node) then
  515. begin
  516. ErrorMessage('台账中无预定义价差节点,不可使用价差功能。');
  517. dxsbViewControl.SelectedItem := dxsbViewControl.ActiveGroup.Items[jpsMain.ActivePageIndex];
  518. Abort;
  519. end
  520. else if ProjectData.ProjProperties.PhaseCount = 0 then
  521. begin
  522. TipMessage('未计量前不可进行材料调差。');
  523. dxsbViewControl.SelectedItem := dxsbViewControl.ActiveGroup.Items[jpsMain.ActivePageIndex];
  524. Abort;
  525. end;
  526. ChangeView;
  527. end;
  528. var
  529. bCloseCompare: Boolean;
  530. begin
  531. if Item.Tag = jpsMain.ActivePageIndex then Exit;
  532. bCloseCompare := (Item.Tag in [0..3]) and (jpsMain.ActivePageIndex = 4);
  533. case Item.Tag of
  534. 0..2: ChangeView;
  535. 3: DisplayPriceMargin;
  536. 4: DisplayCompare;
  537. 5: DisplayReports;
  538. end;
  539. if bCloseCompare then
  540. CloseCompare;
  541. end;
  542. procedure TProjectFrame.CreateBillsFrame;
  543. begin
  544. FBillsCompileFrame := TBillsCompileFrame.Create(Self, FProjectData.BillsCompileData);
  545. FBillsCompileFrame.ShowDesignQuantity := FProjectData.ProjProperties.ShowDesignQuantity;
  546. FBillsCompileFrame.ShowAlias := FProjectData.ProjProperties.ShowAlias;
  547. FBillsCompileFrame.OnAfterSetBookmark := ExpandBookmarkFrame;
  548. AlignControl(FBillsCompileFrame, jpsMainBillsCompile, alClient);
  549. UpdateSysProgress(65, '正在解析数据');
  550. FBillsMeasureFrame := TBillsMeasureFrame.Create(Self, FProjectData.BillsMeasureData);
  551. FBillsMeasureFrame.OnAfterSetBookmark := ExpandBookmarkFrame;
  552. FBillsMeasureFrame.ShowPriceChange := FProjectData.ProjProperties.ShowPriceChange;
  553. FBillsMeasureFrame.ShowBGLCode := FProjectData.ProjProperties.ShowBGLCode;
  554. FBillsMeasureFrame.ShowDesignQuantity := FProjectData.ProjProperties.ShowDesignQuantity;
  555. FBillsMeasureFrame.ShowAlias := FProjectData.ProjProperties.ShowAlias;
  556. AlignControl(FBillsMeasureFrame, jpsMainBillsMeasure, alClient);
  557. end;
  558. procedure TProjectFrame.CreateDealPaymentFrame;
  559. begin
  560. FDealPaymentFrame := TDealPaymentFrame.Create(Self, FProjectData.DealPaymentData);
  561. AlignControl(FDealPaymentFrame, jpsAssistantDealPayment, alClient);
  562. end;
  563. procedure TProjectFrame.CreateBillsGatherFrame;
  564. begin
  565. FBillsGatherFrame := TBillsGatherFrame.Create(Self, FProjectData.BillsGatherData);
  566. AlignControl(FBillsGatherFrame, jpsMainBillsGather, alClient);
  567. FBillsGatherFrame.ShowPriceChange := FProjectData.ProjProperties.ShowPriceChange;
  568. FBillsGatherFrame.ShowPhaseData := FProjectData.ProjProperties.PhaseCount > 0;
  569. end;
  570. procedure TProjectFrame.dxpmExpandBillsPopup(Sender: TObject);
  571. begin
  572. dxpmExpandBills.ItemLinks.Items[8].Visible := G_IsTest;
  573. dxpmExpandBills.ItemLinks.Items[7].Visible := jpsMain.ActivePageIndex in [0, 1, 4];
  574. dxpmExpandBills.ItemLinks.Items[6].Visible := jpsMain.ActivePageIndex in [1, 4];
  575. SetDxBtnAction(actnFirstLevel, MainForm.dxbtnFirstLevel);
  576. SetDxBtnAction(actnSecondLevel, MainForm.dxbtnSecondLevel);
  577. SetDxBtnAction(actnThirdLevel, MainForm.dxbtnThirdLevel);
  578. SetDxBtnAction(actnFourthLevel, MainForm.dxbtnFourthLevel);
  579. SetDxBtnAction(actnFifthLevel, MainForm.dxbtnFifthLevel);
  580. SetDxBtnAction(actnAllLevel, MainForm.dxbtnAllLevel);
  581. SetDxBtnAction(actnCurPhase, MainForm.dxbtnCurPhase);
  582. SetDxBtnAction(actnAllXmj, MainForm.dxbtnAllXmj);
  583. SetDxBtnAction(actnAllPeg, MainForm.dxbtnAllPeg);
  584. end;
  585. procedure TProjectFrame.actnFirstLevelExecute(Sender: TObject);
  586. begin
  587. ExpandNodeTo(TAction(Sender).Tag);
  588. end;
  589. procedure TProjectFrame.tbExpandClick(Sender: TObject);
  590. var
  591. P: TPoint;
  592. begin
  593. P := pnlToolBar.ClientToScreen(Point(tbExpand.Left, tbExpand.Top + tbExpand.Height));
  594. dxpmExpandBills.Popup(P.X, P.Y);
  595. end;
  596. procedure TProjectFrame.actnAllXmjExecute(Sender: TObject);
  597. begin
  598. ExpandAllXmj;
  599. end;
  600. procedure TProjectFrame.ExpandNodeTo(ALevel: Integer);
  601. begin
  602. Screen.Cursor := crHourGlass;
  603. case ALevel of
  604. 0..4: UpdateSysProgress(0, Format('正在显示至第%d层', [ALevel + 1]));
  605. else UpdateSysProgress(0, '正在显示至最底层');
  606. end;
  607. try
  608. case jpsMain.ActivePageIndex of
  609. 0: FBillsCompileFrame.ExpandNodeTo(ALevel);
  610. 1: FBillsMeasureFrame.ExpandNodeTo(ALevel);
  611. 4: FPhaseCompareFrame.ExpandNodeTo(ALevel);
  612. end;
  613. finally
  614. UpdateSysProgress(0, '就绪');
  615. Screen.Cursor := crDefault;
  616. end;
  617. end;
  618. procedure TProjectFrame.ExpandAllXmj;
  619. begin
  620. Screen.Cursor := crHourGlass;
  621. UpdateSysProgress(0, '正在显示至项目节');
  622. try
  623. case jpsMain.ActivePageIndex of
  624. 0: FBillsCompileFrame.ExpandXmjNode;
  625. 1: FBillsMeasureFrame.ExpandXmjNode;
  626. 4: FPhaseCompareFrame.ExpandXmjNode;
  627. end;
  628. finally
  629. UpdateSysProgress(0, '就绪');
  630. Screen.Cursor := crDefault;
  631. end;
  632. end;
  633. procedure TProjectFrame.UnLockData;
  634. procedure DoUnLockData;
  635. begin
  636. FProjectData.CanUnlockInfo := True;
  637. FBillsCompileFrame.stdBillsCompile.Column('LockedInfo').ReadOnly := False;
  638. //FProjectData.BillsData.UnLockedBaseData;
  639. end;
  640. begin
  641. if FProjectData.CheckPassword then
  642. DoUnLockData;
  643. end;
  644. procedure TProjectFrame.CreateCheckerFrame;
  645. begin
  646. FCheckerFrame := TCheckerFrame.Create(Self);
  647. FCheckerFrame.Owner := Self;
  648. FCheckerFrame.ProjectData := FProjectData;
  649. AlignControl(FCheckerFrame, jpsAssistantChecker, alClient);
  650. FCheckerFrame.Init;
  651. end;
  652. procedure TProjectFrame.btnSubmitClick(Sender: TObject);
  653. begin
  654. if not CheckCanReport then Exit;
  655. Screen.Cursor := crHourGlass;
  656. try
  657. UpToWeb(True);
  658. finally
  659. Screen.Cursor := crDefault;
  660. end;
  661. end;
  662. procedure TProjectFrame.btnPassClick(Sender: TObject);
  663. begin
  664. btnSubmitClick(Sender);
  665. end;
  666. function TProjectFrame.IsUped: Boolean; // 是否上传过
  667. begin
  668. Result := False;
  669. // 只有0号台帐那肯定没上传过
  670. if ProjectData.PhaseIndex = 0 then Exit;
  671. // 当前显示的期小于最新期(当前期是旧期),则当前期肯定已经上传过了
  672. if ProjectData.PhaseIndex < ProjectData.ProjProperties.PhaseCount then
  673. begin
  674. Result := True;
  675. end
  676. // 当前显示的期是最新期,分两种情况判断,如果第一审核人已有状态,则上传过了
  677. else if ProjectData.PhaseIndex = ProjectData.ProjProperties.PhaseCount then
  678. begin
  679. // 当用户点击新增一期计量后,会调用该方法,此时,有一期数据,却为上传过
  680. if not Assigned(CheckerFrame) then
  681. Result := False
  682. else if not CheckerFrame.HasChecker then
  683. Result := False
  684. else if CheckerFrame.FirstChecker.CheckStatus = csNotBegin then
  685. Result := False
  686. else
  687. Result := True;
  688. end;
  689. end;
  690. procedure TProjectFrame.ButtonControl_UpToWeb;
  691. begin
  692. if ProjectData.CurUserIsAuthor then
  693. begin
  694. btnSubmit.Visible := True;
  695. // 有计量(非0号台账状态),且当前计量期尚未上报过
  696. btnSubmit.Enabled := (ProjectData.PhaseIndex > 0) and (not IsUped);
  697. btnPass.Visible := False;
  698. btnNotPass.Visible := btnPass.Visible;
  699. btnSubmit.Left := jcbAudit.Left + jcbAudit.Width + 5;
  700. end
  701. else if ProjectData.CurUserIsOwner or ProjectData.CurUserIsChecker then
  702. begin
  703. btnSubmit.Visible := False;
  704. btnPass.Visible := True;
  705. btnNotPass.Visible := btnPass.Visible;
  706. // 在本期我是审核人,切换到历史期有可能我没参与。 所以当CheckerFrame.Me为空时,有可能我是编制人,有可能历史期我没参与。
  707. // 历史期,管你那么多,直接按钮不见。
  708. if ProjectData.PhaseIndex < ProjectData.ProjProperties.PhaseCount then
  709. btnPass.Enabled := False
  710. else
  711. btnPass.Enabled := CheckerFrame.Me.IsChecking;
  712. btnNotPass.Enabled := btnPass.Enabled;
  713. btnPass.Left := jcbAudit.Left + jcbAudit.Width + 5;
  714. btnNotPass.Left := btnPass.Left + btnPass.Width + 1;
  715. end;
  716. if Assigned(CheckerFrame) then
  717. pnlProjectCheckStatus.Visible := CheckerFrame.OwnerFrame.CheckStatus = csFinished
  718. else
  719. pnlProjectCheckStatus.Visible := False;
  720. if Assigned(FCheckerFrame) then
  721. FCheckerFrame.RepairDelete(btnSubmit.Visible and btnSubmit.Enabled);
  722. end;
  723. procedure TProjectFrame.UpToWeb(ACheckPassed: Boolean);
  724. var sURL, sAppFile, sJsonFile_Bills, sJsonFile_Common, sAppFile_UnLock,
  725. sZipFile, sResult, sMD5_JL, sPassedHint1, sPassedHint2,
  726. sNoPassedHint1, sNoPassedHint2, sCheckerMemo: string;
  727. vA, vArr: array of string;
  728. vRec: TsdDataRecord;
  729. bSubmit: Boolean;
  730. vExportor: TTenderExport;
  731. vCF: TCheckerMemoForm;
  732. bNeedFreeEarlier: Boolean;
  733. // 1 审核; 2 批复。
  734. function SaveAndExport(AType: Integer): Boolean;
  735. function InnerSubmit(AType: Integer): Boolean;
  736. begin
  737. if AType = 1 then
  738. Result := ProjectData.SubmitProject(sAppFile)
  739. else if AType = 2 then
  740. Result := ProjectData.ReplyProject(sAppFile);
  741. end;
  742. begin
  743. Result := False;
  744. ProgressProCreate(100, '本地数据文件上传到云端');
  745. ProgressProRun('保存本地数据...', 0);
  746. ProjectData.Save;
  747. ProgressProRun('保存本地数据。OK', 10, pmtEdit);
  748. ProgressProRun('导出并检验文件...', 0);
  749. if not InnerSubmit(AType) then
  750. if not InnerSubmit(AType) then
  751. begin
  752. bNeedFreeEarlier := True;
  753. Application.MessageBox('Sorry!本地文件连续2次导出检验失败!如果重试后仍不能解决该问题,请联系纵横客服。', '提示', MB_OK + MB_ICONWARNING);
  754. Exit;
  755. end;
  756. Result := True;
  757. ProgressProRun('导出并检验文件。OK', 10, pmtEdit);
  758. end;
  759. begin
  760. bSubmit := False;
  761. bNeedFreeEarlier := False;
  762. sAppFile := PHPWeb.UserPath + 'ProjectFile.rmf';
  763. // 只有编制人才真正需要该文件存在
  764. // sAppFile_UnLock := PHPWeb.UserPath + 'ProjectFile_UnLock';
  765. sPassedHint1 :=
  766. '【审批通过】后,计量数据将自动交付给下一审批人进行审批,操作后将不可更改,是否通过审批?';
  767. sPassedHint2 :=
  768. '(终审)审批通过后本期计量审批将标记为审批完成,操作后将不可更改,是否通过审批?';
  769. sNoPassedHint1 :=
  770. '【审批不通过】后,本次审批将结束,后续的审批人也将不会审批本次计量,' +
  771. '本期数据也将直接打回给上报人进行重新计量报审。' + #10#13 +
  772. '点击【确定】进入操作确认。';
  773. sNoPassedHint2 := PHPWeb.RealName +
  774. ',请确认本期计量审批不通过。' + #10#13 + '点击【确定】本期计量审批' +
  775. '不通过,计量将不可再更改。';
  776. vCF := TCheckerMemoForm.Create(nil);
  777. try
  778. if ProjectData.CurUserIsAuthor then
  779. begin
  780. bSubmit := True;
  781. if not CheckerFrame.HasNormalChecker then
  782. begin
  783. Application.MessageBox('上报审批前请先配置审核人!', '提示', MB_OK + MB_ICONWARNING);
  784. tobtnShowChecker.Down := True;
  785. tobtnShowChecker.Click;
  786. Exit;
  787. end;
  788. // 保存一次缓存数据,以保证提示信息能读取正确的值
  789. ProjectData.SaveLastestPhaseMainData;
  790. if Application.MessageBox(PChar(CheckersHint), '询问', MB_YESNO + MB_ICONQUESTION) = ID_No then
  791. Exit;
  792. if not SaveAndExport(1) then Exit;
  793. end
  794. else if ProjectData.CurUserIsChecker then
  795. begin
  796. if ACheckPassed then
  797. begin
  798. vCF.Init(sPassedHint1, 1);
  799. if vCF.ShowModal = mrCancel then
  800. Exit
  801. else
  802. sCheckerMemo := vCF.Memo;
  803. end
  804. else
  805. begin
  806. vCF.Init(sNoPassedHint1, 0);
  807. if vCF.ShowModal = mrCancel then
  808. Exit
  809. else
  810. sCheckerMemo := vCF.Memo;
  811. if Application.MessageBox(PChar(sNoPassedHint2), '询问', MB_OKCANCEL + MB_ICONQUESTION) = ID_CANCEL then
  812. Exit;
  813. end;
  814. if not SaveAndExport(1) then Exit;
  815. end
  816. else if ProjectData.CurUserIsOwner then
  817. begin
  818. if ACheckPassed then
  819. begin
  820. vCF.Init(sPassedHint2, 1);
  821. if vCF.ShowModal = mrCancel then
  822. Exit
  823. else
  824. sCheckerMemo := vCF.Memo;
  825. end
  826. else
  827. begin
  828. vCF.Init(sNoPassedHint1, 0);
  829. if vCF.ShowModal = mrCancel then
  830. Exit
  831. else
  832. sCheckerMemo := vCF.Memo;
  833. if Application.MessageBox(PChar(sNoPassedHint2), '询问', MB_OKCANCEL + MB_ICONQUESTION) = ID_CANCEL then
  834. Exit;
  835. end;
  836. if not SaveAndExport(2) then Exit;
  837. end;
  838. finally
  839. vCF.Free;
  840. if bNeedFreeEarlier then
  841. ProgressProFree;
  842. end;
  843. try
  844. ProgressProRun('导出用于Web展示的清单、汇总数据等...', 0);
  845. sJsonFile_Bills := ExtractFilePath(sAppFile) + 'JsonFile_Bills.json';
  846. sJsonFile_Common := ExtractFilePath(sAppFile) + 'JsonFile_Common.json';
  847. sMD5_JL := MD5_File(sAppFile);
  848. // 上传清单,每期都传,可覆盖旧的。
  849. ProjectData.ExportJson_Bills(sJsonFile_Bills);
  850. ProjectData.ExportJson_Common(sJsonFile_Common);
  851. ProgressProRun('导出用于Web展示的清单、汇总数据等。OK', 10, pmtEdit);
  852. ProgressProRun('生成并检验up数据包文件...', 0);
  853. sZipFile := PHPWeb.zip([sAppFile, sJsonFile_Bills, sJsonFile_Common]);
  854. if not PHPWeb.CheckZip(sZipFile, 3) then
  855. begin
  856. Application.MessageBox('up数据包文件无法通过检验请重试!如果重试后仍不能解决该问题,请联系纵横客服。', '提示', MB_OK + MB_ICONWARNING);
  857. Exit;
  858. end;
  859. ProgressProRun('生成并检验up数据包文件。OK', 10, pmtEdit);
  860. try
  861. ProgressProRun('上传数据包到云端...(温馨提示:请不要乱点哦,Windows容易死机)', 0);
  862. if PHPWeb.UpDataFile(PHPWeb.UserID, ProjectData.WebID, ProjectData.PhaseIndex,
  863. sZipFile, sMD5_JL, bSubmit, sResult, ACheckPassed, sCheckerMemo) then
  864. begin
  865. DeleteFile(sAppFile);
  866. ProgressProRun('上传数据包到云端。OK', 90, pmtEdit, pptSet);
  867. if ProjectData.CurUserIsChecker then
  868. ProjectData.Checkers.FindByID(PHPWeb.UserID).Memo := sCheckerMemo;
  869. if ProjectData.PhaseIndex = 0 then // 0号台账,现已废弃
  870. begin
  871. MainForm.ProjectManagerFrame.ShowProjectInfoTop(0);
  872. end
  873. else
  874. Begin
  875. vRec := MainForm.ProjectManagerFrame.Rec(ProjectData.ProjectID);
  876. vRec.BeginUpdate;
  877. vRec.ValueByName('WebMD5').AsString := sMD5_JL;
  878. vRec.EndUpdate;
  879. MainForm.ProjectManagerFrame.ShowProjectInfoTop;
  880. if ProjectData.CurUserIsAuthor then
  881. begin
  882. CheckerFrame.FirstChecker.CheckStatus := csChecking;
  883. CheckerFrame.AddFrame.Visible := False;
  884. end
  885. else if ProjectData.CurUserIsChecker then
  886. begin
  887. if ACheckPassed then
  888. begin
  889. CheckerFrame.Me.CheckStatus := csFinished;
  890. CheckerFrame.NextChecker.CheckStatus := csChecking;
  891. end
  892. else
  893. CheckerFrame.Me.CheckStatus := csNotPass;
  894. CheckerFrame.Me.CheckerMemo := sCheckerMemo;
  895. end
  896. else if ProjectData.CurUserIsOwner then
  897. begin
  898. if ACheckPassed then
  899. CheckerFrame.Me.CheckStatus := csFinished
  900. else
  901. CheckerFrame.Me.CheckStatus := csNotPass;
  902. end;
  903. end;
  904. btnSubmit.Enabled := False;
  905. FCheckerFrame.RepairDelete(False);
  906. btnPass.Enabled := False;
  907. btnNotPass.Enabled := btnPass.Enabled;
  908. pnlProjectCheckStatus.Visible := CheckerFrame.OwnerFrame.CheckStatus = csFinished;
  909. Application.MessageBox('^_^ 恭喜!数据已成功上传到云端服务器。', '提示', MB_OK + MB_ICONINFORMATION);
  910. end
  911. else
  912. Application.MessageBox(PChar('数据上传失败请重试!服务器故障:' + sResult), '警告', MB_OK + MB_ICONWARNING);
  913. except
  914. Application.MessageBox(PChar('数据上传失败请重试!网络较差,数据文件无法送达云端:' +
  915. sResult), '警告', MB_OK + MB_ICONWARNING);
  916. end;
  917. finally
  918. ProgressProFree;
  919. end;
  920. end;
  921. procedure TProjectFrame.btnNotPassClick(Sender: TObject);
  922. begin
  923. Screen.Cursor := crHourGlass;
  924. try
  925. UpToWeb(False);
  926. finally
  927. Screen.Cursor := crDefault;
  928. end;
  929. end;
  930. function TProjectFrame.CheckersHint: string;
  931. var vSL: TStringList;
  932. i: Integer;
  933. sChecker, sChar: string;
  934. Rec: TsdDataRecord;
  935. begin
  936. vSL := TStringList.Create;
  937. try
  938. CheckerFrame.CheckerNameList(vSL);
  939. for i := 0 to vSL.Count - 1 do
  940. begin
  941. if i = 0 then
  942. sChar := ''
  943. else
  944. sChar := ' > ';
  945. sChecker := sChecker + sChar + vSL[i];
  946. end;
  947. while Length(sChecker) < 38 do // 保证提示框的大小达到最佳效果
  948. sChecker := sChecker + ' ';
  949. Rec := ProjectData.MainListData.GetPhaseMainRecord(FProjectData.PhaseIndex);
  950. Result := Format('本期计量:%m元。%s审批流程:%s%s上报后将不可更改,确定要上报吗?',
  951. [Rec.ValueByName('GatherTotalPrice').AsFloat, #10#13#10#13, sChecker, #10#13#10#13]);
  952. finally
  953. vSL.Free;
  954. end;
  955. end;
  956. procedure TProjectFrame.btnNewPhaseClick(Sender: TObject);
  957. begin
  958. dxsbViewControl.SelectedItem := dxsbViewControl.Groups[0].Items[1];
  959. dxsbViewControl.OnItemClick(Sender, dxsbViewControl.Groups[0].Items[1]);
  960. CreateNewPhase;
  961. end;
  962. procedure TProjectFrame.ButtonControl_NewPhase;
  963. var b1, b2, b3: Boolean;
  964. begin
  965. // “新建一期计量”按钮的显示隐藏
  966. // 计量界面,且是原报才显示
  967. b1 := (dxsbViewControl.SelectedItem.Index = 0) and ProjectData.CurUserIsAuthor;
  968. // ①尚无审核人列表 ②当前期已审核完成
  969. b2 := (not Assigned(CheckerFrame)) or (Assigned(CheckerFrame) and CheckerFrame.OwnerFrame.IsFinished);
  970. // 当前查看的是最新期。查看历史期不显示。
  971. b3 := (FProjectData.ProjProperties.PhaseCount = FProjectData.PhaseIndex);
  972. pnlNewPhase.Visible := b1 and b2 and b3;
  973. end;
  974. procedure TProjectFrame.actnCurPhaseExecute(Sender: TObject);
  975. begin
  976. ExpandCurPhase;
  977. end;
  978. procedure TProjectFrame.RepairAudits;
  979. var i, iSel: Integer;
  980. UserArr: array of string;
  981. sURL: string;
  982. begin
  983. jcbAudit.ItemHeight := 20;
  984. jcbAudit.Font.Name := '微软雅黑';
  985. jcbAudit.Font.Size := 10;
  986. jcbAudit.DropDownBox.Height := jcbAudit.Items.Count * jcbAudit.ItemHeight + 35;
  987. iSel := jcbAudit.ItemIndex;
  988. for i := 0 to jcbAudit.Items.Count - 1 do
  989. begin
  990. if i = 0 then
  991. begin
  992. // 原报:编制人。没有跟审核人一个表,另外查询。个人觉得这里设计得不好。
  993. // 打开软件时自动扫描,杰哥那头返回不了编制人的项目,也是这个原因。
  994. // 说服不了特工,先这样吧。
  995. sURL := Format('%suser/get/%d/info', [PHPWeb.MeasureURL, FProjectData.WebAuthorID]);
  996. UserArr := VarArrayOf(['avatar', 'name', 'jobs', 'company']);
  997. if PHPWeb.Search(sURL, [], [], UserArr) = 1 then
  998. jcbAudit.Items[i] := jcbAudit.Items[i] + ' ' + UserArr[1] + '-' + UserArr[2];
  999. end
  1000. else
  1001. begin
  1002. // 某种漏洞的操作下,文件中记载的审核人数和审核人列表中的审核人数不一致,
  1003. // 匹配时会溢出。这里要加判断。
  1004. if i > CheckerFrame.List.Count then Break;
  1005. if TOrderCheckerFrame(CheckerFrame.List[i - 1]) = FCheckerFrame.OwnerFrame then
  1006. begin
  1007. jcbAudit.Items[i] := ' 终审 ' +
  1008. TOrderCheckerFrame(CheckerFrame.List[i - 1]).UserName + '-' +
  1009. TOrderCheckerFrame(CheckerFrame.List[i - 1]).UserRole
  1010. end
  1011. else
  1012. begin
  1013. jcbAudit.Items[i] := jcbAudit.Items[i] + ' ' +
  1014. TOrderCheckerFrame(CheckerFrame.List[i - 1]).UserName + '-' +
  1015. TOrderCheckerFrame(CheckerFrame.List[i - 1]).UserRole;
  1016. end;
  1017. end;
  1018. end;
  1019. jcbAudit.ItemIndex := iSel;
  1020. end;
  1021. procedure TProjectFrame.CreateFrames;
  1022. begin
  1023. UpdateSysProgress(10, '正在解析数据');
  1024. CreateBillsFrame;
  1025. UpdateSysProgress(130, '正在解析数据');
  1026. CreateDealPaymentFrame;
  1027. UpdateSysProgress(140, '正在解析数据');
  1028. CreateBillsGatherFrame;
  1029. UpdateSysProgress(150, '正在解析数据');
  1030. CreatePriceMarginFrame;
  1031. FZJJLFrame := TZJJLFrame.Create(Self, FProjectData.PhaseData.ZJJLData);
  1032. FZJJLFrame.DataReadOnly := FProjectData.PhaseData.StageDataReadOnly;
  1033. AlignControl(FZJJLFrame, jpsAssistantZJJL, alClient);
  1034. UpdateSysProgress(160, '正在解析数据');
  1035. FBGLFrame := TBGLFrame.Create(Self, FProjectData.BGLData);
  1036. AlignControl(FBGLFrame, jpsAssistantBGL, alClient);
  1037. UpdateSysProgress(170, '正在解析数据');
  1038. FSearchFrame := TSearchFrame.Create(Self, FProjectData.SearchData);
  1039. AlignControl(FSearchFrame, jpsAssistantSearch, alClient);
  1040. UpdateSysProgress(180, '正在解析数据');
  1041. FBookmarkFrame := TBookmarkFrame.Create(Self, FProjectData);
  1042. AlignControl(FBookmarkFrame, jpsAssistantBookmark, alClient);
  1043. UpdateSysProgress(190, '正在解析数据');
  1044. FDealBillsFrame := TDealBillsFrame.Create(Self, FProjectData.DealBillsData);
  1045. AlignControl(FDealBillsFrame, jpsAssistantDealBills, alClient);
  1046. UpdateSysProgress(200, '就绪');
  1047. end;
  1048. procedure TProjectFrame.InitialForVersions;
  1049. begin
  1050. if _ModuleType = mtCompile then
  1051. begin
  1052. // 去掉审核比较
  1053. dxsbViewControl.Groups.Items[0].Items.Delete(3);
  1054. // 去掉计量台账
  1055. dxsbViewControl.Groups.Items[0].Items.Delete(1);
  1056. end;
  1057. end;
  1058. procedure TProjectFrame.ExpandBookmarkFrame(AExpandFrame: Boolean);
  1059. begin
  1060. // 展开书签
  1061. if AExpandFrame then
  1062. begin
  1063. jpsAssistant.ActivePageIndex := tobtnBookmark.Tag;
  1064. sbtnExpend.Tag := tobtnBookmark.Tag;
  1065. ControlAssistantButtonsDown(tobtnBookmark.Tag);
  1066. jpsMain.ActivePage.Tag := tobtnBookmark.Tag;
  1067. SetAssistantViewVisible(True);
  1068. SetImageOfsbtnExpend(True);
  1069. end;
  1070. // 刷新书签批注
  1071. FBookmarkFrame.RefreshMarkMemo;
  1072. end;
  1073. {
  1074. 在意外情况下,文件中记录的审核人与云端记录的审核人不一致,文件中的审核表有时
  1075. 被多创建,有时少创建。这时不允许继续操作,需强制关闭:
  1076. 1、如果第x个人为审核中,则:
  1077. ①当前登录用户,如果非工作中,无论编制人、审核人还是业主,审核表个数应为x。
  1078. ②当前登录用户,如果工作中,必是审核人或业主,审核表个数应为x + 1。
  1079. 2、如果找不到审核中,找到了第x个人为审核不通过,则:
  1080. ①当前登录用户为编制人:
  1081. a.重新开始:审核表个数应为1。
  1082. b.仅查看不通过项目:审核表个数应为x + 1。
  1083. ②当前登录用户为审核人或业主:一定是非工作中(编制人工作中),审核表个数应为x + 1。
  1084. 3、如果找不到审核中,也找不到审核不通过,如果最后一个人是审核完成,则:
  1085. ①当前登录用户为编制人,此时编制人尚末开始新的一期,下拉还是上一期的,审核表个数亦为x+1。
  1086. ②当前登录用户为审核人或业主,审核表个数为x+1。
  1087. 4、如果找不到审核中,也找不到审核不通过,如果第一个人是末审核,则:
  1088. ①当前登录用户为编制人,审核表个数应为1。 }
  1089. function TProjectFrame.CheckFileAndCloudChekerList: Boolean;
  1090. var iNo, iC: Integer;
  1091. begin
  1092. Result := False;
  1093. iC := jcbAudit.Items.Count;
  1094. if not Assigned(FCheckerFrame) then // 0号台帐阶段还没有审核人业务
  1095. begin
  1096. Result := True;
  1097. Exit;
  1098. end;
  1099. iNo := FCheckerFrame.CheckNo(csChecking);
  1100. if iNo <> -1 then // 审核中
  1101. begin
  1102. // FCheckerFrame.Me = nil :编制 (这里体现出编制人不在审核人列表中极不合理!)
  1103. if (FCheckerFrame.Me <> nil) and FCheckerFrame.Me.IsChecking then
  1104. Result := (iC = iNo + 1)
  1105. else
  1106. Result := (iC = iNo);
  1107. end
  1108. else
  1109. begin
  1110. iNo := FCheckerFrame.CheckNo(csNotPass);
  1111. if iNo <> -1 then // 审核不通过
  1112. begin
  1113. if ProjectData.CurUserIsAuthor then
  1114. Result := ((iC = 1) or (iC = iNo + 1))
  1115. else if FCheckerFrame.InCheckerList(PHPWeb.UserID) then
  1116. Result := (iC = iNo + 1);
  1117. end
  1118. else
  1119. begin
  1120. if FCheckerFrame.LastChecker.CheckStatus = csFinished then // 最后一个人是审核完成
  1121. Result := (iC = FCheckerFrame.List.Count + 1)
  1122. else // 第一个人是末审核
  1123. Result := (iC = 1);
  1124. end;
  1125. end;
  1126. end;
  1127. procedure TProjectFrame.tobtnUpFileClick(Sender: TObject);
  1128. begin
  1129. with TToolButton(Sender) do
  1130. begin
  1131. if Down then
  1132. begin
  1133. jpsAssistant.ActivePageIndex := Tag;
  1134. sbtnExpend.Tag := Tag;
  1135. ControlAssistantButtonsDown(Tag);
  1136. jpsMain.ActivePage.Tag := Tag;
  1137. end;
  1138. SetAssistantViewVisible(Down);
  1139. SetImageOfsbtnExpend(Down);
  1140. end;
  1141. CheckUpFile;
  1142. end;
  1143. procedure TProjectFrame.CreateUpFile;
  1144. begin
  1145. FUpFileManageView := TUpFileManageView.Create(nil);
  1146. FUpFileManageView.Owner := Self;
  1147. FUpFileManageView.ProjectData := FProjectData;
  1148. FUpFileManageView.Datas := FProjectData.AttachmentData;
  1149. FUpFileManageView.Parent := jpsAssistantUpFile;
  1150. FUpFileManageView.Align := alClient;
  1151. end;
  1152. procedure TProjectFrame.SetUpFileManageView(
  1153. const Value: TUpFileManageView);
  1154. begin
  1155. FUpFileManageView := Value;
  1156. end;
  1157. procedure TProjectFrame.jpsAssistantActivePageChanged(Sender: TObject);
  1158. begin
  1159. if G_IsCloud then
  1160. CheckUpFile;
  1161. end;
  1162. procedure TProjectFrame.CheckUpFile;
  1163. var vRec: TsdDataRecord;
  1164. begin
  1165. if jpsAssistant.Visible and (jpsAssistant.ActivePage = jpsAssistantUpFile) then
  1166. begin
  1167. if jpsMain.ActivePage = jpsMainBillsCompile then
  1168. begin
  1169. vRec := FBillsCompileFrame.BillsCompileData.sdvBillsCompile.Current;
  1170. if vRec = nil then
  1171. vRec := FBillsCompileFrame.stdBillsCompile.IDTree.Items[0].Rec;
  1172. end
  1173. else if jpsMain.ActivePage = jpsMainBillsMeasure then
  1174. begin
  1175. vRec := FBillsMeasureFrame.BillsMeasureData.sdvBillsMeasure.Current;
  1176. if vRec = nil then
  1177. vRec := FBillsMeasureFrame.stdBillsMeasure.IDTree.Items[0].Rec;
  1178. end;
  1179. FUpFileManageView.DoOnBillChange(vRec);
  1180. end;
  1181. end;
  1182. procedure TProjectFrame.SaveLog(AStr: string);
  1183. var
  1184. sFileName: string;
  1185. F: TextFile;
  1186. begin
  1187. sFileName := GetAppFilePath + 'TimeLog.txt';
  1188. AssignFile(F, sFileName);
  1189. if FileExists(sFileName) then
  1190. Append(F)
  1191. else
  1192. Rewrite(F);
  1193. Writeln(F, AStr);
  1194. CloseFile(F);
  1195. end;
  1196. procedure TProjectFrame.ReLockData;
  1197. begin
  1198. FProjectData.CanUnlockInfo := False;
  1199. FBillsCompileFrame.stdBillsCompile.Column('LockedInfo').ReadOnly := True;
  1200. end;
  1201. procedure TProjectFrame.CloseCompare;
  1202. begin
  1203. FPhaseCompareFrame.Free;
  1204. FProjectData.PhaseCompareData.Close;
  1205. FProjectData.PhaseData.StageCompareData.Close;
  1206. end;
  1207. procedure TProjectFrame.OpenCompare;
  1208. begin
  1209. FProjectData.PhaseData.Save;
  1210. FProjectData.PhaseData.StageCompareData.Open;
  1211. FProjectData.PhaseCompareData.Open;
  1212. FPhaseCompareFrame := TPhaseCompareFrame.Create(Self, FProjectData.PhaseCompareData);
  1213. AlignControl(FPhaseCompareFrame, jpsMainStageCompare, alClient);
  1214. end;
  1215. procedure TProjectFrame.RefreshColumnDisplay;
  1216. begin
  1217. BillsCompileFrame.ShowDesignQuantity := FProjectData.ProjProperties.ShowDesignQuantity;
  1218. BillsCompileFrame.ShowAlias := FProjectData.ProjProperties.ShowAlias;
  1219. BillsMeasureFrame.ShowPriceChange := FProjectData.ProjProperties.ShowPriceChange;
  1220. BillsMeasureFrame.ShowBGLCode := FProjectData.ProjProperties.ShowBGLCode;
  1221. BillsMeasureFrame.ShowDesignQuantity := FProjectData.ProjProperties.ShowDesignQuantity;
  1222. BillsMeasureFrame.ShowAlias := FProjectData.ProjProperties.ShowAlias;
  1223. BillsGatherFrame.ShowPriceChange := FProjectData.ProjProperties.ShowPriceChange;
  1224. end;
  1225. procedure TProjectFrame.RefreshProjectState;
  1226. begin
  1227. FBillsCompileFrame.RefreshPhase_Stage;
  1228. FBillsMeasureFrame.RefreshPhase_Stage;
  1229. FDealPaymentFrame.RefreshPhase_Stage;
  1230. FPriceMarginFrame.ResetViewControl;
  1231. end;
  1232. procedure TProjectFrame.ExpandCurPhase;
  1233. begin
  1234. Screen.Cursor := crHourGlass;
  1235. UpdateSysProgress(0, '正在显示至项目节');
  1236. try
  1237. case jpsMain.ActivePageIndex of
  1238. 1: FBillsMeasureFrame.ExpandCurPhase;
  1239. 4: FPhaseCompareFrame.ExpandCurPhase;
  1240. end;
  1241. finally
  1242. UpdateSysProgress(0, '就绪');
  1243. Screen.Cursor := crDefault;
  1244. end;
  1245. end;
  1246. function TProjectFrame.CheckCanReport: Boolean;
  1247. begin
  1248. Result := QuestMessageYesNo('请确定已生成中间计量数据?');
  1249. // 使用控件点击进行定位,重新定义方法太复杂
  1250. if not Result then
  1251. begin
  1252. // 先定位至计量台账界面
  1253. dxsbViewControl.SelectedItem := dxsbViewControl.ActiveGroup.Items[1];
  1254. dxsbViewControlItemClick(dxsbViewControl, dxsbViewControl.ActiveGroup.Items[1]);
  1255. // 再定位至中间计量界面
  1256. tobtnZJJL.Down := True;
  1257. tobtnZJJL.Click;
  1258. end;
  1259. end;
  1260. procedure TProjectFrame.actnAllPegExecute(Sender: TObject);
  1261. begin
  1262. Screen.Cursor := crHourGlass;
  1263. UpdateSysProgress(0, '正在显示至桩号(项目节)');
  1264. try
  1265. case jpsMain.ActivePageIndex of
  1266. 0: FBillsCompileFrame.ExpandPegXmjNode;
  1267. end;
  1268. finally
  1269. UpdateSysProgress(0, '就绪');
  1270. Screen.Cursor := crDefault;
  1271. end;
  1272. end;
  1273. procedure TProjectFrame.CreatePriceMarginFrame;
  1274. begin
  1275. FPriceMarginFrame := TPriceMarginFrame.Create(FProjectData);
  1276. AlignControl(FPriceMarginFrame, jpsMainPriceMargin, alClient);
  1277. end;
  1278. end.