Commit 9898f02a by 杨树贤

完善禁用逻辑

parent 3f40a276
......@@ -174,7 +174,6 @@ class SupplierApiController extends Controller
}
$channelMap = array_merge($this->channelMap, config('field.AttachmentFields'));
$channel = $request->only($channelMap);
dd($channel);
$service = new SupplierService();
$result = $service->saveSupplier($channel);
if (!$result) {
......
......@@ -15,17 +15,19 @@ class CompanyService
public function getCompanyInfo($supplierName, $taxNumber, $regionType = 1)
{
$params = [
'keyword' => $supplierName ?: $taxNumber,
'company_name' => $supplierName,
'region' => $regionType,
'select_type' => 1,
'company_type' => 1,
'company_tax_no' => $taxNumber,
];
$url = config('website.InternalApiDomain') . '/companyInfo';
$result = curl($url, $params, true);
$url = config('website.UnitedDataDomain') . '/sync/Company/getCompanyInfoByName';
$result = curl($url, $params);
$result = json_decode($result, true);
$company = [];
if (array_get($result, 'code') === 0) {
$companyInfo = array_get(array_get($result['data'], 'company_info_list'), 0);
if (!empty($companyInfo)) {
$companyInfoList = array_get(array_get($result['data'], 'tycList'), 'company_info_list');
if (!empty($companyInfoList)) {
$companyInfo = $companyInfoList[0];
$company = [
'supplier_name' => $companyInfo['com_name'],
'registered_capital' => (int)$companyInfo['registered_capital'],
......
......@@ -247,13 +247,16 @@ class SupplierService
$oldSystemTags);
$tagService->saveTags($supplierId, SupplierTagService::TAG_TYPE_CUSTOMER, $channel['customer_tags'],
$oldCustomerTags);
return $supplierId;
}
//重新生成外部显示的编码
$this->generateSupplierSn($supplierId, $channel['supplier_group']);
//保存和搜索相关的标签情况
$supplierSearchTagService = new SupplierSearchTagService();
$supplierSearchTagService->saveSupplierSearchTags($supplierId);
return $supplierId;
});
//保存日志
......
......@@ -17,7 +17,6 @@ class SupplierValidator
//因为控制器那边已经被之前的人魔改的难用的一比,而且控制器那边还接收了一大堆统一变量
public function checkSave($validateData, $isAudit)
{
dd($validateData['tax_number']);
//整理下请求数据
$validateData = $this->transformRequestData($validateData);
//这个supplierId是用来判断是新增还是修改的
......
......@@ -22,6 +22,7 @@ return [
'UploadKey' => 'fh6y5t4rr351d2c3bryi',
'QueueDomain' => 'http://192.168.1.252:16590/mq/push',
'InternalApiDomain' => 'http://192.168.1.252:8200',
'UnitedDataDomain' => 'http://united_data.liexindev.net',
'WarningRobot' => 'https://oapi.dingtalk.com/robot/send?access_token=7ff88e1ee208e3a637c17bc51c1c879bccbf101fef5885d22ad70d21ea2f966a',
'CSWarningRobot' => 'https://oapi.dingtalk.com/robot/send?access_token=92917a6e090a8a39832c4843a579d6c6f9dfecc46fa275f8753ddee2b4399045',
......
......@@ -86,43 +86,53 @@ function inArray(needle, haystack) {
return false;
}
function attachmentsUploadedChangeSupplierType(supplierType, supplierGroup, fieldName) {
function attachmentsUploadedChangeSupplierType(supplierType, supplierGroup, fieldNameList) {
if (fieldNameList.length === 0) {
return true;
}
let msg = '';
let radioObj = $('input[name="supplier_type"]');
//已经上传品质保证协议(代理商则提示为“已经上传代理证”),是否切换为正式供应商?
if (supplierType === '2') {
//如果已经上传品质保证协议,并且供应商性质不是代理商(代理商要代理证)
if ('quality_assurance_agreement' === fieldName && supplierGroup !== '1') {
if (inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
msg = '已经上传品质保证协议,是否切换为正式供应商?'
layer.confirm(msg, function (index) {
radioObj.get(0).checked = true;
radioObj.get(1).checked = false;
layui.form.render('radio');
layer.closeAll();
});
}
if ('proxy_certificate' === fieldName && supplierGroup === '1') {
if (inArray('proxy_certificate', fieldNameList) && supplierGroup === '1') {
msg = '该供应商为代理供应商,已经上传代理证,是否切换为正式供应商?'
layer.confirm(msg, function (index) {
radioObj.get(0).checked = true;
radioObj.get(1).checked = false;
layui.form.render('radio');
layer.closeAll();
});
}
} else {
if ('quality_assurance_agreement' === fieldName && supplierGroup !== '1') {
if (!inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
msg = '未上传品质保证协议,是否切换为临时供应商?'
layer.confirm(msg, function (index) {
radioObj.get(0).checked = false;
radioObj.get(1).checked = true;
layui.form.render('radio');
layer.closeAll();
});
}
if ('proxy_certificate' === fieldName && supplierGroup === '1') {
if (!inArray('proxy_certificate', fieldNameList) && supplierGroup === '1') {
msg = '该供应商为代理供应商,但是未上传代理证,是否切换为临时供应商?'
layer.confirm(msg, function (index) {
radioObj.get(0).checked = false;
radioObj.get(1).checked = true;
layui.form.render('radio');
layer.closeAll();
});
}
}
layui.form.render('radio');
return msg;
return true;
}
......@@ -55,10 +55,6 @@ function getQueryVariable(variable) {
}
function ajax(url,data){
layer.msg('加载中', {
icon: 16
,shade: 0.01
});
var result=false;
$.ajax({
url:url,
......@@ -73,6 +69,5 @@ function ajax(url,data){
}
}
})
layer.closeAll();
return result;
}
\ No newline at end of file
......@@ -107,6 +107,7 @@
});
form.on('submit(addAndApplySupplier)', function (data) {
//去找出附件的所有数据
let file_name = [];
let file_url = [];
......@@ -130,6 +131,58 @@
data.field.validity_period = validity_period;
data.field.apply_audit_reason = $('#apply_audit_reason').val();
let fieldNameList = field_name;
//提交先提示是否要转换供应商类型
let radioObj = $('input[name="supplier_type"]');
//已经上传品质保证协议(代理商则提示为“已经上传代理证”),是否切换为正式供应商?
let supplierGroup = data.field.supplier_group;
let msg;
let obj1Checked = 0;
let obj2Checked = 0;
if (data.field.supplier_type === '2') {
//如果已经上传品质保证协议,并且供应商性质不是代理商(代理商要代理证)
if (inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
msg = '已经上传品质保证协议,是否切换为正式供应商?'
obj1Checked = true;
obj2Checked = false;
}
if (inArray('proxy_certificate', fieldNameList) && supplierGroup === '1') {
msg = '该供应商为代理供应商,已经上传代理证,是否切换为正式供应商?'
obj1Checked = true;
obj2Checked = false;
}
} else {
if (!inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
msg = '未上传品质保证协议,是否切换为临时供应商?'
obj1Checked = false;
obj2Checked = true;
}
if (!inArray('proxy_certificate', fieldNameList) && supplierGroup === '1') {
msg = '该供应商为代理供应商,但是未上传代理证,是否切换为临时供应商?'
obj1Checked = false;
obj2Checked = true;
}
}
if (msg) {
layer.confirm(msg, function (index) {
if (obj1Checked !== 0) {
radioObj.get(0).checked = obj1Checked;
radioObj.get(1).checked = obj2Checked;
layui.form.render('radio');
data.field.supplier_type = obj1Checked ? 1 : 2;
layer.closeAll();
}
auditAndAddSupplier(data);
});
} else {
auditAndAddSupplier(data);
}
return false;
});
function auditAndAddSupplier(data) {
if (data.field.supplier_type === '2') {
layer.open({
type: 1,
......@@ -152,9 +205,7 @@
addSupplier(data);
});
}
return false;
});
}
function addSupplier(data) {
admin.showLoading({
......@@ -163,6 +214,7 @@
let url = '/api/supplier/AddSupplier?direct_apply=1';
let res = ajax(url, data.field);
if (!res) {
admin.removeLoading();
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
......
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'index', 'laydate', 'xmSelect'], function () {
let admin = layui.admin;
let index = layui.index;
let form = layui.form;
let table = layui.table;
let element = layui.element;
$('#supplierDetailUrl').click(function () {
admin.showLoading({
......@@ -37,6 +35,61 @@
});
form.on('submit(applyAuditSupplier)', function (data) {
let fieldNameList = [];
$('.attachment_fields').each(function () {
fieldNameList.push($(this).text());
});
//提交先提示是否要转换供应商类型
let radioObj = $('input[name="supplier_type"]');
//已经上传品质保证协议(代理商则提示为“已经上传代理证”),是否切换为正式供应商?
let supplierGroup = data.field.supplier_group;
let msg;
let obj1Checked = 0;
let obj2Checked = 0;
if (data.field.supplier_type === '2') {
//如果已经上传品质保证协议,并且供应商性质不是代理商(代理商要代理证)
if (inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
msg = '已经上传品质保证协议,是否切换为正式供应商?'
obj1Checked = true;
obj2Checked = false;
}
if (inArray('proxy_certificate', fieldNameList) && supplierGroup === '1') {
msg = '该供应商为代理供应商,已经上传代理证,是否切换为正式供应商?'
obj1Checked = true;
obj2Checked = false;
}
} else {
if (!inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
msg = '未上传品质保证协议,是否切换为临时供应商?'
obj1Checked = false;
obj2Checked = true;
}
if (!inArray('proxy_certificate', fieldNameList) && supplierGroup === '1') {
msg = '该供应商为代理供应商,但是未上传代理证,是否切换为临时供应商?'
obj1Checked = false;
obj2Checked = true;
}
}
if (msg) {
layer.confirm(msg, function (index) {
if (obj1Checked !== 0) {
radioObj.get(0).checked = obj1Checked;
radioObj.get(1).checked = obj2Checked;
layui.form.render('radio');
data.field.supplier_type = obj1Checked ? "1" : "2";
layer.closeAll();
}
auditAndUpdateSupplier(data);
});
} else {
auditAndUpdateSupplier(data);
}
return false;
});
function auditAndUpdateSupplier(data) {
data.field.is_audit = 1;
if (data.field.supplier_type === '2') {
layer.open({
......@@ -62,12 +115,10 @@
updateSupplier(data);
});
}
});
}
function updateSupplier(data) {
admin.showLoading({
type: 3,
});
admin.showLoading('.layui-layer-btn0');
let res = ajax('/api/supplier/UpdateSupplier', data.field);
if (res.err_code === 0) {
admin.putTempData("needFreshList", 1)
......@@ -76,13 +127,14 @@
layer.msg(res.err_msg, {icon: 6})
} else {
let errMsg = res.err_msg;
console.log(res);
let msg = '';
$.each(errMsg.split('|'), function (index, value) {
msg += "<span>" + value + "</span><br>"
});
layer.msg(msg, {icon: 5})
}
admin.removeLoading();
admin.removeLoading('.layui-layer-btn0');
}
});
</script>
\ No newline at end of file
......@@ -33,11 +33,11 @@
field: 'file_name',
title: '<span class="require">* </span>附件名称', align: 'center', width: 270,
templet: function (data) {
return "<a style='color: blue' href='" + data.file_url + "' target='_blank'>" + data.file_name + "</a>";
return "<a style='color: blue' href='" + data.file_url + "' target='_blank'>" + data.file_name + "<div style='display:none' class='attachment_fields'>" + data.field_name + "</div></a>";
}
},
{field: 'description', title: '附件说明', align: 'center', width: 250},
{field: 'validity_period', title: '<span class="require">* </span>有效期', align: 'center', width: 250},
{field: 'validity_period', title: '<span class="require">* </span>有效期', align: 'center', width: 220},
{field: 'create_name', title: '上传人', align: 'center', width: 100},
{field: 'create_time', title: '上传时间', align: 'center', width: 150},
]],
......
......@@ -97,9 +97,7 @@
});
});
delete this.files[index];
let supplierType = $('input[name="supplier_type"]:checked').val();
layer.close(loadIndex);
attachmentsUploadedChangeSupplierType(supplierType, $('#supplier_group').val(), fieldName)
},
});
......
......@@ -33,7 +33,7 @@
<blockquote class="layui-elem-quote layui-text">
<b>基本信息</b>
</blockquote>
<form class="layui-form" action="">
<form class="layui-form" action="" lay-filter="supplier_form">
<input type="hidden" name="apply_audit_reason" id="apply_audit_reason">
......@@ -61,14 +61,14 @@
<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 layui-disabled" value="" disabled>
placeholder="选择所在区域才允许输入供应商名称" class="layui-input layui-disabled" value="" disabled>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-block" id="tax_number_div">
<label class="layui-form-label"><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>
......
......@@ -25,7 +25,7 @@
}
</style>
<div class="layui-card">
<form class="layui-form" action="">
<form class="layui-form" action="" lay-filter="supplier_form">
<div class="layui-card-header fix-top">
<div class="layui-row">
<div class="layui-col-md2">
......
......@@ -15,7 +15,7 @@
<b>基本信息</b>
</blockquote>
@if($operate=='add')
<form class="layui-form" action="">
<form class="layui-form" action="" lay-filter="supplier_form">
@endif
<?php
$supplierType = config('field.SupplierType');
......@@ -58,7 +58,7 @@
layui-disabled
@endif"
value="{{$supplier['supplier_name'] or ''}}"
@if ($supplier['sync_united_status']==1) readonly @endif>
@if ($supplier['sync_united_status']==1) disabled @endif>
</div>
</div>
<div class="layui-col-md5">
......@@ -66,7 +66,7 @@
<label class="layui-form-label"><span class="require">*</span>公司税号</label>
<div class="layui-input-block">
<input type="text" name="tax_number" id="tax_number" placeholder="请输入公司税号,选择所在区域才允许输入"
class="layui-input layui-disabled" readonly value="{{$supplier['tax_number'] or ''}}">
class="layui-input layui-disabled" disabled value="{{$supplier['tax_number'] or ''}}">
</div>
</div>
</div>
......@@ -95,7 +95,7 @@
<div class="layui-row">
<div class="layui-col-md3">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('purchase_uid','渠道开发员 : ','',$userCodes,['required'=>true,'width'=>'150px']) !!}
{!! $statusPresenter->render('purchase_uid','渠道开发员 : ',$supplier['purchase_uid'],$userCodes,['required'=>true,'width'=>'150px']) !!}
</div>
<div class="layui-col-md3">
<label class="layui-form-label"><span class="require">*</span>注册资金(万): </label>
......
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