Commit 8bf96bad by 杨树贤

调整新增表单页面

parent b86faa69
...@@ -116,7 +116,6 @@ class SupplierApiController extends Controller ...@@ -116,7 +116,6 @@ class SupplierApiController extends Controller
'can_check_uids' 'can_check_uids'
]); ]);
$channel = $request->only($channelMap); $channel = $request->only($channelMap);
dd($channel);
$service = new SupplierService(); $service = new SupplierService();
$result = $service->saveSupplier($channel); $result = $service->saveSupplier($channel);
if (!$result) { if (!$result) {
......
...@@ -62,7 +62,7 @@ class SupplierAttachmentApiController extends Controller ...@@ -62,7 +62,7 @@ class SupplierAttachmentApiController extends Controller
$content = !empty($attachment['attachment_id']) ? '修改附件信息' : '添加附件信息'; $content = !empty($attachment['attachment_id']) ? '修改附件信息' : '添加附件信息';
$remark = json_encode($attachment); $remark = json_encode($attachment);
$logService->AddLog($attachment['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark); $logService->AddLog($attachment['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark);
$this->response(); $this->response(0, '保存成功');
} }
} }
......
...@@ -53,8 +53,31 @@ class SupplierAttachmentService ...@@ -53,8 +53,31 @@ class SupplierAttachmentService
} }
} }
public function batchInsertAttachment($attachmentData) //新增附件来源于新增页面,数据要转换
public static function addAttachmentFromAddPage($supplierId,$attachmentData)
{ {
return SupplierAttachmentsModel::insert($attachmentData); if (empty($attachmentData)) {
return true;
}
$attachments = [];
foreach (count($attachmentData['file_name']) as $key => $value) {
$attachment = [
'supplier_id' => $supplierId,
'file_name' => $attachmentData['file_name'][$key],
'file_url' => $attachmentData['file_url'][$key],
'field_name' => $attachmentData['field_name'][$key],
'validity_type' => $attachmentData['validity_type'][$key],
'create_uid' => request()->user->userId,
'create_name' => request()->user->name,
'type_name' => array_get(config('field.AttachmentFields'), $attachmentData['field_name'][$key]),
];
if ($attachmentData['validity_period']) {
$validityPeriod = explode('~', $attachmentData['validity_period']);
$attachment['validity_start'] = strtotime(trim($validityPeriod[0]));
$attachment['validity_end'] = strtotime(trim($validityPeriod[1]));
}
$attachments[] = $attachment;
}
return SupplierAttachmentsModel::insert($attachments);
} }
} }
\ No newline at end of file
<?php
namespace App\Http\Services;
use App\Model\LogModel;
use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
class SupplierReceiptService
{
public static function addReceiptFromAddPage($supplierId, $receiptData)
{
$receiptData['supplier_id'] = $supplierId;
//判断银行信息是否有,没有的话不用新增
}
}
\ No newline at end of file
...@@ -11,6 +11,7 @@ use App\Model\SupplierAddressModel; ...@@ -11,6 +11,7 @@ use App\Model\SupplierAddressModel;
use App\Model\SupplierAttachmentModel; use App\Model\SupplierAttachmentModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
use App\Model\SupplierReceiptModel;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class SupplierService class SupplierService
...@@ -37,7 +38,7 @@ class SupplierService ...@@ -37,7 +38,7 @@ class SupplierService
$logService = new LogService(); $logService = new LogService();
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
//获取未修改前的供应商,做数据比较存储 //获取未修改前的供应商,做日志数据比较存储
$oldSupplier = $newSupplier = []; $oldSupplier = $newSupplier = [];
if (!empty($channel['supplier_id'])) { if (!empty($channel['supplier_id'])) {
$oldSupplier = $model->where('supplier_id', $channel['supplier_id'])->first(); $oldSupplier = $model->where('supplier_id', $channel['supplier_id'])->first();
...@@ -47,7 +48,8 @@ class SupplierService ...@@ -47,7 +48,8 @@ class SupplierService
//走事务 //走事务
$dataResult = DB::connection('web')->transaction(function () use ($channel, $model, $oldSupplier) { $dataResult = DB::connection('web')->transaction(function () use ($channel, $model, $oldSupplier) {
$tagService = new SupplierTagService(); $tagService = new SupplierTagService();
//获取和非主表有关的数据
//获取附加税数据
$extraFax = [ $extraFax = [
'supplier_id' => $channel['supplier_id'], 'supplier_id' => $channel['supplier_id'],
'supplier_code' => $channel['supplier_code'], 'supplier_code' => $channel['supplier_code'],
...@@ -91,7 +93,6 @@ class SupplierService ...@@ -91,7 +93,6 @@ class SupplierService
$attachmentData = array_only($channel, $attachmentField); $attachmentData = array_only($channel, $attachmentField);
$channel = array_except($channel, $attachmentField); $channel = array_except($channel, $attachmentField);
//处理银行信息,新增的时候才会有附件信息过来 //处理银行信息,新增的时候才会有附件信息过来
$receiptField = [ $receiptField = [
'receipt_type', 'receipt_type',
...@@ -106,7 +107,6 @@ class SupplierService ...@@ -106,7 +107,6 @@ class SupplierService
$receiptData = array_only($channel, $receiptField); $receiptData = array_only($channel, $receiptField);
$channel = array_except($channel, $receiptField); $channel = array_except($channel, $receiptField);
//先去插入到channel表 //先去插入到channel表
$channel['create_uid'] = request()->user->userId; $channel['create_uid'] = request()->user->userId;
$channel['create_name'] = request()->user->name; $channel['create_name'] = request()->user->name;
...@@ -142,19 +142,32 @@ class SupplierService ...@@ -142,19 +142,32 @@ class SupplierService
$contact = array_only($channel, $contactField); $contact = array_only($channel, $contactField);
$channel = array_except($channel, $contactField); $channel = array_except($channel, $contactField);
$channel['channel_uid'] = $contact['can_check_uids']; $channel['channel_uid'] = $contact['can_check_uids'];
//插入供应商返回供应商id
$supplierId = $this->newSupplierId = $model->insertGetId($channel); $supplierId = $this->newSupplierId = $model->insertGetId($channel);
//添加联系人 //添加联系人
//要有数据才新增,麻烦得要死
if (!checkArrayAllValueNull($contact)) {
$contact['supplier_id'] = $supplierId; $contact['supplier_id'] = $supplierId;
$contact['add_time'] = time(); $contact['add_time'] = time();
$contact['admin_id'] = request()->user->userId; $contact['admin_id'] = request()->user->userId;
$contactModel = new SupplierContactModel(); SupplierContactModel::insert($contact);
$contactModel->insert($contact); }
//添加附件
SupplierAttachmentService::addAttachmentFromAddPage($supplierId, $attachmentData);
//添加银行信息,也是有填一个表单域也要新增,排除receipt_type字段,因为这个肯定有的
if (!checkArrayAllValueNull($receiptData, ['receipt_type'])) {
$receiptData['supplier_id'] = $supplierId;
SupplierReceiptModel::insert($receiptData);
}
//如果是临时供应商,要打上临时供应商的标签 //如果是临时供应商,要打上临时供应商的标签
if ($channel['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY) { if ($channel['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY) {
$tagService->saveTags($supplierId, SupplierTagService::TAG_TYPE_SYSTEM, '临时供应商', $tagService->saveTags($supplierId, SupplierTagService::TAG_TYPE_SYSTEM, '临时供应商', '');
'');
} }
//保存生成的内部编码 //保存生成的内部编码
......
...@@ -188,3 +188,19 @@ function BatchTrim($data) ...@@ -188,3 +188,19 @@ function BatchTrim($data)
} }
return $data; return $data;
} }
//判断一个数组是否所有key都是空的
function checkArrayAllValueNull($array, $excludeField = [])
{
foreach ($array as $key => $value) {
if (in_array($key, $excludeField)) {
continue;
}
if (!empty($value)) {
return false;
}
}
return true;
}
\ No newline at end of file
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
.require { .require {
color: red; color: red;
font-size: 16px; font-size: 20px;
margin-right: 5px; margin-right: 3px;
} }
.layui-table-click { .layui-table-click {
......
...@@ -7,6 +7,14 @@ ...@@ -7,6 +7,14 @@
let element = layui.element; let element = layui.element;
let xmSelect = layui.xmSelect; let xmSelect = layui.xmSelect;
form.on('radio(receipt_type)', function (data) {
if (data.value == 1) {
$('#swift_code_div').hide();
} else {
$('#swift_code_div').show();
}
});
//图片上传 //图片上传
upload.render({ upload.render({
elem: '.upload-img' elem: '.upload-img'
......
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
}, },
@endif @endif
{ {
field: 'type_name', title: '附件类型', align: 'center', width: 150 field: 'type_name', title: '<span class="require">* </span>附件类型', align: 'center', width: 150
}, },
{field: 'file_name', title: '附件名称', align: 'center', width: 200}, {field: 'file_name', title: '<span class="require">* </span>附件名称', align: 'center', width: 200},
{field: 'description', title: '附件说明', align: 'center', width: 250}, {field: 'description', title: '附件说明', align: 'center', width: 250},
{field: 'validity_period', title: '有效期', align: 'center', width: 250}, {field: 'validity_period', title: '<span class="require">* </span>有效期', align: 'center', width: 250},
{field: 'create_name', title: '上传人', align: 'center', width: 100}, {field: 'create_name', title: '上传人', align: 'center', width: 100},
{field: 'create_time', title: '上传时间', align: 'center', width: 150}, {field: 'create_time', title: '上传时间', align: 'center', width: 150},
]], ]],
......
...@@ -23,15 +23,15 @@ ...@@ -23,15 +23,15 @@
}, },
@endif @endif
{ {
field: 'supplier_consignee', title: '联系人', align: 'center',width:150 field: 'supplier_consignee', title: '<span class="require">* </span>联系人', align: 'center',width:150
}, },
{field: 'supplier_position', title: '职位', align: 'center',width: 100}, {field: 'supplier_position', title: '<span class="require">* </span>职位', align: 'center',width: 100},
{field: 'supplier_email', title: '邮箱', align: 'center',width: 200}, {field: 'supplier_email', title: '<span class="require">* </span>邮箱', align: 'center',width: 200},
{field: 'supplier_mobile', title: '手机号', align: 'center',width: 150}, {field: 'supplier_mobile', title: '<span class="require">* </span>手机号', align: 'center',width: 150},
{field: 'supplier_telephone', title: '座机', align: 'center',width: 150}, {field: 'supplier_telephone', title: '座机', align: 'center',width: 150},
{field: 'supplier_qq', title: 'QQ', align: 'center',width: 120}, {field: 'supplier_qq', title: 'QQ', align: 'center',width: 120},
{field: 'supplier_fax', title: '传真', align: 'center',width: 140}, {field: 'supplier_fax', title: '传真', align: 'center',width: 140},
{field: 'channel_name', title: '采购员', align: 'center',width: 110}, {field: 'channel_name', title: '<span class="require">* </span>采购员', align: 'center',width: 110},
{field: 'working_status', title: '采购员状态', align: 'center',width: 120}, {field: 'working_status', title: '采购员状态', align: 'center',width: 120},
]], ]],
id: 'contactList', id: 'contactList',
......
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
{ {
field: 'receipt_type', title: '银行类型', align: 'center', width: 120 field: 'receipt_type', title: '银行类型', align: 'center', width: 120
}, },
{field: 'bank_name', title: '开户名称', align: 'center', width: 150}, {field: 'bank_name', title: '<span class="require">* </span>开户名称', align: 'center', width: 150},
{field: 'bank_adderss', title: '开户行', align: 'center', width: 150}, {field: 'bank_adderss', title: '<span class="require">* </span>开户行', align: 'center', width: 150},
{field: 'account_no', title: '银行账号', align: 'center', width: 130}, {field: 'account_no', title: '<span class="require">* </span>银行账号', align: 'center', width: 130},
{field: 'account_name', title: '账户名称', align: 'center', width: 150}, {field: 'account_name', title: '账户名称', align: 'center', width: 150},
{field: 'swift_code', title: '电汇号码', align: 'center', width: 130}, {field: 'swift_code', title: '电汇号码', align: 'center', width: 130},
{ {
field: 'certificate', title: '信息凭证', width: 200, align: 'center', templet: function (data) { field: 'certificate', title: '<span class="require">* </span>信息凭证', width: 200, align: 'center', templet: function (data) {
return "<a href='" + data.certificate + "' target='_blank'>" + data.certificate + "</a>"; return "<a href='" + data.certificate + "' target='_blank'>" + data.certificate + "</a>";
} }
}, },
......
...@@ -218,7 +218,7 @@ ...@@ -218,7 +218,7 @@
<div class="layui-input-block block-42"> <div class="layui-input-block block-42">
<input type="text" name="bank_name" id="bank_name" <input type="text" name="bank_name" id="bank_name"
placeholder="请输入开户名称,比如深圳市猎芯科技有限公司" class="layui-input" placeholder="请输入开户名称,比如深圳市猎芯科技有限公司" class="layui-input"
value="{{$receipt['bank_name'] or ''}}"> value="">
</div> </div>
</div> </div>
<div class="layui-col-md4"> <div class="layui-col-md4">
...@@ -226,7 +226,7 @@ ...@@ -226,7 +226,7 @@
<div class="layui-input-block block-42"> <div class="layui-input-block block-42">
<input type="text" name="bank_adderss" id="bank_adderss" <input type="text" name="bank_adderss" id="bank_adderss"
placeholder="请输入开户行,比如深圳建设银行" class="layui-input" placeholder="请输入开户行,比如深圳建设银行" class="layui-input"
value="{{$receipt['bank_adderss'] or ''}}"> value="">
</div> </div>
</div> </div>
<div class="layui-col-md4"> <div class="layui-col-md4">
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
<div class="layui-input-block block-42"> <div class="layui-input-block block-42">
<input type="text" name="account_no" id="account_no" <input type="text" name="account_no" id="account_no"
placeholder="请输入银行账号" class="layui-input" placeholder="请输入银行账号" class="layui-input"
value="{{$receipt['account_no'] or ''}}"> value="">
</div> </div>
</div> </div>
<div class="layui-col-md4"> <div class="layui-col-md4">
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
<div class="layui-input-block block-42"> <div class="layui-input-block block-42">
<input type="text" name="account_name" id="account_name" <input type="text" name="account_name" id="account_name"
placeholder="请输入账户名称" class="layui-input" placeholder="请输入账户名称" class="layui-input"
value="{{$receipt['account_name'] or ''}}"> value="">
</div> </div>
</div> </div>
<div class="layui-col-md4"> <div class="layui-col-md4">
...@@ -250,11 +250,8 @@ ...@@ -250,11 +250,8 @@
<div class="layui-input-block block-42"> <div class="layui-input-block block-42">
<input type="text" name="account_adderss" id="account_adderss" <input type="text" name="account_adderss" id="account_adderss"
placeholder="请输入银行具体地址,精确到街道" class="layui-input" placeholder="请输入银行具体地址,精确到街道" class="layui-input"
value="{{$receipt['account_adderss'] or ''}}"> value="">
</div>
</div> </div>
<div class="layui-col-md4">
</div> </div>
<div class="layui-col-md4"> <div class="layui-col-md4">
<label class="layui-form-label"> <label class="layui-form-label">
...@@ -262,14 +259,24 @@ ...@@ -262,14 +259,24 @@
</label> </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="hidden" name="certificate" id="certificate" <input type="hidden" name="certificate" id="certificate"
value="{{$receipt['certificate'] or ''}}"> value="">
<button type="button" class="layui-btn upload-img layui-btn-sm" preview="preview" <button type="button" class="layui-btn upload-img layui-btn-sm" preview="preview"
data-obj="certificate"> data-obj="certificate">
<i class="layui-icon">&#xe67c;</i>上传文件 <i class="layui-icon">&#xe67c;</i>上传文件
</button> </button>
<a target="_blank" id="certificate_url" <a target="_blank" id="certificate_url"
href="{{$receipt['certificate'] or ''}}">{{$receipt['certificate'] or ''}}</a> href=""></a>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-form-item" id="swift_code_div" style="display: none">
<label class="layui-form-label"><span class="require">*</span>Swift Code : </label>
<div class="layui-input-block block-42">
<input type="text" name="swift_code" id="Swift Code"
placeholder="请输入电汇号码" class="layui-input"
value="">
</div>
</div> </div>
</div> </div>
<div class="layui-col-md4"> <div class="layui-col-md4">
...@@ -277,7 +284,7 @@ ...@@ -277,7 +284,7 @@
<div class="layui-input-block block-42"> <div class="layui-input-block block-42">
<input type="text" name="remark" id="remark" <input type="text" name="remark" id="remark"
placeholder="请输入备注" class="layui-input" placeholder="请输入备注" class="layui-input"
value="{{$receipt['remark'] or ''}}"> value="">
</div> </div>
</div> </div>
</div> </div>
......
...@@ -154,11 +154,11 @@ ...@@ -154,11 +154,11 @@
</div> </div>
</div> </div>
<blockquote class="layui-elem-quote layui-text"> <blockquote class="layui-elem-quote layui-text">
<b>财务信息</b> <b><span class="require">*</span>财务信息</b>
</blockquote> </blockquote>
@include('web.supplier.SupplierReceipt') @include('web.supplier.SupplierReceipt')
<blockquote class="layui-elem-quote layui-text"> <blockquote class="layui-elem-quote layui-text">
<b>附件管理</b> <b><span class="require">*</span>附件管理</b>
</blockquote> </blockquote>
@include('web.supplier.SupplierAttachment') @include('web.supplier.SupplierAttachment')
<blockquote class="layui-elem-quote layui-text"> <blockquote class="layui-elem-quote layui-text">
......
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