feat: #10000 导入修改

This commit is contained in:
赵世界 2022-08-09 10:57:03 +08:00
parent 12b734e916
commit ec7704bbb2
2 changed files with 5 additions and 3 deletions

View File

@ -333,8 +333,10 @@ class GoodsSkusController extends Controller
]; ];
} }
try { try {
$collection = Excel::import(new GoodsSkusImport(), $request->file('goodsSkus')); $import = new GoodsSkusImport();
$this->setAfterUpdate($collection->toArray()); $path = $request->file('goodsSkus');
Excel::import($import, $path);
$this->setAfterUpdate('');
$this->addLog(0, 'import'); $this->addLog(0, 'import');
} catch (ValidationException $exception) { } catch (ValidationException $exception) {
$this->setValidatorFailResponse($exception->validator->getMessageBag()->getMessages()); $this->setValidatorFailResponse($exception->validator->getMessageBag()->getMessages());

View File

@ -33,7 +33,7 @@ class GoodsSkusImport implements ToCollection, SkipsEmptyRows
'*.0' => ['required', 'string', 'max:255'], '*.0' => ['required', 'string', 'max:255'],
'*.1' => ['required', 'string', 'max:255', 'exists:goods_types,name'], '*.1' => ['required', 'string', 'max:255', 'exists:goods_types,name'],
'*.2' => ['string', 'max:255', 'exists:goods_brands,name'], '*.2' => ['string', 'max:255', 'exists:goods_brands,name'],
'*.3' => ['required', 'alpha_dash', 'max:32', 'unique:goods,goods_code'], '*.3' => ['required', 'alpha_dash', 'max:32'],
'*.4' => ['required', 'string', 'max:255'], '*.4' => ['required', 'string', 'max:255'],
'*.5' => ['required', 'distinct', 'alpha_dash', 'max:32'], '*.5' => ['required', 'distinct', 'alpha_dash', 'max:32'],
'*.6' => ['required', 'string', Rule::in(['下架', '在售', '预警'])], '*.6' => ['required', 'string', Rule::in(['下架', '在售', '预警'])],