Commit 175ec29f by mushishixian

文件上传

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