Commit f6580a64 by 朱继来

temp1

parent aed60613
...@@ -597,15 +597,28 @@ Class AddOrderController extends Controller ...@@ -597,15 +597,28 @@ Class AddOrderController extends Controller
// 商品批量导入 // 商品批量导入
public function batchGoodsImport(Request $request) public function batchGoodsImport(Request $request)
{ {
echo '<pre>'; $file = $_FILES['file']; // $request->file('file')
print_r($_FILES); $type = $request->input('type'); // 1.联营 2.自营
print_r($request->input());die;
$filePath = 'storage/exports/'.iconv('UTF-8', 'GBK', '学生成绩').'.xls'; $filePath = $file['tmp_name']; // 临时路径
Excel::load($filePath, function($reader) { $excel = [];
$data = $reader->all(); Excel::load($filePath, function($reader) use(&$excel){
dd($data); $data = $reader->getSheet(0);
$excel = $data->toArray();
}); });
return $this->excelValid($excel, $type);
}
// 验证导入excel
public function excelValid($excel, $type)
{
$count = count($excel);
if ($count == 1) return ['errcode' => 1, 'errmsg' => '未填写物料信息'];
// if ($type)
} }
} }
\ No newline at end of file
...@@ -609,6 +609,8 @@ Class OrderController extends Controller ...@@ -609,6 +609,8 @@ Class OrderController extends Controller
{ {
$shipping = DB::connection('order')->table('lie_shipping')->select('shipping_id', 'shipping_name')->get(); $shipping = DB::connection('order')->table('lie_shipping')->select('shipping_id', 'shipping_name')->get();
$info['shippings'] = [];
if ($shipping) { if ($shipping) {
foreach ($shipping as $v) { foreach ($shipping as $v) {
$shippingInfo[$v->shipping_id] = $v->shipping_name; $shippingInfo[$v->shipping_id] = $v->shipping_name;
......
...@@ -515,22 +515,23 @@ ...@@ -515,22 +515,23 @@
// 批量导入物料 // 批量导入物料
$('.goods_import').click(function() { $('.goods_import').click(function() {
var form = $('<form id="formUpload" enctype="multipart/form-data">\ var form = $('<form id="formUpload" method="post" enctype="multipart/form-data">\
<input type="file" name="upload" 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">\
</form>'); </form>');
var type = $(this).data('type'); // 1-联营模板,2-自营模板 var type = $(this).data('type'); // 1-联营模板,2-自营模板
console.log(form);
form.find('input').change(function(){ form.find('input').change(function(){
console.log($('#formUpload')) var formData = new FormData();
console.log($('#formUpload')[0]) formData.append('file', this.files[0]);
var formData = new FormData($('#formUpload')[0]);
formData.append('type', type); formData.append('type', type);
console.log(formData); console.log(formData)
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/ajax/batchGoodsImport', url: '/ajax/batchGoodsImport',
data: formData, data: formData,
cache : false, dataType: 'json',
cache: false,
processData: false, processData: false,
contentType: false, contentType: false,
success: function(resp){ success: function(resp){
......
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