Commit 760f46da by 杨树贤

需求完成

parent 6705fe22
...@@ -152,7 +152,9 @@ class SupplierController extends Controller ...@@ -152,7 +152,9 @@ class SupplierController extends Controller
'value' => $userId, 'value' => $userId,
]; ];
} }
$defaultPurchaseUid = $intraCodeModel->getCodeIdByUserName(config('field.DefaultPurchaseName'));
$this->data['operate'] = 'add'; $this->data['operate'] = 'add';
$this->data['default_purchase_uid'] = $defaultPurchaseUid;
//省市区数据放到script模板 //省市区数据放到script模板
$regionService = new RegionService(); $regionService = new RegionService();
$this->data['region_data'] = $regionService->getCityRegionData(); $this->data['region_data'] = $regionService->getCityRegionData();
......
...@@ -70,6 +70,7 @@ class SupplierExaminationService ...@@ -70,6 +70,7 @@ class SupplierExaminationService
$supplierNames = (new SupplierChannelModel())->where('is_type', 0)->pluck('supplier_name')->toArray(); $supplierNames = (new SupplierChannelModel())->where('is_type', 0)->pluck('supplier_name')->toArray();
//拼装数据插入校验,校验完成插入数据库 //拼装数据插入校验,校验完成插入数据库
$examineData = []; $examineData = [];
$errMsg = [];
foreach ($data as $index => $item) { foreach ($data as $index => $item) {
if ($this->checkArrAllNull($item)) { if ($this->checkArrAllNull($item)) {
continue; continue;
...@@ -90,7 +91,7 @@ class SupplierExaminationService ...@@ -90,7 +91,7 @@ class SupplierExaminationService
$supplierName = $item[6]; $supplierName = $item[6];
$skuName = $item[7]; $skuName = $item[7];
$brandName = $item[8]; $brandName = $item[8];
$amount = str_replace(',','',$item[9]); $amount = str_replace(',', '', $item[9]);
$batch = $item[10]; $batch = $item[10];
$producingArea = $item[11]; $producingArea = $item[11];
$stockInDate = $item[12]; $stockInDate = $item[12];
...@@ -98,49 +99,49 @@ class SupplierExaminationService ...@@ -98,49 +99,49 @@ class SupplierExaminationService
$deliverySn = $item[14]; $deliverySn = $item[14];
$tallyRequest = $item[15]; $tallyRequest = $item[15];
$examineRequest = $item[16]; $examineRequest = $item[16];
$unhealthyAmount = str_replace(',','',$item[17]); $unhealthyAmount = str_replace(',', '', $item[17]);
$abnormalLevel = $item[18]; $abnormalLevel = $item[18];
$unhealthyContent = $item[19]; $unhealthyContent = $item[19];
$examineResult = $item[20]; $examineResult = $item[20];
$remark = $item[21]; $remark = $item[21];
if (empty($supplierName)) { if (empty($supplierName)) {
throw new \Exception("供应商名称不能为空! (第${lineNo}行),请修改后再次提交"); $errMsg[] = "供应商名称不能为空! (第${lineNo}行)";
} }
if (empty($examineTime)) { if (empty($examineTime)) {
throw new \Exception("检货时间不能为空! (第${lineNo}行),请修改为 2000-01-01 这种格式后再次提交"); $errMsg[] = "检货时间不能为空! (第${lineNo}行),请修改为 2000-01-01 这种格式后再次提交";
} }
if (!isDateTime($examineTime)) { if (!isDateTime($examineTime)) {
throw new \Exception("检货时间格式不规范! (第${lineNo}行),请修改为 2022/10/10 这种格式后再次提交"); $errMsg[] = "检货时间格式不规范! (第${lineNo}行),请修改为 2022/10/10 这种格式后再次提交";
} }
if (!empty($stockInDate) && !isDateTime($stockInDate)) { if (!empty($stockInDate) && !isDateTime($stockInDate)) {
throw new \Exception("入库日期时间格式不规范! (第${lineNo}行),请修改后再次提交"); $errMsg[] = "入库日期时间格式不规范! (第${lineNo}行)";
} }
if (!in_array($supplierName, $supplierNames)) { if (!in_array($supplierName, $supplierNames)) {
throw new \Exception("存在无效供应商(供应商系统不存在)的数据(第${lineNo}行),请修改后再次提交"); $errMsg[] = "存在无效供应商(供应商系统不存在)的数据(第${lineNo}行)";
} }
if (!in_array($channelUserName, $channelUserNames)) { if (!in_array($channelUserName, $channelUserNames)) {
throw new \Exception("存在无效的采购员(第${lineNo}行),请修改后再次提交"); $errMsg[] = "存在无效的采购员(第${lineNo}行)";
} }
if (empty($skuName)) { if (empty($skuName)) {
throw new \Exception("型号不能为空! (第${lineNo}行),请修改后再次提交"); $errMsg[] = "型号不能为空! (第${lineNo}行)";
} }
if (empty($brandName)) { if (empty($brandName)) {
throw new \Exception("品牌不能为空! (第${lineNo}行),请修改后再次提交"); $errMsg[] = "品牌不能为空! (第${lineNo}行)";
} }
if (!is_numeric($amount) || empty($amount)) { if (!is_numeric($amount) || empty($amount)) {
throw new \Exception("数量只能为纯数字且不能为空! (第${lineNo}行),请修改后再次提交"); $errMsg[] = "数量只能为纯数字且不能为空! (第${lineNo}行)";
} }
if (empty($examineResult) || !in_array($examineResult, if (empty($examineResult) || !in_array($examineResult,
array_values(config('field.SupplierExamineResult')))) { array_values(config('field.SupplierExamineResult')))) {
throw new \Exception("检验结果只能(退货|特批入库|正常入库)其中一个且不能为空 (第${lineNo}行),请修改后再次提交"); $errMsg[] = "检验结果只能(退货|特批入库|正常入库|待处理)其中一个且不能为空 (第${lineNo}行)";
} }
if (!empty($abnormalLevel) && !in_array($abnormalLevel, [1, 2, 3])) { if (!empty($abnormalLevel) && !in_array($abnormalLevel, [1, 2, 3])) {
throw new \Exception("存在不合理的异常等级,等级必须为纯数字1,2,3或者不填 (第${lineNo}行),请修改后再次提交"); $errMsg[] = "存在不合理的异常等级,等级必须为纯数字1,2,3或者不填 (第${lineNo}行)";
} }
$examineData[] = [ $examineData[] = [
...@@ -173,6 +174,11 @@ class SupplierExaminationService ...@@ -173,6 +174,11 @@ class SupplierExaminationService
]; ];
} }
if ($errMsg) {
$errMsg = implode('&', $errMsg);
throw new \Exception($errMsg);
}
$examineData = collect($examineData); $examineData = collect($examineData);
foreach ($examineData->chunk(50) as $chunk) { foreach ($examineData->chunk(50) as $chunk) {
SupplierExaminationModel::insert($chunk->toArray()); SupplierExaminationModel::insert($chunk->toArray());
......
...@@ -116,6 +116,15 @@ class IntracodeModel extends Model ...@@ -116,6 +116,15 @@ class IntracodeModel extends Model
return $result; return $result;
} }
public function getCodeIdByUserName($userName)
{
$codeId = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=', 'user_info.userId')
->where('user_info.name', $userName)
->value('code_id');
return $codeId;
}
public function getEncodeByUserIds($userIds = [], $includeResign = true) public function getEncodeByUserIds($userIds = [], $includeResign = true)
{ {
$query = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=', 'user_info.userId') $query = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=', 'user_info.userId')
......
...@@ -203,5 +203,9 @@ return [ ...@@ -203,5 +203,9 @@ return [
'退货' => '退货', '退货' => '退货',
'特批入库' => '特批入库', '特批入库' => '特批入库',
'正常入库' => '正常入库', '正常入库' => '正常入库',
] '待处理' => '待处理',
],
//新增供应商的时候默认的采购开发员
'DefaultPurchaseName' => '欧中云'
]; ];
\ No newline at end of file
...@@ -219,7 +219,12 @@ ...@@ -219,7 +219,12 @@
layer.msg(res.err_msg, {icon: 6}); layer.msg(res.err_msg, {icon: 6});
table.reload('supplierExaminationList'); table.reload('supplierExaminationList');
} else { } else {
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>"
});
layer.msg(msg, {icon: 5, time: 5000})
} }
}, },
error: function () { error: function () {
......
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
<div class="layui-row"> <div class="layui-row">
<div class="layui-col-md3"> <div class="layui-col-md3">
@inject('statusPresenter','App\Presenters\StatusPresenter') @inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('purchase_uid','渠道开发员 : ','',$userCodes,['required'=>true,'width'=>'150px']) !!} {!! $statusPresenter->render('purchase_uid','渠道开发员 : ',$default_purchase_uid,$userCodes,['required'=>true,'width'=>'150px']) !!}
</div> </div>
<div class="layui-col-md3"> <div class="layui-col-md3">
<label class="layui-form-label"><span class="require">*</span>注册资金(万): </label> <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