Commit f5c205d8 by 杨树贤

补充

parent 90ac87a5
...@@ -197,17 +197,18 @@ class SupplierFilter ...@@ -197,17 +197,18 @@ class SupplierFilter
//搜索创建部门的数据 //搜索创建部门的数据
if (!empty($map['create_user_department'])) { if (!empty($map['create_user_department'])) {
$map['create_user_department'] = explode(',', $map['create_user_department']); $map['create_user_department'] = explode(',', $map['create_user_department']);
$parentDepartmentIds = DepartmentModel::whereIn('department_id',$map['create_user_department']) $parentDepartmentIds = DepartmentModel::whereIn('department_id', $map['create_user_department'])
->pluck('parent_id')->toArray(); ->pluck('parent_id')->toArray();
$parentDepartmentIds = array_unique($parentDepartmentIds); $parentDepartmentIds = array_unique($parentDepartmentIds);
$departmentIds = array_merge($parentDepartmentIds, $map['create_user_department']); $departmentIds = array_merge($parentDepartmentIds, $map['create_user_department']);
//先去找出所有的创建人uid //先去找出所有的创建人uid
$userIds = UserInfoModel::whereIn('department_id',$departmentIds)->pluck('userId')->toArray(); $userIds = UserInfoModel::whereIn('department_id', $departmentIds)->pluck('userId')->toArray();
$query->whereIn('create_uid',$userIds); $query->whereIn('create_uid', $userIds);
} }
//默认过滤带有-1字符串的供应商名称的数据 //默认过滤带有-1字符串的供应商名称的数据
$query->whereRaw('supplier_name NOT LIKE "%-1"'); $query->whereRaw('supplier_name NOT LIKE "%-1"');
return $query; return $query;
} }
...@@ -218,59 +219,61 @@ class SupplierFilter ...@@ -218,59 +219,61 @@ class SupplierFilter
$canViewAllSupplier = checkPerm('ViewAllSupplier'); $canViewAllSupplier = checkPerm('ViewAllSupplier');
$canViewSubordinateSupplier = checkPerm('ViewSubordinateSupplier'); $canViewSubordinateSupplier = checkPerm('ViewSubordinateSupplier');
$canViewFakeSupplier = checkPerm('ViewFakeSupplier'); $canViewFakeSupplier = checkPerm('ViewFakeSupplier');
//现在普通采购也能看到竞调供应商了(与他有关的) $canViewBlockSupplier = checkPerm('ViewBlockSupplier');
if (!$canViewFakeSupplier) { $canViewDisableSupplier = checkPerm('ViewDisableSupplier');
$query->where('is_type', 0); // 构建复合查询条件:基础条件 OR 特殊状态
} $query->where(function ($mainQuery) use ($canViewFakeSupplier, $canViewBlockSupplier, $canViewDisableSupplier, $userId, $codeId, $canViewAllSupplier, $canViewSubordinateSupplier) {
$query->with(['contact', 'attachment']); // 主要条件组:基础业务条件
$query->whereRaw('supplier_name NOT LIKE "%-1"'); $mainQuery->where(function ($baseQuery) use ($canViewFakeSupplier, $userId, $codeId, $canViewAllSupplier, $canViewSubordinateSupplier) {
// 基础类型限制
if (!$canViewFakeSupplier) {
$baseQuery->where('is_type', 0);
}
//默认展示的数据查询 // 权限相关的条件
//看全部的权限,优先级最高 if (!$canViewAllSupplier) {
if ($canViewAllSupplier) { if ($canViewSubordinateSupplier) {
//能查看所有的话,限制基本没有 $departmentService = new DepartmentService();
} else { $subordinateUserIds = $departmentService->getSubordinateUserIds($userId);
//如果能看部下的,那需要判断的地方就多了不少 $adminUserService = new AdminUserService();
if ($canViewSubordinateSupplier) { $subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds);
$departmentService = new DepartmentService(); $subordinateCodeIds = $subordinateCodeIds->toArray();
//下属用户id(结果包括自己的id)
$subordinateUserIds = $departmentService->getSubordinateUserIds($userId); $likeSqlRaw = implode('|', $subordinateCodeIds);
$adminUserService = new AdminUserService(); $inCodeIdSql = implode(',', $subordinateCodeIds);
$subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds); $inUserIdSql = implode(',', $subordinateUserIds);
$subordinateCodeIds = $subordinateCodeIds->toArray(); $inCodeIdSql = "(" . $inCodeIdSql . ")";
//因为可以查看自己部下相关的采购员,开发员的供应商,所以要构建复杂likeIn语句需要的数据 $inUserIdSql = "(" . $inUserIdSql . ")";
//注意下面三个条件最外层要用()包围起来,要不然mysql数据会有问题,具体自己查询mysql的and和or的语法注意事项
$likeSqlRaw = implode('|', $subordinateCodeIds); if ($subordinateCodeIds) {
$inCodeIdSql = implode(',', $subordinateCodeIds); $baseQuery->whereRaw("(create_uid in $inUserIdSql or purchase_uid in $inCodeIdSql or channel_uid REGEXP '$likeSqlRaw')");
$inUserIdSql = implode(',', $subordinateUserIds); } else {
$inCodeIdSql = "(" . $inCodeIdSql . ")"; $baseQuery->whereRaw("(create_uid in $inUserIdSql)");
$inUserIdSql = "(" . $inUserIdSql . ")"; }
if ($subordinateCodeIds) {
if ($canViewFakeSupplier) {
$query->whereRaw(DB::raw("(create_uid in $inUserIdSql or purchase_uid in $inCodeIdSql
or channel_uid REGEXP '$likeSqlRaw' or is_type = 1) "));
} else {
$query->whereRaw(DB::raw("(create_uid in $inUserIdSql or purchase_uid in $inCodeIdSql
or channel_uid REGEXP '$likeSqlRaw') "));
}
} else {
if ($canViewFakeSupplier) {
$query->whereRaw(DB::raw("(create_uid in $inUserIdSql or is_type = 1)"));
} else { } else {
$query->whereRaw(DB::raw("(create_uid in $inUserIdSql)")); // 只能看自己的
$baseQuery->where(function ($selfQuery) use ($userId, $codeId) {
$selfQuery->where('create_uid', $userId)
->orWhere('purchase_uid', $codeId)
->orWhere('channel_uid', 'like', '%' . $codeId . '%');
});
} }
} }
});
} else { // 额外显示的特殊状态(如果有权限)
if ($codeId) { if ($canViewBlockSupplier) {
//剩下的就只是看自己相关的 $mainQuery->orWhere('status', SupplierChannelModel::STATUS_BLOCK);
$query->whereRaw(DB::raw("(create_uid = $userId or purchase_uid = $codeId or channel_uid like '%${codeId}%') "));
} else {
$query->whereRaw(DB::raw("(create_uid = $userId)"));
}
} }
} if ($canViewDisableSupplier) {
$mainQuery->orWhere('status', SupplierChannelModel::STATUS_DISABLE);
}
});
$query->with(['contact', 'attachment']);
$query->whereRaw('supplier_name NOT LIKE "%-1"');
// 权限逻辑已经移到上面的复合查询条件中
//先判断获取类型 //先判断获取类型
switch ($sourceType) { switch ($sourceType) {
case "all": case "all":
...@@ -349,17 +352,21 @@ class SupplierFilter ...@@ -349,17 +352,21 @@ class SupplierFilter
}); });
break; break;
//附件里面缺少品质协议的,而且是现货类型供应商 //附件里面缺少品质协议的,而且是现货类型供应商
// case "no_quality_assurance_agreement": // case "no_quality_assurance_agreement":
// $query->whereDoesntHave('attachment', function ($query) { // $query->whereDoesntHave('attachment', function ($query) {
// $query->whereNotIn('status', // $query->whereNotIn('status',
// [SupplierChannelModel::STATUS_DISABLE, SupplierChannelModel::STATUS_BLOCK]) // [SupplierChannelModel::STATUS_DISABLE, SupplierChannelModel::STATUS_BLOCK])
// ->where('field_name', 'quality_assurance_agreement'); // ->where('field_name', 'quality_assurance_agreement');
// })->where('supplier_group', 2); // })->where('supplier_group', 2);
// break; // break;
//联系人待完善 //联系人待完善
case "contact_no_complete": case "contact_no_complete":
$query->rightjoin('supplier_contact', 'supplier_channel.supplier_id', '=', $query->rightjoin(
'supplier_contact.supplier_id') 'supplier_contact',
'supplier_channel.supplier_id',
'=',
'supplier_contact.supplier_id'
)
->selectRaw('lie_supplier_channel.*') ->selectRaw('lie_supplier_channel.*')
->where(function ($q) { ->where(function ($q) {
$q->where('supplier_consignee', '') $q->where('supplier_consignee', '')
......
...@@ -26,14 +26,19 @@ class SupplierService ...@@ -26,14 +26,19 @@ class SupplierService
//获取供应商列表 //获取供应商列表
public function getSupplierList($map) public function getSupplierList($map)
{ {
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
$query = $model->orderBy('update_time', 'desc'); $query = $model->orderBy('update_time', 'desc');
$filter = new SupplierFilter(); $filter = new SupplierFilter();
$query = $filter->listFilter($map, $query); $query = $filter->listFilter($map, $query);
$limit = array_get($map, 'limit', 10); $limit = array_get($map, 'limit', 10);
if (!empty($map['is_export'])) { if (!empty($map['is_export'])) {
$list = $query->get()->toArray(); $list = $query->get()->toArray();
} else { } else {
$sql = $query->toSql();
$bindings = $query->getBindings();
// dd($sql, $bindings);
$list = $query->paginate($limit)->toArray(); $list = $query->paginate($limit)->toArray();
$transformer = new SupplierTransformer(); $transformer = new SupplierTransformer();
$list['data'] = $transformer->transformList($list['data']); $list['data'] = $transformer->transformList($list['data']);
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
if (data.field.type === '1') { if (data.field.type === '1') {
// 这里需要根据实际的型号字段名进行校验 // 这里需要根据实际的型号字段名进行校验
// 假设型号字段名为 model_number 或者从SKU中提取 // 假设型号字段名为 model_number 或者从SKU中提取
if (!data.field.sku_ids || data.field.sku_ids.trim() === '') { if (!skuIds || skuIds.trim() === '') {
layer.msg('请选择型号', { layer.msg('请选择型号', {
icon: 5 icon: 5
}); });
...@@ -74,6 +74,15 @@ ...@@ -74,6 +74,15 @@
// 按SKU显示类型tab的校验规则 // 按SKU显示类型tab的校验规则
function validateGoodsLabelTab(data) { function validateGoodsLabelTab(data) {
// 检查SKU是否已选择
let skuIds = data.field.sku_ids;
if (!skuIds || skuIds.trim() === '') {
layer.msg('请先选择SKU', {
icon: 5
});
return false;
}
// 检查是否选择了显示类型 // 检查是否选择了显示类型
if (!data.field.goods_label || data.field.goods_label === '') { if (!data.field.goods_label || data.field.goods_label === '') {
layer.msg('请选择SKU显示类型', { layer.msg('请选择SKU显示类型', {
...@@ -95,6 +104,15 @@ ...@@ -95,6 +104,15 @@
// 按SKU接入方式tab的校验规则 // 按SKU接入方式tab的校验规则
function validateGoodsSourceTab(data) { function validateGoodsSourceTab(data) {
// 检查SKU是否已选择
let skuIds = data.field.sku_ids;
if (!skuIds || skuIds.trim() === '') {
layer.msg('请先选择SKU', {
icon: 5
});
return false;
}
// 检查是否选择了接入方式 // 检查是否选择了接入方式
if (!data.field.goods_source || data.field.goods_source === '') { if (!data.field.goods_source || data.field.goods_source === '') {
layer.msg('请选择SKU接入方式', { layer.msg('请选择SKU接入方式', {
...@@ -117,23 +135,23 @@ ...@@ -117,23 +135,23 @@
form.on('submit(addSkuTag)', function(data) { form.on('submit(addSkuTag)', function(data) {
let currentTab = getCurrentTabName(); let currentTab = getCurrentTabName();
// 将当前tab信息添加到提交数据中
data.field.current_tab = currentTab;
// 根据当前tab进行不同的校验 // 根据当前tab进行不同的校验
switch (currentTab) { switch (currentTab) {
case 'tag_setting': case 'tag_setting':
if (!validateTagSettingTab(data)) { //判断radio为type的是否选择了sku,如果没有选择,则不进行提交,直接返回
return false; if (data.field.sku_ids || data.field.sku_ids != '') {
if (!validateTagSettingTab(data)) {
return false;
}
} }
// 标签设置tab的提交逻辑 // 标签设置tab的提交逻辑
if (data.field.sku_tags === '') { if (data.field.sku_tags === '') {
layer.confirm('如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?', function(index) { layer.confirm('如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?', function(index) {
addSkuTag(data, currentTab); addSkuTag(data);
layer.close(index); layer.close(index);
}); });
} else { } else {
addSkuTag(data, currentTab); addSkuTag(data);
} }
break; break;
...@@ -144,11 +162,11 @@ ...@@ -144,11 +162,11 @@
// 按SKU显示类型的提交逻辑 // 按SKU显示类型的提交逻辑
if (data.field.goods_label_system_tags === '') { if (data.field.goods_label_system_tags === '') {
layer.confirm('如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?', function(index) { layer.confirm('如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?', function(index) {
addSkuTag(data, currentTab); addSkuTag(data);
layer.close(index); layer.close(index);
}); });
} else { } else {
addSkuTag(data, currentTab); addSkuTag(data);
} }
break; break;
...@@ -159,11 +177,11 @@ ...@@ -159,11 +177,11 @@
// 按SKU接入方式的提交逻辑 // 按SKU接入方式的提交逻辑
if (data.field.goods_source_system_tags === '') { if (data.field.goods_source_system_tags === '') {
layer.confirm('如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?', function(index) { layer.confirm('如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?', function(index) {
addSkuTag(data, currentTab); addSkuTag(data);
layer.close(index); layer.close(index);
}); });
} else { } else {
addSkuTag(data, currentTab); addSkuTag(data);
} }
break; break;
...@@ -175,26 +193,17 @@ ...@@ -175,26 +193,17 @@
} }
}); });
function addSkuTag(data, currentTab) { function addSkuTag(data) {
admin.showLoading({ admin.showLoading({
type: 3 type: 3
}); });
let sku_ids = getQueryVariable('sku_ids'); let sku_ids = getQueryVariable('sku_ids');
let url = '/api/sku/BatchAddSkuTag'; let url = '/api/sku/BatchAddSkuTag';
// 确保当前tab信息被包含在提交数据中
let submitData = data.field;
if (currentTab) {
submitData.current_tab = currentTab;
}
console.log('提交数据:', submitData); // 调试用,可以看到传递的tab信息
$.ajax({ $.ajax({
url: url url: url
, type: 'POST' , type: 'POST'
, async: true , async: true
, data: submitData , data: data.field
, dataType: 'json' , dataType: 'json'
, timeout: 20000 , timeout: 20000
, success: function(res) { , success: function(res) {
......
...@@ -58,9 +58,9 @@ ...@@ -58,9 +58,9 @@
</div> </div>
<div class="layui-form-item" id="supplier_select_div" style="display: none"> <div class="layui-form-item" id="supplier_select_div" style="display: none">
@inject('multiSelectorPresenter','App\Presenters\MultiSelectorPresenter') @inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $multiSelectorPresenter->render('supplier_code','供应商选择',null, {!! $statusPresenter->render('supplier_code','供应商选择',null,
$supplierCodesForXmSelect,['radio'=>true,'required'=>true,'width'=>'400px']) !!} $supplierCodes,['required'=>true,'width'=>'400px']) !!}
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
...@@ -108,12 +108,12 @@ ...@@ -108,12 +108,12 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach($goodsLabelSystemTagList as $key=>$item) {{-- @foreach($goodsLabelSystemTagList as $item)
<tr> <tr>
<td>{{config('field.SkuGoodsLabel')[$key]}}</td> <td>{{$item['goods_label']}}</td>
<td>{{implode(',', $item['system_tags'])}}</td> <td>{{$item['goods_label_system_tags']}}</td>
</tr> </tr>
@endforeach @endforeach --}}
</tbody> </tbody>
</table> </table>
</div> </div>
...@@ -150,12 +150,12 @@ ...@@ -150,12 +150,12 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach($goodsSourceSystemTagList as $key=>$item) {{-- @foreach($goodsLabelSystemTagList as $item)
<tr> <tr>
<td>{{config('field.SkuSource')[$key]}}</td> <td>{{$item['goods_label']}}</td>
<td>{{implode(',', $item['system_tags'])}}</td> <td>{{$item['goods_label_system_tags']}}</td>
</tr> </tr>
@endforeach @endforeach --}}
</tbody> </tbody>
</table> </table>
</div> </div>
......
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