Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
bcb6f26f
Commit
bcb6f26f
authored
May 20, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产自定义
parent
20a592b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
17 deletions
+111
-17
AssetTree.jsx
src/view/Manage/AssetManage/Component/AssetTree.jsx
+3
-3
CustomDirectoryModal.jsx
...iew/Manage/AssetManage/Component/CustomDirectoryModal.jsx
+103
-12
DragTag.jsx
src/view/Manage/AssetManage/Component/DragTag.jsx
+5
-2
No files found.
src/view/Manage/AssetManage/Component/AssetTree.jsx
View file @
bcb6f26f
...
@@ -250,7 +250,7 @@ const AssetTree = (props) => {
...
@@ -250,7 +250,7 @@ const AssetTree = (props) => {
<
Card
<
Card
className=
{
classes
}
className=
{
classes
}
title=
{
readOnly
?
null
:
(
title=
{
readOnly
?
null
:
(
<
Space
>
<
Space
wrap
>
<
Tooltip
title=
"新增目录"
>
<
Tooltip
title=
"新增目录"
>
<
Button
shape=
"circle"
icon=
{
<
PlusOutlined
/>
}
onClick=
{
addDir
}
/>
<
Button
shape=
"circle"
icon=
{
<
PlusOutlined
/>
}
onClick=
{
addDir
}
/>
</
Tooltip
>
</
Tooltip
>
...
@@ -271,9 +271,9 @@ const AssetTree = (props) => {
...
@@ -271,9 +271,9 @@ const AssetTree = (props) => {
<
Tooltip
title=
"删除"
>
<
Tooltip
title=
"删除"
>
<
Button
shape=
"circle"
icon=
{
<
DeleteOutlined
/>
}
onClick=
{
deleteDir
}
/>
<
Button
shape=
"circle"
icon=
{
<
DeleteOutlined
/>
}
onClick=
{
deleteDir
}
/>
</
Tooltip
>
</
Tooltip
>
{
/*
<Tooltip title="自定义">
<
Tooltip
title=
"自定义"
>
<
Button
shape=
"circle"
icon=
{
<
SettingOutlined
/>
}
onClick=
{
customDir
}
/>
<
Button
shape=
"circle"
icon=
{
<
SettingOutlined
/>
}
onClick=
{
customDir
}
/>
</Tooltip>
*/
}
</
Tooltip
>
</
Space
>
</
Space
>
)
}
)
}
bordered=
{
false
}
bordered=
{
false
}
...
...
src/view/Manage/AssetManage/Component/CustomDirectoryModal.jsx
View file @
bcb6f26f
import
React
,
{
useState
,
useCallback
}
from
'react'
;
import
React
,
{
useState
,
useCallback
}
from
'react'
;
import
{
Modal
,
Tag
}
from
'antd'
;
import
{
Modal
,
Checkbox
,
Row
,
Col
,
Form
,
Input
,
Empty
}
from
'antd'
;
import
{
DndProvider
}
from
'react-dnd'
;
import
{
DndProvider
}
from
'react-dnd'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
update
from
'immutability-helper'
;
import
update
from
'immutability-helper'
;
...
@@ -39,20 +39,68 @@ const CustomDirectoryModal = (props) => {
...
@@ -39,20 +39,68 @@ const CustomDirectoryModal = (props) => {
text
:
'PROFIT'
,
text
:
'PROFIT'
,
},
},
]);
]);
const
[
checkedValues
,
setCheckedValues
]
=
useState
([]);
const
[
checkedData
,
setCheckedData
]
=
useState
([]);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
const
onChange
=
(
checkedValues
)
=>
{
setCheckedValues
(
checkedValues
);
const
_checkedData
=
[];
(
checkedValues
||
[]).
forEach
(
value
=>
{
(
data
||
[]).
forEach
(
item
=>
{
if
(
value
===
item
.
id
)
{
_checkedData
.
push
(
item
);
}
})
})
setCheckedData
(
_checkedData
);
}
const
moveTag
=
useCallback
((
dragIndex
,
hoverIndex
)
=>
{
const
moveTag
=
useCallback
((
dragIndex
,
hoverIndex
)
=>
{
const
dragTag
=
data
[
dragIndex
];
const
dragTag
=
checkedData
[
dragIndex
];
setData
(
update
(
data
,
{
const
newCheckedData
=
update
(
checkedData
,
{
$splice
:
[
$splice
:
[
[
dragIndex
,
1
],
[
dragIndex
,
1
],
[
hoverIndex
,
0
,
dragTag
],
[
hoverIndex
,
0
,
dragTag
],
],
],
}));
});
},
[
data
]);
const
newCheckedValues
=
[];
newCheckedData
.
forEach
(
item
=>
{
newCheckedValues
.
push
(
item
.
id
);
})
setCheckedData
(
newCheckedData
);
setCheckedValues
(
newCheckedValues
);
},
[
checkedData
]);
const
onTagClose
=
(
id
)
=>
{
const
newCheckedValues
=
[...
checkedValues
];
const
index
=
newCheckedValues
.
indexOf
(
id
);
if
(
index
!==
-
1
)
{
newCheckedValues
.
splice
(
index
,
1
);
onChange
(
newCheckedValues
);
}
}
const
renderItem
=
(
item
,
index
)
=>
{
const
renderItem
=
(
item
,
index
)
=>
{
return
(<
DragTag
key=
{
item
.
id
}
index=
{
index
}
id=
{
item
.
id
}
text=
{
item
.
text
}
moveTag=
{
moveTag
}
/>);
return
(<
DragTag
key=
{
item
.
id
}
index=
{
index
}
id=
{
item
.
id
}
text=
{
item
.
text
}
moveTag=
{
moveTag
}
onClose=
{
()
=>
{
onTagClose
(
item
.
id
)}
}
/>);
};
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
5
},
},
wrapperCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
17
},
},
};
};
return
(
return
(
...
@@ -60,14 +108,57 @@ const CustomDirectoryModal = (props) => {
...
@@ -60,14 +108,57 @@ const CustomDirectoryModal = (props) => {
forceRender
forceRender
title=
{
'新增自定义'
}
title=
{
'新增自定义'
}
visible=
{
visible
}
visible=
{
visible
}
width=
{
600
}
width=
{
800
}
confirmLoading=
{
confirmLoading
}
onCancel=
{
()
=>
{
onCancel
&&
onCancel
()
}
}
onCancel=
{
()
=>
{
onCancel
&&
onCancel
()
}
}
>
>
<
DndProvider
backend=
{
HTML5Backend
}
>
<
Row
gutter=
{
30
}
>
{
<
Col
span=
{
8
}
style=
{
{
borderRight
:
'1px solid #EFEFEF'
}
}
>
(
data
||
[]).
map
((
item
,
index
)
=>
renderItem
(
item
,
index
))
<
div
className=
'mb-3'
>
资产要素
</
div
>
}
<
Checkbox
.
Group
value=
{
checkedValues
}
onChange=
{
onChange
}
>
</
DndProvider
>
{
(
data
||
[]).
map
((
item
,
index
)
=>
{
return
(
<
Row
key=
{
index
}
>
<
Checkbox
value=
{
item
.
id
||
''
}
>
{
item
.
text
||
''
}
</
Checkbox
>
</
Row
>
);
})
}
</
Checkbox
.
Group
>
</
Col
>
<
Col
span=
{
16
}
>
{
(
checkedData
||
[]).
length
===
0
&&
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
description=
"暂无层级"
/>
}
{
(
checkedData
||
[]).
length
>
0
&&
<>
<
div
className=
'mb-3'
>
拖动可调整层级
</
div
>
<
DndProvider
backend=
{
HTML5Backend
}
>
{
(
checkedData
||
[]).
map
((
item
,
index
)
=>
renderItem
(
item
,
index
))
}
</
DndProvider
>
</>
}
<
Form
className=
'mt-5'
{
...
formItemLayout
}
form=
{
form
}
>
<
Form
.
Item
label=
'命名'
name=
'name'
rules=
{
[{
required
:
true
,
message
:
'请命名'
}]
}
>
<
Input
/>
</
Form
.
Item
>
<
Form
.
Item
label=
'描述或原因'
name=
'reason'
rules=
{
[{
required
:
true
,
message
:
'请输入描述或原因'
}]
}
>
<
Input
/>
</
Form
.
Item
>
</
Form
>
</
Col
>
</
Row
>
</
Modal
>
</
Modal
>
);
);
}
}
...
...
src/view/Manage/AssetManage/Component/DragTag.jsx
View file @
bcb6f26f
...
@@ -12,7 +12,7 @@ const style = {
...
@@ -12,7 +12,7 @@ const style = {
cursor
:
'move'
,
cursor
:
'move'
,
};
};
const
DragTag
=
({
id
,
text
,
index
,
moveTag
})
=>
{
const
DragTag
=
({
id
,
text
,
index
,
moveTag
,
onClose
})
=>
{
const
ref
=
useRef
(
null
);
const
ref
=
useRef
(
null
);
const
[{
handlerId
},
drop
]
=
useDrop
({
const
[{
handlerId
},
drop
]
=
useDrop
({
accept
:
type
,
accept
:
type
,
...
@@ -59,6 +59,7 @@ const DragTag = ({ id, text, index, moveTag }) => {
...
@@ -59,6 +59,7 @@ const DragTag = ({ id, text, index, moveTag }) => {
item
.
index
=
hoverIndex
;
item
.
index
=
hoverIndex
;
},
},
});
});
const
[{
isDragging
},
drag
]
=
useDrag
({
const
[{
isDragging
},
drag
]
=
useDrag
({
type
:
type
,
type
:
type
,
item
:
()
=>
{
item
:
()
=>
{
...
@@ -68,10 +69,12 @@ const DragTag = ({ id, text, index, moveTag }) => {
...
@@ -68,10 +69,12 @@ const DragTag = ({ id, text, index, moveTag }) => {
isDragging
:
monitor
.
isDragging
(),
isDragging
:
monitor
.
isDragging
(),
}),
}),
});
});
const
opacity
=
isDragging
?
0
:
1
;
const
opacity
=
isDragging
?
0
:
1
;
drag
(
drop
(
ref
));
drag
(
drop
(
ref
));
return
(
return
(
<
Tag
ref=
{
ref
}
style=
{
{
...
style
,
opacity
}
}
data
-
handler
-
id=
{
handlerId
}
closable
>
<
Tag
ref=
{
ref
}
style=
{
{
...
style
,
opacity
}
}
data
-
handler
-
id=
{
handlerId
}
closable
onClose=
{
()
=>
{
onClose
&&
onClose
()}
}
>
{
text
}
{
text
}
</
Tag
>
</
Tag
>
);
);
...
...
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