FindUserFrm.pas 7.6 KB

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