Commit 9ffc9d56 by 杨树贤

公用审核流程修改

parent dbc22472
......@@ -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, '申请失败,系统错误');
......
......@@ -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
......@@ -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;
......
......@@ -98,6 +98,8 @@ return [
'ZiYingDepartmentId' => 51,
//60是本地的数据
'LiangYingDepartmentIds' => [47, 60, 72],
//运营部门id
'YunyingTopDepartmentId' => 9,
//等级显示对应数据
'LevelMap' => [
......
......@@ -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});
}
......
......@@ -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
......@@ -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
......
......@@ -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
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