123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- class DpyhServiceManagerAction extends CommonAction {
- const tableName = 'dpyh_service_manager';
- const pkName = 'ID';
-
-
- function sys_add( ){
- $form = new \Jms\Gui\ClForm();
- $form->before_add = function(&$data){
- //检查用户名是否重复
- $where = array('UserName'=>$data['UserName']);
- if( M('uc_user')->where($where)->count() > 0 ){
- json_fail('用户名已存在');
- }
- //检查密码格式
- if(strlen($data['Password']) < 4 ){
- json_fail('密码长度必须大于4位');
- }
- //检查手机号是否重复(可通过手机号码登录)
- $where = array('Mobile'=>$data['Mobile']);
- if( $data['Mobile'] !== '' && M('uc_user')->where($where)->count() > 0 ){
- json_fail('手机号码已被使用');
- }
- $data['Password'] = \Zndp\User\Util::encPwd( trim($data['Password']) );
- $data['RoleId'] = \Zndp\User\RoleEnum::SERVICE_ADMINISTRATOR; //服务部管理员
- $data['OrganizationId'] = I('get.depart_id');
- };
- $form->display($this);
- }
-
-
- function sys_list( ){
- $list = new \Jms\Gui\ClGrid();
- $list->sql_sort = 'OrganizationId asc';
- $list->sql_filter = function($search,&$cond){
- $cond['RoleId'] = \Zndp\User\RoleEnum::SERVICE_ADMINISTRATOR; //角色:服务部管理员
- $cond['OrganizationId'] = I('get.id');
- };
- $list->toolbar_filter = function(&$button){
- if($button['icon'] == 'add'){
- $button['url'] .= '&depart_id=' .I('get.id');
- }
- };
- $list->display($this);
- }
-
-
- function sys_edit( ){
- $form = new \Jms\Gui\ClForm();
- $form->before_display = function(&$data){
- $data['Password'] = '';
- };
- $form->before_modify = function(&$data){
- $id = I('get.id');
- // 检查用户名是否重复
- $where = array('UserName'=>$data['UserName'],'ID'=>array('neq',$id));
- if( M('uc_user')->where($where)->count() > 0 ){
- json_fail('用户名已存在');
- }
- // 检查密码
- if(!$data['Password']){
- unset($data['Password']);
- }elseif($data['Password'] && strlen($data['Password']) < 4 ){
- json_fail('密码长度必须大于4位');
- }else{
- $data['Password'] = \Zndp\User\Util::encPwd( trim($data['Password']) );
- }
- //检查手机号是否重复(可通过手机号码登录)
- $where = array('Mobile'=>$data['Mobile'],'ID'=>array('neq',$id));
- if( $data['Mobile'] !== '' && M('uc_user')->where($where)->count() > 0 ){
- json_fail('手机号码已被使用');
- }
- };
- $form->display($this);
- }
-
-
- function sys_change_depart( ){
- $form = new \Jms\Gui\ClForm();
- $form->before_modify = function(&$data){
- var_dump($data);exit;
- };
- $form->form_filter = function(&$form){
- $depart_list = get_depart_option();
- $form['fields']['OrganizationId']['editor'] = array('options'=>$depart_list);
- };
- $form->display($this);
- }
-
- }
|