Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
front-backend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
front-backend
Commits
14aa13e7
Commit
14aa13e7
authored
Aug 26, 2019
by
dqjdda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增后端带条件导出功能(示例见用户管理控制器)
parent
52393ef5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
src/api/user.js
+7
-0
src/utils/index.js
+12
-0
src/views/system/user/index.vue
+7
-12
No files found.
src/api/user.js
View file @
14aa13e7
...
@@ -7,6 +7,13 @@ export function add(data) {
...
@@ -7,6 +7,13 @@ export function add(data) {
data
data
})
})
}
}
export
function
downloadUser
()
{
return
request
({
url
:
'api/users/download'
,
method
:
'get'
,
responseType
:
'blob'
})
}
export
function
del
(
id
)
{
export
function
del
(
id
)
{
return
request
({
return
request
({
...
...
src/utils/index.js
View file @
14aa13e7
...
@@ -147,3 +147,15 @@ export function removeClass(ele, cls) {
...
@@ -147,3 +147,15 @@ export function removeClass(ele, cls) {
ele
.
className
=
ele
.
className
.
replace
(
reg
,
' '
)
ele
.
className
=
ele
.
className
.
replace
(
reg
,
' '
)
}
}
}
}
export
function
downloadFile
(
obj
,
name
,
suffix
)
{
const
url
=
window
.
URL
.
createObjectURL
(
new
Blob
([
obj
]))
const
link
=
document
.
createElement
(
'a'
)
link
.
style
.
display
=
'none'
link
.
href
=
url
const
fileName
=
parseTime
(
new
Date
())
+
'-'
+
name
+
'.'
+
suffix
link
.
setAttribute
(
'download'
,
fileName
)
document
.
body
.
appendChild
(
link
)
link
.
click
()
document
.
body
.
removeChild
(
link
)
}
src/views/system/user/index.vue
View file @
14aa13e7
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
<!-- 导出 -->
<!-- 导出 -->
<div
style=
"display: inline-block;"
>
<div
style=
"display: inline-block;"
>
<el-button
<el-button
v-permission=
"['ADMIN']"
v-permission=
"['ADMIN'
,'USER_ALL','USER_SELECT'
]"
:loading=
"downloadLoading"
:loading=
"downloadLoading"
size=
"mini"
size=
"mini"
class=
"filter-item"
class=
"filter-item"
...
@@ -98,9 +98,9 @@
...
@@ -98,9 +98,9 @@
import
checkPermission
from
'@/utils/permission'
import
checkPermission
from
'@/utils/permission'
import
initData
from
'@/mixins/initData'
import
initData
from
'@/mixins/initData'
import
initDict
from
'@/mixins/initDict'
import
initDict
from
'@/mixins/initDict'
import
{
del
}
from
'@/api/user'
import
{
del
,
downloadUser
}
from
'@/api/user'
import
{
getDepts
}
from
'@/api/dept'
import
{
getDepts
}
from
'@/api/dept'
import
{
parseTime
}
from
'@/utils/index'
import
{
parseTime
,
downloadFile
}
from
'@/utils/index'
import
eForm
from
'./form'
import
eForm
from
'./form'
export
default
{
export
default
{
components
:
{
eForm
},
components
:
{
eForm
},
...
@@ -192,15 +192,10 @@ export default {
...
@@ -192,15 +192,10 @@ export default {
// 导出
// 导出
download
()
{
download
()
{
this
.
downloadLoading
=
true
this
.
downloadLoading
=
true
import
(
'@/utils/export2Excel'
).
then
(
excel
=>
{
downloadUser
().
then
(
result
=>
{
const
tHeader
=
[
'ID'
,
'用户名'
,
'邮箱'
,
'头像地址'
,
'状态'
,
'注册日期'
,
'最后修改密码日期'
]
downloadFile
(
result
,
'用户列表'
,
'xls'
)
const
filterVal
=
[
'id'
,
'username'
,
'email'
,
'avatar'
,
'enabled'
,
'createTime'
,
'lastPasswordResetTime'
]
this
.
downloadLoading
=
false
const
data
=
this
.
formatJson
(
filterVal
,
this
.
data
)
}).
catch
(()
=>
{
excel
.
export_json_to_excel
({
header
:
tHeader
,
data
,
filename
:
'table-list'
})
this
.
downloadLoading
=
false
this
.
downloadLoading
=
false
})
})
},
},
...
...
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