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
d3e7851b
Commit
d3e7851b
authored
May 29, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产修改
parent
7a49b741
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
88 deletions
+86
-88
AssetAction.jsx
src/view/Manage/AssetManage/Component/AssetAction.jsx
+86
-88
No files found.
src/view/Manage/AssetManage/Component/AssetAction.jsx
View file @
d3e7851b
import
React
,
{
useEffect
,
useState
,
useContext
,
useMemo
,
useRef
}
from
'react'
;
import
{
Form
,
Spin
,
Input
,
Descriptions
,
Space
,
Button
,
Tooltip
,
Select
,
Cascader
,
Table
,
Radio
,
Divider
,
Typography
,
Modal
}
from
'antd'
;
import
{
DownOutlined
,
UpOutlined
}
from
'@ant-design/icons'
;
import
{
Form
,
Spin
,
Input
,
Descriptions
,
Space
,
Button
,
Tooltip
,
Select
,
Cascader
,
Table
,
Radio
,
Divider
,
Typography
,
Modal
,
Row
,
Col
}
from
'antd'
;
import
{
DownOutlined
,
UpOutlined
,
QuestionCircleOutlined
}
from
'@ant-design/icons'
;
import
MetadataInfo
from
'./MetadataInfo'
;
import
{
dispatch
}
from
'../../../../model'
;
...
...
@@ -27,6 +27,7 @@ const AssetAction = (props) => {
const
[
currentAction
,
setCurrentAction
]
=
useState
(
action
);
const
[
assetParams
,
setAssetParams
]
=
useState
({
assets
:
{},
attributes
:
[],
attributesFoldMap
:
{}
});
const
[
elements
,
setElements
]
=
useState
([]);
const
[
wholeElements
,
setWholeElements
]
=
useState
([]);
const
[
metadataId
,
setMetadataId
]
=
useState
(
''
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
...
...
@@ -44,7 +45,6 @@ const AssetAction = (props) => {
const
[
loadingDepartments
,
setLoadingDepartments
]
=
useState
(
false
);
const
[
treeData
,
setTreeData
]
=
useState
([]);
const
[
treeDataMap
,
setTreeDataMap
]
=
useState
(
undefined
);
const
[
businessData
,
setBusinessData
]
=
useState
(
undefined
);
const
[
currentDomainGroup
,
setCurrentDomainGroup
]
=
useState
(
undefined
);
const
[
canEdit
,
setEdit
]
=
useState
(
false
);
const
[
metadata
,
setMetadata
]
=
useState
(
undefined
);
...
...
@@ -178,10 +178,11 @@ const AssetAction = (props) => {
getTreeData
();
getDepartments
();
if
(
action
===
'add'
)
{
getElements
();
//
getElements();
}
else
{
setCurrentAction
(
'detail'
);
if
((
id
||
''
)
!==
''
)
{
getElements
();
getAssetPaths
();
getResourceRelations
();
checkDataAssetEditable
();
...
...
@@ -224,6 +225,52 @@ const AssetAction = (props) => {
return
[];
},
[
metadataColumnList
,
standardList
])
const
businessData
=
useMemo
(()
=>
{
if
(
assetPaths
?.
length
>
0
&&
treeData
?.
length
>
0
)
{
let
newBusinessData
=
[];
treeData
?.
forEach
(
level1Item
=>
{
const
businessItem
=
{
label
:
level1Item
.
text
,
value
:
level1Item
.
text
,
children
:
[]
};
let
flag
=
false
;
level1Item
.
children
?.
forEach
(
level2Item
=>
{
const
tempLevel2Item
=
{
label
:
level2Item
.
text
,
value
:
level2Item
.
text
,
children
:
[]
};
level2Item
.
children
?.
forEach
(
level3Item
=>
{
tempLevel2Item
.
children
.
push
({
label
:
level3Item
.
text
,
value
:
level3Item
.
text
,
});
if
(
level3Item
.
nodeId
===
assetPaths
[
0
].
dirId
)
{
flag
=
true
;
}
});
if
(
flag
&&
tempLevel2Item
.
children
.
length
!==
0
)
{
businessItem
.
children
.
push
(
tempLevel2Item
);
}
});
if
(
flag
&&
businessItem
.
children
.
length
!==
0
)
{
newBusinessData
.
push
(
businessItem
);
}
});
return
newBusinessData
;
}
return
[];
},
[
assetPaths
,
treeData
])
const
getAssetPaths
=
()
=>
{
dispatch
({
type
:
'assetmanage.getAssetPaths'
,
...
...
@@ -278,39 +325,6 @@ const AssetAction = (props) => {
newTreeDataMap
[
item
.
text
]
=
item
.
children
;
})
setTreeDataMap
(
newTreeDataMap
);
let
newBusinessData
=
[];
data
?.
forEach
(
level1Item
=>
{
const
businessItem
=
{
label
:
level1Item
.
text
,
value
:
level1Item
.
text
,
children
:
[]
};
level1Item
.
children
?.
forEach
(
level2Item
=>
{
const
tempLevel2Item
=
{
label
:
level2Item
.
text
,
value
:
level2Item
.
text
,
children
:
[]
};
level2Item
.
children
?.
forEach
(
level3Item
=>
{
tempLevel2Item
.
children
.
push
({
label
:
level3Item
.
text
,
value
:
level3Item
.
text
,
})
});
if
(
tempLevel2Item
.
children
.
length
!==
0
)
{
businessItem
.
children
.
push
(
tempLevel2Item
);
}
});
if
(
businessItem
.
children
.
length
!==
0
)
{
newBusinessData
.
push
(
businessItem
);
}
});
setBusinessData
(
newBusinessData
);
}
})
}
...
...
@@ -342,7 +356,6 @@ const AssetAction = (props) => {
}
const
getElements
=
(
cb
=
null
)
=>
{
setLoading
(
true
);
dispatch
({
type
:
(
currentAction
===
'add'
)?
'assetmanage.listElementsAndFillValue'
:
'assetmanage.listElements'
,
payload
:
(
currentAction
===
'add'
)?{
...
...
@@ -351,44 +364,7 @@ const AssetAction = (props) => {
}
}:
undefined
,
callback
:
data
=>
{
setLoading
(
false
);
setElements
(
data
||
[]);
onElementsChange
&&
onElementsChange
(
data
||
[]);
const
_attributes
=
[];
(
data
||
[]).
forEach
(
element
=>
{
if
(
_attributes
.
indexOf
(
element
.
type
)
===
-
1
)
{
_attributes
.
push
(
element
.
type
);
}
})
let
newAttributesFoldMap
=
{...
attributesFoldMap
};
(
_attributes
||
[]).
forEach
(
attribute
=>
{
if
(
newAttributesFoldMap
[
attribute
]
===
undefined
||
newAttributesFoldMap
[
attribute
]
===
null
)
{
newAttributesFoldMap
[
attribute
]
=
true
;
}
})
setAssetParams
({
assets
:
{},
attributes
:
_attributes
,
attributesFoldMap
:
newAttributesFoldMap
});
form
?.
resetFields
();
if
(
currentAction
===
'add'
)
{
let
newFiledsValue
=
{};
(
data
||
[]).
forEach
(
element
=>
{
if
(
element
.
defaultValue
)
{
newFiledsValue
[
element
.
name
]
=
element
.
defaultValue
}
});
form
?.
setFieldsValue
(
newFiledsValue
);
}
cb
&&
cb
();
},
error
:
()
=>
{
setLoading
(
false
);
setWholeElements
(
data
||
[]);
}
})
}
...
...
@@ -497,10 +473,10 @@ const AssetAction = (props) => {
const
getMetadataAttributes
=
()
=>
{
setMetadata
(
prevMetadata
=>
{
setLoadingMetadataColumnList
(
true
);
const
ids
=
prevMetadata
?.
columnItems
.
map
(
item
=>
item
.
metadataColumnId
);
if
((
ids
||
[]).
length
>
0
)
{
setLoadingMetadataColumnList
(
true
);
dispatch
({
type
:
'assetmanage.getMetadataAttributes'
,
payload
:
{
...
...
@@ -950,9 +926,15 @@ const AssetAction = (props) => {
<Divider orientation='left'>{attribute}</Divider>
<Descriptions column={1} bordered>
{
elements?.map((element, index) => {
wholeElements?.length>0 &&
elements?.map((element, index) => {
if (element.type!==attribute || element.name === '资产项') return null;
let interpretation = null;
const filterElements = wholeElements?.filter(_element => _element.id === element.id);
if (filterElements.length>0) {
interpretation = filterElements[0].interpretation;
}
return (
<Descriptions.Item
key={index}
...
...
@@ -967,14 +949,27 @@ const AssetAction = (props) => {
labelStyle={{ width: 180 }}
>
{
(currentAction==='add'||currentAction==='edit') ? <Form.Item
label=''
name={element.name}
rules={[{ required: element.required }]}
style={{ width: 500, marginBottom: 0 }}
>
{elementEditComponent(element)}
</Form.Item> : <React.Fragment>
(currentAction==='add'||currentAction==='edit') ?
<Row gutter={8}>
<Col span={22}>
<Form.Item
label=''
name={element.name}
rules={[{ required: element.required }]}
style={{ marginBottom: 0 }}
>
{elementEditComponent(element)}
</Form.Item>
</Col>
{
interpretation && <Col span={2}>
<Tooltip placement="left" title={interpretation}>
<QuestionCircleOutlined style={{ marginTop: 8, fontSize: 16 }} />
</Tooltip>
</Col>
}
</Row>
: <React.Fragment>
{ elementDetailComponent(element) }
</React.Fragment>
}
...
...
@@ -996,11 +991,14 @@ const AssetAction = (props) => {
</div>
<Space style={{ marginLeft: 'auto' }}>
{
{
/* {
(reference===AssetManageReference||canEdit) && <Button type='primary' onClick={() => {
uploadRef.current?.chooseFile()
}}>导入</Button>
}
} */}
<Button type='primary' onClick={() => {
uploadRef.current?.chooseFile()
}}>导入</Button>
<Button type='primary' onClick={onExportClick}>导出</Button>
</Space>
...
...
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