Commit 175ec29f by mushishixian

文件上传

parent 105b40a5
...@@ -95,6 +95,9 @@ class SupplierController extends Controller ...@@ -95,6 +95,9 @@ class SupplierController extends Controller
]); ]);
$this->data['province_city'] = implode(' | ', $regionNames); $this->data['province_city'] = implode(' | ', $regionNames);
$this->data['address'] = $supplierService->getAddress($supplierId); $this->data['address'] = $supplierService->getAddress($supplierId);
$supplierAttachmentService = new SupplierAttachmentService();
$this->data['attachment'] = $supplierAttachmentService->getAttachment($supplierId);
// dd($supplierAttachmentService->getAttachment($supplierId));
return $this->view('供应商详情'); return $this->view('供应商详情');
} }
......
...@@ -5,6 +5,7 @@ namespace App\Http\Services; ...@@ -5,6 +5,7 @@ namespace App\Http\Services;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel; use App\Model\RedisModel;
use App\Model\SupplierAttachmentModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
...@@ -169,7 +170,7 @@ class SupplierAuditService ...@@ -169,7 +170,7 @@ class SupplierAuditService
} }
//判断是否要进入审核中状态,因为部分字段修改是不需要走审核的 //判断是否要进入审核中状态,因为部分字段修改是不需要走审核的
public function checkNeedAudit($supplierId, $channel) public function checkNeedAudit($supplierId, $channel, $attachment)
{ {
$notNeedAuditField = [ $notNeedAuditField = [
'register_company_name', 'register_company_name',
...@@ -188,6 +189,15 @@ class SupplierAuditService ...@@ -188,6 +189,15 @@ class SupplierAuditService
return true; return true;
} }
$attachmentModel = new SupplierAttachmentModel();
//判断附件有没有变化,有变化也要进入审核
$oldAttachment = $attachmentModel->select(array_keys(config('fixed.FileNameMapping')))
->where('supplier_id', $supplierId)->first();
$oldAttachment = !empty($oldAttachment) ? $oldAttachment->toArray() : [];
$newAttachment = $attachment;
if ($oldAttachment != $newAttachment) {
return true;
}
$supplier = $model->select($selectField)->where('supplier_id', $supplierId)->first()->toArray(); $supplier = $model->select($selectField)->where('supplier_id', $supplierId)->first()->toArray();
$changeField = []; $changeField = [];
foreach ($supplier as $key => $value) { foreach ($supplier as $key => $value) {
......
...@@ -123,7 +123,7 @@ class SupplierService ...@@ -123,7 +123,7 @@ class SupplierService
$supplierId = $this->newSupplierId = $channel['supplier_id']; $supplierId = $this->newSupplierId = $channel['supplier_id'];
//要做进一步判断,部分字段修改不需要审核 //要做进一步判断,部分字段修改不需要审核
$auditService = new SupplierAuditService(); $auditService = new SupplierAuditService();
$needAudit = $auditService->checkNeedAudit($supplierId, $channel); $needAudit = $auditService->checkNeedAudit($supplierId, $channel,$attachment);
if ($needAudit) { if ($needAudit) {
$channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW; $channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW;
} }
......
...@@ -39,17 +39,19 @@ ...@@ -39,17 +39,19 @@
}, },
choose: function (obj) { choose: function (obj) {
var files = this.files = obj.pushFile(); let files = this.files = obj.pushFile();
let recentFile = files[Object.keys(files)[Object.keys(files).length - 1]] let recentFile = files[Object.keys(files)[Object.keys(files).length - 1]]
fileName = recentFile.name; fileName = recentFile.name;
loadIndex = layer.load(1); loadIndex = layer.load(1);
}, },
done: function (res, index, upload) { done: function (res, index, upload) {
fileName = this.files[index].name;
if (res.code === 200) { if (res.code === 200) {
//动态添加js //动态添加js
let fileTemplateObj = $('#file_template') let fileTemplateObj = $('#file_template')
fileTemplateObj.find('a').attr('href', res.data[0]); fileTemplateObj.find('a').attr('href', res.data[0]);
fileTemplateObj.find('a').text(fileName); fileTemplateObj.find('a').text(fileName);
fileTemplateObj.find('a').attr('value',fileName);
let fileTemplate = fileTemplateObj.html(); let fileTemplate = fileTemplateObj.html();
$('#' + fileType + '_div').show(); $('#' + fileType + '_div').show();
$('#' + fileType + '_file_div').append(fileTemplate); $('#' + fileType + '_file_div').append(fileTemplate);
...@@ -64,10 +66,13 @@ ...@@ -64,10 +66,13 @@
//删除文件操作 //删除文件操作
$(document).on('click', '.delete_file', function () { $(document).on('click', '.delete_file', function () {
let fileType = $(this).parent().parent().parent().find('input').attr('id'); // layer.confirm('确定要删除该文件吗?', function (index) {
//找出对应的div删除 let fileType = $(this).parent().parent().parent().find('input').attr('id');
$(this).parent().remove(); //找出对应的div删除
setFileTypeValue(fileType) $(this).parent().remove();
setFileTypeValue(fileType)
// return false;
// });
}); });
//遍历找出文件list复制到表单域 //遍历找出文件list复制到表单域
...@@ -77,7 +82,7 @@ ...@@ -77,7 +82,7 @@
let fileValueArr = []; let fileValueArr = [];
fileTypeDiv.find('a').each(function () { fileTypeDiv.find('a').each(function () {
let url = $(this).attr('href'); let url = $(this).attr('href');
let fileName = $(this).text(); let fileName = $(this).attr('value');
let fileValueMap = { let fileValueMap = {
file_name: fileName, file_name: fileName,
url: url, url: url,
...@@ -85,7 +90,16 @@ ...@@ -85,7 +90,16 @@
} }
fileValueArr.push(fileValueMap) fileValueArr.push(fileValueMap)
}) })
fileTypeObj.val(JSON.stringify(fileValueArr)); if (fileValueArr.length === 0) {
fileTypeObj.val('');
}else{
fileTypeObj.val(JSON.stringify(fileValueArr));
}
//判断是否没有子元素了,没有的话直接隐藏父元素
// let fileListSize = $('#fileType').find('a').size();
// if (fileListSize === 0) {
// fileTypeDiv.hide();
// }
} }
}); });
</script> </script>
\ No newline at end of file
...@@ -148,15 +148,20 @@ ...@@ -148,15 +148,20 @@
</div> </div>
</div> </div>
<div class="layui-row" style="width: 700px"> <div class="layui-row" style="width: 700px">
{{-- @foreach($supplier['qualification_photos'] as $name=>$file)--}} @if (!empty($attachment))
{{-- @if(!empty($file['url']))--}} @foreach($attachment as $key=>$item)
{{-- <div class="layui-col-md6">--}} @if(in_array($key,array_keys(config('fixed.FileNameMapping'))))
{{-- {{array_get(config('fixed.FileNameMapping'),$name)}} :<a--}} @if (!empty($item))
{{-- style="color: dodgerblue" href="{{$file['url']}}" target="_blank">--}} <div class="layui-col-md12">
{{-- {{$file['file_name']}}</a>--}} {{array_get(config('fixed.FileNameMapping'),$key)}} :
{{-- </div>--}} @foreach($item as $k=>$v)
{{-- @endif--}} <a href="{{$v['url']}}" style="color: dodgerblue" target="_blank">{{$v['file_name']}}</a> |
{{-- @endforeach--}} @endforeach
</div>
@endif
@endif
@endforeach
@endif
</div> </div>
<hr/> <hr/>
<blockquote class="layui-elem-quote layui-text"> <blockquote class="layui-elem-quote layui-text">
......
...@@ -23,14 +23,6 @@ ...@@ -23,14 +23,6 @@
width: 100%; width: 100%;
z-index: 10; z-index: 10;
} }
/*.layui-form-label {*/
/* width: 150px;*/
/*}*/
/*.layui-input-block {*/
/* margin-left: 180px;*/
/*}*/
</style> </style>
<div class="layui-card"> <div class="layui-card">
<form class="layui-form" action=""> <form class="layui-form" action="">
......
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-row"> <div class="layui-row">
<div class="layui-col-md2"> <div class="@if (empty($supplier['supplier_id']))layui-col-md4 @else layui-col-md2 @endif">
<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 block-12" style="width: 155px" id="file_type_selector"> <div class="layui-input-block block-12" style="width: 155px" id="file_type_selector">
<select lay-verify="" lay-filter="file_type_selector"> <select lay-verify="" lay-filter="file_type_selector">
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
</select> </select>
</div> </div>
</div> </div>
<div class="layui-col-md10"> @if (empty($supplier['supplier_id']))
@endif
<div @if (empty($supplier['supplier_id']))class="layui-col-md8" style="margin-left: -30px;"@else class="layui-col-md10" style="padding-left: 10px;" @endif >
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm layui-btn-disabled" <button type="button" class="layui-btn layui-btn-primary layui-btn-sm layui-btn-disabled"
id="disable_upload_button">请选择附件类型再上传 id="disable_upload_button">请选择附件类型再上传
</button> </button>
...@@ -21,23 +24,25 @@ ...@@ -21,23 +24,25 @@
<input type="hidden" class="upload_obj" value=""> <input type="hidden" class="upload_obj" value="">
</div> </div>
<div class="layui-col-md12" style="padding-left: 35px;margin-top: 20px"> <div class="layui-col-md12" style="padding-left: 35px;margin-top: 20px">
<blockquote class="layui-elem-quote layui-quote-nm"> <blockquote class="layui-elem-quote layui-quote-nm" style="padding-bottom: 5px">
<div id="file_list" class="layui-row"> <div id="file_list" class="layui-row">
@foreach(config('fixed.FileNameMapping') as $name=>$cnName) @foreach(config('fixed.FileNameMapping') as $name=>$cnName)
@if (!empty($attachment[$name])) @if (!empty($attachment[$name]))
<div id="{{$name}}_div"> <div id="{{$name}}_div">
<input type="hidden" name="{{$name}}" id="{{$name}}" value="{{json_encode($attachment[$name])}}"> <input type="hidden" name="{{$name}}" id="{{$name}}"
value="{{json_encode($attachment[$name])}}">
<span>{{$cnName}} : </span> <span>{{$cnName}} : </span>
<div id="{{$name}}_file_div"></div> <div id="{{$name}}_file_div">
@foreach($attachment[$name] as $k=>$item) @foreach($attachment[$name] as $k=>$item)
<span class="single_file_div"> <span class="single_file_div">
<a href="{{$item['url']}}" target="_blank"> <a href="{{$item['url']}}" target="_blank">
{{$item['file_name']}} {{$item['file_name']}}
</a> </a>
<i class="layui-icon delete_file" <i class="layui-icon delete_file"
style="font-size: 15px !important; color: red;cursor: pointer;margin-left: 3px;">X</i> &nbsp; style="font-size: 15px !important; color: red;cursor: pointer;margin-left: 3px;">X</i> &nbsp;
</span> </span>
@endforeach @endforeach
</div>
<hr> <hr>
</div> </div>
@else @else
......
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