diff --git a/app/common.php b/app/common.php index d128e4d..8ed0106 100644 --- a/app/common.php +++ b/app/common.php @@ -261,6 +261,21 @@ function get_department_role($uid = 0) } } +//读取是否是某员工的上级领导 +function get_user_role($leader_id=0,$uid = 0) +{ + $did = get_admin($uid)['did']; + //获取子部门 + $department = get_department(); + $department_list = get_data_node($department, $did); + $department_array = array_column($department_list, 'id'); + //包括自己部门在内 + $department_array[] = $did; + //判断是否是部门负责人 + $is_leader = Db::name('Department')->where([['id','in',$did,'leader_id'=>$leader_id]])->count(); + return $is_leader; +} + //读取职位 function get_position() { diff --git a/app/customer/controller/Api.php b/app/customer/controller/Api.php index 9c6608f..6ea337b 100644 --- a/app/customer/controller/Api.php +++ b/app/customer/controller/Api.php @@ -80,7 +80,7 @@ class Api extends BaseController if (!empty($param['id']) && $param['id'] > 0) { $param['update_time'] = time(); $old = CustomerTrace::where(['id' => $param['id']])->find(); - if($this->uid!=$old['admin_id']){ + if($this->uid!=$old['admin_id'] && get_user_role($this->uid,$old['admin_id'])==0){ return to_assign(1, "只有所属员工才有权限操作"); } $res = CustomerTrace::strict(false)->field(true)->update($param); @@ -199,7 +199,7 @@ class Api extends BaseController if (!empty($param['id']) && $param['id'] > 0) { $param['update_time'] = time(); $old = CustomerChance::where(['id' => $param['id']])->find(); - if($this->uid!=$old['admin_id']){ + if($this->uid!=$old['admin_id'] && get_user_role($this->uid,$old['admin_id'])==0){ return to_assign(1, "只有所属员工才有权限操作"); } $res = CustomerChance::strict(false)->field(true)->update($param); diff --git a/app/customer/view/contact/index.html b/app/customer/view/contact/index.html index 67c156e..9a81e78 100644 --- a/app/customer/view/contact/index.html +++ b/app/customer/view/contact/index.html @@ -4,7 +4,6 @@