Commit 5a370456 by mushishixian

拉黑功能

parent 6e46ab24
......@@ -409,15 +409,41 @@ class SupplierApiController extends Controller
public function BlockSupplier($request)
{
$supplierId = $request->get('supplier_id');
$blockReason = $request->get('block_reason');
if (empty($blockReason)) {
$this->response(-1, '必须填写拉黑原因');
}
$channelModel = new SupplierChannelModel();
$result = $channelModel->where('supplier_id', $supplierId)->update([
'block_reason' => $request->get('block_reason'),
'status' => -3,
'update_time' => time(),
]);
if ($result) {
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '拉黑', '拉黑供应商');
$this->response(0, '拉黑成功');
} else {
$this->response(-1, '拉黑操作失败 ');
}
}
//取消拉黑供应商
public function CancelBlockSupplier($request)
{
$supplierId = $request->get('supplier_id');
$channelModel = new SupplierChannelModel();
$result = $channelModel->where('supplier_id', $supplierId)->update([
'status' => 1,
'update_time' => time(),
]);
if ($result) {
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '取消拉黑', '取消拉黑供应商');
$this->response(0, '取消拉黑成功');
} else {
$this->response(-1, '取消拉黑操作失败');
}
}
}
......@@ -103,7 +103,7 @@ class SupplierFilter
if (!$canViewFakeSupplier) {
$query->where('is_type', 0);
}
$query->with(['contact', 'attachment']);
$query->whereRaw('supplier_name NOT LIKE "%-1"');
//默认展示的数据查询
......@@ -158,6 +158,10 @@ class SupplierFilter
//待复审供应商
$query->where('status', SupplierChannelModel::STATUS_PENDING);
break;
case "need_review":
//待复审供应商
$query->where('status', SupplierChannelModel::STATUS_NEED_REVIEW);
break;
case "in_review":
//审核中
$query->where('status', SupplierChannelModel::STATUS_IN_REVIEW);
......@@ -206,6 +210,38 @@ class SupplierFilter
//没有sku
$query->where('sku_num', 0);
break;
case "block":
$query->where('status', SupplierChannelModel::STATUS_BLOCK);
break;
case "has_tag_supplier":
$query->where('has_tag', 1);
break;
//附件里面缺少品质协议的
// case "no_quality_assurance_agreement":
// $query->leftjoin('supplier_attachment', 'supplier_channel.supplier_id', '=',
// 'supplier_attachment.supplier_id')
// ->selectRaw('lie_supplier_channel.*,
// lie_supplier_attachment.quality_assurance_agreement,lie_supplier_attachment.supplier_id')
// ->where(function ($q) {
// $q->where('supplier_attachment.quality_assurance_agreement', '')
// ->orWhereNull('supplier_attachment.supplier_id');
// });
// break;
case "no_quality_assurance_agreement":
$query->whereHas('attachment', function ($q) {
$q->where('quality_assurance_agreement', '')->orWhereNull('supplier_id');
});
break;
//联系人待完善
case "contact_no_complete":
$query->whereHas('contact', function ($q) {
$q->where('supplier_consignee', '')
->orWhere('supplier_position', '')
->orWhere('supplier_email', '')
->orWhere('supplier_mobile', '')
->orWhere('supplier_telephone', '');
});
break;
}
return $query;
}
......
......@@ -273,4 +273,14 @@ class SupplierController extends Controller
return $this->view('审核供应商');
}
//拉黑供应商
public function BlockSupplier($request)
{
$supplierId = $request->get('supplier_id');
$supplierModel = new SupplierChannelModel();
$supplier = $supplierModel->where('supplier_id',$supplierId)->first()->toArray();
$this->data['supplier'] = $supplier;
return $this->view('加入黑名单');
}
}
\ No newline at end of file
......@@ -35,7 +35,7 @@ class SupplierAuditService
//第一次审核,通过是将审核状态置为待复审
//通过
if ($status == SupplierChannelModel::STATUS_PASSED) {
$dbStatus = SupplierChannelModel::STATUS_PENDING;
$dbStatus = SupplierChannelModel::STATUS_NEED_REVIEW;
} else {
//不通过
$dbStatus = $status;
......@@ -48,7 +48,7 @@ class SupplierAuditService
$result = $model->where('supplier_id', $supplierId)->update($update);
//如果是待复审状态,通过的话还要将是否需要复审状态置为0
} elseif ($supplier['status'] === SupplierChannelModel::STATUS_PENDING) {
} elseif ($supplier['status'] === SupplierChannelModel::STATUS_NEED_REVIEW) {
if ($status == SupplierChannelModel::STATUS_PASSED) {
$result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
......@@ -83,7 +83,7 @@ class SupplierAuditService
$auditStatus = $status == SupplierChannelModel::STATUS_DISABLE ? '审核通过,禁用供应商' : '审核不通过,原因是 : ' . $rejectReason;
} else {
//如果状态是复审
if ($supplier['status'] == SupplierChannelModel::STATUS_PENDING) {
if ($supplier['status'] == SupplierChannelModel::STATUS_NEED_REVIEW) {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '复审通过' : '复审不通过,原因是 : ' . $rejectReason;
$action = '复审供应商';
} else {
......
......@@ -4,6 +4,7 @@
namespace App\Http\Services;
use App\Http\Controllers\Filter\SupplierFilter;
use App\Model\RedisModel;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
......@@ -12,9 +13,15 @@ class SupplierStatisticsService
//获取供应商列表需要统计的信息
public function getSupplierListStatistics()
{
$redis = new RedisModel();
$result = json_decode($redis->get('supplier_list_statistics'), true);
if ($result) {
return $result;
}
$total = $this->getStatisticsCount('all');
//待复审
$needReview = $this->getStatisticsCount('need_review');
//待审核
$pending = $this->getStatisticsCount('pending');
//审核中
$inReview = $this->getStatisticsCount('in_review');
......@@ -26,6 +33,8 @@ class SupplierStatisticsService
$disable = $this->getStatisticsCount('disable');
//没有渠道开发员
$noPurchaseUid = $this->getStatisticsCount('no_purchase_uid');
//没有采购
$noChannelUid = $this->getStatisticsCount('no_channel_uid');
//存在无效(离职)采购员
$invalidChannelUid = $this->getStatisticsCount('invalid_channel_uid');
//存在无效(离职)开发员
......@@ -34,19 +43,33 @@ class SupplierStatisticsService
$toFollowUp = $this->getStatisticsCount('to_follow_up');
//没有sku的
$noSku = $this->getStatisticsCount('no_sku');
//拉黑的
$block = $this->getStatisticsCount('block');
//没有品牌协议附件的
$noQualityAssuranceAgreement = $this->getStatisticsCount('no_quality_assurance_agreement');
//有标签的(客户指定供应商)
$hasTagSupplier = 0;
//联系人未完善
$concatNoComplete = $this->getStatisticsCount('contact_no_complete');
$result = [
'total' => $total,
'need_review' => $needReview,
'pending' => $pending,
'in_review' => $inReview,
'passed' => $passed,
'rejected' => $rejected,
'disable' => $disable,
'block' => $block,
'no_purchase_uid' => $noPurchaseUid,
'no_channel_uid' => $noChannelUid,
'invalid_channel_uid' => $invalidChannelUid,
'invalid_purchase_uid' => $invalidPurchaseUid,
'to_follow_up' => $toFollowUp,
'no_sku' => $noSku,
'no_quality_assurance_agreement' => $noQualityAssuranceAgreement,
'has_tag_supplier' => $hasTagSupplier,
'contact_no_complete' => $concatNoComplete,
];
$result = array_map(function ($value) {
if ($value > 999) {
......@@ -54,16 +77,17 @@ class SupplierStatisticsService
}
return $value;
}, $result);
$redis->set('supplier_list_statistics', json_encode($result));
$redis->expire('supplier_list_statistics', 1);
return $result;
}
private function getStatisticsCount($type)
{
$model = new SupplierChannelModel();
$model = $model->where('supplier_id','>',0);
//显示默认的数据(有权限逻辑)
$filter = new SupplierFilter();
$model = $model->where('supplier_id', '>', 0);
return $filter->defaultFilter($model, $type)->count();
}
}
\ No newline at end of file
......@@ -11,7 +11,9 @@ class SupplierChannelModel extends Model
public $timestamps = false;
//待复审(第一次新增)
const STATUS_PENDING = -1;
const STATUS_NEED_REVIEW = -1;
//待审核
const STATUS_PENDING = 0;
//审核中
const STATUS_IN_REVIEW = 1;
//通过
......@@ -34,4 +36,10 @@ class SupplierChannelModel extends Model
{
return $this->hasMany(SupplierContactModel::class, 'supplier_id', 'supplier_id');
}
//附件
public function attachment()
{
return $this->hasOne(SupplierAttachmentModel::class, 'supplier_id', 'supplier_id');
}
}
......@@ -188,7 +188,6 @@ return [
1 => '先款后货',
2 => '月结',
],
'FileNameMapping' => [
'business_license' => '营业执照',
'billing_information' => '开票资料',
......@@ -205,16 +204,23 @@ return [
//罗盘菜单对应id
'CompassMenuMap' => [
'total' => '全部',
'pending' => '待复审',
'pending' => '待审核',
'need_review' => '待复审',
'in_review' => '审核中',
'draft' => '草稿',
'passed' => '已通过',
'rejected' => '未通过',
'block' => '黑名单',
'disable' => '禁止交易',
'no_purchase_uid' => '渠道未分配',
'no_channel_uid' => '采购未分配',
'invalid_channel_uid' => '无效采购员',
'invalid_purchase_uid' => '无效渠道员',
'contact_no_complete' => '联系人不完善',
'to_follow_up' => '待跟进',
'no_sku' => '无sku',
'no_quality_assurance_agreement' => '无品质协议',
'has_tag_supplier' => '客户指定供应商',
],
//Sku列表的罗盘对应菜单id
'SkuListCompassMenuMap' => [
......
This diff could not be displayed because it is too large.
......@@ -20,6 +20,10 @@
font-size: 12px !important;
}
input:focus, textarea:focus {
outline: 1px solid #AFECAB;
}
.layui-input {
height: 30px;
}
......
<script>
layui.use(['table', 'form', 'element', 'layer','admin'], function () {
let admin = layui.admin;
let form = layui.form;
form.on('submit(blockSupplier)', function (data) {
let supplierId = getQueryVariable('supplier_id');
let url = '/api/supplier/BlockSupplier?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 {
parent.layer.msg(res.err_msg, {icon: 5});
}
}
return false;
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>
\ No newline at end of file
......@@ -16,15 +16,13 @@
})
$('#cancel_block_supplier').click(function () {
layer.confirm('你确定要取消拉黑该供应商吗,取消后会进入审核中状态?', function (index) {
let supplierId = data[0].supplier_id;
let res = ajax('/api/supplier/ChangeSupplierIsType', {supplier_id: supplierId, is_type: 0})
layer.confirm('对应的供应商设为取消拉黑后,该供应商将重新走审核流程,通过后将重新启用,是否执行当前操作?', function (index) {
let supplierId = getQueryVariable('supplier_id');
let res = ajax('/api/supplier/CancelBlockSupplier', {supplier_id: supplierId, is_type: 0})
if (res.err_code === 0) {
saveRefreshData('detail', supplierId)
table.reload('list')
supplierStatistics();
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
location.reload();
} else {
layer.msg(res.err_msg, {icon: 5})
}
......
......@@ -3,7 +3,7 @@
let $ = layui.jquery;
let Split = layui.Split;
// 水平分割,需要分割的元素(id)、默认大小(百分比)、最小值(单位px)
Split(['#s1', '#s2', '#s3', '#s4', '#s5'], {sizes: [9, 12, 12, 12, 55], minSize: 70});
Split(['#s1', '#s2', '#s3', '#s4', '#s5', '#s6'], {sizes: [9, 12, 12, 12, 12, 43], minSize: 70});
let table = layui.table;
let form = layui.form;
let admin = layui.admin;
......@@ -65,7 +65,15 @@
"' style='color: dodgerblue' ew-title='供应商详情 - " + data.supplier_code + "'>" + data.supplier_code + "</a>"
}
},
{field: 'supplier_name', title: '供应商名称', align: 'center', width: 230},
{
field: 'supplier_name', title: '供应商名称', align: 'center', width: 230, templet: function (data) {
if (data.status === -3) {
return "<span title='" + data.block_reason + "'>" + data.supplier_name + "</span>"
} else {
return data.supplier_name;
}
}
},
{field: 'supplier_group', title: '供应商性质', align: 'center', width: 115},
{
field: 'stockup_type', title: '合作类型', align: 'center', width: 120, templet: function (data) {
......@@ -267,11 +275,6 @@
layer.msg('该操作不支持多选', {icon: 5})
return;
}
// const is_type = data[0].is_type;
// if (is_type === 1) {
// layer.msg('该供应商为非正式供应商,请先将该供应商转正', {icon: 5})
// return false;
// }
const status = data[0].status;
if ((status === 3 || status === 2 || status === -2)) {
let supplierId = data[0].supplier_id;
......@@ -334,11 +337,6 @@
layer.msg('该操作不支持多选', {icon: 5})
return;
}
// const is_type = data[0].is_type;
// if (is_type === 1) {
// layer.msg('该供应商为非正式供应商,请先将该供应商转正', {icon: 5})
// return false;
// }
const status = data[0].status;
if ((status === 3 || status === 2 || status === -2)) {
let supplierId = data[0].supplier_id;
......@@ -430,7 +428,7 @@
});
}
});
//加入黑名单
$("#block_supplier").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
......@@ -441,20 +439,29 @@
layer.msg('该操作不支持多选', {icon: 5})
return;
}
layer.confirm('确定要拉黑这家供应商吗?', function (index) {
const status = data[0].status;
if (status === -3) {
layer.msg('该供应商已经在黑名单', {icon: 5});
return false;
}
if ((status === -1 || status === 1)) {
layer.msg('审核中/待复审状态的供应商无法加入黑名单', {icon: 5});
return false;
} else {
let supplierId = data[0].supplier_id;
let res = ajax('/api/supplier/block_supplier', {supplier_id: supplierId, is_type: 0})
if (res.err_code === 0) {
layer.open({
type: 2,
content: '/supplier/BlockSupplier?view=iframe&supplier_id=' + supplierId,
area: ['650px', '40%'],
title: '加入黑名单',
end: function () {
saveRefreshData('detail', supplierId)
table.reload('list')
table.reload('list');
supplierStatistics();
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
}
}
});
//点击查询按钮
form.on('submit(load)', function (data) {
......
......@@ -18,6 +18,10 @@
.layui-layout-admin .layui-body {
buttom: 1px;
}
input:focus, textarea:focus {
outline: 1px solid #AFECAB;
}
</style>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
......@@ -61,15 +65,7 @@
if (d.layId.search('SupplierList') !== -1) {
setTimeout(function () {
$('.admin-iframe').contents().find('#refreshWindow').click()
// let iframe = $('#admin-iframe')[0].contentWindow.refreshWindow();
}, 10);
// let flag = admin.getTempData("needFreshList");
// if (flag) {
// setTimeout(function () {
// $('.admin-iframe').contents().find('#getSupplierListButton').click()
// admin.putTempData("needFreshList", null);
// }, 10);
// }
}
//判断详情是否需要刷新
if (d.layId.search('SupplierDetail') !== -1) {
......
......@@ -69,7 +69,7 @@
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">保存</button>
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">确认</button>
</div>
</div>
</form>
......
......@@ -100,7 +100,7 @@
<div align="center" style="margin-top: 20px">
<button type="button" id="addSupplierReceipt" class="layui-btn layui-btn-info submit-loading"
lay-submit
lay-filter="addSupplierReceipt">保存
lay-filter="addSupplierReceipt">确认
</button>
</div>
</div>
......
......@@ -36,7 +36,7 @@
<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
lay-filter="auditSupplier">保存
lay-filter="auditSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
......@@ -34,7 +34,7 @@
<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
lay-filter="auditSupplier">保存
lay-filter="auditSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
......@@ -48,7 +48,7 @@
<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
lay-filter="auditSupplier">保存
lay-filter="auditSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
......@@ -20,7 +20,7 @@
<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
lay-filter="auditSupplier">保存
lay-filter="auditSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
<div class="layui-card-body">
<form class="layui-form" action="">
<input type="hidden" name="supplier_id" value="{{$supplier['supplier_id']}}">
<div class="layui-form-item">
<label class="layui-form-label">基本信息 : </label>
<div class="layui-input-block block-42" style="padding-top: 7px">
{{$supplier['supplier_name']}}
<a style="color: dodgerblue;margin-left: 20px"
ew-href="/supplier/SupplierDetail?view=iframe&supplier_id={{$supplier['supplier_id']}}"
ew-title='供应商详情 - {{$supplier['supplier_code']}}'
>{{$supplier['supplier_code']}}</a>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">原因说明 : </label>
<div class="layui-input-block">
<textarea name="block_reason" required placeholder="请填写拉黑原因" class="layui-textarea"></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
lay-filter="blockSupplier">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
</button>
</div>
</div>
</form>
</div>
</div>
\ No newline at end of file
......@@ -17,7 +17,7 @@
<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
lay-filter="setYunxinChannelUid">保存
lay-filter="setYunxinChannelUid">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
......
......@@ -54,7 +54,7 @@
class="layui-btn layui-btn layui-btn-disabled">供应商为非正式供应商,请先转正
</button>
@else
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_PENDING)
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_NEED_REVIEW)
<button type="button" style="margin-bottom: 25px;margin-top: 5px"
class="layui-btn layui-btn layui-btn-disabled">待复审,不能修改
</button>
......
......@@ -71,7 +71,7 @@
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">保存</button>
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">确认</button>
</div>
</div>
</form>
......
......@@ -2,6 +2,7 @@
.main_filter {
cursor: pointer;
}
.status_filter {
cursor: pointer;
}
......@@ -16,34 +17,31 @@
</div>
</div>
<div class="split-item" id="s2" style="text-align: center">
@if(checkPerm('SupplierPendingList'))
<div class="layui-row">
<a class="status_filter" id="pending" data-value="-1">
<a class="status_filter" id="need_review" data-value="-1">
</a>
</div>
@endif
@if(checkPerm('SupplierInReviewList'))
@if(checkPerm('SupplierPendingList'))
<div class="layui-row">
<a class="status_filter" id="in_review" data-value="1">
<a class="status_filter" id="pending" data-value="0">
</a>
</div>
@endif
@if(checkPerm('SupplierPassedList'))
@if(checkPerm('SupplierInReviewList'))
<div class="layui-row">
<a class="status_filter" id="passed" data-value="2">
<a class="status_filter" id="in_review" data-value="1">
</a>
</div>
@endif
@if(checkPerm('SupplierRejectList'))
<div class="layui-row">
<a class="status_filter" id="rejected" data-value="3">
<a class="status_filter" id="rejected" data-value="-2">
</a>
</div>
@endif
@if(checkPerm('SupplierDisableList'))
@if(checkPerm('SupplierPassedList'))
<div class="layui-row">
<a class="status_filter" id="disable" data-value="-2">
<a class="status_filter" id="passed" data-value="2">
</a>
</div>
@endif
......@@ -55,6 +53,12 @@
</a>
</div>
@endif
@if(checkPerm('SupplierNoChannelUidList'))
<div class="layui-row">
<a title="采购员为空的供应商" class="main_filter" id="no_channel_uid">
</a>
</div>
@endif
@if(checkPerm('SupplierInvalidChannelUidList'))
<div class="layui-row">
<a title="非禁止交易状态联系人绑定的采购员姓名不在组织架构中(采购员离职)的供应商" class="main_filter"
......@@ -69,6 +73,11 @@
</a>
</div>
@endif
<div class="layui-row">
<a title="联系人中存在非必填字段未填写" class="main_filter"
id="contact_no_complete">
</a>
</div>
</div>
<div class="split-item" id="s4" style="text-align: center">
@if(checkPerm('SupplierToFollowUpList'))
......@@ -84,8 +93,31 @@
</a>
</div>
@endif
<div class="layui-row">
<a class="main_filter" id="no_quality_assurance_agreement">
</a>
</div>
</div>
<div class="split-item" id="s5" style="text-align: center">
@if(checkPerm('SupplierBlockList'))
<div class="layui-row">
<a class="status_filter" id="block" data-value="-3">
</a>
</div>
@endif
@if(checkPerm('SupplierDisableList'))
<div class="layui-row">
<a class="status_filter" id="disable" data-value="-2">
</a>
</div>
@endif
<div class="layui-row">
<a class="main_filter" id="has_tag_supplier">
</a>
</div>
</div>
<div class="split-item" id="s5">
<div class="split-item" id="s6">
</div>
</div>
</div>
......
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