Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
efd0a2e7
authored
Apr 13, 2020
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
导入品牌黑名单
parent
99feade5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
110 additions
and
3 deletions
app/Http/Controllers/AddOrderController.php
app/Http/routes.php
app/Model/BrandBlackListModel.php
public/js/web/brandBlackList.js
public/js/web/brandblackList.js
resources/views/web/brandBlackList.blade.php
app/Http/Controllers/AddOrderController.php
View file @
efd0a2e7
...
...
@@ -15,6 +15,7 @@ use App\Model\OrderModel;
use
App\Model\CrmModel
;
use
App\Model\CmsModel
;
use
Excel
;
use
App\Model\BrandBlackListModel
;
Class
AddOrderController
extends
Controller
{
...
...
@@ -888,4 +889,37 @@ Class AddOrderController extends Controller
}
}
// 批量导入品牌黑名单
public
function
batchImportBlackList
(
Request
$request
)
{
$file
=
$_FILES
[
'file'
];
// $request->file('file')
$filePath
=
$file
[
'tmp_name'
];
// 临时路径
// 获取导入内容
$excel
=
[];
Excel
::
load
(
$filePath
,
function
(
$reader
)
use
(
&
$excel
){
$data
=
$reader
->
getSheet
(
0
);
$excel
=
$data
->
toArray
();
},
'GBK'
);
if
(
empty
(
$excel
))
return
[
'errcode'
=>
1
,
'errmsg'
=>
'未获取到模板内容,请检查模板内容数据格式'
];
array_shift
(
$excel
);
// 删除第一行
$BrandBlackListModel
=
new
BrandBlackListModel
;
$err
=
[];
foreach
(
$excel
as
$k
=>
$v
)
{
$res
=
$BrandBlackListModel
->
setBlackList
(
$request
,
$v
[
0
],
$v
[
1
]);
if
(
$res
[
0
]
==
0
)
continue
;
$err
[]
=
'第'
.
(
$k
+
1
)
.
'行导入失败,原因:'
.
$res
[
1
];
}
if
(
!
empty
(
$err
))
return
[
'errcode'
=>
2
,
'errmsg'
=>
'请检查导入表格,'
.
implode
(
'; '
,
$err
)];
return
[
'errcode'
=>
0
,
'errmsg'
=>
'导入成功'
];
}
}
\ No newline at end of file
app/Http/routes.php
View file @
efd0a2e7
...
...
@@ -141,6 +141,9 @@ Route::group(['middleware' => 'web'], function () {
Route
::
post
(
'/ajax/addGoods'
,
'AddOrderController@addGoods'
);
Route
::
post
(
'/ajax/uploadContract'
,
'OrderController@uploadContract'
);
Route
::
post
(
'/ajax/getOrderItemsTrack'
,
'OrderController@getOrderItemsTrack'
);
Route
::
post
(
'/ajax/batchImportBlackList'
,
'AddOrderController@batchImportBlackList'
);
});
// 不需要登陆态
...
...
app/Model/BrandBlackListModel.php
View file @
efd0a2e7
...
...
@@ -80,11 +80,11 @@ class BrandBlackListModel extends Model
}
// 新增、编辑
public
function
setBlackList
(
$request
)
public
function
setBlackList
(
$request
,
$brand_name
=
''
,
$com_name
=
''
)
{
$id
=
$request
->
input
(
'id'
,
0
);
$data
[
'brand_name'
]
=
$request
->
input
(
'brand_name'
,
''
);
$data
[
'com_name'
]
=
$request
->
input
(
'com_name'
,
''
);
$data
[
'brand_name'
]
=
$
brand_name
?
$brand_name
:
$
request
->
input
(
'brand_name'
,
''
);
$data
[
'com_name'
]
=
$
com_name
?
$com_name
:
$
request
->
input
(
'com_name'
,
''
);
$res
=
$this
->
where
(
$data
)
->
first
();
...
...
public/js/web/brandBlackList.js
View file @
efd0a2e7
...
...
@@ -184,5 +184,38 @@ layui.use(['form', 'table', 'laydate'], function(){
}
});
// 批量导入物料
$
(
'.import'
).
click
(
function
()
{
// 上传文件
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, .csv">\
</form>'
);
form
.
find
(
'input'
).
change
(
function
(){
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
files
[
0
]);
$
.
ajax
({
type
:
"POST"
,
url
:
'/ajax/batchImportBlackList'
,
data
:
formData
,
dataType
:
'json'
,
cache
:
false
,
processData
:
false
,
contentType
:
false
,
success
:
function
(
resp
){
if
(
resp
.
errcode
==
0
)
{
layer
.
msg
(
resp
.
errmsg
);
return
false
;
}
layer
.
alert
(
resp
.
errmsg
);
}
})
})
form
.
find
(
'input[type="file"]'
).
trigger
(
'click'
);
})
});
\ No newline at end of file
public/js/web/brandblackList.js
View file @
efd0a2e7
...
...
@@ -184,5 +184,38 @@ layui.use(['form', 'table', 'laydate'], function(){
}
});
// 批量导入物料
$
(
'.import'
).
click
(
function
()
{
// 上传文件
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, .csv">\
</form>'
);
form
.
find
(
'input'
).
change
(
function
(){
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
files
[
0
]);
$
.
ajax
({
type
:
"POST"
,
url
:
'/ajax/batchImportBlackList'
,
data
:
formData
,
dataType
:
'json'
,
cache
:
false
,
processData
:
false
,
contentType
:
false
,
success
:
function
(
resp
){
if
(
resp
.
errcode
==
0
)
{
layer
.
msg
(
resp
.
errmsg
);
return
false
;
}
layer
.
alert
(
resp
.
errmsg
);
}
})
})
form
.
find
(
'input[type="file"]'
).
trigger
(
'click'
);
})
});
\ No newline at end of file
resources/views/web/brandBlackList.blade.php
View file @
efd0a2e7
...
...
@@ -42,6 +42,7 @@
<button
lay-submit
lay-filter=
"load"
class=
"layui-btn"
data-type=
"search"
>
搜索
</button>
<!-- <button type="button" class="layui-btn layui-btn-normal export">导出</button> -->
<a
class=
"layui-btn layui-btn-normal add"
>
新增
</a>
<a
class=
"layui-btn layui-btn-warm import"
>
导入
</a>
</div>
</div>
</form>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment