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
9ffc9d56
authored
Jul 12, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
公用审核流程修改
parent
dbc22472
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
136 additions
and
45 deletions
app/Http/Controllers/Api/SupplierShareApplyApiController.php
app/Http/Services/SupplierShareApplyService.php
app/Http/Transformers/SupplierShareApplyTransformer.php
config/field.php
resources/views/script/ApplySupplierShareScript.blade.php
resources/views/script/AuditSupplierShareApplyScript.blade.php
resources/views/web/ApplySupplierShare.blade.php
resources/views/web/AuditSupplierShareApply.blade.php
app/Http/Controllers/Api/SupplierShareApplyApiController.php
View file @
9ffc9d56
...
...
@@ -48,6 +48,7 @@ class SupplierShareApplyApiController extends Controller
if
(
empty
(
$supplier
))
{
$this
->
response
(
-
1
,
'该供应商名称不存在,请输入正确供应商名称'
);
}
$hasYunxinChannelUid
=
$supplier
[
'yunxin_channel_uid'
]
?
1
:
0
;
$userId
=
$request
->
user
->
userId
;
$codeId
=
$request
->
user
->
codeId
;
if
(
empty
(
$codeId
))
{
...
...
@@ -60,7 +61,8 @@ class SupplierShareApplyApiController extends Controller
$q
->
orWhere
(
'purchase_uid'
,
$codeId
)
->
orwhere
(
'channel_uid'
,
'like'
,
"%
$codeId
%"
);
}
})
->
where
(
'is_type'
,
0
)
->
first
();
})
->
where
(
'is_type'
,
0
)
->
first
();
if
(
$isOwn
)
{
$this
->
response
(
-
1
,
'你已经可以管理该供应商,无需申请共用'
);
}
...
...
@@ -78,7 +80,11 @@ class SupplierShareApplyApiController extends Controller
if
(
empty
(
$departments
))
{
$this
->
response
(
-
1
,
'该供应商不存在相关联的部门'
);
}
$this
->
response
(
0
,
'匹配到供应商数据,可以下拉选择你需要申请的部门'
,
$departments
,
$supplier
[
'supplier_id'
]);
$data
=
[
'departments'
=>
$departments
,
'has_yunxin_channel_uid'
=>
$hasYunxinChannelUid
,
];
$this
->
response
(
0
,
'匹配到供应商数据,可以下拉选择你需要申请的部门'
,
$data
,
$supplier
[
'supplier_id'
]);
}
//保存共用申请
...
...
@@ -86,10 +92,11 @@ class SupplierShareApplyApiController extends Controller
{
$map
=
$request
->
only
([
'apply_department_id'
,
'apply_reason'
,
'supplier_id'
,
]);
if
(
empty
(
$map
[
'apply_department_id'
])
||
empty
(
$map
[
'supplier_id'
]))
{
$this
->
response
(
-
1
,
'
缺少参数
'
);
$this
->
response
(
-
1
,
'
被申请部门不能为空
'
);
}
if
(
empty
(
$request
->
user
->
codeId
))
{
$this
->
response
(
-
1
,
'你还没有绑定内部编码,无法申请共用'
);
...
...
@@ -100,6 +107,12 @@ class SupplierShareApplyApiController extends Controller
if
(
$hasNoFinish
)
{
$this
->
response
(
-
1
,
'你存在对该供应商的申请,正在审核流程中,请等待对应的审核流程走完方可针对该供应商进行新的共用申请'
);
}
//如果是包含sku采购员的供应商,那么就要有申请理由
if
(
SupplierChannelModel
::
where
(
'supplier_id'
,
$map
[
'supplier_id'
])
->
value
(
'yunxin_channel_uid'
))
{
if
(
!
$map
[
'apply_reason'
])
{
$this
->
response
(
-
1
,
'申请原因不能为空'
);
}
}
$result
=
$applyService
->
saveSupplierShareApply
(
$map
);
if
(
!
$result
)
{
$this
->
response
(
-
1
,
'申请失败,系统错误'
);
...
...
app/Http/Services/SupplierShareApplyService.php
View file @
9ffc9d56
...
...
@@ -45,13 +45,21 @@ class SupplierShareApplyService
public
function
getApplyCanUseDepartments
(
$supplier
)
{
$supplier
=
$supplier
->
toArray
();
//找出采购,开发员,创建者所属部门,一个供应商可能和多个部门相关,因为采购可能有自营或者联营的
$purchaseUid
=
$supplier
[
'purchase_uid'
];
$channelUids
=
explode
(
','
,
$supplier
[
'channel_uid'
]);
$createUid
=
$supplier
[
'create_uid'
];
$yunxinChannelUid
=
$supplier
[
'yunxin_channel_uid'
];
//如果是有芯链sku采购员的,那么就只取sku采购员所在的部门进行审核
if
(
$yunxinChannelUid
)
{
$purchaseUid
=
0
;
$channelUids
=
[
$yunxinChannelUid
];
$createUid
=
0
;
}
else
{
//找出采购,开发员,创建者所属部门,一个供应商可能和多个部门相关,因为采购可能有自营或者联营的
$purchaseUid
=
$supplier
[
'purchase_uid'
];
$channelUids
=
explode
(
','
,
$supplier
[
'channel_uid'
]);
$createUid
=
$supplier
[
'create_uid'
];
}
//dd($purchaseUid,$channelUids,$createUid);
$departmentService
=
new
DepartmentService
();
$adminService
=
new
AdminUserService
();
$purchaseUser
=
$adminService
->
getAdminUserInfoByCodeId
(
$purchaseUid
);
$purchaseDepartment
=
$departmentService
->
getUpperDepartmentByUserIdForShareApply
(
$purchaseUser
[
'userId'
]);
$createDepartment
=
$departmentService
->
getUpperDepartmentByUserIdForShareApply
(
$createUid
);
...
...
@@ -75,6 +83,12 @@ class SupplierShareApplyService
$allDepartments
=
array_filter
(
$allDepartments
,
function
(
$department
)
{
return
!
empty
(
$department
);
});
//这里还要去判断,如果返回的部门里面有多个部门,并且包含运营部,那么就要去除运营部
if
(
count
(
$allDepartments
)
>
1
)
{
$allDepartments
=
array_filter
(
$allDepartments
,
function
(
$department
)
{
return
$department
[
'department_id'
]
!=
config
(
'field.YunyingTopDepartmentId'
);
});
}
return
$allDepartments
;
}
...
...
@@ -112,7 +126,7 @@ class SupplierShareApplyService
$applyModel
=
new
SupplierShareApplyModel
();
$query
=
$applyModel
::
with
([
'supplier'
=>
function
(
$q
)
{
$q
->
select
([
'supplier_name'
,
'supplier_id'
]);
$q
->
select
([
'supplier_name'
,
'supplier_id'
,
'yunxin_channel_uid'
]);
},
'department'
,
'apply_department'
,
...
...
@@ -125,6 +139,14 @@ class SupplierShareApplyService
$q
->
where
(
'apply_department_id'
,
$departmentId
)
->
where
(
'review_uid'
,
0
)
->
where
(
'audit_uid'
,
'!='
,
0
)
->
where
(
'status'
,
SupplierShareApplyModel
::
STATUS_NEED_REVIEW
);
})
->
orderBy
(
'id'
,
'desc'
);
// $query = $applyModel::with([
// 'supplier' => function ($q) {
// $q->select(['supplier_name', 'supplier_id','yunxin_channel_uid']);
// },
// 'department',
// 'apply_department',
// 'apply_user'
// ])->orderBy('id', 'desc');
$limit
=
request
()
->
get
(
'limit'
,
20
);
$list
=
$query
->
paginate
(
$limit
)
->
toArray
();
$transformer
=
new
SupplierShareApplyTransformer
();
...
...
@@ -163,7 +185,6 @@ class SupplierShareApplyService
$syncService
->
syncSupplierToErp
(
$apply
[
'supplier_id'
]);
}
}
return
$applyModel
->
where
(
'id'
,
$id
)
->
update
(
$apply
);
}
}
\ No newline at end of file
app/Http/Transformers/SupplierShareApplyTransformer.php
View file @
9ffc9d56
...
...
@@ -14,6 +14,7 @@ class SupplierShareApplyTransformer
foreach
(
$list
as
&
$item
)
{
$item
[
'create_time'
]
=
date
(
'Y-m-d H:i:s'
,
$item
[
'create_time'
]);
$item
[
'status_name'
]
=
array_get
(
config
(
'field.SupplierShareApplyStatus'
),
$item
[
'status'
]);
$item
[
'yunxin_channel_name'
]
=
(
new
AdminUserService
())
->
getAdminUserNameByCodeId
(
$item
[
'supplier'
][
'yunxin_channel_uid'
]);
}
unset
(
$item
);
return
$list
;
...
...
config/field.php
View file @
9ffc9d56
...
...
@@ -98,6 +98,8 @@ return [
'ZiYingDepartmentId'
=>
51
,
//60是本地的数据
'LiangYingDepartmentIds'
=>
[
47
,
60
,
72
],
//运营部门id
'YunyingTopDepartmentId'
=>
9
,
//等级显示对应数据
'LevelMap'
=>
[
...
...
resources/views/script/ApplySupplierShareScript.blade.php
View file @
9ffc9d56
...
...
@@ -43,6 +43,7 @@
//点击校验按钮
$
(
'#check_apply_supplier_share'
).
click
(
function
()
{
$
(
'#apply_reason_div'
).
hide
();
let
supplierName
=
$
(
'#supplier_name'
).
val
();
let
url
=
'/api/supplier_share_apply/CheckApplySupplierShare'
;
let
data
=
{
...
...
@@ -50,17 +51,25 @@
}
let
res
=
ajax
(
url
,
data
);
if
(
res
.
err_code
===
0
)
{
//是否有sku采购
if
(
res
.
total
>
0
)
{
$
(
'#apply_audit_reason'
)
}
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
//设置对应的supplier_id,后端暂时放到res.count这个字段吧...
let
supplierId
=
res
.
count
;
$
(
'#supplier_id'
).
val
(
supplierId
);
//渲染下拉框
let
optionHtml
=
'
<
option
value
=
""
>
请选择一个部门
<
/option>'
;
$
.
each
(
res
.
data
,
function
(
index
,
value
)
{
$
.
each
(
res
.
data
.
departments
,
function
(
index
,
value
)
{
optionHtml
+=
"
<
option
value
=
'" + value.department_id + "'
>
" + value.department_name + "
<
/option>
"
})
$
(
'#apply_department_id'
).
html
(
optionHtml
);
form
.
render
(
'select'
);
let
hasYunxinChannelUid
=
res
.
data
.
has_yunxin_channel_uid
;
if
(
hasYunxinChannelUid
)
{
$
(
'#apply_reason_div'
).
show
();
}
}
else
{
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
}
...
...
resources/views/script/AuditSupplierShareApplyScript.blade.php
View file @
9ffc9d56
...
...
@@ -29,7 +29,11 @@
}
},
{
field
:
'apply_department_name'
,
title
:
'被申请部门'
,
width
:
150
,
align
:
'center'
,
templet
:
function
(
d
)
{
field
:
'apply_department_name'
,
title
:
'被申请部门'
,
width
:
150
,
align
:
'center'
,
templet
:
function
(
d
)
{
return
d
.
apply_department
?
d
.
apply_department
.
department_name
:
''
;
}
},
...
...
@@ -41,23 +45,56 @@
,
page
:
{}
});
$
(
document
).
on
(
'click'
,
'.audit_supplier_share_apply'
,
function
()
{
let
status
=
$
(
this
).
attr
(
'status'
);
let
id
=
$
(
this
).
val
();
let
statusName
=
status
===
'pass'
?
'通过'
:
'拒绝'
;
layer
.
confirm
(
'确定要'
+
statusName
+
'该申请吗?'
,
function
()
{
let
url
=
'/api/supplier_share_apply/AuditSupplierShareApply'
;
let
result
=
ajax
(
url
,
{
status
:
status
,
id
:
id
,
});
if
(
result
.
err_code
===
0
)
{
layer
.
msg
(
'审核成功'
,
{
icon
:
6
})
table
.
reload
(
'auditList'
);
table
.
on
(
'tool(auditList)'
,
function
(
obj
)
{
//注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
var
data
=
obj
.
data
;
//获得当前行数据
var
layEvent
=
obj
.
event
;
//获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var
tr
=
obj
.
tr
;
//获得当前行 tr 的 DOM 对象(如果有的话)
if
(
layEvent
===
'pass'
||
layEvent
===
'reject'
)
{
//查看
let
hasYunxinChannelUid
=
data
.
supplier
.
yunxin_channel_uid
;
let
statusName
=
layEvent
===
'pass'
?
'通过'
:
'拒绝'
;
let
status
=
layEvent
;
//没有芯链采购员
if
(
!
hasYunxinChannelUid
)
{
layer
.
confirm
(
'确定要'
+
statusName
+
'该申请吗?'
,
function
()
{
let
url
=
'/api/supplier_share_apply/AuditSupplierShareApply'
;
let
result
=
ajax
(
url
,
{
status
:
status
,
id
:
id
,
});
if
(
result
.
err_code
===
0
)
{
layer
.
msg
(
'审核成功'
,
{
icon
:
6
})
table
.
reload
(
'auditList'
);
}
else
{
layer
.
msg
(
result
.
err_msg
,
{
icon
:
5
})
}
});
}
else
{
layer
.
msg
(
result
.
err_msg
,
{
icon
:
5
})
layer
.
confirm
(
'确定要'
+
statusName
+
'该申请吗?'
,{
area
:
[
'700px'
,
'500px'
],
title
:
'确定要'
+
statusName
+
'该申请吗?'
,
content
:
'
<
div
><
div
style
=
"margin-left: 20px;margin-bottom: 20px"
><
p
>
该供应商有
<
span
style
=
"color: #D9001B"
>
SKU
采购员
:
' + data.yunxin_channel_name + '
<
/span>,请确认是否同意<span style="color: #E85B2F">"' + data.apply_user.name + '"</
span
>
的共用申请
<
/p></
div
><
div
>
' +
'
<
div
class
=
"layui-form-item"
><
label
class
=
"layui-form-label"
>
申请原因
:
<
/label><div class="layui-input-block"><textarea class="layui-textarea layui-disabled" disabled>' + data.apply_reason + '</
textarea
><
/div></
div
><
/div></
div
>
',
btn: ['
确定
', '
取消
']
}, function (index) {
let url = '
/
api
/
supplier_share_apply
/
AuditSupplierShareApply
';
let result = ajax(url, {
status: status,
id: data.id,
});
if (result.err_code === 0) {
layer.msg('
审核成功
', {icon: 6})
table.reload('
auditList
'
);
}
else
{
layer
.
msg
(
result
.
err_msg
,
{
icon
:
5
})
}
},
function
(
index
)
{
// 取消按钮点击回调函数
layer
.
close
(
index
);
});
return
false
;
}
});
}
});
});
</script>
\ No newline at end of file
resources/views/web/ApplySupplierShare.blade.php
View file @
9ffc9d56
...
...
@@ -4,26 +4,26 @@
}
</style>
<div
class=
"layui-card"
>
{{--
<div
class=
"layui-card-header"
style=
"height: 90px"
>
--}}
{{--
<div
class=
"layui-card-header"
style=
"height: 90px"
>
--}}
{{--
</div>
--}}
{{--
</div>
--}}
<div
class=
"layui-card-body"
>
<form
class=
"layui-form"
action=
""
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-xs8"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
供应商名称 :
</label>
<div
class=
"layui-inline"
style=
"width: 250px"
>
<input
type=
"text"
id=
"supplier_name"
placeholder=
"请输入供应商名称进行校验"
class=
"layui-input"
value=
""
>
</div>
<input
type=
"hidden"
name=
"supplier_id"
id=
"supplier_id"
>
</div>
<div
class=
"layui-col-xs4"
>
<button
type=
"button"
class=
"layui-btn layui-btn-sm"
id=
"check_apply_supplier_share"
>
校验
</button>
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-xs8"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
供应商名称 :
</label>
<div
class=
"layui-inline"
style=
"width: 250px"
>
<input
type=
"text"
id=
"supplier_name"
placeholder=
"请输入供应商名称进行校验"
class=
"layui-input"
value=
""
>
</div>
<input
type=
"hidden"
name=
"supplier_id"
id=
"supplier_id"
>
</div>
<div
class=
"layui-col-xs4"
>
<button
type=
"button"
class=
"layui-btn layui-btn-sm"
id=
"check_apply_supplier_share"
>
校验
</button>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
被申请部门 :
</label>
...
...
@@ -33,6 +33,13 @@
</select>
</div>
</div>
<div
class=
"layui-form-item"
style=
"display: none"
id=
"apply_reason_div"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
申请原因 :
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"apply_reason"
placeholder=
"请填写申请原因"
></textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
align=
"center"
style=
"margin-top: 20px;text-align: right"
>
<button
type=
"button"
class=
"layui-btn layui-btn-sm layui-btn-info submit-loading"
lay-submit
...
...
resources/views/web/AuditSupplierShareApply.blade.php
View file @
9ffc9d56
...
...
@@ -4,9 +4,9 @@
<table
class=
"layui-table"
id=
"auditList"
lay-filter=
"auditList"
></table>
<script
type=
"text/html"
id=
"operate"
>
<
div
>
<
button
type
=
"button"
value
=
"@{{ d.id}}"
status
=
"pass"
class
=
"layui-btn layui-btn-xs audit_supplier_share_apply"
>
同意
<
button
type
=
"button"
value
=
"@{{ d.id}}"
status
=
"pass"
class
=
"layui-btn layui-btn-xs audit_supplier_share_apply"
lay
-
event
=
"pass"
>
同意
<
/button
>
<
button
type
=
"button"
value
=
"@{{ d.id}}"
status
=
"reject"
class
=
"layui-btn layui-btn-xs layui-btn-danger audit_supplier_share_apply"
>
拒绝
<
button
type
=
"button"
value
=
"@{{ d.id}}"
status
=
"reject"
class
=
"layui-btn layui-btn-xs layui-btn-danger audit_supplier_share_apply"
lay
-
event
=
"reject"
>
拒绝
<
/button
>
<
/div
>
</script>
\ No newline at end of file
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