Commit b1c3adf1 by 杨树贤

权限查询

parent 022b576b
...@@ -3,9 +3,12 @@ ...@@ -3,9 +3,12 @@
namespace App\Http\Controllers\Filter; namespace App\Http\Controllers\Filter;
use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
use App\Model\SupplierAccountModel; use App\Model\SupplierAccountModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierExaminationModel; use App\Model\SupplierExaminationModel;
use Illuminate\Support\Facades\DB;
class SupplierExaminationFilter class SupplierExaminationFilter
{ {
...@@ -15,16 +18,26 @@ class SupplierExaminationFilter ...@@ -15,16 +18,26 @@ class SupplierExaminationFilter
$map = $request->all(); $map = $request->all();
$canViewAllSupplierExamination = checkPerm('ViewAllSupplierExamination'); $canViewAllSupplierExamination = checkPerm('ViewAllSupplierExamination');
$canViewSubordinateSupplierExamination = checkPerm('ViewSubordinateSupplierExamination');
$userId = $request->user->userId;
$name = $request->user->name; $name = $request->user->name;
$model = new SupplierExaminationModel(); $model = new SupplierExaminationModel();
$query = $model->orderBy('id', 'desc'); $query = $model->orderBy('id', 'desc');
if ($canViewAllSupplierExamination) { if ($canViewAllSupplierExamination) {
//能查看所有的话,限制基本没有
} else {
//如果能看部下的,那需要判断的地方就多了不少
if ($canViewSubordinateSupplierExamination) {
$departmentService = new DepartmentService();
//下属用户(结果包括自己)
$subordinateUserNames = $departmentService->getSubordinateUserNames($userId);
$query->whereIn('purchase_name', $subordinateUserNames);
} else { } else {
$query->where('purchase_name', $name); $query->where('purchase_name', $name);
} }
}
if (!empty($map['supplier_name'])) { if (!empty($map['supplier_name'])) {
$query->where('supplier_name', 'like', "%${map['supplier_name']}%"); $query->where('supplier_name', 'like', "%${map['supplier_name']}%");
......
...@@ -21,6 +21,13 @@ class DepartmentService ...@@ -21,6 +21,13 @@ class DepartmentService
return array_column($users, 'userId'); return array_column($users, 'userId');
} }
public function getSubordinateUserNames($adminId)
{
$departmentId = DB::table('user_info')->where('userId', $adminId)->value('department_id');
$users = $this->getUserByDepartmentId($departmentId);
return array_column($users, 'name');
}
// 获取部门人员 // 获取部门人员
public function getUserByDepartmentId($departmentId, $status = '', $filter = '') public function getUserByDepartmentId($departmentId, $status = '', $filter = '')
{ {
......
...@@ -55,7 +55,6 @@ ...@@ -55,7 +55,6 @@
<button type="button" class="layui-btn layui-btn-sm" id="delete_supplier_examination">删除</button> <button type="button" class="layui-btn layui-btn-sm" id="delete_supplier_examination">删除</button>
@endif @endif
</div> </div>
<table class="layui-table" id="supplierExaminationList" lay-filter="supplierExaminationList"></table> <table class="layui-table" id="supplierExaminationList" lay-filter="supplierExaminationList"></table>
</div> </div>
@if(request()->get('supplier_id')) @if(request()->get('supplier_id'))
......
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