Commit 805546a1 by 杨树贤

查看权限需求

parent 69efea34
......@@ -4,8 +4,12 @@
namespace App\Http\Controllers\Filter;
use App\Http\Services\DepartmentService;
use App\Model\IntracodeModel;
use App\Model\UserInfoModel;
use App\Model\DepartmentModel;
use App\Model\SupplierSyncModel;
use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
class SkuListFilter
{
......@@ -15,8 +19,8 @@ class SkuListFilter
$map = request()->all();
$map = array_map(function ($item) {
return trim($item);
},$map);
//dd($map);
}, $map);
//dd($map);
//只获取专卖的数据
$map['supplier_id'] = 17;
if ((!empty($map['create_time']))) {
......@@ -30,7 +34,17 @@ class SkuListFilter
if (!checkPerm('ViewAllSku')) {
$map['encoded/condition'] = request()->user->codeId;
}
$userId = request()->user->userId;
if (checkPerm('ViewSubordinateSku')) {
//查看下级
$departmentService = new DepartmentService();
//下属用户id(结果包括自己的id)
$subordinateUserIds = $departmentService->getSubordinateUserIds($userId);
$adminUserService = new AdminUserService();
$subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds);
$subordinateCodeIds = $subordinateCodeIds->toArray();
$map['encoded/eqs'] = implode(',', $subordinateCodeIds);
}
if ((!empty($map['update_time']))) {
$times = explode('~', $map['update_time']);
$startTime = strtotime($times[0]) ?: 1420041600;
......@@ -57,7 +71,7 @@ class SkuListFilter
if (!empty($map['has_price'])) {
if ($map['has_price'] == 1) {
$map['single_price/sr'] = 'gt,0';
}else{
} else {
$map['single_price/eq'] = '0';
}
unset($map['source_type']);
......@@ -78,6 +92,30 @@ class SkuListFilter
unset($map['stock_compare_type'], $map['stock_num']);
}
//搜索创建部门的数据
if (!empty($map['create_user_department'])) {
$map['create_user_department'] = explode(',', $map['create_user_department']);
$parentDepartmentIds = DepartmentModel::whereIn('department_id', $map['create_user_department'])
->pluck('parent_id')->toArray();
$parentDepartmentIds = array_unique($parentDepartmentIds);
$departmentIds = array_merge($parentDepartmentIds, $map['create_user_department']);
//先去找出所有的创建人uid
$userIds = UserInfoModel::whereIn('department_id', $departmentIds)->pluck('userId')->toArray();
//再去找出所有创建人的codeId
$codeList = (new IntracodeModel())->getEncodeByUserIds($userIds);
$codeIds = array_column($codeList, 'code_id');
if (!empty($map['encoded/eqs'])) {
$existCodeIds = explode(',', $map['encoded/eqs']);
// 只保留codeIds中在existCodeIds范围内的
$filteredCodeIds = array_intersect($codeIds, $existCodeIds);
$map['encoded/eqs'] = implode(',', $filteredCodeIds);
} else {
$map['encoded/eqs'] = implode(',', $codeIds);
}
unset($map['create_user_department']);
}
unset($map['create_user_department']);
foreach ($map as $k => $v) {
if (empty($v) and $v != '0') {
unset($map[$k]);
......
......@@ -4,6 +4,8 @@ namespace App\Http\Controllers\Filter;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContractModel;
use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
class SupplierContractFilter
{
......@@ -14,9 +16,31 @@ class SupplierContractFilter
$model = new SupplierContractModel();
$query = $model->with('supplier');
$userId = $request->user->userId;
if ($userId!=1000) {
$query = $query->where('create_uid', $userId);
if ($userId != 1000) {
if (checkPerm('ViewAllSupplierContract')) {
# code...
} else {
$codeId = $request->user->codeId;
$codeIds = [$codeId];
if (checkPerm('ViewSubordinateSupplierContract')) {
//查看下级
$departmentService = new DepartmentService();
//下属用户id(结果包括自己的id)
$subordinateUserIds = $departmentService->getSubordinateUserIds($userId);
$adminUserService = new AdminUserService();
$subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds);
$subordinateCodeIds = $subordinateCodeIds->toArray();
$codeIds = array_merge($codeIds, $subordinateCodeIds);
}
$query = $query->where(function ($q) use ($userId, $codeIds) {
$q->where('create_uid', $userId)->orWhereHas('supplier', function ($q) use ($codeIds) {
$q->whereIn('yunxin_channel_uid', $codeIds);
});
});
}
}
$query = $query->orderBy('id', 'desc');
if (!empty($map['supplier_code'])) {
$supplierId = SupplierChannelModel::where('supplier_code', $map['supplier_code'])->value('supplier_id');
......
......@@ -2,20 +2,21 @@
namespace App\Http\Controllers;
use App\Http\Controllers\Filter\LogFilter;
use App\Http\Controllers\Filter\SupplierLogFilter;
use App\Http\Services\LogService;
use App\Http\Services\SupplierService;
use App\Http\Services\SupplierTagService;
use App\Model\BrandModel;
use App\Model\IntracodeModel;
use DB;
use GuzzleHttp\Client;
use App\Model\LogModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierLogModel;
use App\Model\TagsModel;
use GuzzleHttp\Client;
use App\Model\BrandModel;
use Illuminate\Http\Request;
use DB;
use App\Model\IntracodeModel;
use App\Model\SupplierLogModel;
use App\Http\Services\LogService;
use App\Model\SupplierChannelModel;
use App\Http\Services\SupplierService;
use App\Http\Services\DepartmentService;
use App\Http\Services\SupplierTagService;
use App\Http\Controllers\Filter\LogFilter;
use App\Http\Controllers\Filter\SupplierLogFilter;
class SkuController extends Controller
{
......@@ -64,6 +65,7 @@ class SkuController extends Controller
$this->data['brandSelectValue'] = $brandSelectValue;
$intraCodeModel = new IntracodeModel();
$this->data['userCodes'] = $intraCodeModel->getSampleEncode();
$this->data['createUserDepartmentList'] = (new DepartmentService())->getCreateUserDepartmentListForXmSelect();
return $this->view('供应商日志');
}
......
......@@ -252,6 +252,32 @@
});
brandSelect.setValue(JSON.parse($('#brand_id_condition').attr('select_value')));
var createUserDepartmentSelector = xmSelect.render({
el: '#create_user_department',
autoRow: true,
name: 'create_user_department',
filterable: true,
direction: 'down',
tree: {
show: true,
showFolderIcon: true,
showLine: true,
indent: 20,
expandedKeys: true,
},
size: 'mini',
toolbar: {
show: true,
list: ['ALL', 'CLEAR']
},
height: 'auto',
data: function () {
//这个数据在对应的blade页面下面...
return {!! json_encode($createUserDepartmentList) !!};
}
})
//批量上架
$("#batch_putaway").click(function () {
let checkStatus = table.checkStatus('skuList');
......
......@@ -148,6 +148,12 @@
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('ability_level/eq','履约程度',request()->get('ability_level/eq'),config('field.AbilityLevel')) !!}
</div>
<div class="layui-inline">
<label class="layui-form-label">创建部门</label>
<div class="layui-input-inline">
<div id="create_user_department" style="width: 150px"></div>
</div>
</div>
<div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'上传时间']) !!}
......
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