Commit d75fe64a by 杨树贤

sku上传情况

parent c60c9d82
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\AdminUserService;
use App\Http\Services\SkuUploadLogService;
use App\Http\Transformers\LogTransformer;
use App\Model\LogModel;
use Illuminate\Http\Request;
class SkuUploadLogApiController extends Controller
{
public function Entrance(Request $request, $id)
{
$this->$id($request, $id);
}
//获取供应商信息变更记录
public function GetSkuUploadLogList($request)
{
$data = $request->only([
'supplier_id',
'limit',
'page'
]);
$list = (new SkuUploadLogService())->getSkuUploadLogList($data);
$this->response(0, 'ok', $list['data'], $list['total']);
}
}
...@@ -4,6 +4,7 @@ namespace App\Http\Controllers; ...@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Http\Services\LogService; use App\Http\Services\LogService;
use App\Http\Services\RegionService; use App\Http\Services\RegionService;
use App\Http\Services\SkuUploadLogService;
use App\Http\Services\SupplierAttachmentService; use App\Http\Services\SupplierAttachmentService;
use App\Http\Services\SupplierService; use App\Http\Services\SupplierService;
use App\Http\Services\SupplierShareApplyService; use App\Http\Services\SupplierShareApplyService;
...@@ -128,6 +129,7 @@ class SupplierController extends Controller ...@@ -128,6 +129,7 @@ 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);
$this->data['sku_upload_log_count'] = (new SkuUploadLogService())->getSkuUploadLogCount($supplierId);
return $this->view('供应商详情'); return $this->view('供应商详情');
} }
...@@ -212,6 +214,7 @@ class SupplierController extends Controller ...@@ -212,6 +214,7 @@ class SupplierController extends Controller
$this->data['address'] = $supplierService->getAddress($supplierId); $this->data['address'] = $supplierService->getAddress($supplierId);
$this->data['ignore_supplier_type_change_tips'] = in_array($supplier['supplier_name'], $this->data['ignore_supplier_type_change_tips'] = in_array($supplier['supplier_name'],
config('field.SkipChangeSupplierTypeNames')); config('field.SkipChangeSupplierTypeNames'));
$this->data['sku_upload_log_count'] = (new SkuUploadLogService())->getSkuUploadLogCount($supplierId);
return $this->view('编辑供应商'); return $this->view('编辑供应商');
} }
......
<?php
namespace App\Http\Services;
use App\Http\Controllers\Filter\LogFilter;
use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\SkuUploadLogTransformer;
use App\Http\Transformers\SupplierTransformer;
use App\Model\LogModel;
use App\Model\SkuUploadLogModel;
use App\Model\SupplierChannelModel;
class SkuUploadLogService
{
public function getSkuUploadLogList($params)
{
$limit = array_get($params, 'limit', 10);
$query = SkuUploadLogModel::withCount('upload_items')->orderBy('id', 'desc');
if (!empty($params['supplier_id'])) {
$supplierCode = SupplierChannelModel::where('supplier_id', $params['supplier_id'])->value('supplier_code');
$query->where('supplier_code', $supplierCode);
}
$list = $query->paginate($limit)->toArray();
$list['data'] = (new SkuUploadLogTransformer())->transformList($list['data']);
return $list;
}
//获取上传次数
public function getSkuUploadLogCount($supplierId)
{
$supplierCode = SupplierChannelModel::where('supplier_id', $supplierId)->value('supplier_code');
return SkuUploadLogModel::where('supplier_code', $supplierCode)->count();
}
}
\ No newline at end of file
...@@ -68,7 +68,11 @@ class SupplierExaminationService ...@@ -68,7 +68,11 @@ class SupplierExaminationService
//拼装数据插入校验,校验完成插入数据库 //拼装数据插入校验,校验完成插入数据库
$examineData = []; $examineData = [];
foreach ($data as $index => $item) { foreach ($data as $index => $item) {
//检测模板头部
if ($index == 0) { if ($index == 0) {
if (!$this->checkImportCsvHeader($item)) {
throw new \Exception('文件不是标准上传模板');
}
continue; continue;
} }
$item = array_map(function ($value) { $item = array_map(function ($value) {
...@@ -118,8 +122,31 @@ class SupplierExaminationService ...@@ -118,8 +122,31 @@ class SupplierExaminationService
}, $fileType); }, $fileType);
} catch (\Exception $exception) { } catch (\Exception $exception) {
return $exception->getMessage(); return $exception->getMessage();
} finally {
unlink($filePath);
} }
return true; return true;
} }
private function checkImportCsvHeader($header)
{
$validHeader = [
'检货时间',
'采购员',
'供应商',
'型号',
'品牌',
'数量',
'检验数量',
'不良数',
'异常等级',
'不良现象',
'检验结果',
'处理方式',
'备注'
];
return $validHeader == $header;
}
} }
\ No newline at end of file
<?php
namespace App\Http\Transformers;
class SkuUploadLogTransformer
{
public function transformList($list)
{
foreach ($list as &$item) {
$item['create_time'] = !empty($item['create_time']) ? date('Y-m-d H:i:s', $item['create_time']) : '';
$item['status'] = array_get(config('field.SkuUploadLogStatus'), $item['status']);
}
unset($item);
return $list;
}
}
\ No newline at end of file
...@@ -20,20 +20,19 @@ class SupplierExaminationValidator ...@@ -20,20 +20,19 @@ class SupplierExaminationValidator
"purchase_name" => "required", "purchase_name" => "required",
"sku_name" => "required", "sku_name" => "required",
"brand_name" => "required", "brand_name" => "required",
"amount" => "required|numeric", "amount" => "required",
"examine_amount" => "required", "examine_amount" => "required",
"unhealthy_amount" => "required", "unhealthy_amount" => "required",
"unhealthy_content" => "required", "unhealthy_content" => "required",
"examine_result" => "required", "examine_result" => "required",
"abnormal_level" => "required", "abnormal_level" => "required",
"handle_way" => "required", "handle_way" => "required",
"remark" => "required",
]; ];
$messages = $this->messages(); $messages = $this->messages();
$validator = Validator::make($params, $rules, $messages, $this->attributes()); $validator = Validator::make($params, $rules, $messages, $this->attributes());
//判断联系方式的表单验证 //判断联系方式的表单验证
if ($validator->fails()) { if ($validator->fails()) {
return $validator->errors()->first(); return implode('|',$validator->errors()->all());
} }
return null; return null;
......
...@@ -47,6 +47,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () { ...@@ -47,6 +47,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/supplier_tag/{key}', 'SupplierTagApiController@Entrance'); Route::match(['get', 'post'], '/api/supplier_tag/{key}', 'SupplierTagApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_share_apply/{key}', 'SupplierShareApplyApiController@Entrance'); Route::match(['get', 'post'], '/api/supplier_share_apply/{key}', 'SupplierShareApplyApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_examination/{key}', 'SupplierExaminationApiController@Entrance'); Route::match(['get', 'post'], '/api/supplier_examination/{key}', 'SupplierExaminationApiController@Entrance');
Route::match(['get', 'post'], '/api/sku_upload_log/{key}', 'SkuUploadLogApiController@Entrance');
}); });
//提供给其它系统使用的接口 //提供给其它系统使用的接口
......
...@@ -12,4 +12,9 @@ class SkuUploadLogModel extends Model ...@@ -12,4 +12,9 @@ class SkuUploadLogModel extends Model
public $timestamps = false; public $timestamps = false;
const STATUS_HANDLED = 3; const STATUS_HANDLED = 3;
public function upload_items()
{
return $this->hasMany(SkuUploadItem::class, 'log_id', 'id');
}
} }
...@@ -184,4 +184,11 @@ return [ ...@@ -184,4 +184,11 @@ return [
//专门给采购助理这个账号要做特殊逻辑,采购系统那边没有按照正常流程去判断,导致这个账号的部门分布完全不合理,所以供应商系统这边只能恶心自己去加特殊跳过了 //专门给采购助理这个账号要做特殊逻辑,采购系统那边没有按照正常流程去判断,导致这个账号的部门分布完全不合理,所以供应商系统这边只能恶心自己去加特殊跳过了
'AssistantUserId' => 1635, 'AssistantUserId' => 1635,
'SkuUploadLogStatus' => [
1 => '待处理',
2 => '处理中',
3 => '执行上传完成',
4 => '其他失败',
]
]; ];
\ No newline at end of file
检货时间,采购员,供应商,型号,品牌,数量,检验数量,不良数,异常等级,不良现象,检验结果,处理方式,备注 检货时间,采购员,供应商,型号,品牌,数量,检验数量,不良数,异常等级,不良现象,检验结果,处理方式,备注
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
2020/8/31,谭博利,Bentley Technologies,PM75CSA120,MITSUBISHI,2,2,,,使用过的擦磨旧货,,己跟采购说明,已出货。, 2020/8/31,谭博利,Bentley Technologies,PM75CSA120,MITSUBISHI,2,2,,,使用过的擦磨旧货,,己跟采购说明,已出货。,
2020/8/31,马玉强,深圳市有芯电子有限公司,17-21/Y2C-AN1P2B/3T,亿光,3K,3K,,,标签不正常,,己跟采购说明,已出货。, 2020/8/31,马玉强,深圳市有芯电子有限公司,17-21/Y2C-AN1P2B/3T,亿光,3K,3K,,,标签不正常,,己跟采购说明,已出货。,
2020/9/1,邓小姣,深圳市铭盛微电子有限公司,MP6922DSE-LF-Z,MPS,2253,2253,标签不正常,,本体丝印格式错误且与标签信息不符,山寨货,退货, 2020/9/1,邓小姣,深圳市铭盛微电子有限公司,MP6922DSE-LF-Z,MPS,2253,2253,标签不正常,,本体丝印格式错误且与标签信息不符,山寨货,退货,
2020/9/1,陈燕,深圳市长河世纪科技有限公司,LMDL301T1G,LRC,3K,3K,标签不正常,,本体丝印错误,山寨货,退货, 2020/9/1,陈燕,深圳市长河世纪科技有限公司,LMDL301T1G,LRC,3K,3K,标签不正常,,本体丝印错误,山寨货,退货1,
2020/9/1,段灵芝,Integrated Electronics Company,IXBA14N300HV,IXYS,525,525,无原标签,,本体丝印不统一且与标签D/C不相符,重编带货,让步采用, 2020/9/1,段灵芝,Integrated Electronics Company,IXBA14N300HV,IXYS,525,525,无原标签,,本体丝印不统一且与标签D/C不相符,重编带货,让步采用,
2020/9/17,汤浩升,深圳市亿威盛创科技有限公司,TS3USB221RSER,TI,800,800,无盘无标签,,反面有明显划痕,1136重新编带货,, 2020/9/17,汤浩升,深圳市亿威盛创科技有限公司,TS3USB221RSER,TI,800,800,无盘无标签,,反面有明显划痕,1136重新编带货,,
2020/9/21,陈泽彬,深圳市满多鑫电子有限公司,MTFC4GMDEA-4M IT,MICRON,12,12,无盘无标签,,反面有污迹少数球珠有伤痕个别球珠有氧化现象,重编带货,, 2020/9/21,陈泽彬,深圳市满多鑫电子有限公司,MTFC4GMDEA-4M IT,MICRON,12,12,无盘无标签,,反面有污迹少数球珠有伤痕个别球珠有氧化现象,重编带货,,
......
...@@ -16,7 +16,12 @@ ...@@ -16,7 +16,12 @@
admin.closeThisDialog(); admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6}); parent.layer.msg(res.err_msg, {icon: 6});
} else { } else {
parent.layer.msg(res.err_msg, {icon: 5}); let errMsg = res.err_msg;
let msg = '';
$.each(errMsg.split('|'), function (index, value) {
msg += "<span>" + value + "</span><br>"
});
parent.layer.msg(msg, {icon: 5})
} }
} }
return false; return false;
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
if (!data.length) { if (!data.length) {
layer.msg('请先选择要操作的检测数据', {icon: 5}) layer.msg('请先选择要操作的检测数据', {icon: 5})
} else { } else {
layer.confirm('确定要删除检测数据吗?', function (index) { layer.confirm('是否对该条记录进行删除?', function (index) {
let ids = []; let ids = [];
$.each(data, function (index, value) { $.each(data, function (index, value) {
ids.push(value.id); ids.push(value.id);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
let xmSelect = layui.xmSelect; let xmSelect = layui.xmSelect;
form.on('submit(addSupplierExamination)', function (data) { form.on('submit(addSupplierExamination)', function (data) {
layer.confirm('是否确认修改IQC检测资料s?', function (index) { layer.confirm('是否确认修改IQC检测资料?', function (index) {
let url = '/api/supplier_examination/UpdateSupplierExamination'; let url = '/api/supplier_examination/UpdateSupplierExamination';
let res = ajax(url, data.field); let res = ajax(url, data.field);
if (!res) { if (!res) {
...@@ -16,7 +16,12 @@ ...@@ -16,7 +16,12 @@
admin.closeThisDialog(); admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6}); parent.layer.msg(res.err_msg, {icon: 6});
} else { } else {
parent.layer.msg(res.err_msg, {icon: 5}); let errMsg = res.err_msg;
let msg = '';
$.each(errMsg.split('|'), function (index, value) {
msg += "<span>" + value + "</span><br>"
});
parent.layer.msg(msg, {icon: 5})
} }
} }
return false; return false;
......
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin'], function () {
let table = layui.table;
table.render({
elem: '#skuUploadLogList',
url: '/api/sku_upload_log/GetSkuUploadLogList',
method: 'get',
cellMinWidth: 80,//全局定义常规单元格的最小宽度
where: {
supplier_id: getQueryVariable("supplier_id")
},
size: 'sm',
loading: true,
first: true,//不显示首页
last: false,//不显示尾页
cols: [[
{
field: 'create_time', title: '上传时间', align: 'center', width: 150
},
{field: 'status', title: '状态', align: 'center', width: 600},
{field: 'upload_items_count', title: '上传SKU数量', align: 'center', width: 500},
]],
id: 'skuUploadLogList',
page: {},
});
});
</script>
\ No newline at end of file
...@@ -89,9 +89,9 @@ ...@@ -89,9 +89,9 @@
</button> </button>
@endif @endif
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_BLOCK && checkPerm('CancelBlockSupplier')) @if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_BLOCK && checkPerm('CancelBlockSupplier'))
{{-- <button type="button" style="margin-bottom: 25px;margin-top: 5px" id="cancel_block_supplier"--}} {{-- <button type="button" style="margin-bottom: 25px;margin-top: 5px" id="cancel_block_supplier"--}}
{{-- class="layui-btn layui-btn">取消拉黑--}} {{-- class="layui-btn layui-btn">取消拉黑--}}
{{-- </button>--}} {{-- </button>--}}
@endif @endif
@endif @endif
@if (checkPerm('PrintSupplier')) @if (checkPerm('PrintSupplier'))
...@@ -134,7 +134,8 @@ ...@@ -134,7 +134,8 @@
供应商英文名称 :{{$supplier['supplier_name_en']}} 供应商英文名称 :{{$supplier['supplier_name_en']}}
</div> </div>
<div class="layui-row"> <div class="layui-row">
<span class="required_field">*</span>注册资金 :{{$supplier['registered_capital']?$supplier['registered_capital']."(万)":'未设置'}} <span class="required_field">*</span>注册资金
:{{$supplier['registered_capital']?$supplier['registered_capital']."(万)":'未设置'}}
</div> </div>
<div class="layui-row"> <div class="layui-row">
<span class="is_business_abnormal">*</span>是否历史经营异常 <span class="is_business_abnormal">*</span>是否历史经营异常
...@@ -466,6 +467,7 @@ ...@@ -466,6 +467,7 @@
</div> </div>
</div> </div>
</div> </div>
@include('web.supplier.SkuUploadStatus');
<hr> <hr>
</div> </div>
</div> </div>
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
@endif @endif
</div> </div>
</div> </div>
@include('web.supplier.SkuUploadStatus');
</div> </div>
@include('script.supplier.SkuRulerScript') @include('script.supplier.SkuRulerScript')
\ No newline at end of file
<blockquote class="layui-elem-quote layui-text">
<b>sku上传情况</b>
</blockquote>
<div class="layui-row" style="padding-left: 20px">
<div class="layui-col-md2">
SKU 上传次数 :<b style="color: red">{{$sku_upload_log_count or 0}}</b>
</div>
</div>
<div class="layui-row" style="padding-left: 20px">
<div class="layui-col-md12">
SKU 历史上传情况 :
</div>
<table class="layui-table" lay-filter="skuUploadLogList" id="skuUploadLogList"></table>
</div>
@include('script.supplier.SkuUploadStatusScript')
\ No newline at end of file
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