DpyhServiceManagerAction.class.php 2.8 KB

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