更新限制
This commit is contained in:
parent
95748c879f
commit
2f4b309430
@ -223,7 +223,8 @@ class StoreImport extends BaseController
|
|||||||
'L1'=>'商品条码',
|
'L1'=>'商品条码',
|
||||||
'M1'=>'商品品牌',
|
'M1'=>'商品品牌',
|
||||||
];
|
];
|
||||||
SpreadsheetExcelService::instance()->checkImport($path,$check);
|
$a=SpreadsheetExcelService::instance()->checkImport($path,$check,true);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'mer_id' => $this->request->merId(),
|
'mer_id' => $this->request->merId(),
|
||||||
'data' => [
|
'data' => [
|
||||||
@ -251,7 +252,7 @@ class StoreImport extends BaseController
|
|||||||
'K1'=>'商品条码',
|
'K1'=>'商品条码',
|
||||||
'L1'=>'商品品牌',
|
'L1'=>'商品品牌',
|
||||||
];
|
];
|
||||||
SpreadsheetExcelService::instance()->checkImport($path,$check);
|
SpreadsheetExcelService::instance()->checkImport($path,$check,true);
|
||||||
$data = [
|
$data = [
|
||||||
'mer_id' => $this->request->merId(),
|
'mer_id' => $this->request->merId(),
|
||||||
'data' => [
|
'data' => [
|
||||||
|
@ -369,12 +369,19 @@ class SpreadsheetExcelService
|
|||||||
* @author Qinii
|
* @author Qinii
|
||||||
* @day 5/7/21
|
* @day 5/7/21
|
||||||
*/
|
*/
|
||||||
public function checkImport($filePath,$check = [])
|
public function checkImport($filePath,$check = [],$is_limit=false,$count=1000)
|
||||||
{
|
{
|
||||||
$ext = ucfirst(pathinfo($filePath, PATHINFO_EXTENSION));
|
$ext = ucfirst(pathinfo($filePath, PATHINFO_EXTENSION));
|
||||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($ext);
|
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($ext);
|
||||||
$spreadsheet = $reader->load($filePath);
|
$spreadsheet = $reader->load($filePath);
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
|
if($is_limit==true){
|
||||||
|
$limit=$sheet->getHighestRow();
|
||||||
|
if($limit>$count){
|
||||||
|
throw new ValidateException('导入的条数超过限制数量:'.$count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($check)){
|
if(!empty($check)){
|
||||||
foreach ($check as $s => $c){
|
foreach ($check as $s => $c){
|
||||||
$_c = $sheet->getCell($s)->getValue();
|
$_c = $sheet->getCell($s)->getValue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user