SysCompManagerAction.class.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. class SysCompManagerAction extends CommonAction {
  3. const tableName = 'sys_comp_manager';
  4. const pkName = 'ID';
  5. function sys_add( ){
  6. $form = new \Jms\Gui\ClForm();
  7. $form->before_display = function(&$data){
  8. $data['Password'] = '';
  9. };
  10. $form->before_add = function(&$data){
  11. //检查用户名是否重复
  12. $where = array('UserName'=>$data['UserName']);
  13. if( M('uc_user')->where($where)->count() > 0 ){
  14. json_fail('用户名已存在');
  15. }
  16. //检查密码格式
  17. if(strlen($data['Password']) < 4 ){
  18. json_fail('密码长度必须大于4位');
  19. }
  20. //检查手机号是否重复(可通过手机号码登录)
  21. $where = array('Mobile'=>$data['Mobile']);
  22. if( $data['Mobile'] !== '' && M('uc_user')->where($where)->count() > 0 ){
  23. json_fail('手机号码已注册');
  24. }
  25. $data['Password'] = \Zndp\User\Util::encPwd( trim($data['Password']) );
  26. $data['RoleId'] = \Zndp\User\RoleEnum::COMPANY_ADMINISTRATOR; //公司管理员
  27. };
  28. $form->before_modify = function(&$data){
  29. };
  30. $form->form_filter = function(&$form){
  31. $depart_list = get_depart_option();
  32. $form['fields']['OrganizationId']['editor'] = array('options'=>$depart_list);
  33. };
  34. $form->display($this);
  35. }
  36. function sys_list( ){
  37. $list = new \Jms\Gui\ClGrid();
  38. $list->sql_sort = 'OrganizationId asc';
  39. $list->sql_filter = function($search,&$cond){
  40. $cond['RoleId'] = \Zndp\User\RoleEnum::COMPANY_ADMINISTRATOR;
  41. };
  42. $list->row_filter = function(&$row){
  43. };
  44. $list->display($this);
  45. }
  46. function sys_edit( ){
  47. $form = new \Jms\Gui\ClForm();
  48. $form->before_display = function(&$data){
  49. $data['Password'] = '';
  50. };
  51. $form->before_add = function(&$data){
  52. //检查用户名是否重复
  53. $where = array('UserName'=>$data['UserName']);
  54. if( M('uc_user')->where($where)->count() > 0 ){
  55. json_fail('用户名已存在');
  56. }
  57. //检查密码格式
  58. if(strlen($data['Password']) < 4 ){
  59. json_fail('密码长度必须大于4位');
  60. }
  61. //检查手机号是否重复(可通过手机号码登录)
  62. $where = array('Mobile'=>$data['Mobile']);
  63. if( $data['Mobile'] !== '' && M('uc_user')->where($where)->count() > 0 ){
  64. json_fail('手机号码已注册');
  65. }
  66. $data['Password'] = \Zndp\User\Util::encPwd( trim($data['Password']) );
  67. $data['RoleId'] = \Zndp\User\RoleEnum::COMPANY_ADMINISTRATOR; //公司管理员
  68. };
  69. $form->before_modify = function(&$data){
  70. };
  71. $form->form_filter = function(&$form){
  72. $depart_list = get_depart_option();
  73. $form['fields']['OrganizationId']['editor'] = array('options'=>$depart_list);
  74. };
  75. $form->display($this);
  76. }
  77. }