Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f5c205d8
authored
Jul 18, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
补充
parent
90ac87a5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
96 deletions
app/Http/Controllers/Filter/SupplierFilter.php
app/Http/Services/SupplierService.php
resources/views/script/BatchAddSkuTagScript.blade.php
resources/views/web/BatchAddSkuTag.blade.php
app/Http/Controllers/Filter/SupplierFilter.php
View file @
f5c205d8
...
...
@@ -197,17 +197,18 @@ class SupplierFilter
//搜索创建部门的数据
if
(
!
empty
(
$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
();
$parentDepartmentIds
=
array_unique
(
$parentDepartmentIds
);
$departmentIds
=
array_merge
(
$parentDepartmentIds
,
$map
[
'create_user_department'
]);
//先去找出所有的创建人uid
$userIds
=
UserInfoModel
::
whereIn
(
'department_id'
,
$departmentIds
)
->
pluck
(
'userId'
)
->
toArray
();
$query
->
whereIn
(
'create_uid'
,
$userIds
);
$userIds
=
UserInfoModel
::
whereIn
(
'department_id'
,
$departmentIds
)
->
pluck
(
'userId'
)
->
toArray
();
$query
->
whereIn
(
'create_uid'
,
$userIds
);
}
//默认过滤带有-1字符串的供应商名称的数据
$query
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
);
return
$query
;
}
...
...
@@ -218,59 +219,61 @@ class SupplierFilter
$canViewAllSupplier
=
checkPerm
(
'ViewAllSupplier'
);
$canViewSubordinateSupplier
=
checkPerm
(
'ViewSubordinateSupplier'
);
$canViewFakeSupplier
=
checkPerm
(
'ViewFakeSupplier'
);
//现在普通采购也能看到竞调供应商了(与他有关的)
if
(
!
$canViewFakeSupplier
)
{
$query
->
where
(
'is_type'
,
0
);
}
$query
->
with
([
'contact'
,
'attachment'
]);
$query
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
);
$canViewBlockSupplier
=
checkPerm
(
'ViewBlockSupplier'
);
$canViewDisableSupplier
=
checkPerm
(
'ViewDisableSupplier'
);
// 构建复合查询条件:基础条件 OR 特殊状态
$query
->
where
(
function
(
$mainQuery
)
use
(
$canViewFakeSupplier
,
$canViewBlockSupplier
,
$canViewDisableSupplier
,
$userId
,
$codeId
,
$canViewAllSupplier
,
$canViewSubordinateSupplier
)
{
// 主要条件组:基础业务条件
$mainQuery
->
where
(
function
(
$baseQuery
)
use
(
$canViewFakeSupplier
,
$userId
,
$codeId
,
$canViewAllSupplier
,
$canViewSubordinateSupplier
)
{
// 基础类型限制
if
(
!
$canViewFakeSupplier
)
{
$baseQuery
->
where
(
'is_type'
,
0
);
}
//默认展示的数据查询
//看全部的权限,优先级最高
if
(
$canViewAllSupplier
)
{
//能查看所有的话,限制基本没有
}
else
{
//如果能看部下的,那需要判断的地方就多了不少
if
(
$canViewSubordinateSupplier
)
{
$departmentService
=
new
DepartmentService
();
//下属用户id(结果包括自己的id)
$subordinateUserIds
=
$departmentService
->
getSubordinateUserIds
(
$userId
);
$adminUserService
=
new
AdminUserService
();
$subordinateCodeIds
=
$adminUserService
->
getCodeIdsByUserIds
(
$subordinateUserIds
);
$subordinateCodeIds
=
$subordinateCodeIds
->
toArray
();
//因为可以查看自己部下相关的采购员,开发员的供应商,所以要构建复杂likeIn语句需要的数据
//注意下面三个条件最外层要用()包围起来,要不然mysql数据会有问题,具体自己查询mysql的and和or的语法注意事项
$likeSqlRaw
=
implode
(
'|'
,
$subordinateCodeIds
);
$inCodeIdSql
=
implode
(
','
,
$subordinateCodeIds
);
$inUserIdSql
=
implode
(
','
,
$subordinateUserIds
);
$inCodeIdSql
=
"("
.
$inCodeIdSql
.
")"
;
$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)"
));
// 权限相关的条件
if
(
!
$canViewAllSupplier
)
{
if
(
$canViewSubordinateSupplier
)
{
$departmentService
=
new
DepartmentService
();
$subordinateUserIds
=
$departmentService
->
getSubordinateUserIds
(
$userId
);
$adminUserService
=
new
AdminUserService
();
$subordinateCodeIds
=
$adminUserService
->
getCodeIdsByUserIds
(
$subordinateUserIds
);
$subordinateCodeIds
=
$subordinateCodeIds
->
toArray
();
$likeSqlRaw
=
implode
(
'|'
,
$subordinateCodeIds
);
$inCodeIdSql
=
implode
(
','
,
$subordinateCodeIds
);
$inUserIdSql
=
implode
(
','
,
$subordinateUserIds
);
$inCodeIdSql
=
"("
.
$inCodeIdSql
.
")"
;
$inUserIdSql
=
"("
.
$inUserIdSql
.
")"
;
if
(
$subordinateCodeIds
)
{
$baseQuery
->
whereRaw
(
"(create_uid in
$inUserIdSql
or purchase_uid in
$inCodeIdSql
or channel_uid REGEXP '
$likeSqlRaw
')"
);
}
else
{
$baseQuery
->
whereRaw
(
"(create_uid in
$inUserIdSql
)"
);
}
}
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
)
{
//剩下的就只是看自己相关的
$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
(
$canViewBlockSupplier
)
{
$mainQuery
->
orWhere
(
'status'
,
SupplierChannelModel
::
STATUS_BLOCK
);
}
}
if
(
$canViewDisableSupplier
)
{
$mainQuery
->
orWhere
(
'status'
,
SupplierChannelModel
::
STATUS_DISABLE
);
}
});
$query
->
with
([
'contact'
,
'attachment'
]);
$query
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
);
// 权限逻辑已经移到上面的复合查询条件中
//先判断获取类型
switch
(
$sourceType
)
{
case
"all"
:
...
...
@@ -349,17 +352,21 @@ class SupplierFilter
});
break
;
//附件里面缺少品质协议的,而且是现货类型供应商
// case "no_quality_assurance_agreement":
// $query->whereDoesntHave('attachment', function ($query) {
// $query->whereNotIn('status',
// [SupplierChannelModel::STATUS_DISABLE, SupplierChannelModel::STATUS_BLOCK])
// ->where('field_name', 'quality_assurance_agreement');
// })->where('supplier_group', 2);
// break;
// case "no_quality_assurance_agreement":
// $query->whereDoesntHave('attachment', function ($query) {
// $query->whereNotIn('status',
// [SupplierChannelModel::STATUS_DISABLE, SupplierChannelModel::STATUS_BLOCK])
// ->where('field_name', 'quality_assurance_agreement');
// })->where('supplier_group', 2);
// break;
//联系人待完善
case
"contact_no_complete"
:
$query
->
rightjoin
(
'supplier_contact'
,
'supplier_channel.supplier_id'
,
'='
,
'supplier_contact.supplier_id'
)
$query
->
rightjoin
(
'supplier_contact'
,
'supplier_channel.supplier_id'
,
'='
,
'supplier_contact.supplier_id'
)
->
selectRaw
(
'lie_supplier_channel.*'
)
->
where
(
function
(
$q
)
{
$q
->
where
(
'supplier_consignee'
,
''
)
...
...
app/Http/Services/SupplierService.php
View file @
f5c205d8
...
...
@@ -26,14 +26,19 @@ class SupplierService
//获取供应商列表
public
function
getSupplierList
(
$map
)
{
$model
=
new
SupplierChannelModel
();
$query
=
$model
->
orderBy
(
'update_time'
,
'desc'
);
$filter
=
new
SupplierFilter
();
$query
=
$filter
->
listFilter
(
$map
,
$query
);
$limit
=
array_get
(
$map
,
'limit'
,
10
);
if
(
!
empty
(
$map
[
'is_export'
]))
{
$list
=
$query
->
get
()
->
toArray
();
}
else
{
$sql
=
$query
->
toSql
();
$bindings
=
$query
->
getBindings
();
// dd($sql, $bindings);
$list
=
$query
->
paginate
(
$limit
)
->
toArray
();
$transformer
=
new
SupplierTransformer
();
$list
[
'data'
]
=
$transformer
->
transformList
(
$list
[
'data'
]);
...
...
resources/views/script/BatchAddSkuTagScript.blade.php
View file @
f5c205d8
...
...
@@ -51,7 +51,7 @@
if
(
data
.
field
.
type
===
'1'
)
{
// 这里需要根据实际的型号字段名进行校验
// 假设型号字段名为 model_number 或者从SKU中提取
if
(
!
data
.
field
.
sku_ids
||
data
.
field
.
sku_i
ds
.
trim
()
===
''
)
{
if
(
!
skuIds
||
skuI
ds
.
trim
()
===
''
)
{
layer
.
msg
(
'请选择型号'
,
{
icon
:
5
});
...
...
@@ -74,6 +74,15 @@
// 按SKU显示类型tab的校验规则
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
===
''
)
{
layer
.
msg
(
'请选择SKU显示类型'
,
{
...
...
@@ -95,6 +104,15 @@
// 按SKU接入方式tab的校验规则
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
===
''
)
{
layer
.
msg
(
'请选择SKU接入方式'
,
{
...
...
@@ -117,23 +135,23 @@
form
.
on
(
'submit(addSkuTag)'
,
function
(
data
)
{
let
currentTab
=
getCurrentTabName
();
// 将当前tab信息添加到提交数据中
data
.
field
.
current_tab
=
currentTab
;
// 根据当前tab进行不同的校验
switch
(
currentTab
)
{
case
'tag_setting'
:
if
(
!
validateTagSettingTab
(
data
))
{
return
false
;
//判断radio为type的是否选择了sku,如果没有选择,则不进行提交,直接返回
if
(
data
.
field
.
sku_ids
||
data
.
field
.
sku_ids
!=
''
)
{
if
(
!
validateTagSettingTab
(
data
))
{
return
false
;
}
}
// 标签设置tab的提交逻辑
if
(
data
.
field
.
sku_tags
===
''
)
{
layer
.
confirm
(
'如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?'
,
function
(
index
)
{
addSkuTag
(
data
,
currentTab
);
addSkuTag
(
data
);
layer
.
close
(
index
);
});
}
else
{
addSkuTag
(
data
,
currentTab
);
addSkuTag
(
data
);
}
break
;
...
...
@@ -144,11 +162,11 @@
// 按SKU显示类型的提交逻辑
if
(
data
.
field
.
goods_label_system_tags
===
''
)
{
layer
.
confirm
(
'如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?'
,
function
(
index
)
{
addSkuTag
(
data
,
currentTab
);
addSkuTag
(
data
);
layer
.
close
(
index
);
});
}
else
{
addSkuTag
(
data
,
currentTab
);
addSkuTag
(
data
);
}
break
;
...
...
@@ -159,11 +177,11 @@
// 按SKU接入方式的提交逻辑
if
(
data
.
field
.
goods_source_system_tags
===
''
)
{
layer
.
confirm
(
'如果没有选择任何标签点击确认将把原标签全部删除,确定要删除吗?'
,
function
(
index
)
{
addSkuTag
(
data
,
currentTab
);
addSkuTag
(
data
);
layer
.
close
(
index
);
});
}
else
{
addSkuTag
(
data
,
currentTab
);
addSkuTag
(
data
);
}
break
;
...
...
@@ -175,26 +193,17 @@
}
});
function
addSkuTag
(
data
,
currentTab
)
{
function
addSkuTag
(
data
)
{
admin
.
showLoading
({
type
:
3
});
let
sku_ids
=
getQueryVariable
(
'sku_ids'
);
let
url
=
'/api/sku/BatchAddSkuTag'
;
// 确保当前tab信息被包含在提交数据中
let
submitData
=
data
.
field
;
if
(
currentTab
)
{
submitData
.
current_tab
=
currentTab
;
}
console
.
log
(
'提交数据:'
,
submitData
);
// 调试用,可以看到传递的tab信息
$
.
ajax
({
url
:
url
,
type
:
'POST'
,
async
:
true
,
data
:
submitData
,
data
:
data
.
field
,
dataType
:
'json'
,
timeout
:
20000
,
success
:
function
(
res
)
{
...
...
resources/views/web/BatchAddSkuTag.blade.php
View file @
f5c205d8
...
...
@@ -58,9 +58,9 @@
</div>
<div
class=
"layui-form-item"
id=
"supplier_select_div"
style=
"display: none"
>
@inject('
multiSelectorPresenter','App\Presenters\MultiSelector
Presenter')
{!! $
multiSelector
Presenter->render('supplier_code','供应商选择',null,
$supplierCodes
ForXmSelect,['radio'=>true,
'required'=>true,'width'=>'400px']) !!}
@inject('
statusPresenter','App\Presenters\Status
Presenter')
{!! $
status
Presenter->render('supplier_code','供应商选择',null,
$supplierCodes
,[
'required'=>true,'width'=>'400px']) !!}
</div>
<div
class=
"layui-form-item"
>
...
...
@@ -108,12 +108,12 @@
</tr>
</thead>
<tbody>
@foreach($goodsLabelSystemTagList as $key=>
$item)
{{-- @foreach($goodsLabelSystemTagList as
$item)
<tr>
<td>
{{
config('field.SkuGoodsLabel')[$key
]}}
</td>
<td>
{{implode(',', $item['system_tags'])
}}
</td>
</tr>
@endforeach
<td>
{{
$item['goods_label'
]}}
</td>
<td>
{{$item['goods_label_system_tags']
}}
</td>
</tr>
@endforeach
--}}
</tbody>
</table>
</div>
...
...
@@ -150,12 +150,12 @@
</tr>
</thead>
<tbody>
@foreach($goodsSourceSystemTagList as $key=>
$item)
<tr>
<td>
{{config('field.SkuSource')[$key
]}}
</td>
<td>
{{implode(',', $item['system_tags'])
}}
</td>
</tr>
@endforeach
{{-- @foreach($goodsLabelSystemTagList as
$item)
<tr>
<td>
{{$item['goods_label'
]}}
</td>
<td>
{{$item['goods_label_system_tags']
}}
</td>
</tr>
@endforeach
--}}
</tbody>
</table>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment