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
1d71d2cc
Commit
1d71d2cc
authored
Nov 24, 2019
by
dqjdda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
b428376e
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
155 additions
and
447 deletions
+155
-447
src/api/tools/localStorage.js
+1
-8
src/api/tools/picture.js
+1
-8
src/api/tools/qiniu.js
+1
-8
src/mixins/crud.js
+36
-0
src/views/tools/picture/index.vue
+19
-88
src/views/tools/storage/local/form.vue
+0
-123
src/views/tools/storage/local/index.vue
+67
-103
src/views/tools/storage/qiniu/form.vue
+0
-1
src/views/tools/storage/qiniu/index.vue
+30
-108
No files found.
src/api/tools/localStorage.js
View file @
1d71d2cc
...
@@ -31,11 +31,4 @@ export function edit(data) {
...
@@ -31,11 +31,4 @@ export function edit(data) {
})
})
}
}
export
function
downloadStorage
(
params
)
{
export
default
{
add
,
edit
,
del
,
delAll
}
return
request
({
url
:
'api/localStorage/download'
,
method
:
'get'
,
params
,
responseType
:
'blob'
})
}
src/api/tools/picture.js
View file @
1d71d2cc
...
@@ -15,11 +15,4 @@ export function delAll(ids) {
...
@@ -15,11 +15,4 @@ export function delAll(ids) {
})
})
}
}
export
function
downloadPicture
(
params
)
{
export
default
{
del
,
delAll
}
return
request
({
url
:
'api/pictures/download'
,
method
:
'get'
,
params
,
responseType
:
'blob'
})
}
src/api/tools/qiniu.js
View file @
1d71d2cc
...
@@ -44,11 +44,4 @@ export function delAll(ids) {
...
@@ -44,11 +44,4 @@ export function delAll(ids) {
})
})
}
}
export
function
downloadQiNiu
(
params
)
{
export
default
{
del
,
download
,
sync
,
delAll
}
return
request
({
url
:
'api/qiNiuContent/download/list'
,
method
:
'get'
,
params
,
responseType
:
'blob'
})
}
src/mixins/crud.js
View file @
1d71d2cc
...
@@ -31,6 +31,7 @@ export default {
...
@@ -31,6 +31,7 @@ export default {
loading
:
true
,
loading
:
true
,
// 删除 Loading 属性
// 删除 Loading 属性
delLoading
:
false
,
delLoading
:
false
,
delAllLoading
:
false
,
// 弹窗属性
// 弹窗属性
dialog
:
false
,
dialog
:
false
,
// Form 表单
// Form 表单
...
@@ -171,6 +172,41 @@ export default {
...
@@ -171,6 +172,41 @@ export default {
afterDelMethod
()
{
afterDelMethod
()
{
},
},
/**
/**
* 多选删除提示
*/
beforeDelAllMethod
()
{
this
.
$confirm
(
'你确定删除选中的数据吗?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
delAllMethod
()
})
},
/**
* 多选删除
*/
delAllMethod
()
{
this
.
delAllLoading
=
true
const
data
=
this
.
$refs
.
table
.
selection
const
ids
=
[]
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
ids
.
push
(
data
[
i
].
id
)
}
this
.
crudMethod
.
delAll
(
ids
).
then
(()
=>
{
this
.
delAllLoading
=
false
this
.
dleChangePage
(
ids
.
length
)
this
.
init
()
this
.
$notify
({
title
:
'删除成功'
,
type
:
'success'
,
duration
:
2500
})
}).
catch
(()
=>
{
this
.
delAllLoading
=
false
})
},
/**
* 显示新增弹窗前可以调用该方法
* 显示新增弹窗前可以调用该方法
*/
*/
beforeShowAddForm
()
{
beforeShowAddForm
()
{
...
...
src/views/tools/picture/index.vue
View file @
1d71d2cc
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<!--搜索-->
<!--搜索-->
<el-input
v-model=
"query.filename"
clearable
size=
"small"
placeholder=
"输入文件名"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"toQuery"
/>
<el-input
v-model=
"query.filename"
clearable
size=
"small"
placeholder=
"输入文件名"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"toQuery"
/>
<el-date-picker
<el-date-picker
v-model=
"query.
dat
e"
v-model=
"query.
createTim
e"
:default-time=
"['00:00:00','23:59:59']"
:default-time=
"['00:00:00','23:59:59']"
type=
"daterange"
type=
"daterange"
range-separator=
":"
range-separator=
":"
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
/>
/>
<el-button
class=
"filter-item"
size=
"mini"
type=
"success"
icon=
"el-icon-search"
@
click=
"toQuery"
>
搜索
</el-button>
<el-button
class=
"filter-item"
size=
"mini"
type=
"success"
icon=
"el-icon-search"
@
click=
"toQuery"
>
搜索
</el-button>
<!-- 上传 -->
<!-- 上传 -->
<div
style=
"display: inline-block;margin: 0px 2px;"
>
<el-button
<el-button
v-permission=
"['admin','pictures:add']"
v-permission=
"['admin','pictures:add']"
class=
"filter-item"
class=
"filter-item"
...
@@ -26,18 +25,16 @@
...
@@ -26,18 +25,16 @@
icon=
"el-icon-upload"
icon=
"el-icon-upload"
@
click=
"dialog = true"
@
click=
"dialog = true"
>
上传图片
</el-button>
>
上传图片
</el-button>
</div>
<div
v-permission=
"['admin','pictures:del']"
style=
"display: inline-block;"
>
<el-button
<el-button
v-permission=
"['admin','pictures:del']"
:loading=
"delAllLoading"
:loading=
"delAllLoading"
:disabled=
"data.length === 0 || $refs.table.selection.length === 0"
:disabled=
"data.length === 0 || $refs.table.selection.length === 0"
class=
"filter-item"
class=
"filter-item"
size=
"mini"
size=
"mini"
type=
"danger"
type=
"danger"
icon=
"el-icon-delete"
icon=
"el-icon-delete"
@
click=
"open
"
@
click=
"beforeDelAllMethod
"
>
删除
</el-button>
>
删除
</el-button>
</div>
<!-- 导出 -->
<!-- 导出 -->
<div
style=
"display: inline-block;"
>
<div
style=
"display: inline-block;"
>
<el-button
<el-button
...
@@ -46,7 +43,7 @@
...
@@ -46,7 +43,7 @@
class=
"filter-item"
class=
"filter-item"
type=
"warning"
type=
"warning"
icon=
"el-icon-download"
icon=
"el-icon-download"
@
click=
"download"
@
click=
"download
Method
"
>
导出
</el-button>
>
导出
</el-button>
</div>
</div>
</div>
</div>
...
@@ -77,8 +74,14 @@
...
@@ -77,8 +74,14 @@
<el-table-column
prop=
"filename"
label=
"文件名"
/>
<el-table-column
prop=
"filename"
label=
"文件名"
/>
<el-table-column
prop=
"username"
label=
"上传者"
/>
<el-table-column
prop=
"username"
label=
"上传者"
/>
<el-table-column
ref=
"table"
:show-overflow-tooltip=
"true"
prop=
"url"
label=
"缩略图"
>
<el-table-column
ref=
"table"
:show-overflow-tooltip=
"true"
prop=
"url"
label=
"缩略图"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"
{row}">
<a
:href=
"scope.row.url"
style=
"color: #42b983"
target=
"_blank"
><img
:src=
"scope.row.url"
alt=
"点击打开"
class=
"el-avatar"
></a>
<el-image
:src=
"row.url"
:preview-src-list=
"[row.url]"
fit=
"contain"
lazy
class=
"el-avatar"
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
prop=
"size"
label=
"文件大小"
/>
<el-table-column
prop=
"size"
label=
"文件大小"
/>
...
@@ -99,7 +102,7 @@
...
@@ -99,7 +102,7 @@
<p>
确定删除本条数据吗?
</p>
<p>
确定删除本条数据吗?
</p>
<div
style=
"text-align: right; margin: 0"
>
<div
style=
"text-align: right; margin: 0"
>
<el-button
size=
"mini"
type=
"text"
@
click=
"$refs[scope.row.id].doClose()"
>
取消
</el-button>
<el-button
size=
"mini"
type=
"text"
@
click=
"$refs[scope.row.id].doClose()"
>
取消
</el-button>
<el-button
:loading=
"delLoading"
type=
"primary"
size=
"mini"
@
click=
"
subDelete
(scope.row.id)"
>
确定
</el-button>
<el-button
:loading=
"delLoading"
type=
"primary"
size=
"mini"
@
click=
"
delMethod
(scope.row.id)"
>
确定
</el-button>
</div>
</div>
<el-button
slot=
"reference"
type=
"danger"
icon=
"el-icon-delete"
size=
"mini"
/>
<el-button
slot=
"reference"
type=
"danger"
icon=
"el-icon-delete"
size=
"mini"
/>
</el-popover>
</el-popover>
...
@@ -119,23 +122,20 @@
...
@@ -119,23 +122,20 @@
</template>
</template>
<
script
>
<
script
>
import
checkPermission
from
'@/utils/permission'
// 权限判断函数
import
crud
from
'@/mixins/crud'
import
initData
from
'@/mixins/initData'
import
{
parseTime
,
downloadFile
}
from
'@/utils/index'
import
{
mapGetters
}
from
'vuex'
import
{
mapGetters
}
from
'vuex'
import
{
del
,
delAll
,
downloadPicture
}
from
'@/api/tools/picture'
import
crudPic
from
'@/api/tools/picture'
import
{
getToken
}
from
'@/utils/auth'
import
{
getToken
}
from
'@/utils/auth'
export
default
{
export
default
{
name
:
'Pictures'
,
name
:
'Pictures'
,
mixins
:
[
initData
],
mixins
:
[
crud
],
data
()
{
data
()
{
return
{
return
{
delLoading
:
false
,
title
:
'图片'
,
delAllLoading
:
false
,
crudMethod
:
{
...
crudPic
}
,
headers
:
{
headers
:
{
'Authorization'
:
'Bearer '
+
getToken
()
'Authorization'
:
'Bearer '
+
getToken
()
},
},
dialog
:
false
,
dialogImageUrl
:
''
,
dialogImageUrl
:
''
,
dialogVisible
:
false
,
dialogVisible
:
false
,
fileList
:
[],
fileList
:
[],
...
@@ -153,69 +153,10 @@ export default {
...
@@ -153,69 +153,10 @@ export default {
})
})
},
},
methods
:
{
methods
:
{
parseTime
,
checkPermission
,
beforeInit
()
{
beforeInit
()
{
this
.
url
=
'api/pictures'
this
.
url
=
'api/pictures'
const
sort
=
'id,desc'
const
query
=
this
.
query
const
filename
=
query
.
filename
this
.
params
=
{
page
:
this
.
page
,
size
:
this
.
size
,
sort
:
sort
}
if
(
filename
)
{
this
.
params
[
filename
]
=
filename
}
if
(
query
.
date
)
{
this
.
params
[
'startTime'
]
=
query
.
date
[
0
]
this
.
params
[
'endTime'
]
=
query
.
date
[
1
]
}
return
true
return
true
},
},
subDelete
(
id
)
{
this
.
delLoading
=
true
del
(
id
).
then
(
res
=>
{
this
.
delLoading
=
false
this
.
$refs
[
id
].
doClose
()
this
.
dleChangePage
()
this
.
init
()
this
.
$notify
({
title
:
'删除成功'
,
type
:
'success'
,
duration
:
2500
})
}).
catch
(
err
=>
{
this
.
delLoading
=
false
this
.
$refs
[
id
].
doClose
()
console
.
log
(
err
.
response
.
data
.
message
)
})
},
doDelete
()
{
this
.
delAllLoading
=
true
const
data
=
this
.
$refs
.
table
.
selection
const
ids
=
[]
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
ids
.
push
(
data
[
i
].
id
)
}
delAll
(
ids
).
then
(
res
=>
{
this
.
delAllLoading
=
false
this
.
init
()
this
.
dleChangePage
(
ids
.
length
)
this
.
$notify
({
title
:
'删除成功'
,
type
:
'success'
,
duration
:
2500
})
}).
catch
(
err
=>
{
this
.
delAllLoading
=
false
console
.
log
(
err
.
response
.
data
.
message
)
})
},
open
()
{
this
.
$confirm
(
'你确定删除选中的数据吗?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
doDelete
()
})
},
handleSuccess
(
response
,
file
,
fileList
)
{
handleSuccess
(
response
,
file
,
fileList
)
{
const
uid
=
file
.
uid
const
uid
=
file
.
uid
const
id
=
response
.
id
const
id
=
response
.
id
...
@@ -224,7 +165,7 @@ export default {
...
@@ -224,7 +165,7 @@ export default {
handleBeforeRemove
(
file
,
fileList
)
{
handleBeforeRemove
(
file
,
fileList
)
{
for
(
let
i
=
0
;
i
<
this
.
pictures
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
pictures
.
length
;
i
++
)
{
if
(
this
.
pictures
[
i
].
uid
===
file
.
uid
)
{
if
(
this
.
pictures
[
i
].
uid
===
file
.
uid
)
{
del
(
this
.
pictures
[
i
].
id
).
then
(
res
=>
{})
this
.
crudMethod
.
del
(
this
.
pictures
[
i
].
id
).
then
(
res
=>
{})
return
true
return
true
}
}
}
}
...
@@ -249,16 +190,6 @@ export default {
...
@@ -249,16 +190,6 @@ export default {
type
:
'error'
,
type
:
'error'
,
duration
:
2500
duration
:
2500
})
})
},
download
()
{
this
.
beforeInit
()
this
.
downloadLoading
=
true
downloadPicture
(
this
.
params
).
then
(
result
=>
{
downloadFile
(
result
,
'图片列表'
,
'xlsx'
)
this
.
downloadLoading
=
false
}).
catch
(()
=>
{
this
.
downloadLoading
=
false
})
}
}
}
}
}
}
...
...
src/views/tools/storage/local/form.vue
deleted
100644 → 0
View file @
b428376e
<
template
>
<el-dialog
:append-to-body=
"true"
:close-on-click-modal=
"false"
:before-close=
"cancel"
:visible
.
sync=
"dialog"
:title=
"isAdd ? '上传文件' : '编辑文件'"
width=
"500px"
>
<el-form
ref=
"form"
:model=
"form"
:rules=
"rules"
size=
"small"
label-width=
"80px"
>
<el-form-item
label=
"文件名"
>
<el-input
v-model=
"form.name"
style=
"width: 370px;"
/>
</el-form-item>
<!-- 上传文件 -->
<el-form-item
v-if=
"isAdd"
label=
"上传"
>
<el-upload
ref=
"upload"
:limit=
"1"
:before-upload=
"beforeUpload"
:auto-upload=
"false"
:headers=
"headers"
:on-success=
"handleSuccess"
:on-error=
"handleError"
:action=
"fileUploadApi + '?name=' + form.name"
>
<div
class=
"eladmin-upload"
><i
class=
"el-icon-upload"
/>
添加文件
</div>
<div
slot=
"tip"
class=
"el-upload__tip"
>
可上传任意格式文件,且不超过100M
</div>
</el-upload>
</el-form-item>
</el-form>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
type=
"text"
@
click=
"cancel"
>
取消
</el-button>
<el-button
:loading=
"loading"
type=
"primary"
@
click=
"doSubmit"
>
确认
</el-button>
</div>
</el-dialog>
</
template
>
<
script
>
import
{
mapGetters
}
from
'vuex'
import
{
getToken
}
from
'@/utils/auth'
import
{
edit
}
from
'@/api/tools/localStorage'
export
default
{
props
:
{
isAdd
:
{
type
:
Boolean
,
required
:
true
}
},
data
()
{
return
{
loading
:
false
,
dialog
:
false
,
headers
:
{
'Authorization'
:
'Bearer '
+
getToken
()
},
form
:
{
id
:
''
,
name
:
''
},
rules
:
{
}
}
},
computed
:
{
...
mapGetters
([
'fileUploadApi'
])
},
methods
:
{
cancel
()
{
this
.
resetForm
()
},
doSubmit
()
{
this
.
loading
=
true
if
(
this
.
isAdd
)
{
this
.
$refs
.
upload
.
submit
()
}
else
this
.
doEdit
()
},
doEdit
()
{
edit
(
this
.
form
).
then
(
res
=>
{
this
.
resetForm
()
this
.
$notify
({
title
:
'修改成功'
,
type
:
'success'
,
duration
:
2500
})
this
.
loading
=
false
this
.
$parent
.
init
()
}).
catch
(
err
=>
{
this
.
loading
=
false
console
.
log
(
err
.
response
.
data
.
message
)
})
},
resetForm
()
{
this
.
dialog
=
false
this
.
$refs
[
'form'
].
resetFields
()
this
.
form
=
{
id
:
''
,
name
:
''
}
},
beforeUpload
(
file
)
{
let
isLt2M
=
true
isLt2M
=
file
.
size
/
1024
/
1024
<
100
if
(
!
isLt2M
)
{
this
.
$message
.
error
(
'上传文件大小不能超过 100MB!'
)
}
this
.
loading
=
false
return
isLt2M
},
handleSuccess
(
response
,
file
,
fileList
)
{
this
.
dialog
=
false
this
.
resetForm
()
this
.
$refs
.
upload
.
clearFiles
()
this
.
$parent
.
init
()
},
// 监听上传失败
handleError
(
e
,
file
,
fileList
)
{
const
msg
=
JSON
.
parse
(
e
.
message
)
this
.
$notify
({
title
:
msg
.
message
,
type
:
'error'
,
duration
:
2500
})
this
.
loading
=
false
}
}
}
</
script
>
<
style
scoped
>
</
style
>
src/views/tools/storage/local/index.vue
View file @
1d71d2cc
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
<!--工具栏-->
<!--工具栏-->
<div
class=
"head-container"
>
<div
class=
"head-container"
>
<!-- 搜索 -->
<!-- 搜索 -->
<el-input
v-model=
"query.
value
"
clearable
size=
"small"
placeholder=
"输入内容模糊搜索"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"toQuery"
/>
<el-input
v-model=
"query.
blurry
"
clearable
size=
"small"
placeholder=
"输入内容模糊搜索"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"toQuery"
/>
<el-date-picker
<el-date-picker
v-model=
"query.
dat
e"
v-model=
"query.
createTim
e"
:default-time=
"['00:00:00','23:59:59']"
:default-time=
"['00:00:00','23:59:59']"
type=
"daterange"
type=
"daterange"
range-separator=
":"
range-separator=
":"
...
@@ -17,19 +17,16 @@
...
@@ -17,19 +17,16 @@
/>
/>
<el-button
class=
"filter-item"
size=
"mini"
type=
"success"
icon=
"el-icon-search"
@
click=
"toQuery"
>
搜索
</el-button>
<el-button
class=
"filter-item"
size=
"mini"
type=
"success"
icon=
"el-icon-search"
@
click=
"toQuery"
>
搜索
</el-button>
<!-- 新增 -->
<!-- 新增 -->
<div
style=
"display: inline-block;margin: 0px 2px;"
>
<el-button
<el-button
v-permission=
"['admin','storage:add']"
v-permission=
"['admin','storage:add']"
class=
"filter-item"
class=
"filter-item"
size=
"mini"
size=
"mini"
type=
"primary"
type=
"primary"
icon=
"el-icon-upload"
icon=
"el-icon-upload"
@
click=
"add
"
@
click=
"showAddFormDialog
"
>
文件上传
>
文件上传
</el-button>
</el-button>
</div>
<!-- 多选删除 -->
<!-- 多选删除 -->
<div
style=
"display: inline-block;margin: 0px 2px;"
>
<el-button
<el-button
v-permission=
"['admin','storage:del']"
v-permission=
"['admin','storage:del']"
:loading=
"delAllLoading"
:loading=
"delAllLoading"
...
@@ -38,24 +35,47 @@
...
@@ -38,24 +35,47 @@
size=
"mini"
size=
"mini"
type=
"danger"
type=
"danger"
icon=
"el-icon-delete"
icon=
"el-icon-delete"
@
click=
"open
"
@
click=
"beforeDelAllMethod
"
>
删除
>
删除
</el-button>
</el-button>
</div>
<!-- 导出 -->
<!-- 导出 -->
<div
style=
"display: inline-block;"
>
<el-button
<el-button
:loading=
"downloadLoading"
:loading=
"downloadLoading"
size=
"mini"
size=
"mini"
class=
"filter-item"
class=
"filter-item"
type=
"warning"
type=
"warning"
icon=
"el-icon-download"
icon=
"el-icon-download"
@
click=
"downloa
d"
@
click=
"downloadMetho
d"
>
导出
</el-button>
>
导出
</el-button>
</div>
</div>
</div>
<!--表单组件-->
<!--表单组件-->
<eForm
ref=
"form"
:is-add=
"isAdd"
/>
<el-dialog
:append-to-body=
"true"
:close-on-click-modal=
"false"
:before-close=
"cancel"
:visible
.
sync=
"dialog"
:title=
"getFormTitle()"
width=
"500px"
>
<el-form
ref=
"form"
:model=
"form"
size=
"small"
label-width=
"80px"
>
<el-form-item
label=
"文件名"
>
<el-input
v-model=
"form.name"
style=
"width: 370px;"
/>
</el-form-item>
<!-- 上传文件 -->
<el-form-item
v-if=
"isAdd"
label=
"上传"
>
<el-upload
ref=
"upload"
:limit=
"1"
:before-upload=
"beforeUpload"
:auto-upload=
"false"
:headers=
"headers"
:on-success=
"handleSuccess"
:on-error=
"handleError"
:action=
"fileUploadApi + '?name=' + form.name"
>
<div
class=
"eladmin-upload"
><i
class=
"el-icon-upload"
/>
添加文件
</div>
<div
slot=
"tip"
class=
"el-upload__tip"
>
可上传任意格式文件,且不超过100M
</div>
</el-upload>
</el-form-item>
</el-form>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
type=
"text"
@
click=
"cancel"
>
取消
</el-button>
<el-button
:loading=
"loading"
type=
"primary"
@
click=
"submitMethod"
>
确认
</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<!--表格渲染-->
<el-table
ref=
"table"
v-loading=
"loading"
:data=
"data"
size=
"small"
style=
"width: 100%;"
>
<el-table
ref=
"table"
v-loading=
"loading"
:data=
"data"
size=
"small"
style=
"width: 100%;"
>
<el-table-column
type=
"selection"
width=
"55"
/>
<el-table-column
type=
"selection"
width=
"55"
/>
...
@@ -106,7 +126,7 @@
...
@@ -106,7 +126,7 @@
</el-table-column>
</el-table-column>
<el-table-column
v-if=
"checkPermission(['admin','storage:edit','storage:del'])"
label=
"操作"
width=
"150px"
align=
"center"
>
<el-table-column
v-if=
"checkPermission(['admin','storage:edit','storage:del'])"
label=
"操作"
width=
"150px"
align=
"center"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<el-button
v-permission=
"['admin','storage:edit']"
size=
"mini"
type=
"primary"
icon=
"el-icon-edit"
@
click=
"
edit
(scope.row)"
/>
<el-button
v-permission=
"['admin','storage:edit']"
size=
"mini"
type=
"primary"
icon=
"el-icon-edit"
@
click=
"
showEditFormDialog
(scope.row)"
/>
<el-popover
<el-popover
:ref=
"scope.row.id"
:ref=
"scope.row.id"
v-permission=
"['admin','storage:del']"
v-permission=
"['admin','storage:del']"
...
@@ -116,7 +136,7 @@
...
@@ -116,7 +136,7 @@
<p>
确定删除本条数据吗?
</p>
<p>
确定删除本条数据吗?
</p>
<div
style=
"text-align: right; margin: 0"
>
<div
style=
"text-align: right; margin: 0"
>
<el-button
size=
"mini"
type=
"text"
@
click=
"$refs[scope.row.id].doClose()"
>
取消
</el-button>
<el-button
size=
"mini"
type=
"text"
@
click=
"$refs[scope.row.id].doClose()"
>
取消
</el-button>
<el-button
:loading=
"delLoading"
type=
"primary"
size=
"mini"
@
click=
"
subDelete
(scope.row.id)"
>
确定
<el-button
:loading=
"delLoading"
type=
"primary"
size=
"mini"
@
click=
"
delMethod
(scope.row.id)"
>
确定
</el-button>
</el-button>
</div>
</div>
<el-button
slot=
"reference"
type=
"danger"
icon=
"el-icon-delete"
size=
"mini"
/>
<el-button
slot=
"reference"
type=
"danger"
icon=
"el-icon-delete"
size=
"mini"
/>
...
@@ -138,28 +158,24 @@
...
@@ -138,28 +158,24 @@
<
script
>
<
script
>
import
{
mapGetters
}
from
'vuex'
import
{
mapGetters
}
from
'vuex'
import
checkPermission
from
'@/utils/permission'
import
{
getToken
}
from
'@/utils/auth'
import
initData
from
'@/mixins/initData'
import
crud
from
'@/mixins/crud'
import
{
del
,
delAll
,
downloadStorage
}
from
'@/api/tools/localStorage'
import
crudFile
from
'@/api/tools/localStorage'
import
{
parseTime
,
downloadFile
}
from
'@/utils/index'
import
eForm
from
'./form'
export
default
{
export
default
{
components
:
{
eForm
},
mixins
:
[
crud
],
mixins
:
[
initData
],
data
()
{
data
()
{
return
{
return
{
delLoading
:
false
,
delAllLoading
:
false
,
title
:
'文件'
,
queryTypeOptions
:
[
crudMethod
:
{
...
crudFile
},
{
key
:
'name'
,
display_name
:
'文件名'
},
delAllLoading
:
false
,
{
key
:
'suffix'
,
display_name
:
'后缀'
},
headers
:
{
'Authorization'
:
'Bearer '
+
getToken
()
},
{
key
:
'type'
,
display_name
:
'类型'
},
form
:
{
id
:
null
,
name
:
null
}
{
key
:
'operate'
,
display_name
:
'操作人'
}
]
}
}
},
},
computed
:
{
computed
:
{
...
mapGetters
([
...
mapGetters
([
'baseApi'
'baseApi'
,
'fileUploadApi'
])
])
},
},
created
()
{
created
()
{
...
@@ -168,91 +184,39 @@ export default {
...
@@ -168,91 +184,39 @@ export default {
})
})
},
},
methods
:
{
methods
:
{
parseTime
,
// 获取数据前设置好接口地址
checkPermission
,
beforeInit
()
{
beforeInit
()
{
this
.
url
=
'api/localStorage'
this
.
url
=
'api/localStorage'
const
sort
=
'id,desc'
this
.
params
=
{
page
:
this
.
page
,
size
:
this
.
size
,
sort
:
sort
}
const
query
=
this
.
query
const
value
=
query
.
value
if
(
value
)
{
this
.
params
[
'blurry'
]
=
value
}
if
(
query
.
date
)
{
this
.
params
[
'startTime'
]
=
query
.
date
[
0
]
this
.
params
[
'endTime'
]
=
query
.
date
[
1
]
}
return
true
return
true
},
},
subDelete
(
id
)
{
// 上传文件
this
.
delLoading
=
true
addMethod
()
{
del
(
id
).
then
(
res
=>
{
this
.
$refs
.
upload
.
submit
()
this
.
delLoading
=
false
this
.
$refs
[
id
].
doClose
()
this
.
dleChangePage
()
this
.
init
()
this
.
$notify
({
title
:
'删除成功'
,
type
:
'success'
,
duration
:
2500
})
}).
catch
(
err
=>
{
this
.
delLoading
=
false
this
.
$refs
[
id
].
doClose
()
console
.
log
(
err
.
response
.
data
.
message
)
})
},
add
()
{
this
.
isAdd
=
true
this
.
$refs
.
form
.
dialog
=
true
},
},
edit
(
data
)
{
beforeUpload
(
file
)
{
this
.
isAdd
=
false
let
isLt2M
=
true
const
_this
=
this
.
$refs
.
form
isLt2M
=
file
.
size
/
1024
/
1024
<
100
_this
.
form
=
{
if
(
!
isLt2M
)
{
id
:
data
.
id
,
this
.
$message
.
error
(
'上传文件大小不能超过 100MB!'
)
name
:
data
.
name
}
}
_this
.
dialog
=
true
this
.
loading
=
false
return
isLt2M
},
},
doDelete
()
{
handleSuccess
(
response
,
file
,
fileList
)
{
this
.
delAllLoading
=
true
this
.
dialog
=
false
const
data
=
this
.
$refs
.
table
.
selection
this
.
cancel
()
const
ids
=
[]
this
.
$refs
.
upload
.
clearFiles
()
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
ids
.
push
(
data
[
i
].
id
)
}
delAll
(
ids
).
then
(
res
=>
{
this
.
delAllLoading
=
false
this
.
dleChangePage
(
ids
.
length
)
this
.
init
()
this
.
init
()
},
// 监听上传失败
handleError
(
e
,
file
,
fileList
)
{
const
msg
=
JSON
.
parse
(
e
.
message
)
this
.
$notify
({
this
.
$notify
({
title
:
'删除成功'
,
title
:
msg
.
message
,
type
:
'success
'
,
type
:
'error
'
,
duration
:
2500
duration
:
2500
})
})
}).
catch
(
err
=>
{
this
.
loading
=
false
this
.
delAllLoading
=
false
console
.
log
(
err
.
response
.
data
.
message
)
})
},
open
()
{
this
.
$confirm
(
'你确定删除选中的数据吗?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
doDelete
()
})
},
download
()
{
this
.
beforeInit
()
this
.
downloadLoading
=
true
downloadStorage
(
this
.
params
).
then
(
result
=>
{
downloadFile
(
result
,
'文件列表'
,
'xlsx'
)
this
.
downloadLoading
=
false
}).
catch
(()
=>
{
this
.
downloadLoading
=
false
})
}
}
}
}
}
}
...
...
src/views/tools/storage/qiniu/form.vue
View file @
1d71d2cc
<
template
>
<
template
>
<!--上传图片-->
<el-dialog
:visible
.
sync=
"dialog"
:close-on-click-modal=
"false"
title=
"七牛云配置"
append-to-body
width=
"580px"
>
<el-dialog
:visible
.
sync=
"dialog"
:close-on-click-modal=
"false"
title=
"七牛云配置"
append-to-body
width=
"580px"
>
<el-form
ref=
"form"
:model=
"form"
:rules=
"rules"
style=
"margin-top: 6px;"
size=
"small"
label-width=
"110px"
>
<el-form
ref=
"form"
:model=
"form"
:rules=
"rules"
style=
"margin-top: 6px;"
size=
"small"
label-width=
"110px"
>
<el-form-item
label=
"Access Key"
prop=
"accessKey"
>
<el-form-item
label=
"Access Key"
prop=
"accessKey"
>
...
...
src/views/tools/storage/qiniu/index.vue
View file @
1d71d2cc
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
<!-- 工具栏 -->
<!-- 工具栏 -->
<div
class=
"head-container"
>
<div
class=
"head-container"
>
<!-- 搜索 -->
<!-- 搜索 -->
<el-input
v-model=
"query.
value
"
clearable
size=
"small"
placeholder=
"输入文件名称搜索"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"toQuery"
/>
<el-input
v-model=
"query.
key
"
clearable
size=
"small"
placeholder=
"输入文件名称搜索"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"toQuery"
/>
<el-date-picker
<el-date-picker
v-model=
"query.
date
"
v-model=
"query.
c
"
:default-time=
"['00:00:00','23:59:59']"
:default-time=
"['00:00:00','23:59:59']"
type=
"daterange"
type=
"daterange"
range-separator=
":"
range-separator=
":"
...
@@ -19,13 +19,10 @@
...
@@ -19,13 +19,10 @@
/>
/>
<el-button
class=
"filter-item"
size=
"mini"
type=
"success"
icon=
"el-icon-search"
@
click=
"toQuery"
>
搜索
</el-button>
<el-button
class=
"filter-item"
size=
"mini"
type=
"success"
icon=
"el-icon-search"
@
click=
"toQuery"
>
搜索
</el-button>
<!-- 上传 -->
<!-- 上传 -->
<div
style=
"display: inline-block;margin: 0px 2px;"
>
<el-button
class=
"filter-item"
size=
"mini"
type=
"primary"
icon=
"el-icon-upload"
@
click=
"dialog = true"
>
上传文件
</el-button>
<el-button
class=
"filter-item"
size=
"mini"
type=
"primary"
icon=
"el-icon-upload"
@
click=
"dialog = true"
>
上传文件
</el-button>
</div>
<!-- 同步 -->
<!-- 同步 -->
<el-button
:icon=
"icon"
class=
"filter-item"
size=
"mini"
type=
"warning"
@
click=
"synchronize"
>
同步数据
</el-button>
<el-button
:icon=
"icon"
class=
"filter-item"
size=
"mini"
type=
"warning"
@
click=
"synchronize"
>
同步数据
</el-button>
<!-- 配置 -->
<!-- 配置 -->
<div
style=
"display: inline-block;margin: 0px 2px;"
>
<el-button
<el-button
class=
"filter-item"
class=
"filter-item"
size=
"mini"
size=
"mini"
...
@@ -33,9 +30,7 @@
...
@@ -33,9 +30,7 @@
icon=
"el-icon-s-tools"
icon=
"el-icon-s-tools"
@
click=
"doConfig"
@
click=
"doConfig"
>
七牛配置
</el-button>
>
七牛配置
</el-button>
</div>
<!-- 多选删除 -->
<!-- 多选删除 -->
<div
style=
"display: inline-block;margin: 0px 2px;"
>
<el-button
<el-button
:loading=
"delAllLoading"
:loading=
"delAllLoading"
:disabled=
"data.length === 0 || $refs.table.selection.length === 0"
:disabled=
"data.length === 0 || $refs.table.selection.length === 0"
...
@@ -43,20 +38,17 @@
...
@@ -43,20 +38,17 @@
size=
"mini"
size=
"mini"
type=
"danger"
type=
"danger"
icon=
"el-icon-delete"
icon=
"el-icon-delete"
@
click=
"open
"
@
click=
"beforeDelAllMethod
"
>
删除
</el-button>
>
删除
</el-button>
</div>
<!-- 导出 -->
<!-- 导出 -->
<div
style=
"display: inline-block;"
>
<el-button
<el-button
:loading=
"downloadLoading"
:loading=
"downloadLoading"
size=
"mini"
size=
"mini"
class=
"filter-item"
class=
"filter-item"
type=
"warning"
type=
"warning"
icon=
"el-icon-download"
icon=
"el-icon-download"
@
click=
"downloadList
"
@
click=
"downloadMethod
"
>
导出
</el-button>
>
导出
</el-button>
</div>
<!-- 文件上传 -->
<!-- 文件上传 -->
<el-dialog
:visible
.
sync=
"dialog"
:close-on-click-modal=
"false"
append-to-body
width=
"500px"
@
close=
"doSubmit"
>
<el-dialog
:visible
.
sync=
"dialog"
:close-on-click-modal=
"false"
append-to-body
width=
"500px"
@
close=
"doSubmit"
>
<el-upload
<el-upload
...
@@ -103,7 +95,7 @@
...
@@ -103,7 +95,7 @@
<p>
确定删除本条数据吗?
</p>
<p>
确定删除本条数据吗?
</p>
<div
style=
"text-align: right; margin: 0"
>
<div
style=
"text-align: right; margin: 0"
>
<el-button
size=
"mini"
type=
"text"
@
click=
"$refs[scope.row.id].doClose()"
>
取消
</el-button>
<el-button
size=
"mini"
type=
"text"
@
click=
"$refs[scope.row.id].doClose()"
>
取消
</el-button>
<el-button
:loading=
"delLoading"
type=
"primary"
size=
"mini"
@
click=
"
subDelete
(scope.row.id)"
>
确定
</el-button>
<el-button
:loading=
"delLoading"
type=
"primary"
size=
"mini"
@
click=
"
delMethod
(scope.row.id)"
>
确定
</el-button>
</div>
</div>
<el-button
slot=
"reference"
type=
"danger"
icon=
"el-icon-delete"
size=
"mini"
/>
<el-button
slot=
"reference"
type=
"danger"
icon=
"el-icon-delete"
size=
"mini"
/>
</el-popover>
</el-popover>
...
@@ -124,21 +116,21 @@
...
@@ -124,21 +116,21 @@
</template>
</template>
<
script
>
<
script
>
import
initData
from
'@/mixins/initData'
import
crud
from
'@/mixins/crud'
import
{
del
,
download
,
sync
,
delAll
,
downloadQiNiu
}
from
'@/api/tools/qiniu'
import
crudQiNiu
from
'@/api/tools/qiniu'
import
{
parseTime
,
downloadFile
}
from
'@/utils/index'
import
{
mapGetters
}
from
'vuex'
import
{
mapGetters
}
from
'vuex'
import
{
getToken
}
from
'@/utils/auth'
import
{
getToken
}
from
'@/utils/auth'
import
eForm
from
'./form'
import
eForm
from
'./form'
export
default
{
export
default
{
components
:
{
eForm
},
components
:
{
eForm
},
mixins
:
[
initData
],
mixins
:
[
crud
],
data
()
{
data
()
{
return
{
return
{
icon
:
'el-icon-refresh'
,
delAllLoading
:
false
,
title
:
'文件'
,
crudMethod
:
{
...
crudQiNiu
},
icon
:
'el-icon-refresh'
,
url
:
''
,
headers
:
{
'Authorization'
:
'Bearer '
+
getToken
()
},
dialog
:
false
,
url
:
''
,
headers
:
{
'Authorization'
:
'Bearer '
+
getToken
()
},
dialog
:
false
,
dialogImageUrl
:
''
,
dialogVisible
:
false
,
fileList
:
[],
files
:
[],
dialogImageUrl
:
''
,
dialogVisible
:
false
,
fileList
:
[],
files
:
[],
newWin
:
null
newWin
:
null
,
downloadLoading
:
false
,
delLoading
:
false
}
}
},
},
computed
:
{
computed
:
{
...
@@ -158,54 +150,17 @@ export default {
...
@@ -158,54 +150,17 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
parseTime
,
// 获取数据前设置好接口地址
beforeInit
()
{
beforeInit
()
{
this
.
url
=
'api/qiNiuContent'
this
.
url
=
'api/qiNiuContent'
const
sort
=
'id,desc'
const
query
=
this
.
query
const
value
=
query
.
value
this
.
params
=
{
page
:
this
.
page
,
size
:
this
.
size
,
sort
:
sort
}
if
(
value
)
{
this
.
params
[
'key'
]
=
value
}
if
(
query
.
date
)
{
this
.
params
[
'startTime'
]
=
query
.
date
[
0
]
this
.
params
[
'endTime'
]
=
query
.
date
[
1
]
}
return
true
return
true
},
},
// 七牛云配置
doConfig
()
{
doConfig
()
{
const
_this
=
this
.
$refs
.
form
const
_this
=
this
.
$refs
.
form
_this
.
init
()
_this
.
init
()
_this
.
dialog
=
true
_this
.
dialog
=
true
},
},
subDelete
(
id
)
{
this
.
delLoading
=
true
del
(
id
).
then
(
res
=>
{
this
.
delLoading
=
false
this
.
$refs
[
id
].
doClose
()
this
.
init
()
this
.
$notify
({
title
:
'删除成功'
,
type
:
'success'
,
duration
:
2500
})
}).
catch
(
err
=>
{
this
.
delLoading
=
false
this
.
$refs
[
id
].
doClose
()
console
.
log
(
err
.
response
.
data
.
message
)
})
},
download
(
id
)
{
this
.
downloadLoading
=
true
// 先打开一个空的新窗口,再请求
this
.
newWin
=
window
.
open
()
download
(
id
).
then
(
res
=>
{
this
.
downloadLoading
=
false
this
.
url
=
res
.
url
}).
catch
(
err
=>
{
this
.
downloadLoading
=
false
console
.
log
(
err
.
response
.
data
.
message
)
})
},
handleSuccess
(
response
,
file
,
fileList
)
{
handleSuccess
(
response
,
file
,
fileList
)
{
const
uid
=
file
.
uid
const
uid
=
file
.
uid
const
id
=
response
.
id
const
id
=
response
.
id
...
@@ -214,7 +169,7 @@ export default {
...
@@ -214,7 +169,7 @@ export default {
handleBeforeRemove
(
file
,
fileList
)
{
handleBeforeRemove
(
file
,
fileList
)
{
for
(
let
i
=
0
;
i
<
this
.
files
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
files
.
length
;
i
++
)
{
if
(
this
.
files
[
i
].
uid
===
file
.
uid
)
{
if
(
this
.
files
[
i
].
uid
===
file
.
uid
)
{
del
(
this
.
files
[
i
].
id
).
then
(
res
=>
{})
this
.
crudMethod
.
del
(
this
.
files
[
i
].
id
).
then
(
res
=>
{})
return
true
return
true
}
}
}
}
...
@@ -234,18 +189,26 @@ export default {
...
@@ -234,18 +189,26 @@ export default {
// 监听上传失败
// 监听上传失败
handleError
(
e
,
file
,
fileList
)
{
handleError
(
e
,
file
,
fileList
)
{
const
msg
=
JSON
.
parse
(
e
.
message
)
const
msg
=
JSON
.
parse
(
e
.
message
)
this
.
$notify
({
this
.
notify
(
msg
.
message
,
'error'
)
title
:
msg
.
message
,
},
type
:
'error'
,
// 下载文件
duration
:
2500
download
(
id
)
{
this
.
downloadLoading
=
true
// 先打开一个空的新窗口,再请求
this
.
newWin
=
window
.
open
()
this
.
crudMethod
.
download
(
id
).
then
(
res
=>
{
this
.
downloadLoading
=
false
this
.
url
=
res
.
url
}).
catch
(
err
=>
{
this
.
downloadLoading
=
false
console
.
log
(
err
.
response
.
data
.
message
)
})
})
},
},
// 同步数据
synchronize
()
{
synchronize
()
{
this
.
icon
=
'el-icon-loading'
this
.
icon
=
'el-icon-loading'
this
.
buttonName
=
'同步中'
this
.
crudMethod
.
sync
().
then
(
res
=>
{
sync
().
then
(
res
=>
{
this
.
icon
=
'el-icon-refresh'
this
.
icon
=
'el-icon-refresh'
this
.
buttonName
=
'同步数据'
this
.
$message
({
this
.
$message
({
showClose
:
true
,
showClose
:
true
,
message
:
'数据同步成功'
,
message
:
'数据同步成功'
,
...
@@ -255,49 +218,8 @@ export default {
...
@@ -255,49 +218,8 @@ export default {
this
.
toQuery
()
this
.
toQuery
()
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
this
.
icon
=
'el-icon-refresh'
this
.
icon
=
'el-icon-refresh'
this
.
buttonName
=
'同步数据'
console
.
log
(
err
.
response
.
data
.
message
)
})
},
doDelete
()
{
this
.
delAllLoading
=
true
const
data
=
this
.
$refs
.
table
.
selection
const
ids
=
[]
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
ids
.
push
(
data
[
i
].
id
)
}
delAll
(
ids
).
then
(
res
=>
{
this
.
delAllLoading
=
false
this
.
dleChangePage
(
ids
.
length
)
this
.
init
()
this
.
$notify
({
title
:
'删除成功'
,
type
:
'success'
,
duration
:
2500
})
}).
catch
(
err
=>
{
this
.
delAllLoading
=
false
console
.
log
(
err
.
response
.
data
.
message
)
console
.
log
(
err
.
response
.
data
.
message
)
})
})
},
open
()
{
this
.
$confirm
(
'你确定删除选中的数据吗?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
doDelete
()
})
},
downloadList
()
{
this
.
beforeInit
()
this
.
downloadLoading
=
true
downloadQiNiu
(
this
.
params
).
then
(
result
=>
{
downloadFile
(
result
,
'七牛云文件列表'
,
'xlsx'
)
this
.
downloadLoading
=
false
}).
catch
(()
=>
{
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