Commit c95f35bb by 朱继来

批量下单替换为CSV模板

parent a3a660e6
...@@ -632,8 +632,8 @@ Class AddOrderController extends Controller ...@@ -632,8 +632,8 @@ Class AddOrderController extends Controller
Excel::load($filePath, function($reader) use(&$excel){ Excel::load($filePath, function($reader) use(&$excel){
$data = $reader->getSheet(0); $data = $reader->getSheet(0);
$excel = $data->toArray(); $excel = $data->toArray();
}); }, 'GBK');
if (empty($excel)) return ['errcode' => 1, 'errmsg' => '未获取到模板内容,请检查模板内容数据格式']; if (empty($excel)) return ['errcode' => 1, 'errmsg' => '未获取到模板内容,请检查模板内容数据格式'];
$type = $request->input('type'); // 1.联营 2.自营 $type = $request->input('type'); // 1.联营 2.自营
...@@ -651,6 +651,8 @@ Class AddOrderController extends Controller ...@@ -651,6 +651,8 @@ Class AddOrderController extends Controller
return ['errcode' => 1, 'errmsg' => '导入模板错误,需导入'.$type_val.'模板']; return ['errcode' => 1, 'errmsg' => '导入模板错误,需导入'.$type_val.'模板'];
} }
$excel = $this->handleData($excel, $map); // 处理数据
// 验证excel内容 // 验证excel内容
$valid = $this->excelValid($excel); $valid = $this->excelValid($excel);
...@@ -661,10 +663,8 @@ Class AddOrderController extends Controller ...@@ -661,10 +663,8 @@ Class AddOrderController extends Controller
array_shift($excel); // 删除第一行 array_shift($excel); // 删除第一行
$goods_info = $this->handleData($excel, $map); // 处理数据
// 推送到API // 推送到API
$data['data'] = $goods_info; $data['data'] = $excel;
$data['operator_id'] = $request->user->userId; $data['operator_id'] = $request->user->userId;
$data['type'] = 3; // 后台批量添加标记 $data['type'] = 3; // 后台批量添加标记
$data['uid'] = $request->input('user_id'); $data['uid'] = $request->input('user_id');
...@@ -709,6 +709,14 @@ Class AddOrderController extends Controller ...@@ -709,6 +709,14 @@ Class AddOrderController extends Controller
break; break;
} }
} }
// 自营ID、采购数量和单价为数字类型
if ($k == 'id' || $k == 'num' || $k == 'goods_price') {
if (!preg_match('/\d/', $v)) {
$err = ['errcode' => 2, 'errmsg' => $required[$k].'列,第'.$key.'行格式错误'];
break;
}
}
} }
} }
}); });
......
...@@ -582,7 +582,7 @@ ...@@ -582,7 +582,7 @@
// 上传文件 // 上传文件
var form = $('<form id="formUpload" method="post" enctype="multipart/form-data">\ var form = $('<form id="formUpload" method="post" enctype="multipart/form-data">\
<input type="file" name="upload" id="fileInput" accept="application/vnd.ms-excel, application/x-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">\ <input type="file" name="upload" id="fileInput" accept="application/vnd.ms-excel, application/x-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, .csv">\
</form>'); </form>');
var type = $(this).data('type'); // 1-联营模板,2-自营模板 var type = $(this).data('type'); // 1-联营模板,2-自营模板
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<div class="batch-btn"> <div class="batch-btn">
<a class="btn btn-success goods_import" data-type="2">批量导入物料</a> <a class="btn btn-success goods_import" data-type="2">批量导入物料</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.xlsx">自营物料模板下载</a> <a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.csv">自营物料模板下载</a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
<div class="batch-btn"> <div class="batch-btn">
<a class="btn btn-success goods_import" data-type="2">批量导入物料</a> <a class="btn btn-success goods_import" data-type="2">批量导入物料</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.xlsx">自营物料模板下载</a> <a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.csv">自营物料模板下载</a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
<div class="batch-btn"> <div class="batch-btn">
<a class="btn btn-success goods_import" data-type="1">批量导入物料</a> <a class="btn btn-success goods_import" data-type="1">批量导入物料</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%81%94%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.xlsx">联营物料模板下载</a> <a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%81%94%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.csv">联营物料模板下载</a>
</div> </div>
</div> </div>
</div> </div>
......
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