FindUserFrm.pas 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. {*******************************************************************************
  2. 单元名称: FindUserFrm.pas
  3. 单元说明: 查找审核人。
  4. 作者时间: Chenshilong, 2014-07-11
  5. 2017.06.19 该窗口定制太深,不通用,改成通用查询窗口。
  6. *******************************************************************************}
  7. unit FindUserFrm;
  8. interface
  9. uses
  10. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  11. Dialogs, JimPages, StdCtrls, cxLookAndFeelPainters, cxButtons,
  12. cxControls, cxContainer, cxEdit, cxTextEdit, ExtCtrls;
  13. type
  14. TFindUserForm = class(TForm)
  15. JimPageControl1: TJimPageControl;
  16. JimPageControl1Page1: TJimPage;
  17. JimPageControl1Page2: TJimPage;
  18. lblHint1: TLabel;
  19. lblHint2: TLabel;
  20. edtMail: TcxTextEdit;
  21. btnSearch: TcxButton;
  22. pnlUser: TPanel;
  23. bvl1: TBevel;
  24. lbl3: TLabel;
  25. imgUserPic: TImage;
  26. lblUserName: TLabel;
  27. lblUserRole: TLabel;
  28. lblUserCompany: TLabel;
  29. shp2: TShape;
  30. btnAdd: TcxButton;
  31. lblHint: TLabel;
  32. procedure btnSearchClick(Sender: TObject);
  33. procedure edtMailKeyDown(Sender: TObject; var Key: Word;
  34. Shift: TShiftState);
  35. procedure btnAddClick(Sender: TObject);
  36. procedure edtMailClick(Sender: TObject);
  37. procedure FormActivate(Sender: TObject);
  38. private
  39. FOwner: TObject;
  40. FType: Integer;
  41. FWebID: Integer;
  42. FPhaseIndex: Integer;
  43. FAccount: string;
  44. { Private declarations }
  45. public
  46. { Public declarations }
  47. // AType调用类型: 0审批人, 1关注人。 AValuesArr:第一个值WebID,第二个值PhaseIndex。
  48. constructor Create(AOwner: TObject; AType: Integer; AValuesArr: array of Integer);
  49. end;
  50. implementation
  51. uses PHPWebDm, ConstUnit, CheckerFme, ProjectFme, ProjectManagerFme,
  52. OrderCheckerFme, SetGuestFrm;
  53. {$R *.dfm}
  54. var
  55. UserArr: array of string;
  56. PicPath: string;
  57. procedure TFindUserForm.btnSearchClick(Sender: TObject);
  58. var bChecker, bSelf, bFull, bGuest: Boolean;
  59. begin
  60. Screen.Cursor := crHourGlass;
  61. try
  62. FAccount := Trim(edtMail.Text);
  63. UserArr := VarArrayOf(['avatar', 'name', 'jobs', 'company', 'uid']);
  64. case PHPWeb.Search(PHPWeb.MeasureURL + 'user/get/search', ['uemail'], [AnsiToUtf8(FAccount)], UserArr) of
  65. 1:
  66. begin
  67. lblHint.Caption := '';
  68. lblUserName.Caption := TOrderCheckerFrame(Owner).IsMe(StrToInt(UserArr[4]), UserArr[1]) ;
  69. lblUserRole.Caption := UserArr[2];
  70. lblUserCompany.Caption := UserArr[3];
  71. PicPath := PHPWeb.UserPath + '1_' + UserArr[4] + '.jpg';
  72. if PHPWeb.DownFile(UserArr[0], PicPath) then
  73. imgUserPic.Picture.LoadFromFile(PicPath);
  74. pnlUser.Visible := True;
  75. bSelf := StrToInt(UserArr[4]) = PHPWeb.UserID;
  76. case FType of
  77. 0:
  78. begin
  79. bChecker := TCheckerFrame(TOrderCheckerFrame(Owner).Owner).InCheckerList(StrToInt(UserArr[4]));
  80. // AddFrame包含在List.Count中,等效于原报不在List.Count中
  81. bFull := (TCheckerFrame(TOrderCheckerFrame(Owner).Owner).List.Count >= 15);
  82. btnAdd.Enabled := (not bChecker) and (not bSelf) and (not bFull);
  83. if bFull then
  84. btnAdd.Caption := '限添加14人'
  85. else if bSelf then
  86. btnAdd.Caption := '不能添加自己'
  87. else if bChecker then
  88. btnAdd.Caption := '已使用'
  89. else
  90. btnAdd.Caption := '使用Ta';
  91. end;
  92. 1:
  93. begin
  94. bChecker := TProjectManagerFrame(TSetGuestForm(FOwner).Owner).UserIsChecker(StrToInt(UserArr[4])); // 判断是否是参与人
  95. bGuest := TSetGuestForm(FOwner).HasGuest(StrToInt(UserArr[4]));
  96. btnAdd.Enabled := (not bChecker) and (not bGuest);
  97. if bChecker then
  98. btnAdd.Caption := '已是参与人'
  99. else if bGuest then
  100. btnAdd.Caption := '已是关注人'
  101. else
  102. btnAdd.Caption := '使用Ta';
  103. end;
  104. else ;
  105. end;
  106. end;
  107. -1:
  108. begin
  109. // Application.MessageBox(PChar(PHPWeb.NetError('无法查询用户')),
  110. // '警告', MB_OK + MB_ICONWARNING);
  111. lblHint.Caption := '没有找到该用户的相关信息!';
  112. pnlUser.Visible := False;
  113. btnAdd.Enabled := False;
  114. Exit;
  115. end;
  116. 0:
  117. begin
  118. // Application.MessageBox(PChar(PHPWeb.PageError('无法查询用户' + '[' + edtMail.Text + ']')),
  119. // '警告', MB_OK + MB_ICONWARNING);
  120. lblHint.Caption := '没有找到该用户的相关信息!';
  121. pnlUser.Visible := False;
  122. btnAdd.Enabled := False;
  123. Exit;
  124. end;
  125. end;
  126. finally
  127. Screen.Cursor := crDefault;
  128. end;
  129. end;
  130. procedure TFindUserForm.edtMailKeyDown(Sender: TObject; var Key: Word;
  131. Shift: TShiftState);
  132. begin
  133. if Key = VK_Return then
  134. btnSearch.Click;
  135. end;
  136. procedure TFindUserForm.btnAddClick(Sender: TObject);
  137. var sURL: string;
  138. vArr: array of string;
  139. vOwner: TCheckerFrame;
  140. begin
  141. vArr := VarArrayOf(['msg']);
  142. case FType of
  143. 0:
  144. begin
  145. sURL := PHPWeb.MeasureURL + 'user/add/audit/measure';
  146. // 标段ID(网络)、谁添加的、添加的谁、期号
  147. if PHPWeb.Search(sURL, ['pmid', 'creatoruid', 'auditoruid', 'numpname'],
  148. [IntToStr(FWebID), IntToStr(PHPWeb.UserID), UserArr[4], IntToStr(FPhaseIndex)], vArr) = 1 then
  149. begin
  150. btnAdd.Enabled := False;
  151. btnAdd.Caption := '添加成功';
  152. vOwner := TCheckerFrame(TOrderCheckerFrame(FOwner).Owner);
  153. vOwner.AddNewChecker(cftChecker, StrToInt(UserArr[4]), UserArr[1], UserArr[2], UserArr[3], PicPath, '', csNotBegin, '', -1);
  154. vOwner.RepairOrder;
  155. vOwner.RepairDelete(True);
  156. end;
  157. end;
  158. 1:
  159. begin
  160. sURL := PHPWeb.MeasureURL + 'tender/concernaudit/create'; // AAAAA 添加关注人
  161. // 标段ID(网络)、谁添加的、添加的谁
  162. if PHPWeb.Search(sURL, ['tenderid', 'uid'], [IntToStr(FWebID), UserArr[4]], vArr) = 1 then
  163. begin
  164. btnAdd.Enabled := False;
  165. btnAdd.Caption := '添加成功';
  166. TSetGuestForm(FOwner).AddGuest(StrToInt(UserArr[4]), UserArr[1], FAccount);
  167. end;
  168. end;
  169. end;
  170. end;
  171. procedure TFindUserForm.edtMailClick(Sender: TObject);
  172. begin
  173. if G_IsTest then
  174. begin
  175. if edtMail.Text = '1' then
  176. begin
  177. edtMail.Text := '2636698008@qq.com';
  178. end
  179. else if edtMail.Text = '2' then
  180. begin
  181. edtMail.Text := '1971614655@qq.com';
  182. end
  183. else if edtMail.Text = '3' then
  184. begin
  185. edtMail.Text := '1835082984@qq.com';
  186. end
  187. else if edtMail.Text = '4' then
  188. begin
  189. edtMail.Text := '2417587264@qq.com';
  190. end
  191. else if edtMail.Text = '5' then
  192. begin
  193. edtMail.Text := '2609827960@qq.com';
  194. end
  195. else if edtMail.Text = '6' then
  196. begin
  197. edtMail.Text := '1240621850@qq.com';
  198. end
  199. else if edtMail.Text = '7' then
  200. begin
  201. edtMail.Text := '1014149875@qq.com';
  202. end
  203. else if edtMail.Text = '8' then
  204. begin
  205. edtMail.Text := '1525739553@qq.com';
  206. end
  207. else if edtMail.Text = '9' then
  208. begin
  209. edtMail.Text := '1391010261@qq.com';
  210. end
  211. else if edtMail.Text = '10' then
  212. begin
  213. edtMail.Text := '916960227@qq.com';
  214. end;
  215. end;
  216. end;
  217. constructor TFindUserForm.Create(AOwner: TObject; AType: Integer; AValuesArr: array of Integer);
  218. var sName: string;
  219. begin
  220. inherited Create(nil);
  221. FOwner := AOwner;
  222. FType := AType;
  223. FWebID := AValuesArr[0];
  224. FPhaseIndex := AValuesArr[1];
  225. lblHint.Caption := '';
  226. pnlUser.Visible := False;
  227. case AType of
  228. 0: sName := '审批人';
  229. 1: sName := '关注人';
  230. else sName := '用户';
  231. end;
  232. self.Caption := '添加' + sName;
  233. JimPageControl1Page1.Caption := Format('查询新%s', [sName]);
  234. lblHint1.Caption := Format('输入%s的通行帐号注册邮箱,查询并确认后,点击“使用Ta”完成添加%s。', [sName, sName]);
  235. lblHint2.Caption := Format('添加新%s', [sName]);
  236. end;
  237. procedure TFindUserForm.FormActivate(Sender: TObject);
  238. begin
  239. Self.Top := Self.Top + 60;
  240. end;
  241. end.