Commit e950dcaa by 杨树贤

申请审核优化

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