Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyang
sts网站
Commits
e852fdb6
Commit
e852fdb6
authored
Apr 30, 2025
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传组件新增拖动排序属性
parent
baf2f6f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
4 deletions
+49
-4
index.vue
ruoyi-ui/src/components/FileUpload/index.vue
+26
-1
index.vue
ruoyi-ui/src/components/ImageUpload/index.vue
+23
-3
No files found.
ruoyi-ui/src/components/FileUpload/index.vue
View file @
e852fdb6
...
...
@@ -43,6 +43,7 @@
<
script
>
import
{
getToken
}
from
"@/utils/auth"
import
Sortable
from
'sortablejs'
export
default
{
name
:
"FileUpload"
,
...
...
@@ -82,6 +83,11 @@ export default {
disabled
:
{
type
:
Boolean
,
default
:
false
},
// 拖动排序
drag
:
{
type
:
Boolean
,
default
:
true
}
},
data
()
{
...
...
@@ -93,7 +99,22 @@ export default {
headers
:
{
Authorization
:
"Bearer "
+
getToken
(),
},
fileList
:
[],
fileList
:
[]
}
},
mounted
()
{
if
(
this
.
drag
)
{
this
.
$nextTick
(()
=>
{
const
element
=
document
.
querySelector
(
'.upload-file-list'
)
Sortable
.
create
(
element
,
{
ghostClass
:
'file-upload-darg'
,
onEnd
:
(
evt
)
=>
{
const
movedItem
=
this
.
fileList
.
splice
(
evt
.
oldIndex
,
1
)[
0
]
this
.
fileList
.
splice
(
evt
.
newIndex
,
0
,
movedItem
)
this
.
$emit
(
"input"
,
this
.
listToString
(
this
.
fileList
))
}
})
})
}
},
watch
:
{
...
...
@@ -216,6 +237,10 @@ export default {
</
script
>
<
style
scoped
lang=
"scss"
>
.file-upload-darg
{
opacity
:
0
.5
;
background
:
#c8ebfb
;
}
.upload-file-uploader
{
margin-bottom
:
5px
;
}
...
...
ruoyi-ui/src/components/ImageUpload/index.vue
View file @
e852fdb6
...
...
@@ -46,6 +46,7 @@
<
script
>
import
{
getToken
}
from
"@/utils/auth"
import
{
isExternal
}
from
"@/utils/validate"
import
Sortable
from
'sortablejs'
export
default
{
props
:
{
...
...
@@ -62,22 +63,27 @@ export default {
// 图片数量限制
limit
:
{
type
:
Number
,
default
:
5
,
default
:
5
},
// 大小限制(MB)
fileSize
:
{
type
:
Number
,
default
:
5
,
default
:
5
},
// 文件类型, 例如['png', 'jpg', 'jpeg']
fileType
:
{
type
:
Array
,
default
:
()
=>
[
"png"
,
"jpg"
,
"jpeg"
]
,
default
:
()
=>
[
"png"
,
"jpg"
,
"jpeg"
]
},
// 是否显示提示
isShowTip
:
{
type
:
Boolean
,
default
:
true
},
// 拖动排序
drag
:
{
type
:
Boolean
,
default
:
true
}
},
data
()
{
...
...
@@ -95,6 +101,20 @@ export default {
fileList
:
[]
}
},
mounted
()
{
if
(
this
.
drag
)
{
this
.
$nextTick
(()
=>
{
const
element
=
document
.
querySelector
(
'.el-upload-list'
)
Sortable
.
create
(
element
,
{
onEnd
:
(
evt
)
=>
{
const
movedItem
=
this
.
fileList
.
splice
(
evt
.
oldIndex
,
1
)[
0
]
this
.
fileList
.
splice
(
evt
.
newIndex
,
0
,
movedItem
)
this
.
$emit
(
"input"
,
this
.
listToString
(
this
.
fileList
))
}
})
})
}
},
watch
:
{
value
:
{
handler
(
val
)
{
...
...
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