| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 | {*******************************************************************************  单元名称:  FindUserFrm.pas  单元说明:  查找审核人。  作者时间:  Chenshilong, 2014-07-11                2017.06.19 该窗口定制太深,不通用,改成通用查询窗口。*******************************************************************************}unit FindUserFrm;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, JimPages, StdCtrls, cxLookAndFeelPainters, cxButtons,  cxControls, cxContainer, cxEdit, cxTextEdit, ExtCtrls;type  TFindUserForm = class(TForm)    JimPageControl1: TJimPageControl;    JimPageControl1Page1: TJimPage;    JimPageControl1Page2: TJimPage;    lblHint1: TLabel;    lblHint2: TLabel;    edtMail: TcxTextEdit;    btnSearch: TcxButton;    pnlUser: TPanel;    bvl1: TBevel;    lbl3: TLabel;    imgUserPic: TImage;    lblUserName: TLabel;    lblUserRole: TLabel;    lblUserCompany: TLabel;    shp2: TShape;    btnAdd: TcxButton;    lblHint: TLabel;    procedure btnSearchClick(Sender: TObject);    procedure edtMailKeyDown(Sender: TObject; var Key: Word;      Shift: TShiftState);    procedure btnAddClick(Sender: TObject);    procedure edtMailClick(Sender: TObject);  private    FOwner: TObject;    FType: Integer;    FWebID: Integer;    FPhaseIndex: Integer;    FAccount: string;    { Private declarations }  public    { Public declarations }     // AType调用类型: 0审批人, 1关注人。 AValuesArr:第一个值WebID,第二个值PhaseIndex。     constructor Create(AOwner: TObject; AType: Integer; AValuesArr: array of Integer);  end;implementationuses PHPWebDm, ConstUnit, CheckerFme, ProjectFme, ProjectManagerFme,  OrderCheckerFme, SetGuestFrm;{$R *.dfm}var  UserArr: array of string;  PicPath: string;procedure TFindUserForm.btnSearchClick(Sender: TObject);var bChecker, bSelf, bFull, bGuest: Boolean;begin  Screen.Cursor := crHourGlass;  try    FAccount := Trim(edtMail.Text);    UserArr := VarArrayOf(['avatar', 'name', 'jobs', 'company', 'uid']);    case PHPWeb.Search(PHPWeb.MeasureURL + 'user/get/search', ['uemail'], [AnsiToUtf8(FAccount)], UserArr) of      1:      begin        lblHint.Caption := '';        lblUserName.Caption := TOrderCheckerFrame(Owner).IsMe(StrToInt(UserArr[4]), UserArr[1]) ;        lblUserRole.Caption := UserArr[2];        lblUserCompany.Caption := UserArr[3];        PicPath := PHPWeb.UserPath + '1_' + UserArr[4] + '.jpg';        if PHPWeb.DownFile(UserArr[0], PicPath) then          imgUserPic.Picture.LoadFromFile(PicPath);        pnlUser.Visible := True;        bSelf := StrToInt(UserArr[4]) = PHPWeb.UserID;        case FType of          0:          begin            bChecker := TCheckerFrame(TOrderCheckerFrame(Owner).Owner).InCheckerList(StrToInt(UserArr[4]));            // AddFrame包含在List.Count中,等效于原报不在List.Count中            bFull := (TCheckerFrame(TOrderCheckerFrame(Owner).Owner).List.Count >= 15);            btnAdd.Enabled := (not bChecker) and (not bSelf) and (not bFull);            if bFull then              btnAdd.Caption := '限添加14人'            else if bSelf then              btnAdd.Caption := '不能添加自己'            else if bChecker then              btnAdd.Caption := '已使用'            else              btnAdd.Caption := '使用Ta';          end;          1:          begin            bChecker := TProjectManagerFrame(TSetGuestForm(FOwner).Owner).UserIsChecker(StrToInt(UserArr[4]));     // 判断是否是参与人            bGuest := TSetGuestForm(FOwner).HasGuest(StrToInt(UserArr[4]));            btnAdd.Enabled := (not bChecker) and (not bGuest);            if bChecker then              btnAdd.Caption := '已是参与人'            else if bGuest then              btnAdd.Caption := '已是关注人'            else              btnAdd.Caption := '使用Ta';          end;        else ;        end;      end;      -1:      begin        Application.MessageBox(PChar(PHPWeb.NetError('无法查询用户')),            '警告', MB_OK + MB_ICONWARNING);        lblHint.Caption := '没有找到该用户的相关信息!';        pnlUser.Visible := False;        btnAdd.Enabled := False;        Exit;      end;      0:      begin        Application.MessageBox(PChar(PHPWeb.PageError('无法查询用户' + '[' + edtMail.Text + ']')),            '警告', MB_OK + MB_ICONWARNING);        lblHint.Caption := '没有找到该用户的相关信息!';        pnlUser.Visible := False;        btnAdd.Enabled := False;        Exit;      end;    end;  finally    Screen.Cursor := crDefault;  end;end;procedure TFindUserForm.edtMailKeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);begin  if Key = VK_Return then    btnSearch.Click;end;procedure TFindUserForm.btnAddClick(Sender: TObject);var sURL: string;  vArr: array of string;  vOwner: TCheckerFrame;begin  vArr := VarArrayOf(['msg']);  case FType of    0:    begin      sURL := PHPWeb.MeasureURL + 'user/add/audit/measure';      // 标段ID(网络)、谁添加的、添加的谁、期号      if PHPWeb.Search(sURL, ['pmid', 'creatoruid', 'auditoruid', 'numpname'],        [IntToStr(FWebID), IntToStr(PHPWeb.UserID), UserArr[4], IntToStr(FPhaseIndex)], vArr) = 1 then      begin        btnAdd.Enabled := False;        btnAdd.Caption := '添加成功';        vOwner := TCheckerFrame(TOrderCheckerFrame(FOwner).Owner);        vOwner.AddNewChecker(cftChecker, StrToInt(UserArr[4]), UserArr[1], UserArr[2], UserArr[3], PicPath, '', csNotBegin, '', -1);        vOwner.RepairOrder;        vOwner.RepairDelete(True);      end;    end;    1:    begin      sURL := PHPWeb.MeasureURL + 'api/client/tender/concernaudit/create';    // AAAAA  添加关注人      // 标段ID(网络)、谁添加的、添加的谁      if PHPWeb.Search(sURL, ['tenderid', 'uid'], [IntToStr(FWebID), UserArr[4]], vArr) = 1 then      begin        btnAdd.Enabled := False;        btnAdd.Caption := '添加成功';        TSetGuestForm(FOwner).AddGuest(StrToInt(UserArr[4]), UserArr[1], FAccount);      end;    end;  end;  end;procedure TFindUserForm.edtMailClick(Sender: TObject);begin  if G_IsTest then  begin    if edtMail.Text = '1' then    begin      edtMail.Text := '2636698008@qq.com';    end    else if edtMail.Text = '2' then    begin      edtMail.Text := '1971614655@qq.com';    end    else if edtMail.Text = '3' then    begin      edtMail.Text := '1835082984@qq.com';    end    else if edtMail.Text = '4' then    begin      edtMail.Text := '2417587264@qq.com';    end    else if edtMail.Text = '5' then    begin      edtMail.Text := '2609827960@qq.com';    end    else if edtMail.Text = '6' then    begin      edtMail.Text := '1240621850@qq.com';    end    else if edtMail.Text = '7' then    begin      edtMail.Text := '1014149875@qq.com';    end    else if edtMail.Text = '8' then    begin      edtMail.Text := '1525739553@qq.com';    end    else if edtMail.Text = '9' then    begin      edtMail.Text := '1391010261@qq.com';    end    else if edtMail.Text = '10' then    begin      edtMail.Text := '916960227@qq.com';    end;  end;end;constructor TFindUserForm.Create(AOwner: TObject; AType: Integer; AValuesArr: array of Integer);var sName: string;begin  inherited Create(nil);  FOwner := AOwner;  FType := AType;  FWebID := AValuesArr[0];  FPhaseIndex := AValuesArr[1];  lblHint.Caption := '';  pnlUser.Visible := False;  case AType of    0: sName := '审批人';    1: sName := '关注人';  else sName := '用户';  end;  self.Caption := '添加' + sName;  JimPageControl1Page1.Caption := Format('查询新%s', [sName]);  lblHint1.Caption := Format('输入%s的通行帐号注册邮箱,查询并确认后,点击“使用Ta”完成添加%s。', [sName, sName]);  lblHint2.Caption := Format('添加新%s', [sName]);end;end.
 |