Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
merchant-manage-ui
Commits
4212a03a
Commit
4212a03a
authored
Sep 16, 2022
by
武广
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/serviceGoodsDrag' into 'master'
Feature/service goods drag See merge request
!48
parents
0842ec3b
5e37a5c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
2 deletions
+75
-2
common.less
src/pages/ServiceGoods/common.less
+31
-0
UploadImage.jsx
src/pages/ServiceGoods/components/UploadImage.jsx
+44
-2
No files found.
src/pages/ServiceGoods/common.less
View file @
4212a03a
...
@@ -81,3 +81,34 @@
...
@@ -81,3 +81,34 @@
top: 30px;
top: 30px;
right: 40px;
right: 40px;
}
}
.sortImg {
position: relative;
display: inline-block;
width: 105px;
height: 105px;
margin-right: 10px;
margin-bottom: 10px;
padding: 9px;
border: 1px solid #ddd;
border-radius: 6px;
}
.mask {
position: absolute;
top: 9px;
right: 9px;
bottom: 9px;
left: 9px;
padding-top: 27%;
text-align: center;
// width: 100%;
// height: 100%;
background: #000;
opacity: 0.5;
}
.maskIcon {
margin-right: 5px;
color: #efefef;
font-size: 16px;
cursor: pointer;
}
src/pages/ServiceGoods/components/UploadImage.jsx
View file @
4212a03a
import
{
PlusOutlined
}
from
'
@ant-design/icons
'
;
import
{
PlusOutlined
,
DeleteOutlined
,
EyeOutlined
}
from
'
@ant-design/icons
'
;
import
{
Modal
,
Upload
,
notification
,
Spin
,
Button
}
from
'
antd
'
;
import
{
Modal
,
Upload
,
notification
,
Spin
,
Icon
,
Button
}
from
'
antd
'
;
import
React
,
{
useState
,
useEffect
,
useRef
,
forwardRef
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
,
useRef
,
forwardRef
}
from
'
react
'
;
import
lodash
from
'
lodash
'
;
import
lodash
from
'
lodash
'
;
import
{
ReactSortable
}
from
'
react-sortablejs
'
;
import
{
merchantUpload
}
from
'
../service
'
;
import
{
merchantUpload
}
from
'
../service
'
;
import
styles
from
'
../common.less
'
;
const
MAX_FILE_SIZE
=
5
;
const
MAX_FILE_SIZE
=
5
;
const
UNIT
=
1024
*
1024
;
const
UNIT
=
1024
*
1024
;
...
@@ -38,6 +40,7 @@ const UploadImage = forwardRef((props, ref) => {
...
@@ -38,6 +40,7 @@ const UploadImage = forwardRef((props, ref) => {
const
[
previewImage
,
setPreviewImage
]
=
useState
(
''
);
const
[
previewImage
,
setPreviewImage
]
=
useState
(
''
);
const
[
previewTitle
,
setPreviewTitle
]
=
useState
(
''
);
const
[
previewTitle
,
setPreviewTitle
]
=
useState
(
''
);
const
[
fileList
,
setFileList
]
=
useState
([]);
const
[
fileList
,
setFileList
]
=
useState
([]);
const
[
activeImgIndex
,
setActiveImgIndex
]
=
useState
(
null
);
const
fileListRef
=
useRef
([]);
const
fileListRef
=
useRef
([]);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -151,6 +154,44 @@ const UploadImage = forwardRef((props, ref) => {
...
@@ -151,6 +154,44 @@ const UploadImage = forwardRef((props, ref) => {
return
(
return
(
<
Spin
tip=
"正在上传..."
spinning=
{
uploadLoading
}
delay=
{
100
}
>
<
Spin
tip=
"正在上传..."
spinning=
{
uploadLoading
}
delay=
{
100
}
>
<
div
className=
{
styles
.
imgContent
}
>
{
fileList
.
length
>
0
&&
(
<
ReactSortable
animation=
{
300
}
list=
{
fileList
}
setList=
{
list
=>
bundleChange
(
list
)
}
>
{
fileList
.
map
((
item
,
index
)
=>
(
<
div
// eslint-disable-next-line react/no-array-index-key
key=
{
index
}
className=
{
styles
.
sortImg
}
onMouseEnter=
{
()
=>
setActiveImgIndex
(
index
)
}
onMouseLeave=
{
()
=>
setActiveImgIndex
(
null
)
}
>
<
div
style=
{
{
width
:
'
100%
'
,
height
:
'
100%
'
,
overflow
:
'
hidden
'
}
}
>
<
img
width=
"100%"
key=
{
item
.
uid
}
src=
{
item
.
url
}
alt=
""
/>
</
div
>
{
activeImgIndex
===
index
&&
(
<
div
className=
{
styles
.
mask
}
>
{
/* <Icon
type="eye"
className={styles.maskIcon}
onClick={() => handlePreview(item)}
/> */
}
<
EyeOutlined
className=
{
styles
.
maskIcon
}
onClick=
{
()
=>
handlePreview
(
item
)
}
/>
<
DeleteOutlined
className=
{
styles
.
maskIcon
}
onClick=
{
()
=>
handleRemove
(
item
)
}
/>
{
/* <Icon
type="delete"
className={styles.maskIcon}
onClick={() => handleRemove(item)}
/> */
}
</
div
>
)
}
</
div
>
))
}
</
ReactSortable
>
)
}
</
div
>
<
Upload
<
Upload
{
...
uploadParams
}
{
...
uploadParams
}
disabled=
{
Boolean
(
disabled
)
}
disabled=
{
Boolean
(
disabled
)
}
...
@@ -162,6 +203,7 @@ const UploadImage = forwardRef((props, ref) => {
...
@@ -162,6 +203,7 @@ const UploadImage = forwardRef((props, ref) => {
fileList=
{
fileList
}
fileList=
{
fileList
}
onPreview=
{
handlePreview
}
onPreview=
{
handlePreview
}
onRemove=
{
handleRemove
}
onRemove=
{
handleRemove
}
showUploadList=
{
false
}
>
>
{
limit
!==
null
&&
fileList
.
length
>=
limit
?
null
:
UploadButton
}
{
limit
!==
null
&&
fileList
.
length
>=
limit
?
null
:
UploadButton
}
</
Upload
>
</
Upload
>
...
...
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