Commit 08897255 by 杨树贤

完善逻辑

parent 5bde83ae
......@@ -322,7 +322,7 @@ class SupplierApiController extends Controller
}
$regionType = $region == 2 ? 1 : 2;
//还要去请求天眼查获取资料
$company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber,$regionType);
$company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber, $regionType);
if (!$company) {
$this->response(-2, '公司未进行工商注册,请修改后重新提交');
}
......@@ -440,6 +440,37 @@ class SupplierApiController extends Controller
$this->response(0, '已发送同步请求');
}
//发送一体化同步请求
public function SyncToUnited($request)
{
$supplierId = $request->get('supplier_id');
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
if (in_array($supplier['supplier_name'],config('field.SkipChangeSupplierTypeNames'))) {
$service = new SyncSupplierService();
$service->syncSupplierToUnited($supplierId);
$this->response(0, '属于代购供应商,直接发送同步');
}
//去调取天眼查数据,有数据的话,更新
$regionType = $supplier['region'] == 2 ? 1 : 2;
$companyInfo = (new CompanyService())->getCompanyInfo($supplier['supplier_name'], '', $regionType);
//先判断是否是标准添加,如果标准添加,国内地区,但是没有税号的,不允许同步
if ($supplier['is_standard_add'] == 1 && $supplier['region'] == 2 && !$supplier['tax_number']) {
$this->response(-1, '该供应商属于国内,但是没有税号,不允许同步');
}
if ($supplier['is_standard_add'] == 1 && $supplier['region'] != 2) {
if (empty($companyInfo)) {
$this->response(-1, '该供应商属于海外,但是无法查询公司信息,不允许同步');
}
}
$service = new SyncSupplierService();
$service->syncSupplierToUnited($supplierId);
$this->response(0, '已发送同步请求');
}
//设置云芯账号
public function SetYunxinChannelUid($request)
{
......
......@@ -543,5 +543,15 @@ class DataService
echo json_encode($exportJson);
}
//禁用(没有集团编码)供应商
public function disableNoUnitedSupplier()
{
SupplierChannelModel::where('is_type', 0)->where('group_code', '')
->update([
'is_type' => 2,
'update_time' => time(),
]);
}
}
......@@ -152,7 +152,7 @@
obj2Checked = false;
}
} else {
if (!inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
if (!inArray('quality_assurance_agreement', fieldNameList) && !inArray(supplierGroup, ['1', '4'])) {
msg = '未上传品质保证协议,是否切换为临时供应商?'
obj1Checked = false;
obj2Checked = true;
......
......@@ -296,6 +296,29 @@
}
});
//同步一体化的手动操作
$("#sync_supplier_to_united").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
let supplierId = data[0].supplier_id;
let res = ajax('/api/supplier/SyncToUnited', {supplier_id: supplierId})
if (res.err_code === 0) {
table.reload('list')
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
} else {
layer.msg(res.err_msg, {icon: 5})
}
}
});
//审批供应商弹窗
$("#audit_supplier").click(function () {
let checkStatus = table.checkStatus('list');
......
......@@ -60,7 +60,7 @@
obj2Checked = false;
}
} else {
if (!inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
if (!inArray('quality_assurance_agreement', fieldNameList) && !inArray(supplierGroup, ['1', '4'])) {
msg = '未上传品质保证协议,是否切换为临时供应商?'
obj1Checked = false;
obj2Checked = true;
......
......@@ -116,6 +116,7 @@
//监听所在区域变化,中国才显示省市选择
//而且有值+新增供应商操作 才能修改供应商名字和税号
//如果区域是海外(非中国),就去掉税号的必填星号
form.on('select(region)', function (data) {
@if(empty($supplier))
let supplierNameObj = $('#supplier_name');
......@@ -133,8 +134,10 @@
}
@endif
if (data.value === '2') {
$('#tax_number_required_span').show();
$('.city-div').show();
} else {
$('#tax_number_required_span').hide();
$('.city-div').hide();
}
});
......
......@@ -66,9 +66,9 @@
</div>
<div class="layui-col-md5">
<div class="layui-block" id="tax_number_div">
<label class="layui-form-label"><span class="require">*</span>公司税号</label>
<label class="layui-form-label"><span id="tax_number_required_span" class="require">*</span>公司税号</label>
<div class="layui-input-block">
<input type="text" name="tax_number" id="tax_number" placeholder="选择所在区域才允许输入公司税号"
<input type="text" name="tax_number" id="tax_number" placeholder="选择所在区域才允许输入公司税号,海外供应商没有税号可以不填"
class="layui-input layui-disabled" disabled value="">
</div>
</div>
......
......@@ -38,6 +38,9 @@
<button type="button" class="layui-btn layui-btn-sm" title="该操作可以将供应商同步到供应商" id="sync_supplier_to_erp">
金蝶同步
</button>
<button type="button" class="layui-btn layui-btn-sm" title="该操作可以将供应商同步到一体化" id="sync_supplier_to_united">
一体化同步
</button>
@endif
@if(checkPerm('ApplySupplierShare'))
{{-- @if(checkPerm('BlockSupplier'))--}}
......
......@@ -54,7 +54,7 @@
<label class="layui-form-label"><span class="require">*</span>供应商名称 : </label>
<div class="layui-input-block">
<input type="text" name="supplier_name" id="supplier_name"
placeholder="输入供应商名称" class="layui-input @if ($supplier)
placeholder="选择所在区域才允许输入供应商名称" class="layui-input @if ($supplier)
layui-disabled
@endif"
value="{{$supplier['supplier_name'] or ''}}"
......@@ -66,9 +66,9 @@
</div>
<div class="layui-col-md5">
<div class="layui-block" id="tax_number_div">
<label class="layui-form-label"><span class="require">*</span>公司税号</label>
<label class="layui-form-label"><span id="tax_number_required_span" class="require">*</span>公司税号</label>
<div class="layui-input-block">
<input type="text" name="tax_number" id="tax_number" placeholder="请输入公司税号,选择所在区域才允许输入"
<input type="text" name="tax_number" id="tax_number" placeholder="选择所在区域才允许输入公司税号,海外供应商没有税号可以不填"
class="layui-input layui-disabled" disabled value="{{$supplier['tax_number'] or ''}}">
</div>
<div id='supplier_check_tip' style='margin-top: 5px'>
......
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