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
31cd327c
authored
Jul 05, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-供应商新需求-20220627' into ysx-供应商新建-20220701
parents
1e371191
f5f80f27
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
166 additions
and
114 deletions
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Controllers/Filter/SupplierFilter.php
app/Http/Controllers/SupplierController.php
app/Http/Services/SupplierService.php
app/Presenters/MultiSelectorPresenter.php
config/fixed.php
resources/views/script/AllocateChannelUserScript.blade.php
resources/views/script/SupplierListScript.blade.php
resources/views/web/AllocateChannelUser.blade.php
resources/views/web/supplier/SupplierListCommon.blade.php
app/Http/Controllers/Api/SupplierApiController.php
View file @
31cd327c
...
...
@@ -421,6 +421,32 @@ class SupplierApiController extends Controller
$this
->
response
(
0
,
'添加采购员成功'
);
}
//分配采购员(支持批量操作)
public
function
BatchAllocateChannelUser
(
$request
)
{
$channelUid
=
$request
->
get
(
'channel_uid'
);
$supplierIds
=
$request
->
get
(
'supplier_ids'
);
if
(
empty
(
$channelUid
))
{
$this
->
response
(
-
1
,
'采购员不能为空'
);
}
$adminService
=
new
AdminUserService
();
$check
=
$adminService
->
checkIsResignedByCodeId
(
$channelUid
);
if
(
$check
)
{
$this
->
response
(
-
1
,
'该采购员已经离职,请选择其他人员'
);
}
$supplierIds
=
explode
(
','
,
$supplierIds
);
$model
=
new
SupplierChannelModel
();
foreach
(
$supplierIds
as
$supplierId
)
{
$service
=
new
SupplierService
();
$result
=
$service
->
allocateChannelUser
(
$supplierId
,
$channelUid
);
if
(
!
$result
)
{
$this
->
response
(
-
1
,
'添加采购员失败'
);
}
}
$this
->
response
(
0
,
'添加采购员成功'
);
}
//转正供应商
public
function
ChangeSupplierIsType
(
$request
)
{
...
...
app/Http/Controllers/Filter/SupplierFilter.php
View file @
31cd327c
...
...
@@ -25,8 +25,8 @@ class SupplierFilter
if
(
!
empty
(
$map
[
'supplier_id'
]))
{
$query
->
where
(
'supplier_channel.supplier_id'
,
$map
[
'supplier_id'
]);
}
if
(
!
empty
(
$map
[
'supplier_type'
]))
{
$query
->
where
(
'supplier_channel.supplier_type'
,
$map
[
'supplier_type'
]
);
if
(
(
isset
(
$map
[
'supplier_type'
])
&&
$map
[
'supplier_type'
]
===
"0"
)
||
!
empty
(
$map
[
'supplier_type'
]))
{
$query
->
where
In
(
'supplier_type'
,
explode
(
','
,
$map
[
'supplier_type'
])
);
}
if
(
!
empty
(
$map
[
'supplier_name'
]))
{
$query
->
where
(
'supplier_name'
,
'like'
,
"%
{
$map
[
'supplier_name'
]
}
%"
);
...
...
@@ -45,8 +45,11 @@ class SupplierFilter
$query
->
where
(
'company_nature'
,
$map
[
'company_nature'
]);
}
if
(
!
empty
(
$map
[
'stockup_type'
]))
{
$query
->
where
(
'stockup_type'
,
'like'
,
"%
{
$map
[
'stockup_type'
]
}
%"
);
$regexStr
=
'('
.
str_replace
(
','
,
'|'
,
$map
[
'stockup_type'
])
.
')'
;
// $query->where('stockup_type', 'like', "%{$map['stockup_type']}%");
$query
->
whereRaw
(
"stockup_type REGEXP '${regexStr}'"
);
}
if
(
!
empty
(
$map
[
'purchase_uid'
]))
{
$query
->
where
(
'purchase_uid'
,
$map
[
'purchase_uid'
]);
}
...
...
@@ -70,11 +73,9 @@ class SupplierFilter
if
(
!
empty
(
$map
[
'is_type'
]))
{
$query
->
where
(
'is_type'
,
$map
[
'is_type'
]);
}
if
(
!
empty
(
$map
[
'level'
]))
{
$query
->
where
(
'level'
,
$map
[
'level'
]);
if
((
isset
(
$map
[
'level'
])
&&
$map
[
'level'
]
===
"0"
)
||
!
empty
(
$map
[
'level'
]))
{
$query
->
whereIn
(
'level'
,
explode
(
','
,
$map
[
'level'
]));
}
if
(
isset
(
$map
[
'is_type'
])
&&
$map
[
'is_type'
]
===
"0"
)
{
$query
->
where
(
'is_type'
,
$map
[
'is_type'
]);
}
...
...
app/Http/Controllers/SupplierController.php
View file @
31cd327c
...
...
@@ -74,6 +74,30 @@ class SupplierController extends Controller
];
}
$this
->
data
[
'statusData'
]
=
$statusData
;
$stockupTypeData
=
[];
foreach
(
config
(
'fixed.StockupType'
)
as
$key
=>
$value
)
{
$stockupTypeData
[]
=
[
'name'
=>
$value
,
'value'
=>
$key
,
];
}
$this
->
data
[
'stockupTypeData'
]
=
$stockupTypeData
;
$levelData
=
[];
foreach
(
config
(
'field.LevelMap'
)
as
$key
=>
$value
)
{
$levelData
[]
=
[
'name'
=>
$value
,
'value'
=>
$key
,
];
}
$this
->
data
[
'levelData'
]
=
$levelData
;
$supplierTypeData
=
[];
foreach
(
config
(
'field.SupplierType'
)
as
$key
=>
$value
)
{
$supplierTypeData
[]
=
[
'name'
=>
$value
,
'value'
=>
$key
,
];
}
$this
->
data
[
'supplierTypeData'
]
=
$supplierTypeData
;
return
$this
->
view
(
'供应商列表'
);
}
...
...
@@ -250,16 +274,17 @@ class SupplierController extends Controller
return
$this
->
view
(
'批量分配渠道开发员'
);
}
//添加采购员
//
批量
添加采购员
public
function
AllocateChannelUser
(
$request
)
{
$supplierId
=
$request
->
get
(
'supplier_id'
);
$supplierIds
=
$request
->
get
(
'supplier_ids'
);
$this
->
data
[
'supplierIds'
]
=
$supplierIds
;
$supplierIds
=
explode
(
','
,
$supplierIds
);
$model
=
new
SupplierChannelModel
();
$supplier
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
first
();
$supplier
=
$supplier
?
$supplier
->
toArray
()
:
[];
$suppliers
=
$model
->
whereIn
(
'supplier_id'
,
$supplierIds
)
->
get
()
->
toArray
();
$transformer
=
new
SupplierTransformer
();
$supplier
=
$transformer
->
transformInfo
(
$supplier
);
$this
->
data
[
'supplier
'
]
=
$supplier
;
$supplier
s
=
$transformer
->
transformList
(
$suppliers
);
$this
->
data
[
'supplier
s'
]
=
$suppliers
;
$intraCodeModel
=
new
IntracodeModel
();
$this
->
data
[
'userCodes'
]
=
$intraCodeModel
->
getChannelUsersEncode
(
false
);
return
$this
->
view
(
'添加采购员'
);
...
...
app/Http/Services/SupplierService.php
View file @
31cd327c
...
...
@@ -428,6 +428,16 @@ class SupplierService
//分配采购员
public
function
allocateChannelUser
(
$supplierId
,
$channelUid
,
$logFlag
=
true
)
{
$supplier
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
first
();
if
(
empty
(
$supplier
))
{
return
true
;
}
$supplier
=
$supplier
->
toArray
();
$preChannelUid
=
explode
(
','
,
$supplier
[
'channel_uid'
]);
//如果之前已经存在对应的采购,直接返回
if
(
in_array
(
$channelUid
,
$preChannelUid
))
{
return
true
;
}
$result
=
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$supplierId
,
$channelUid
,
$logFlag
)
{
$model
=
new
SupplierChannelModel
();
$supplier
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
first
();
...
...
@@ -461,7 +471,7 @@ class SupplierService
$contactResult
=
$contactModel
->
insert
(
$contact
);
}
if
(
$contactResult
&&
$logFlag
)
{
//判断是否是非正式供应商,如果是,自动转正,并且修改为待审核状态
//判断是否是非正式
(is_type=1)
供应商,如果是,自动转正,并且修改为待审核状态
$this
->
autoChangeIsType
(
$supplier
);
//记录日志
$adminUserService
=
new
AdminUserService
();
...
...
app/Presenters/MultiSelectorPresenter.php
View file @
31cd327c
...
...
@@ -18,12 +18,11 @@ 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: 15
5
px;">
<div id="$elemId" class="layui-input-inline" value="$value" style="width: 15
8
px;">
</div>
<input type="hidden" name="$name" id="$name" value="$value">
</div>
<script>
window.onload = function(){
layui.use(['xmSelect', 'element'], function () {
let xmSelect = layui.xmSelect;
//渲染多选
...
...
@@ -57,10 +56,8 @@ class MultiSelectorPresenter
let values = $('#$elemId').attr('value');
selector.setValue(values.split(','));
});
}
</script>
EOF;
return
$html
;
}
}
\ No newline at end of file
config/fixed.php
View file @
31cd327c
...
...
@@ -84,7 +84,7 @@ return [
//账期-周期结算
1
=>
'账期'
,
//账期-定期结算
2
=>
'
货到
付款'
,
2
=>
'
验货
付款'
,
// 4 => '定金'
5
=>
'验货付款'
,
],
...
...
resources/views/script/AllocateChannelUserScript.blade.php
View file @
31cd327c
...
...
@@ -4,47 +4,33 @@
let
form
=
layui
.
form
;
let
table
=
layui
.
table
let
element
=
layui
.
element
;
table
.
render
({
elem
:
'#logList'
,
url
:
'/api/log/GetLogList'
,
method
:
'post'
,
size
:
'sm'
,
limit
:
10
,
cellMinWidth
:
80
//全局定义常规单元格的最小宽度
,
where
:
{
supplier_id
:{{
$supplier
[
'supplier_id'
]}},
action
:
'添加采购员'
,
}
,
loading
:
true
,
first
:
true
//不显示首页
,
last
:
false
//不显示尾页
,
cols
:
[[
{
field
:
'add_time'
,
title
:
'日志时间'
,
width
:
150
,
align
:
'center'
},
{
field
:
'content'
,
title
:
'日志内容'
,
align
:
'center'
,
templet
:
function
(
data
)
{
return
data
.
admin_name
+
data
.
content
;
form
.
on
(
'submit(auditSupplier)'
,
function
(
data
)
{
admin
.
showLoading
({
type
:
3
,
});
let
supplierIds
=
getQueryVariable
(
'supplier_ids'
);
let
url
=
'/api/supplier/BatchAllocateChannelUser?supplier_ids='
+
supplierIds
;
$
.
ajax
({
url
:
url
,
type
:
'GET'
,
async
:
true
,
data
:
data
.
field
,
dataType
:
'json'
,
timeout
:
20000
,
success
:
function
(
res
)
{
if
(
res
.
err_code
===
0
)
{
admin
.
closeThisDialog
();
parent
.
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
}
else
{
admin
.
removeLoading
();
parent
.
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
}
},
]]
,
id
:
'logList'
,
page
:
{}
});
form
.
on
(
'submit(auditSupplier)'
,
function
(
data
)
{
admin
.
btnLoading
(
'.submit-loading'
);
let
supplierId
=
getQueryVariable
(
'supplier_id'
);
let
url
=
'/api/supplier/AllocateChannelUser?supplier_id='
+
supplierId
;
let
res
=
ajax
(
url
,
data
.
field
);
if
(
!
res
)
{
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
}
else
{
if
(
res
.
err_code
===
0
)
{
admin
.
closeThisDialog
();
parent
.
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
}
else
{
admin
.
btnLoading
(
'.submit-loading'
,
false
);
parent
.
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
error
:
function
()
{
admin
.
removeLoading
();
parent
.
layer
.
msg
(
'网络错误'
,
{
icon
:
5
});
}
}
}
);
return
false
;
});
form
.
on
(
'submit(cancel)'
,
function
(
data
)
{
...
...
resources/views/script/SupplierListScript.blade.php
View file @
31cd327c
...
...
@@ -435,36 +435,41 @@
})
//分配采购员
//分配采购员
,现在改成可以批量的了
$
(
"#allocate_channel_user"
).
click
(
function
()
{
let
checkStatus
=
table
.
checkStatus
(
'list'
);
let
data
=
checkStatus
.
data
;
if
(
!
data
.
length
)
{
layer
.
msg
(
'请先选择要操作的供应商'
,
{
icon
:
5
})
}
else
{
if
(
data
.
length
>
1
)
{
layer
.
msg
(
'该操作不支持多选'
,
{
icon
:
5
})
return
;
}
const
status
=
data
[
0
].
status
;
if
((
status
!==
-
1
||
status
!==
1
))
{
let
supplierId
=
data
[
0
].
supplier_id
;
let
status
=
Array
.
from
(
data
,
({
status
})
=>
status
);
let
canApplyInReview
=
true
;
$
.
each
(
status
,
function
(
index
,
value
)
{
console
.
log
(
value
);
if
(
value
===
-
1
||
value
===
1
)
{
canApplyInReview
=
false
;
}
});
if
(
!
canApplyInReview
)
{
layer
.
msg
(
'选择的供应商里,存在 审核中/待复审 状态的供应商,无法申请审核'
,
{
icon
:
5
})
}
else
{
let
supplierIds
=
Array
.
from
(
data
,
({
supplier_id
})
=>
supplier_id
);
if
(
supplierIds
.
length
>
20
)
{
layer
.
msg
(
'最多一次操作20个供应商'
,
{
icon
:
5
})
return
;
}
supplierIds
=
supplierIds
.
join
(
','
);
layer
.
open
({
type
:
2
,
content
:
'/supplier/AllocateChannelUser?view=iframe&supplier_id
='
+
supplierId
,
area
:
[
'
650px
'
,
'80%'
],
content
:
'/supplier/AllocateChannelUser?view=iframe&supplier_id
s='
+
supplierIds
,
area
:
[
'
80%
'
,
'80%'
],
title
:
'新增采购员'
,
end
:
function
()
{
saveRefreshData
(
'detail'
,
supplierId
)
table
.
reload
(
'list'
);
supplierStatistics
();
}
});
}
else
{
layer
.
msg
(
'审核中/待复审状态的供应商无法分配采购员'
,
{
icon
:
5
})
return
false
;
}
}
})
...
...
resources/views/web/AllocateChannelUser.blade.php
View file @
31cd327c
...
...
@@ -4,37 +4,21 @@
}
</style>
<div
class=
"layui-card"
>
<div
class=
"layui-card-header"
style=
"height: 90px"
>
<div
class=
"layui-row"
>
<div
class=
"layui-col-xs6"
>
供应商名称 :
<b>
{{$supplier['supplier_name']}}
</b>
</div>
<div
class=
"layui-col-xs6"
>
状态 : {{$supplier['status_name']}}
</div>
<div
class=
"layui-col-xs6"
>
公司性质 : {{$supplier['supplier_group_name']}}
</div>
<div
class=
"layui-col-xs6"
>
合作类型 : {{$supplier['stockup_type']}}
</div>
<div
class=
"layui-col-xs12"
>
当前采购 : {{$supplier['channel_username']}}
</div>
</div>
</div>
<div
class=
"layui-card-body"
>
<div
class=
"layui-card-header"
style=
"height: 170px"
>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
采购员设置
</b>
</blockquote>
<form
class=
"layui-form"
action=
""
>
<input
type=
"hidden"
name=
"supplier_id
"
value=
"{{$supplier['supplier_id']
}}"
>
<input
type=
"hidden"
name=
"supplier_id
s"
value=
"{{$supplierIds
}}"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
style=
"margin-left: -30px"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('channel_uid','
新增采购员',''
,
{!! $statusPresenter->render('channel_uid','
采购员',null
,
$userCodes,['required'=>true,'width'=>'150px']) !!}
</div>
</div>
<div
class=
"layui-form-item"
>
<div
align=
"center"
style=
"margin-top:
2
0px;text-align: right"
>
<div
align=
"center"
style=
"margin-top:
1
0px;text-align: right"
>
<button
type=
"button"
class=
"layui-btn layui-btn-sm layui-btn-info submit-loading"
lay-submit
lay-filter=
"auditSupplier"
>
确认
</button>
...
...
@@ -45,13 +29,35 @@
</div>
</form>
</div>
<div
class=
"layui-card-body"
>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b
style=
"color: red"
>
注意 : 由于采购和联系人强制绑定的,所以这个页面添加采购,会默认添加一个与其对应空的联系人.
</b>
<br>
<b
style=
"margin-left: 35px;color: red"
>
如果想要完善联系人,可以进供应商的修改页面进行修改
</b>
</blockquote>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
当前选中需要批量新增采购员的供应商列表
</b>
</blockquote>
<table
class=
"layui-table"
>
<colgroup>
<col
width=
"200"
>
<col
width=
"700"
>
<col>
</colgroup>
<thead>
<tr>
<th>
供应商名称
</th>
<th>
当前采购员
</th>
</tr>
</thead>
<tbody>
@foreach($suppliers as $supplier)
<tr>
<td>
{{$supplier['supplier_name']}}
</td>
<td>
{{$supplier['channel_username']}}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
注意 : 由于采购和联系人强制绑定的,所以这个页面添加采购,会默认添加一个与其对应空的联系人.
</b>
<br>
<b
style=
"margin-left: 35px"
>
如果想要完善联系人,可以进供应商的修改页面进行修改
</b>
</blockquote>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
操作日志
</b>
</blockquote>
<table
class=
"layui-table"
id=
"logList"
lay-filter=
"logList"
></table>
resources/views/web/supplier/SupplierListCommon.blade.php
View file @
31cd327c
...
...
@@ -160,8 +160,8 @@
{!! $multiSelectorPresenter->render('status','供应商状态','',$statusData) !!}
</div>
<div
class=
"layui-inline"
>
@inject('
statusPresenter','App\Presenters\Status
Presenter')
{!! $
statusPresenter->render('stockup_type','合作类型','',config('fixed.StockupType')
) !!}
@inject('
multiSelectorPresenter','App\Presenters\MultiSelector
Presenter')
{!! $
multiSelectorPresenter->render('stockup_type','合作类型','',$stockupTypeData
) !!}
</div>
<div
class=
"layui-inline"
>
@inject('transformableSelectPresenter','App\Presenters\Filter\TransformableSelectPresenter')
...
...
@@ -174,17 +174,14 @@
{!! $multiTransformableSelectPresenter->render(['has_sku'=>'SKU上传','sku_tag'=>'SKU标准','sku_mode'=>'SKU模式','uploaded_sku' => '历史SKU合作','outside_contact_type' => 'SKU上传方式'],
['has_sku'=>[1=>'是',-1=>'否'],'sku_tag'=>config('field.SkuTag'),'sku_mode'=>config('field.SkuMode'),'outside_contact_type'=>config('field.OutsideContactType')]) !!}
</div>
{{-- @if(checkPerm('ViewFakeSupplier'))--}}
<div
class=
"layui-inline"
>
@inject('
statusPresenter','App\Presenters\Status
Presenter')
{!! $
statusPresenter->render('supplier_type','供应商类别','',config('field.SupplierType')
) !!}
@inject('
multiSelectorPresenter','App\Presenters\MultiSelector
Presenter')
{!! $
multiSelectorPresenter->render('supplier_type','供应商类型','',$supplierTypeData
) !!}
</div>
{{-- @endif--}}
<div
class=
"layui-inline"
>
@inject('
statusPresenter','App\Presenters\Status
Presenter')
{!! $
statusPresenter->render('level','等级','',config('field.LevelMap')
) !!}
@inject('
multiSelectorPresenter','App\Presenters\MultiSelector
Presenter')
{!! $
multiSelectorPresenter->render('level','等级','',$levelData
) !!}
</div>
<div
class=
"layui-inline"
style=
"width: 600px"
>
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'创建时间']) !!}
...
...
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