ProjectFme.pas 46 KB

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