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
3977d8ae
authored
Sep 26, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加自营样片导出
parent
f77c6faf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
6 deletions
app/Http/Controllers/ExportController.php
app/Http/routes.php
app/Model/UserSampleApplyModel.php
public/js/web/selfSampleList.js
app/Http/Controllers/ExportController.php
0 → 100644
View file @
3977d8ae
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
App\Model\UserSampleApplyModel
;
use
DB
;
use
Excel
;
Class
ExportController
extends
Controller
{
// 统一入口
public
function
entrance
(
Request
$request
,
$id
)
{
return
$this
->
$id
(
$request
);
}
// 导出会员
public
function
selfSampleExport
(
$request
)
{
$UserSampleApplyModel
=
new
UserSampleApplyModel
();
$data
=
$UserSampleApplyModel
->
lists
(
$request
,
1
);
foreach
(
$data
as
$k
=>
$v
)
{
$cellData
[
$k
][
'user_id'
]
=
$v
[
'user_id'
];
$cellData
[
$k
][
'account'
]
=
$v
[
'account'
];
$cellData
[
$k
][
'invite_count'
]
=
$v
[
'invite_count'
];
$cellData
[
$k
][
'apply_num_total'
]
=
$v
[
'apply_num_total'
];
$cellData
[
$k
][
'apply_count'
]
=
$v
[
'apply_count'
];
$cellData
[
$k
][
'order_id'
]
=
$v
[
'order_id'
];
$cellData
[
$k
][
'order_sn'
]
=
$v
[
'order_sn'
];
$cellData
[
$k
][
'goods_id'
]
=
$v
[
'goods_id'
];
$cellData
[
$k
][
'goods_name'
]
=
$v
[
'goods_name'
];
$cellData
[
$k
][
'create_time'
]
=
$v
[
'create_time'
];
}
$headerCell
=
[
'用户ID'
,
'用户账户'
,
'邀请人数'
,
'已申请样片数'
,
'剩余领取次数'
,
'订单ID'
,
'订单编号'
,
'样片ID'
,
'样片名称'
,
'最近一次领取时间'
];
$fileName
=
'自营样片领取记录导出'
.
date
(
'_YmdHis'
);
$sheetName
=
'自营样片'
;
$this
->
commonFunc
(
$cellData
,
$headerCell
,
$fileName
,
$sheetName
);
}
/**
* 导出
* @param [type] $cellData [导出数据]
* @param [type] $headerCell [菜单项]
* @param [type] $fileName [文件名]
* @param string $sheetName [sheet名]
* @return [type] [description]
*/
public
function
commonFunc
(
$cellData
,
$headerCell
,
$fileName
,
$sheetName
=
''
)
{
$sheetName
=
$sheetName
?
$sheetName
:
'导出'
;
array_unshift
(
$cellData
,
$headerCell
);
Excel
::
create
(
$fileName
,
function
(
$excel
)
use
(
$cellData
,
$sheetName
){
$excel
->
sheet
(
$sheetName
,
function
(
$sheet
)
use
(
$cellData
){
$sheet
->
rows
(
$cellData
);
});
})
->
export
(
'xls'
);
}
}
\ No newline at end of file
app/Http/routes.php
View file @
3977d8ae
...
...
@@ -108,6 +108,7 @@ Route::group(['middleware' => 'web'], function () {
Route
::
match
([
'get'
,
'post'
],
'/web/{key}'
,
'WebController@info'
);
Route
::
match
([
'get'
,
'post'
],
'/api/{key}'
,
'ApiController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/export/{key}'
,
'ExportController@entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/refund/{id}'
,
'OrderController@refund'
);
...
...
app/Model/UserSampleApplyModel.php
View file @
3977d8ae
...
...
@@ -72,6 +72,8 @@ class UserSampleApplyModel extends Model
if
(
$export
)
{
$list
=
$list
->
get
()
->
toArray
();
$list
=
$this
->
handle
(
$list
);
if
(
empty
(
$list
))
{
echo
'<script>alert("导出数据为空");history.go(-1);</script>'
;
die
;
}
...
...
public/js/web/selfSampleList.js
View file @
3977d8ae
...
...
@@ -23,13 +23,14 @@ layui.use(['form', 'table', 'laydate'], function(){
,{
field
:
'user_id'
,
title
:
'用户ID'
,
width
:
100
}
,{
field
:
'account'
,
title
:
'用户账户'
,
width
:
150
}
,{
field
:
'invite_count'
,
title
:
'邀请人数'
,
width
:
100
}
,{
field
:
'apply_num_total'
,
title
:
'已申请样片数'
,
width
:
150
}
,{
field
:
'apply_count'
,
title
:
'剩余领取次数'
,
width
:
150
}
,{
field
:
'apply_num_total'
,
title
:
'已申请样片数'
,
width
:
120
}
,{
field
:
'apply_count'
,
title
:
'剩余领取次数'
,
width
:
120
}
,{
field
:
'order_id'
,
title
:
'订单ID'
,
width
:
100
}
,{
field
:
'order_sn'
,
title
:
'订单编号'
,
width
:
150
}
,{
field
:
'goods_id'
,
title
:
'样片ID'
,
width
:
100
}
,{
field
:
'goods_name'
,
title
:
'样片名称'
,
width
:
2
15
}
,{
field
:
'create_time'
,
title
:
'最近一次领取时间'
,
width
:
20
0
}
,{
title
:
'操作'
,
align
:
'center'
,
fixed
:
'right'
,
toolbar
:
'#list_action'
,
width
:
200
}
,{
field
:
'goods_name'
,
title
:
'样片名称'
,
width
:
2
00
}
,{
field
:
'create_time'
,
title
:
'最近一次领取时间'
,
width
:
18
0
}
,{
title
:
'操作'
,
align
:
'center'
,
fixed
:
'right'
,
toolbar
:
'#list_action'
,
width
:
195
}
]]
,
limit
:
10
,
limits
:
[
10
,
20
,
50
,]
...
...
@@ -47,6 +48,29 @@ layui.use(['form', 'table', 'laydate'], function(){
return
false
;
});
// 导出
$
(
'.export'
).
click
(
function
()
{
var
account
=
$
(
'input[name=account]'
).
val
(),
goods_name
=
$
(
'input[name=goods_name]'
).
val
(),
order_sn
=
$
(
'input[name=order_sn]'
).
val
(),
begin_time
=
$
(
'input[name=begin_time]'
).
val
(),
end_time
=
$
(
'input[name=end_time]'
).
val
(),
url
=
'/export/selfSampleExport'
;
if
(
!
account
&&
!
goods_name
&&
!
order_sn
&&
!
begin_time
&&
!
end_time
)
{
layer
.
msg
(
'请选择筛选条件'
);
return
false
;
}
layer
.
confirm
(
'确定导出数据吗?'
,
{
title
:
'导出数据'
,
btn
:
[
'确定'
,
'取消'
]
},
function
(){
layer
.
closeAll
(
'dialog'
);
// 确定时关闭弹框
window
.
location
.
href
=
url
+
'?account='
+
account
+
'&goods_name='
+
goods_name
+
'&order_sn='
+
order_sn
+
'&begin_time='
+
begin_time
+
'&end_time='
+
end_time
;
});
})
});
\ No newline at end of file
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