Commit f6580a64 by 朱继来

temp1

parent aed60613
......@@ -597,15 +597,28 @@ Class AddOrderController extends Controller
// 商品批量导入
public function batchGoodsImport(Request $request)
{
echo '<pre>';
print_r($_FILES);
print_r($request->input());die;
$filePath = 'storage/exports/'.iconv('UTF-8', 'GBK', '学生成绩').'.xls';
Excel::load($filePath, function($reader) {
$data = $reader->all();
dd($data);
$file = $_FILES['file']; // $request->file('file')
$type = $request->input('type'); // 1.联营 2.自营
$filePath = $file['tmp_name']; // 临时路径
$excel = [];
Excel::load($filePath, function($reader) use(&$excel){
$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
{
$shipping = DB::connection('order')->table('lie_shipping')->select('shipping_id', 'shipping_name')->get();
$info['shippings'] = [];
if ($shipping) {
foreach ($shipping as $v) {
$shippingInfo[$v->shipping_id] = $v->shipping_name;
......
......@@ -515,22 +515,23 @@
// 批量导入物料
$('.goods_import').click(function() {
var form = $('<form id="formUpload" enctype="multipart/form-data">\
<input type="file" name="upload" accept="application/vnd.ms-excel, application/x-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">\
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">\
</form>');
var type = $(this).data('type'); // 1-联营模板,2-自营模板
console.log(form);
form.find('input').change(function(){
console.log($('#formUpload'))
console.log($('#formUpload')[0])
var formData = new FormData($('#formUpload')[0]);
var formData = new FormData();
formData.append('file', this.files[0]);
formData.append('type', type);
console.log(formData);
console.log(formData)
$.ajax({
type: "POST",
url: '/ajax/batchGoodsImport',
data: formData,
cache : false,
dataType: 'json',
cache: false,
processData: false,
contentType: false,
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