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
82e7d84b
authored
Jul 12, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
等级E去除
parent
7cdffa6b
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
236 additions
and
68 deletions
app/Http/Controllers/Api/SupplierExaminationApiController.php
app/Http/Controllers/Api/SupplierTagApiController.php
app/Http/Controllers/SupplierTagsController.php → app/Http/Controllers/SupplierTagController.php
app/Http/Services/DataService.php
app/Http/Services/SupplierService.php
app/Http/Services/SupplierTagService.php
app/Http/routes.php
app/Presenters/MultiSelectorPresenter.php
config/field.php
resources/views/script/BatchAddTags.blade.php → resources/views/script/BatchAddTagScript.blade.php
resources/views/script/SupplierListScript.blade.php
resources/views/web/BatchAddTags.blade.php → resources/views/web/BatchAddTag.blade.php
resources/views/web/SupplierList.blade.php
resources/views/web/supplier/SupplierBase.blade.php
app/Http/Controllers/Api/SupplierExaminationApiController.php
0 → 100644
View file @
82e7d84b
<?php
namespace
App\Http\Controllers\Api
;
use
App\Http\Controllers\Controller
;
use
App\Http\Transformers\SupplierLogTransformer
;
use
App\Model\LogModel
;
use
App\Model\SupplierLogModel
;
use
Illuminate\Http\Request
;
//供应商检测
class
SupplierExaminationApiController
extends
Controller
{
public
function
Entrance
(
Request
$request
,
$id
)
{
$this
->
$id
(
$request
,
$id
);
}
//获取供应商信息变更记录
public
function
GetSupplierLogList
(
$request
)
{
$supplierId
=
$request
->
get
(
'supplier_id'
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$model
=
new
SupplierLogModel
();
$list
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
orderBy
(
'id'
,
'desc'
)
->
paginate
(
$limit
)
->
toArray
();
$transformer
=
new
SupplierLogTransformer
();
$list
[
'data'
]
=
$transformer
->
transformList
(
$list
[
'data'
]);
$this
->
response
(
0
,
'ok'
,
$list
[
'data'
],
$list
[
'total'
]);
}
//添加
public
function
AddSupplierLog
(
$request
)
{
$data
=
$request
->
only
([
'supplier_id'
,
'type'
,
'desc'
]);
if
(
empty
(
$data
[
'type'
])
||
empty
(
$data
[
'desc'
]))
{
$this
->
response
(
-
1
,
'类型或者描述都不能为空'
);
}
if
(
strlen
(
$data
[
'desc'
])
>
500
)
{
$this
->
response
(
-
1
,
'描述不能超过500个字'
);
}
$data
[
'admin_id'
]
=
$request
->
user
->
userId
;
$data
[
'admin_name'
]
=
$request
->
user
->
name
;
$data
[
'add_time'
]
=
time
();
$model
=
new
SupplierLogModel
();
$result
=
$model
->
insert
(
$data
);
if
(
$result
)
{
//还要添加操作记录
$logModel
=
new
LogModel
();
$data
=
[
'action'
=>
'添加信息记录'
,
'content'
=>
$data
[
'desc'
],
'add_time'
=>
time
(),
'admin_name'
=>
$request
->
user
->
name
,
'admin_id'
=>
$request
->
user
->
userId
,
];
$logModel
->
insert
(
$data
);
$this
->
response
(
0
,
'添加成功'
);
}
$this
->
response
(
-
1
,
'添加失败'
,
$result
);
}
//删除
public
function
DeleteSupplierLog
(
$request
)
{
$logId
=
$request
->
get
(
'id'
);
$model
=
new
SupplierLogModel
();
$result
=
$model
->
where
(
'id'
,
$logId
)
->
delete
();
if
(
$result
)
{
$this
->
response
(
0
,
'删除成功'
);
}
$this
->
response
(
-
1
,
'删除失败'
,
$result
);
}
}
app/Http/Controllers/Api/SupplierTagApiController.php
View file @
82e7d84b
...
...
@@ -28,10 +28,10 @@ class SupplierTagApiController extends Controller
}
//批量新增标签
public
function
BatchAddTag
s
(
$request
)
public
function
BatchAddTag
(
$request
)
{
$supplierIds
=
$request
->
get
(
'supplier_ids'
);
$systemTags
=
$request
->
get
(
'system_tags
'
);
$systemTags
=
trim
(
$request
->
get
(
'system_tags'
),
',
'
);
$customTags
=
$request
->
get
(
'customer_tags'
);
$supplierIds
=
$supplierIds
?
explode
(
','
,
$supplierIds
)
:
[];
$systemTags
=
$systemTags
?
explode
(
','
,
$systemTags
)
:
[];
...
...
app/Http/Controllers/SupplierTag
s
Controller.php
→
app/Http/Controllers/SupplierTagController.php
View file @
82e7d84b
...
...
@@ -14,37 +14,35 @@ use App\Model\SupplierReceiptModel;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
class
SupplierTag
s
Controller
extends
Controller
class
SupplierTagController
extends
Controller
{
public
function
info
(
Request
$request
,
$id
=
'
'
)
public
function
Entrance
(
Request
$request
,
$id
=
'index
'
)
{
{
if
(
$request
->
path
()
==
'/'
)
{
$path
=
'web/index'
;
}
else
{
$path
=
$request
->
path
();
}
$this
->
data
=
[
'menus'
=>
$request
->
menus
,
'header'
=>
$request
->
user
->
header
,
'username'
=>
$request
->
user
->
email
,
'user_email'
=>
$request
->
user
->
email
,
'uri'
=>
'/'
.
$path
,
'id'
=>
$id
,
];
return
$this
->
$id
(
$request
);
if
(
$request
->
path
()
==
'/'
)
{
$path
=
'web/index'
;
}
else
{
$path
=
$request
->
path
();
}
$this
->
data
=
[
'menus'
=>
$request
->
menus
,
'header'
=>
$request
->
user
->
header
,
'username'
=>
$request
->
user
->
email
,
'user_email'
=>
$request
->
user
->
email
,
'uri'
=>
'/'
.
$path
,
'id'
=>
$id
];
return
$this
->
$id
(
$request
);
}
public
function
__call
(
$
name
,
$arr
)
public
function
__call
(
$
method
,
$parameters
)
{
$data
[
'errinfo'
]
=
'访问路径错误'
;
return
view
(
'errors.error'
,
$data
);
return
$this
->
errhtml
(
'Not'
,
'没有这个页面'
);
}
//供应商详情
public
function
BatchAddTag
s
(
$request
)
public
function
BatchAddTag
(
$request
)
{
$supplierIds
=
$request
->
get
(
'supplier_ids'
);
$this
->
data
[
'supplierIds'
]
=
$supplierIds
;
...
...
app/Http/Services/DataService.php
View file @
82e7d84b
...
...
@@ -719,14 +719,14 @@ class DataService
$supervisor
=
''
;
$user
=
UserInfoModel
::
where
(
'userId'
,
$supplier
[
'create_uid'
])
->
first
();
$user
=
!
empty
(
$user
)
?
$user
->
toArray
()
:
[];
$supervisorDepartmentId
=
$user
[
'department_id'
];
$supervisorDepartmentId
=
$user
[
'department_id'
];
$positionId
=
\DB
::
table
(
'user_position'
)
->
where
(
'department_id'
,
$supervisorDepartmentId
)
->
where
(
'position_name'
,
'采购总监'
)
->
value
(
'position_id'
);
if
(
empty
(
$positionId
))
{
$positionId
=
\DB
::
table
(
'user_position'
)
->
where
(
'position_name'
,
'运营总监'
)
->
value
(
'position_id'
);
}
$supervisor
=
UserInfoModel
::
where
(
'position_id'
,
$positionId
)
->
value
(
'name'
);
$supervisor
=
UserInfoModel
::
where
(
'position_id'
,
$positionId
)
->
value
(
'name'
);
$excelData
[]
=
[
$supplier
[
'supplier_name'
],
$supplier
[
'supplier_code'
],
...
...
@@ -742,5 +742,33 @@ class DataService
});
})
->
export
(
'csv'
);
}
//修复等级E的问题
public
function
repairLevelESupplierData
(
$isUpdate
=
false
)
{
$suppliers
=
SupplierChannelModel
::
where
(
'level'
,
'E'
)
->
select
([
'supplier_id'
,
'supplier_name'
,
'supplier_type'
,
])
->
get
()
->
toArray
();
foreach
(
$suppliers
as
$supplier
)
{
//去除供应商E等级,之前为E等级并且无品质保证协议的正式供应商,统一改为临时供应商。有品质保证协议的正式供应商继续保持为正式。
$hasQualityAssuranceAgreement
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
where
(
'field_name'
,
'quality_assurance_agreement'
)
->
exists
();
if
(
!
$hasQualityAssuranceAgreement
&&
!
in_array
(
$supplier
[
'supplier_name'
],
config
(
'field.SkipChangeSupplierTypeNames'
)))
{
if
(
$supplier
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_TEMPORARY
)
{
continue
;
}
dump
(
"没有品质保证协议,修改为临时供应商 : "
.
$supplier
[
'supplier_name'
]);
if
(
$isUpdate
)
{
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
'level'
=>
''
,
'supplier_type'
=>
SupplierChannelModel
::
SUPPLIER_TYPE_TEMPORARY
]);
}
}
}
}
}
app/Http/Services/SupplierService.php
View file @
82e7d84b
...
...
@@ -210,14 +210,6 @@ class SupplierService
if
(
$channel
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_OFFICIAL
&&
$oldSupplier
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_TEMPORARY
)
{
$channel
[
'need_review'
]
=
1
;
if
(
$channel
[
'level'
]
==
'E'
)
{
$channel
[
'level'
]
=
''
;
}
}
//只要是临时供应商类型,等级就是E
if
(
$channel
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_TEMPORARY
)
{
$channel
[
'level'
]
=
'E'
;
}
$channel
[
'system_tags'
]
=
trim
(
implode
(
','
,
$channel
[
'system_tags'
]),
','
);
...
...
app/Http/Services/SupplierTagService.php
View file @
82e7d84b
...
...
@@ -128,8 +128,14 @@ class SupplierTagService
foreach
(
$suppliers
as
$supplier
)
{
$oldSystemTags
=
$supplier
[
'system_tags'
]
?
explode
(
','
,
$supplier
[
'system_tags'
])
:
[];
$oldCustomTags
=
$supplier
[
'customer_tags'
]
?
explode
(
','
,
$supplier
[
'customer_tags'
])
:
[];
$newSystemTags
=
array_merge
(
$oldSystemTags
,
$addSysTags
);
$newCustomTags
=
array_merge
(
$oldCustomTags
,
$addCusTags
);
$newSystemTags
=
array_unique
(
array_merge
(
$oldSystemTags
,
$addSysTags
));
$newCustomTags
=
array_unique
(
array_merge
(
$oldCustomTags
,
$addCusTags
));
$newCustomTags
=
implode
(
','
,
$newCustomTags
);
$newSystemTags
=
implode
(
','
,
$newSystemTags
);
$oldCustomTags
=
implode
(
','
,
$oldCustomTags
);
$oldSystemTags
=
implode
(
','
,
$oldSystemTags
);
$this
->
saveTags
(
$supplier
[
'supplier_id'
],
self
::
TAG_TYPE_SYSTEM
,
$newSystemTags
,
$oldSystemTags
);
$this
->
saveTags
(
$supplier
[
'supplier_id'
],
self
::
TAG_TYPE_CUSTOMER
,
$newCustomTags
,
$oldCustomTags
);
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
...
...
app/Http/routes.php
View file @
82e7d84b
...
...
@@ -24,6 +24,7 @@ Route::group(['middleware' => ['web', 'menu']], function () {
Route
::
match
([
'get'
,
'post'
],
'/supplier_receipt/{key}'
,
'SupplierReceiptController@info'
);
Route
::
match
([
'get'
,
'post'
],
'/supplier_account/{key}'
,
'SupplierAccountController@info'
);
Route
::
match
([
'get'
,
'post'
],
'/supplier_share_apply/{key}'
,
'SupplierShareApplyController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/supplier_tag/{key}'
,
'SupplierTagController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/index/{key}'
,
'IndexController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/sku/{key}'
,
'SkuController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/log/{key}'
,
'LogController@Entrance'
);
...
...
@@ -60,5 +61,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
(
new
\App\Http\Services\DataService
())
->
exportHalfYearSupplier
();
(
new
\App\Http\Services\DataService
())
->
repairLevelESupplierData
();
});
app/Presenters/MultiSelectorPresenter.php
View file @
82e7d84b
...
...
@@ -10,6 +10,7 @@ class MultiSelectorPresenter
{
$data
=
$data
?:
[[
'name'
=>
'启用'
,
'value'
=>
1
],
[
'name'
=>
'禁用'
,
'value'
=>
-
1
]];
$isRequired
=
array_get
(
$option
,
'required'
,
false
);
$width
=
array_get
(
$option
,
'width'
,
'157px'
);
$requiredHtml
=
$isRequired
?
'<span style="color: red">*</span>'
:
""
;
$elemId
=
$name
.
"Selector"
;
$data
=
json_encode
(
$data
);
...
...
@@ -18,7 +19,7 @@ class MultiSelectorPresenter
$requiredHtml
$text</label>
<div class="layui-input-inline" style="margin-top: 0">
<div id="$elemId" class="layui-input-inline" value="$value" style="width:
157px
;">
<div id="$elemId" class="layui-input-inline" value="$value" style="width:
$width
;">
</div>
<input type="hidden" name="$name" id="$name" value="$value">
</div>
...
...
config/field.php
View file @
82e7d84b
...
...
@@ -105,7 +105,6 @@ return [
'B'
=>
'B(优秀级)'
,
'C'
=>
'C(次优级)'
,
'D'
=>
'D(合格级)'
,
'E'
=>
'E(临时供应商)'
,
],
'SupplierIsType'
=>
[
...
...
resources/views/script/BatchAddTag
s
.blade.php
→
resources/views/script/BatchAddTag
Script
.blade.php
View file @
82e7d84b
<script>
layui
.
use
([
'table'
,
'form'
,
'element'
,
'table'
,
'layer'
,
'admin'
],
function
()
{
layui
.
use
([
'table'
,
'form'
,
'element'
,
'table'
,
'
xmSelect'
,
'tagsInput'
,
'
layer'
,
'admin'
],
function
()
{
let
admin
=
layui
.
admin
;
let
form
=
layui
.
form
;
let
table
=
layui
.
table
let
element
=
layui
.
element
;
let
xmSelect
=
layui
.
xmSelect
;
let
tagsInput
=
layui
.
tagsInput
;
form
.
on
(
'submit(auditSupplier)'
,
function
(
data
)
{
admin
.
showLoading
({
type
:
3
});
let
supplierIds
=
getQueryVariable
(
'supplier_ids'
);
let
url
=
'/api/supplier
/BatchAllocatePurchaseUser
?supplier_ids='
+
supplierIds
;
let
url
=
'/api/supplier
_tag/BatchAddTag
?supplier_ids='
+
supplierIds
;
$
.
ajax
({
url
:
url
,
type
:
'GET'
,
...
...
@@ -36,5 +39,45 @@
form
.
on
(
'submit(cancel)'
,
function
(
data
)
{
admin
.
closeThisDialog
();
});
function
getTagOption
(
element
)
{
//获取系统标签列表
let
url
=
'/api/supplier_tag/GetSystemTagList'
;
let
tagResult
=
ajax
(
url
);
let
tagList
=
tagResult
.
data
;
return
{
el
:
'#'
+
element
,
filterable
:
true
,
paging
:
true
,
height
:
'250px'
,
size
:
'small'
,
direction
:
'auto'
,
autoRow
:
true
,
prop
:
{
name
:
'tag_name'
,
value
:
'tag_id'
,
},
pageSize
:
30
,
data
:
tagList
,
on
:
function
(
tagList
)
{
let
arr
=
tagList
.
arr
;
let
tagIds
=
''
;
for
(
let
i
in
arr
)
{
tagIds
+=
arr
[
i
].
tag_id
+
','
;
}
let
idName
=
'system_tags'
;
$
(
'#'
+
idName
).
val
(
tagIds
);
},
};
}
let
systemTagOption
=
getTagOption
(
'system_tags_selector'
,
2
);
let
tagSelector
=
xmSelect
.
render
(
systemTagOption
);
let
tagIds
=
$
(
'#system_tags'
).
attr
(
'value'
);
tagSelector
.
setValue
(
tagIds
.
split
(
','
));
//自定义标签
$
(
'#customer_tags'
).
tagsInput
({});
});
</script>
\ No newline at end of file
resources/views/script/SupplierListScript.blade.php
View file @
82e7d84b
...
...
@@ -584,6 +584,26 @@
});
});
//批量修改供应商标签
$
(
"#batch_add_tags"
).
click
(
function
()
{
let
checkStatus
=
table
.
checkStatus
(
'list'
);
let
data
=
checkStatus
.
data
;
let
supplierIds
=
Array
.
from
(
data
,
({
supplier_id
})
=>
supplier_id
);
supplierIds
=
supplierIds
.
join
(
','
);
if
(
!
data
.
length
)
{
layer
.
msg
(
'请先选择要操作的供应商'
,
{
icon
:
5
})
}
else
{
layer
.
open
({
type
:
2
,
content
:
'/supplier_tag/BatchAddTag?view=iframe&supplier_ids='
+
supplierIds
,
area
:
[
'70%'
,
'90%'
],
title
:
'供应商标签添加'
,
end
:
function
()
{
}
});
}
});
//点击查询按钮
form
.
on
(
'submit(load)'
,
function
(
data
)
{
//罗盘选项会跳回全部
...
...
@@ -640,17 +660,4 @@
function
clearTypeFilter
()
{
$
(
'.main_filter'
).
attr
(
'class'
,
'main_filter'
);
}
//批量修改供应商标签
//共用供应商申请
$
(
"#batch_add_tags"
).
click
(
function
()
{
layer
.
open
({
type
:
2
,
content
:
'/supplier_tag/BatchAddTags?view=iframe'
,
area
:
[
'700px'
,
'80%'
],
title
:
'供应商标签添加'
,
end
:
function
()
{
}
});
});
</script>
\ No newline at end of file
resources/views/web/BatchAddTag
s
.blade.php
→
resources/views/web/BatchAddTag.blade.php
View file @
82e7d84b
...
...
@@ -4,17 +4,31 @@
}
</style>
<div
class=
"layui-card"
>
<div
class=
"layui-card-header"
style=
"height:
17
0px"
>
<div
class=
"layui-card-header"
style=
"height:
23
0px"
>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
渠道开发员设置
</b>
<b>
标签新增
</b>
</blockquote>
<form
class=
"layui-form"
action=
""
>
<input
type=
"hidden"
name=
"supplier_ids"
value=
"{{$supplierIds}}"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
style=
"margin-left: -30px"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('purchase_uid','渠道开发员',null,
$userCodes,['required'=>true,'width'=>'150px']) !!}
<div
class=
"layui-input-block"
style=
"margin-left: -30px"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
系统标签 :
</label>
<div
class=
"layui-input-block"
style=
"margin-top: 15px"
>
<div
id=
"system_tags_selector"
class=
"layui-input-inline"
style=
"width: 100%;"
>
</div>
<input
type=
"hidden"
name=
"system_tags"
value=
"{{$supplier['system_tags'] or ''}}"
id=
"system_tags"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
自定义标签 :
</label>
<div
class=
"layui-input-block"
style=
"margin-top: 15px"
>
<input
name=
"customer_tags"
id=
"customer_tags"
value=
"{{$supplier['customer_tags'] or ''}}"
>
</div>
</div>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
@@ -31,25 +45,27 @@
</div>
<div
class=
"layui-card-body"
>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
当前选中需要批量
修改渠道员
的供应商列表
</b>
<b>
当前选中需要批量
新增标签
的供应商列表
</b>
</blockquote>
<table
class=
"layui-table"
>
<colgroup>
<col
width=
"300"
>
<col
width=
"
1
00"
>
<col>
<col
width=
"
4
00"
>
<col
width=
"400"
>
</colgroup>
<thead>
<tr>
<th>
供应商名称
</th>
<th>
当前渠道开发员
</th>
<th>
系统标签
</th>
<th>
自定义标签
</th>
</tr>
</thead>
<tbody>
@foreach($suppliers as $supplier)
<tr>
<td>
{{$supplier['supplier_name']}}
</td>
<td>
{{$supplier['purchase_username']}}
</td>
<td>
{{$supplier['system_tags']}}
</td>
<td>
{{$supplier['customer_tags']}}
</td>
</tr>
@endforeach
</tbody>
...
...
resources/views/web/SupplierList.blade.php
View file @
82e7d84b
...
...
@@ -57,9 +57,9 @@
@endif
</button>
@endif
@if(checkPerm('BatchAddTag
s
'))
@if(checkPerm('BatchAddTag'))
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
batch_add_tags
">
批量修改
供应商标签
新增
供应商标签
</button>
@endif
</div>
...
...
resources/views/web/supplier/SupplierBase.blade.php
View file @
82e7d84b
...
...
@@ -256,7 +256,7 @@
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-md3"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('level','等级',!empty($supplier)?$supplier['level']:'',['A'=>'A','B'=>'B','C'=>'C','D'=>'D'
,'E'=>'E'
],['width'=>'150px']) !!}
{!! $statusPresenter->render('level','等级',!empty($supplier)?$supplier['level']:'',['A'=>'A','B'=>'B','C'=>'C','D'=>'D'],['width'=>'150px']) !!}
</div>
<div
class=
"layui-col-md3"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
...
...
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