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
da4d7eed
Commit
da4d7eed
authored
Jul 23, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产挂载到不同目录
parent
8c0fa746
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
141 additions
and
22 deletions
+141
-22
AssetTable.jsx
src/view/Manage/AssetManage/Component/AssetTable.jsx
+24
-1
AssetTree.jsx
src/view/Manage/AssetManage/Component/AssetTree.jsx
+80
-3
AssetMount.jsx
src/view/Manage/AssetRecycle/Component/AssetMount.jsx
+37
-18
No files found.
src/view/Manage/AssetManage/Component/AssetTable.jsx
View file @
da4d7eed
import
React
,{
useState
,
useEffect
,
useRef
}
from
"react"
;
import
React
,{
useState
,
useEffect
,
useRef
}
from
"react"
;
import
{
Card
,
Checkbox
,
Button
,
List
,
Pagination
,
Space
,
Modal
,
Switch
,
Tooltip
,
Popover
,
Input
,
Spin
}
from
"antd"
;
import
{
Card
,
Checkbox
,
Button
,
List
,
Pagination
,
Space
,
Modal
,
Switch
,
Tooltip
,
Popover
,
Input
,
Spin
}
from
"antd"
;
import
{
EditOutlined
,
ReconciliationOutlined
,
DeleteOutlined
}
from
'@ant-design/icons'
;
import
{
EditOutlined
,
ReconciliationOutlined
,
DeleteOutlined
,
UndoOutlined
}
from
'@ant-design/icons'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
AutoSizer
from
'react-virtualized/dist/commonjs/AutoSizer'
;
import
AutoSizer
from
'react-virtualized/dist/commonjs/AutoSizer'
;
import
VList
from
'react-virtualized/dist/commonjs/List'
;
import
VList
from
'react-virtualized/dist/commonjs/List'
;
...
@@ -8,6 +8,7 @@ import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs
...
@@ -8,6 +8,7 @@ import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs
import
ImportElement
from
'./ImportElement'
;
import
ImportElement
from
'./ImportElement'
;
import
FilterElement
from
'./FilterElement'
;
import
FilterElement
from
'./FilterElement'
;
import
AssetMount
from
'../../AssetRecycle/Component/AssetMount'
;
import
ImportAsset
from
'./ImportAsset'
;
import
ImportAsset
from
'./ImportAsset'
;
import
AssetEdit
from
'./AssetEdit'
;
import
AssetEdit
from
'./AssetEdit'
;
import
AssetDetail
from
"./AssetDetail"
;
import
AssetDetail
from
"./AssetDetail"
;
...
@@ -33,6 +34,7 @@ const AssetTable = (props) => {
...
@@ -33,6 +34,7 @@ const AssetTable = (props) => {
const
[
filterElementVisible
,
setFilterElementVisible
]
=
useState
(
false
);
const
[
filterElementVisible
,
setFilterElementVisible
]
=
useState
(
false
);
const
[
assetEditVisible
,
setAssetEditVisible
]
=
useState
(
false
);
const
[
assetEditVisible
,
setAssetEditVisible
]
=
useState
(
false
);
const
[
assetDetailVisible
,
setAssetDetailVisible
]
=
useState
(
false
);
const
[
assetDetailVisible
,
setAssetDetailVisible
]
=
useState
(
false
);
const
[
assetMountVisible
,
setAssetMountVisible
]
=
useState
(
false
);
const
[
currentAssetId
,
setCurrentAssetId
]
=
useState
(
''
);
const
[
currentAssetId
,
setCurrentAssetId
]
=
useState
(
''
);
const
[
assetEditAction
,
setAssetEditAction
]
=
useState
(
''
);
const
[
assetEditAction
,
setAssetEditAction
]
=
useState
(
''
);
const
[
pagination
,
setPagination
]
=
useState
(
{
pageNum
:
1
,
pageSize
:
20
}
);
const
[
pagination
,
setPagination
]
=
useState
(
{
pageNum
:
1
,
pageSize
:
20
}
);
...
@@ -197,6 +199,16 @@ const AssetTable = (props) => {
...
@@ -197,6 +199,16 @@ const AssetTable = (props) => {
setAssetEditVisible(true);
setAssetEditVisible(true);
}
}
const mountAsset = (item) => {
setCurrentAssetId(item.id);
setAssetMountVisible(true);
}
const onAssetMountCancel = (refresh = false) => {
setAssetMountVisible(false);
refresh && getDataAssets();
}
const deleteAsset = (item) =>{
const deleteAsset = (item) =>{
modal.confirm({
modal.confirm({
title: '提示',
title: '提示',
...
@@ -456,6 +468,11 @@ const AssetTable = (props) => {
...
@@ -456,6 +468,11 @@ const AssetTable = (props) => {
<Button icon={<ReconciliationOutlined />} size='small' onClick={() => { detailAsset(item); }} />
<Button icon={<ReconciliationOutlined />} size='small' onClick={() => { detailAsset(item); }} />
</Tooltip>
</Tooltip>
{
{
!readOnly && <Tooltip placement='bottom' title={'挂载'}>
<Button icon={<UndoOutlined />} size='small' onClick={() => { mountAsset(item); }} />
</Tooltip>
}
{
!readOnly && <Tooltip placement='bottom' title={'删除'}>
!readOnly && <Tooltip placement='bottom' title={'删除'}>
<Button icon={<DeleteOutlined />} size='small' onClick={() => { deleteAsset(item); }} />
<Button icon={<DeleteOutlined />} size='small' onClick={() => { deleteAsset(item); }} />
</Tooltip>
</Tooltip>
...
@@ -513,6 +530,12 @@ const AssetTable = (props) => {
...
@@ -513,6 +530,12 @@ const AssetTable = (props) => {
nodeId={nodeId}
nodeId={nodeId}
onCancel={onImportAssetCancel}
onCancel={onImportAssetCancel}
/>
/>
<AssetMount
visible={ assetMountVisible }
id={ currentAssetId }
onCancel={ onAssetMountCancel }
{...props}
/>
{contextHolder}
{contextHolder}
</Card>
</Card>
)
)
...
...
src/view/Manage/AssetManage/Component/AssetTree.jsx
View file @
da4d7eed
...
@@ -13,12 +13,14 @@ import './AssetTree.less';
...
@@ -13,12 +13,14 @@ import './AssetTree.less';
const
AssetTree
=
(
props
)
=>
{
const
AssetTree
=
(
props
)
=>
{
const
{
readOnly
=
false
,
onSelect
,
className
}
=
props
;
const
{
readOnly
=
false
,
checkable
=
false
,
onSelect
,
className
,
onCheck
,
tableId
}
=
props
;
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
treeData
,
setTreeData
]
=
useState
([]);
const
[
treeData
,
setTreeData
]
=
useState
([]);
const
[
dataList
,
setDataList
]
=
useState
([]);
const
[
dataList
,
setDataList
]
=
useState
([]);
const
[
groupIds
,
setGroupIds
]
=
useState
([]);
const
[
expandedKeys
,
setExpandedKeys
]
=
useState
([]);
const
[
expandedKeys
,
setExpandedKeys
]
=
useState
([]);
const
[
checkedKeys
,
setCheckedKeys
]
=
useState
([]);
const
[
autoExpandParent
,
setAutoExpandParent
]
=
useState
(
false
);
const
[
autoExpandParent
,
setAutoExpandParent
]
=
useState
(
false
);
const
[
currentDirId
,
setCurrentDirId
]
=
useState
(
''
);
const
[
currentDirId
,
setCurrentDirId
]
=
useState
(
''
);
const
[
currentDirType
,
setCurrentDirType
]
=
useState
(
''
);
const
[
currentDirType
,
setCurrentDirType
]
=
useState
(
''
);
...
@@ -42,6 +44,11 @@ const AssetTree = (props) => {
...
@@ -42,6 +44,11 @@ const AssetTree = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
timestamp
])
},
[
timestamp
])
useEffect
(()
=>
{
getTableDirIds
();
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
tableId
])
const
getDataAssetLocationThenGetTreeData
=
()
=>
{
const
getDataAssetLocationThenGetTreeData
=
()
=>
{
setLoading
(
true
);
setLoading
(
true
);
dispatch
({
dispatch
({
...
@@ -58,6 +65,18 @@ const AssetTree = (props) => {
...
@@ -58,6 +65,18 @@ const AssetTree = (props) => {
});
});
}
}
const
getTableDirIds
=
()
=>
{
dispatch
({
type
:
'assetmanage.getDataAssetDetail'
,
payload
:
{
dataAssetId
:
tableId
},
callback
:
data
=>
{
setCheckedKeys
(
data
.
dirIds
||
[]);
},
})
}
const
getAllDirectoryAsTree
=
(
resetCurrentDirId
=
true
,
defaultSelectedId
=
''
)
=>
{
const
getAllDirectoryAsTree
=
(
resetCurrentDirId
=
true
,
defaultSelectedId
=
''
)
=>
{
setLoading
(
true
);
setLoading
(
true
);
if
(
resetCurrentDirId
)
{
if
(
resetCurrentDirId
)
{
...
@@ -70,9 +89,11 @@ const AssetTree = (props) => {
...
@@ -70,9 +89,11 @@ const AssetTree = (props) => {
setLoading
(
false
);
setLoading
(
false
);
setTreeData
(
data
);
setTreeData
(
data
);
const
_dataList
=
[];
const
_dataList
=
[]
,
_groupIds
=
[]
;
generateList
(
data
,
_dataList
);
generateList
(
data
,
_dataList
);
generateGroupIds
(
data
,
_groupIds
);
setDataList
(
_dataList
);
setDataList
(
_dataList
);
setGroupIds
(
_groupIds
);
let
defaultItem
=
null
;
let
defaultItem
=
null
;
...
@@ -143,6 +164,32 @@ const AssetTree = (props) => {
...
@@ -143,6 +164,32 @@ const AssetTree = (props) => {
}
}
};
};
const
generateGroupIds
=
(
treeData
,
list
)
=>
{
function
generateGroupItem
(
data
,
list
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
const
node
=
data
[
i
];
list
.
push
(
node
.
nodeId
);
if
(
node
.
children
)
{
generateGroupItem
(
node
.
children
,
list
);
}
}
}
for
(
let
i
=
0
;
i
<
treeData
.
length
;
i
++
)
{
const
node
=
treeData
[
i
];
const
{
nodeId
}
=
node
;
const
groupItem
=
[
nodeId
];
if
(
node
.
children
)
{
generateGroupItem
(
node
.
children
,
groupItem
);
}
list
.
push
(
groupItem
);
}
};
const
getParentKey
=
(
key
,
tree
)
=>
{
const
getParentKey
=
(
key
,
tree
)
=>
{
let
parentKey
;
let
parentKey
;
for
(
let
i
=
0
;
i
<
tree
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
tree
.
length
;
i
++
)
{
...
@@ -293,6 +340,32 @@ const AssetTree = (props) => {
...
@@ -293,6 +340,32 @@ const AssetTree = (props) => {
setCurrentDirType
(
getCurrentType
(
keys
[
0
],
treeData
));
setCurrentDirType
(
getCurrentType
(
keys
[
0
],
treeData
));
onSelect
&&
onSelect
(
keys
[
0
]);
onSelect
&&
onSelect
(
keys
[
0
]);
}
}
const
onTreeCheck
=
(
values
,
e
)
=>
{
const
_checkedKeysValue
=
[...(
values
.
checked
||
[])];
if
(
e
.
checked
)
{
const
_currentNodeId
=
e
.
node
?.
key
;
let
_groupItem
=
[];
groupIds
.
forEach
(
groupItem
=>
{
groupItem
.
forEach
(
id
=>
{
if
(
id
===
_currentNodeId
)
{
_groupItem
=
groupItem
;
}
})
})
const
_filterKeys
=
(
_checkedKeysValue
.
filter
(
item
=>
item
===
_currentNodeId
||
!
(
_groupItem
.
includes
(
item
))));
setCheckedKeys
(
_filterKeys
);
onCheck
&&
onCheck
(
_filterKeys
);
}
else
{
setCheckedKeys
(
_checkedKeysValue
);
onCheck
&&
onCheck
(
_checkedKeysValue
);
}
}
const
onExpand
=
(
expandedKeys
)
=>
{
const
onExpand
=
(
expandedKeys
)
=>
{
setExpandedKeys
(
expandedKeys
);
setExpandedKeys
(
expandedKeys
);
...
@@ -407,6 +480,7 @@ const AssetTree = (props) => {
...
@@ -407,6 +480,7 @@ const AssetTree = (props) => {
onChange=
{
(
e
)
=>
{
onChange
(
e
)
}
}
onChange=
{
(
e
)
=>
{
onChange
(
e
)
}
}
/>
/>
<
Tree
<
Tree
checkable=
{
checkable
}
showLine=
{
true
}
showLine=
{
true
}
showIcon=
{
false
}
showIcon=
{
false
}
onExpand=
{
onExpand
}
onExpand=
{
onExpand
}
...
@@ -415,7 +489,10 @@ const AssetTree = (props) => {
...
@@ -415,7 +489,10 @@ const AssetTree = (props) => {
treeData=
{
loop
(
treeData
)
}
treeData=
{
loop
(
treeData
)
}
selectedKeys=
{
[
currentDirId
||
''
]
}
selectedKeys=
{
[
currentDirId
||
''
]
}
onSelect=
{
onTreeSelect
}
onSelect=
{
onTreeSelect
}
/>
onCheck=
{
onTreeCheck
}
checkedKeys=
{
checkedKeys
}
checkStrictly
/>
</
Spin
>
</
Spin
>
<
UpdateDirectoryModal
<
UpdateDirectoryModal
...
...
src/view/Manage/AssetRecycle/Component/AssetMount.jsx
View file @
da4d7eed
...
@@ -8,11 +8,15 @@ import { showMessage } from '../../../../util';
...
@@ -8,11 +8,15 @@ import { showMessage } from '../../../../util';
const
AssetMount
=
(
props
)
=>
{
const
AssetMount
=
(
props
)
=>
{
const
{
onCancel
,
visible
,
id
}
=
props
;
const
{
onCancel
,
visible
,
id
}
=
props
;
const
[
nodeId
,
setNodeId
]
=
useState
(
null
);
const
[
ids
,
setIds
]
=
useState
([]
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
onCheck
=
(
values
)
=>
{
setIds
(
values
||
[]);
}
const
onOk
=
()
=>
{
const
onOk
=
()
=>
{
if
(
!
nodeId
)
{
if
(
(
ids
||
[]).
length
===
0
)
{
showMessage
(
'warn'
,
'请先选择资产目录'
);
showMessage
(
'warn'
,
'请先选择资产目录'
);
return
;
return
;
}
}
...
@@ -22,13 +26,14 @@ const AssetMount = (props) => {
...
@@ -22,13 +26,14 @@ const AssetMount = (props) => {
type
:
'assetmanage.loadDataAssets'
,
type
:
'assetmanage.loadDataAssets'
,
payload
:
{
payload
:
{
params
:
{
params
:
{
dirId
:
nodeId
,
dirId
:
ids
.
join
(
","
)
,
},
},
data
:
[
id
||
''
]
data
:
[
id
||
''
]
},
},
callback
:
data
=>
{
callback
:
data
=>
{
setConfirmLoading
(
false
);
setConfirmLoading
(
false
);
reset
();
onCancel
&&
onCancel
(
true
);
onCancel
&&
onCancel
(
true
);
},
},
error
:
()
=>
{
error
:
()
=>
{
...
@@ -37,21 +42,35 @@ const AssetMount = (props) => {
...
@@ -37,21 +42,35 @@ const AssetMount = (props) => {
})
})
}
}
const
reset
=
()
=>
{
setConfirmLoading
(
false
);
setIds
([]);
}
return
(
return
(
<
Modal
<
div
>
title=
'挂载详情'
{
visible=
{
visible
}
visible
&&
<
Modal
width=
{
400
}
title=
'挂载详情'
confirmLoading=
{
confirmLoading
}
visible=
{
visible
}
onCancel=
{
()
=>
{
onCancel
&&
onCancel
()}
}
width=
{
400
}
onOk=
{
onOk
}
confirmLoading=
{
confirmLoading
}
>
onCancel=
{
()
=>
{
<
AssetTree
reset
();
readOnly=
{
true
}
onCancel
&&
onCancel
()
onSelect=
{
(
value
)
=>
setNodeId
(
value
)
}
}
}
{
...
props
}
onOk=
{
onOk
}
/>
>
</
Modal
>
<
AssetTree
readOnly=
{
true
}
checkable=
{
true
}
onCheck=
{
onCheck
}
tableId=
{
id
}
{
...
props
}
/>
</
Modal
>
}
</
div
>
)
)
}
}
...
...
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