Commit 8836acdb by 朱继来

调整查看下级权限

parent 72a566f7
Showing with 8 additions and 16 deletions
......@@ -357,27 +357,19 @@ class PermController extends Controller
array_unshift($sale_ids, $userId); // 将当前用户添加到数组
$user_info = DB::table('user_info')->where('userId', $userId)->select('department_id')->first(); // 用户信息
$department_id = DB::table('user_info')->where('userId', $userId)->value('department_id'); // 用户信息
if (!$user_info['department_id']) return $sale_ids;
if (!$department_id) return $sale_ids;
// 获取当前用户下级部门
$department = DB::table('user_department')
->where('parent_id', $user_info['department_id'])
->select('department_id', 'department_name')
->get();
$department_ids = [];
if (!$department) {
$tmp = DB::table('user_info')->where('department_id', $user_info['department_id'])->lists('userId');
$this->getSubDepartmentId($department_id, $department_ids); // 获取下级部门ID
$sale_ids = array_merge($sale_ids, $tmp);
} else {
// 获取下级部门的人员
foreach ($department as $v) {
$tmp = DB::table('user_info')->where('department_id', $v['department_id'])->lists('userId');
// 获取下级部门的人员
foreach ($department_ids as $v) {
$tmp = DB::table('user_info')->where('department_id', $v)->lists('userId');
$sale_ids = array_merge($sale_ids, $tmp);
}
$sale_ids = array_merge($sale_ids, $tmp);
}
return array_unique($sale_ids); // 去重返回
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment