Commit e950dcaa by 杨树贤

申请审核优化

parent ee7bc937
...@@ -560,6 +560,10 @@ class SupplierApiController extends Controller ...@@ -560,6 +560,10 @@ class SupplierApiController extends Controller
if ($supplierType == SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY && !$reason) { if ($supplierType == SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY && !$reason) {
$this->response(-1, '临时类型的供应商申请审核必须填写申请原因'); $this->response(-1, '临时类型的供应商申请审核必须填写申请原因');
} }
$errorMsg = SupplierService::checkSupplierFieldCompleted($supplierId);
if ($errorMsg) {
$this->response(-1, $errorMsg);
}
$auditData[] = [ $auditData[] = [
'supplier_id' => $supplierId, 'supplier_id' => $supplierId,
'apply_audit_reason' => $reason, 'apply_audit_reason' => $reason,
......
...@@ -95,14 +95,23 @@ class SupplierAuditService ...@@ -95,14 +95,23 @@ class SupplierAuditService
{ {
foreach ($supplierIds as $supplierId) { foreach ($supplierIds as $supplierId) {
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray(); $supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
$validator = new SupplierValidator(); //要将部分字段从0改成'',要不然表单验证会有问题
$check = $validator->checkSave($supplier, true); $needChangeField = [
if ($check) { 'pay_type',
return '供应商 : [ ' . $supplier['supplier_name'] . ' ] 必要信息填写不完整,请完善必填信息,原因 : '.$check; 'currency',
'supplier_group',
'supplier_type',
'settlement_type',
];
foreach ($supplier as $key=>&$value) {
if (in_array($key,$needChangeField) && empty($value)) {
$value = '';
}
} }
return true; unset($value);
$validator = new SupplierValidator();
return $validator->checkSave($supplier, true);
} }
} }
//判断是否是可以由当前用户审核 //判断是否是可以由当前用户审核
......
...@@ -5,6 +5,7 @@ namespace App\Http\Services; ...@@ -5,6 +5,7 @@ namespace App\Http\Services;
use App\Http\Controllers\Filter\SupplierFilter; use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Transformers\SupplierTransformer; use App\Http\Transformers\SupplierTransformer;
use App\Http\Validators\SupplierValidator;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel; use App\Model\RedisModel;
use App\Model\SupplierAddressModel; use App\Model\SupplierAddressModel;
...@@ -566,4 +567,26 @@ class SupplierService ...@@ -566,4 +567,26 @@ class SupplierService
return $suppliers; return $suppliers;
} }
//校验供应商是否必填都完整了
public static function checkSupplierFieldCompleted($supplierId)
{
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
//要将部分字段从0改成'',要不然表单验证会有问题
$needChangeField = [
'pay_type',
'currency',
'supplier_group',
'supplier_type',
'settlement_type',
];
foreach ($supplier as $key=>&$value) {
if (in_array($key,$needChangeField) && empty($value)) {
$value = '';
}
}
unset($value);
$validator = new SupplierValidator();
return $validator->checkSave($supplier, true);
}
} }
\ No newline at end of file
...@@ -49,6 +49,7 @@ class SupplierValidator ...@@ -49,6 +49,7 @@ class SupplierValidator
'pay_type' => 'required', 'pay_type' => 'required',
'settlement_type' => 'required', 'settlement_type' => 'required',
'currency' => 'required', 'currency' => 'required',
'supplier_group' => 'required',
'main_customers' => 'max:100', 'main_customers' => 'max:100',
'ticket_time' => 'max:20', 'ticket_time' => 'max:20',
'region' => 'required', 'region' => 'required',
...@@ -175,7 +176,6 @@ class SupplierValidator ...@@ -175,7 +176,6 @@ class SupplierValidator
$errorMessageList = array_merge($errors, $errorMessageList); $errorMessageList = array_merge($errors, $errorMessageList);
} }
//检验名称是否已经存在数据库 //检验名称是否已经存在数据库
if (!empty($validateData['supplier_name'])) { if (!empty($validateData['supplier_name'])) {
$companyNameCount = 0; $companyNameCount = 0;
......
...@@ -16,7 +16,12 @@ ...@@ -16,7 +16,12 @@
parent.layer.msg(res.err_msg, {icon: 6}); parent.layer.msg(res.err_msg, {icon: 6});
admin.closeThisDialog(); admin.closeThisDialog();
} else { } else {
parent.layer.msg(res.err_msg, {icon: 5}); let errMsg = res.err_msg;
let msg = '';
$.each(errMsg.split('|'), function (index, value) {
msg += "<span>" + value + "</span><br>"
});
parent.layer.msg(msg, {icon: 5})
} }
} }
return false; return false;
......
...@@ -354,6 +354,10 @@ ...@@ -354,6 +354,10 @@
let checkStatus = table.checkStatus('list'); let checkStatus = table.checkStatus('list');
let data = checkStatus.data; let data = checkStatus.data;
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id); let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
supplierIds = supplierIds.join(','); supplierIds = supplierIds.join(',');
if (!data.length) { if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5}) layer.msg('请先选择要操作的供应商', {icon: 5})
...@@ -367,19 +371,18 @@ ...@@ -367,19 +371,18 @@
}); });
if (!canApplyInReview) { if (!canApplyInReview) {
layer.msg('选择的供应商里,存在非待审核状态的供应商,无法申请审核', {icon: 5}) layer.msg('选择的供应商里,存在非待审核状态的供应商,无法申请审核', {icon: 5})
return false; return;
} }
//还要去事先检测供应商信息是否完整 //还要去事先检测供应商信息是否完整
let checkApplyMsg = checkCanApplyInReview(supplierIds); let checkApplyMsg = checkCanApplyInReview(supplierIds);
if (checkApplyMsg !== '') { if (checkApplyMsg !== '') {
layer.msg(checkApplyMsg, {icon: 5}); return false;
return
} }
layer.open({ layer.open({
type: 2, type: 2,
content: '/supplier/BatchApplyInReviewSupplier?view=iframe&supplier_ids=' + supplierIds, content: '/supplier/BatchApplyInReviewSupplier?view=iframe&supplier_ids=' + supplierIds,
area: ['800px', '70%'], area: ['800px', '70%'],
title: '批量申请审核供应商', title: '申请审核供应商',
end: function () { end: function () {
table.reload('list'); table.reload('list');
supplierStatistics(); supplierStatistics();
...@@ -591,7 +594,13 @@ ...@@ -591,7 +594,13 @@
let url = '/api/supplier/CheckCanApplyInReview?supplier_ids=' + supplierIds; let url = '/api/supplier/CheckCanApplyInReview?supplier_ids=' + supplierIds;
let res = ajax(url); let res = ajax(url);
if (res.err_code !== 0) { if (res.err_code !== 0) {
return res.err_msg; let errMsg = res.err_msg;
let msg = '';
$.each(errMsg.split('|'), function (index, value) {
msg += "<span>" + value + "</span><br>"
});
layer.msg(msg, {icon: 5})
return false;
} else { } else {
return ''; return '';
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<form class="layui-form" action=""> <form class="layui-form" action="">
<div class="layui-card-body"> <div class="layui-card-body">
<blockquote class="layui-elem-quote layui-text"> <blockquote class="layui-elem-quote layui-text">
<b>当前选中需要批量申请审核的供应商列表</b> <b>当前选中需要申请审核的供应商列表</b>
</blockquote> </blockquote>
<table class="layui-table"> <table class="layui-table">
<colgroup> <colgroup>
......
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
转正供应商 转正供应商
</button> </button>
@endif @endif
{{-- <button type="button" class="layui-btn layui-btn-sm" title="点击确定审核后会进入审核中状态" id="batch_apply_in_review_supplier">--}} {{-- <button type="button" class="layui-btn layui-btn-sm" title="点击确定审核后会进入审核中状态"--}}
{{-- 申请审核--}} {{-- id="batch_apply_in_review_supplier">--}}
{{-- </button>--}} {{-- 申请审核--}}
{{-- </button>--}}
@if(checkPerm('BlockSupplier')) @if(checkPerm('BlockSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="block_supplier"> <button type="button" class="layui-btn layui-btn-sm" id="block_supplier">
拉黑 拉黑
......
...@@ -171,8 +171,8 @@ ...@@ -171,8 +171,8 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label"><span class="require">*</span>合作类型</label> <label class="layui-form-label"><span class="require">*</span>合作类型</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="hidden" name="stockup_type" {{-- <input type="hidden" name="stockup_type"--}}
value="{{$supplier['stockup_type'] or ''}}"> {{-- value="{{$supplier['stockup_type'] or ''}}">--}}
@foreach(config('fixed.StockupType') as $k=>$type) @foreach(config('fixed.StockupType') as $k=>$type)
<input type="checkbox" name="stockup_type[{{$k}}]" <input type="checkbox" name="stockup_type[{{$k}}]"
lay-skin="primary" lay-skin="primary"
......
...@@ -166,12 +166,12 @@ ...@@ -166,12 +166,12 @@
{!! $multiTransformableSelectPresenter->render(['has_sku'=>'SKU上传','sku_tag'=>'SKU标准','sku_mode'=>'SKU模式','uploaded_sku' => '历史SKU合作'], {!! $multiTransformableSelectPresenter->render(['has_sku'=>'SKU上传','sku_tag'=>'SKU标准','sku_mode'=>'SKU模式','uploaded_sku' => '历史SKU合作'],
['has_sku'=>[1=>'是',-1=>'否'],'sku_tag'=>config('field.SkuTag'),'sku_mode'=>config('field.SkuMode')]) !!} ['has_sku'=>[1=>'是',-1=>'否'],'sku_tag'=>config('field.SkuTag'),'sku_mode'=>config('field.SkuMode')]) !!}
</div> </div>
@if(checkPerm('ViewFakeSupplier')) {{-- @if(checkPerm('ViewFakeSupplier'))--}}
<div class="layui-inline"> <div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter') @inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('supplier_type','供应商类别','',config('field.SupplierType')) !!} {!! $statusPresenter->render('supplier_type','供应商类别','',config('field.SupplierType')) !!}
</div> </div>
@endif {{-- @endif--}}
<div class="layui-inline"> <div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter') @inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('level','等级','',config('field.LevelMap')) !!} {!! $statusPresenter->render('level','等级','',config('field.LevelMap')) !!}
......
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