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
0020f2ca
Commit
0020f2ca
authored
Jun 09, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产
parent
fa425c05
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
292 additions
and
81 deletions
+292
-81
assetmanage.js
src/model/assetmanage.js
+20
-0
dataassetmanager.js
src/service/dataassetmanager.js
+20
-0
AssetTable.jsx
src/view/Manage/AssetManage/Component/AssetTable.jsx
+15
-2
AttributeRelationModal.jsx
...w/Manage/AssetManage/Component/AttributeRelationModal.jsx
+237
-79
No files found.
src/model/assetmanage.js
View file @
0020f2ca
...
...
@@ -165,10 +165,30 @@ export function* getRelAttrByModel(payload) {
return
yield
call
(
service
.
getRelAttrByModel
,
payload
);
}
export
function
*
listSourceModels
(
payload
)
{
return
yield
call
(
service
.
listSourceModels
,
payload
);
}
export
function
*
saveEleAndAttrRelWithSourceModel
(
payload
)
{
return
yield
call
(
service
.
saveEleAndAttrRelWithSourceModel
,
payload
);
}
export
function
*
getRelAttrBySourceModel
(
payload
)
{
return
yield
call
(
service
.
getRelAttrBySourceModel
,
payload
);
}
export
function
*
deleteRelAttrBySourceModel
(
payload
)
{
return
yield
call
(
service
.
deleteRelAttrBySourceModel
,
payload
);
}
export
function
*
fillElementValueBeforeCreate
(
payload
)
{
return
yield
call
(
service
.
fillElementValueBeforeCreate
,
payload
);
}
export
function
*
listSupportSourceModels
()
{
return
yield
call
(
service
.
listSupportSourceModels
)
}
export
function
*
countResourceState
(
payload
)
{
return
yield
call
(
service
.
countResourceState
,
payload
);
}
...
...
src/service/dataassetmanager.js
View file @
0020f2ca
...
...
@@ -172,10 +172,30 @@ export function getRelAttrByModel(payload) {
return
PostJSON
(
"/dataassetmanager/eleAndAttrApi/getRelAttrByModel"
,
payload
);
}
export
function
listSourceModels
()
{
return
GetJSON
(
"/dataassetmanager/eleAndAttrApi/listSourceModels"
)
}
export
function
saveEleAndAttrRelWithSourceModel
(
payload
)
{
return
PostJSON
(
"/dataassetmanager/eleAndAttrApi/saveEleAndAttrRelWithSourceModel"
,
payload
)
}
export
function
getRelAttrBySourceModel
(
payload
)
{
return
GetJSON
(
"/dataassetmanager/eleAndAttrApi/getRelAttrBySourceModel"
,
payload
)
}
export
function
deleteRelAttrBySourceModel
(
payload
)
{
return
PostJSON
(
"/dataassetmanager/eleAndAttrApi/delEleAndAttrRelWithSourceModel"
,
payload
)
}
export
function
fillElementValueBeforeCreate
(
payload
)
{
return
PostJSON
(
"/dataassetmanager/eleAndAttrApi/fillElementValueBeforeCreate"
,
payload
);
}
export
function
listSupportSourceModels
()
{
return
GetJSON
(
"/dataassetmanager/eleAndAttrApi/listSupportSourceModels"
);
}
export
function
countResourceState
(
payload
)
{
return
GetJSON
(
"/dataassetmanager/countApi/countResourceState"
,
payload
);
}
...
...
src/view/Manage/AssetManage/Component/AssetTable.jsx
View file @
0020f2ca
...
...
@@ -125,8 +125,6 @@ const AssetTable = (props) => {
id
:
MENU_ID
,
});
const
{
env
}
=
useContext
(
AppContext
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
columns
,
setColumns
]
=
useState
([]);
const
[
assets
,
setAssets
]
=
useState
([]);
...
...
@@ -158,6 +156,8 @@ const AssetTable = (props) => {
const
anchorId
=
getQueryParam
(
AnchorId
,
props
.
location
.
search
);
const
timestamp
=
getQueryParam
(
AnchorTimestamp
,
props
.
location
.
search
);
const
app
=
useContext
(
AppContext
);
const
{
env
}
=
app
;
const
shouldScrollRef
=
useRef
(
false
);
const
metadataIndexRef
=
useRef
(
''
);
...
...
@@ -672,6 +672,16 @@ const AssetTable = (props) => {
});
}
});
}
else
if
(
key
===
'authorization'
)
{
if
(
contextMenuItem
?.
metadata
?.
metadataTableId
)
{
console
.
log
(
'metadataTableId'
,
contextMenuItem
?.
metadata
?.
metadataTableId
);
app
?.
setGlobalState
&&
app
?.
setGlobalState
({
message
:
'data-govern-assets-admit'
,
data
:
contextMenuItem
})
}
else
{
showMessage
(
"warn"
,
"该资产没有关联元数据信息"
);
}
}
}
...
...
@@ -1005,6 +1015,9 @@ const AssetTable = (props) => {
转为非资产
</
RcItem
>
}
<
RcItem
id=
"authorization"
onClick=
{
handleItemClick
}
>
授权
</
RcItem
>
</
RcMenu
>
{
contextHolder
}
...
...
src/view/Manage/AssetManage/Component/AttributeRelationModal.jsx
View file @
0020f2ca
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Modal
,
Form
,
TreeSelect
,
Select
,
Space
,
Button
,
Row
,
Col
,
}
from
'antd'
;
import
React
,
{
useEffect
,
use
Memo
,
useRef
,
use
State
}
from
'react'
;
import
{
Modal
,
Form
,
TreeSelect
,
Select
,
Space
,
Button
,
Row
,
Col
,
Tabs
,
Spin
,
Input
}
from
'antd'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
showMessage
}
from
'../../../../util'
;
const
AddSourceModelName
=
'新增数据来源'
const
MetaModelSelect
=
({
value
=
{},
metaModelTreeData
=
[],
onChange
,
...
restProps
})
=>
{
const
[
attributes
,
setAttributes
]
=
useState
([]);
...
...
@@ -98,82 +101,79 @@ const MetaModelSelect = ({ value = {}, metaModelTreeData = [], onChange, ...rest
);
}
const
AttributeRelationModal
=
(
props
)
=>
{
const
{
visible
,
onCancel
}
=
props
;
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
AttributeRelationWithSourceModel
=
(
props
)
=>
{
const
{
elements
,
sourceModel
,
supportSourceModelsName
,
metadataModelTreeData
,
activeKey
,
onChange
}
=
props
;
const
[
metadataModelTreeData
,
setMetadataModelTreeData
]
=
useState
([]);
const
[
elements
,
setElements
]
=
useState
([]);
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
currentRelations
,
setCurrentRelations
]
=
useState
();
const
[
form
]
=
Form
.
useForm
();
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
()
useEffect
(()
=>
{
if
(
visible
)
{
getMetadataModelTree
();
if
(
sourceModel
)
{
getRelAttrBySourceModel
()
}
else
{
form
.
resetFields
()
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
visible
])
form
.
setFieldsValue
({
sourceModel
})
},
[
activeKey
,
sourceModel
])
const
getMetadataModelTree
=
()
=>
{
dispatch
({
type
:
'assetmanage.getMetadataModelTree'
,
callback
:
data
=>
{
let
newData
=
[...
data
];
function
recursion
(
_data
,
superKey
=
''
)
{
if
((
_data
||
[]).
length
===
0
)
return
;
(
_data
||
[]).
forEach
(
item
=>
{
item
.
title
=
item
.
nodeName
||
''
;
item
.
value
=
superKey
+
'/'
+
(
item
.
nodeName
||
''
);
recursion
(
item
.
children
,
item
.
value
);
useEffect
(()
=>
{
if
(
currentRelations
&&
elements
?.
length
>
0
)
{
let
newFiledsValue
=
{};
(
currentRelations
||
[]).
forEach
(
item
=>
{
newFiledsValue
[
item
.
elementId
]
=
{
model
:
item
.
model
,
modelValue
:
item
.
model
,
attrName
:
item
.
attrName
||
''
,
attrCnName
:
item
.
attrCnName
||
''
};
})
}
recursion
(
newData
);
setMetadataModelTreeData
(
newData
||
[]);
loadElementWithoutCustom
();
},
error
:
()
=>
{
}
});
form
.
setFieldsValue
(
newFiledsValue
);
}
},
[
currentRelations
,
elements
])
const
loadElementWithoutCustom
=
()
=>
{
const
getRelAttrBySourceModel
=
()
=>
{
setLoading
(
true
)
dispatch
({
type
:
'assetmanage.loadElementWithoutCustom'
,
type
:
'assetmanage.getRelAttrBySourceModel'
,
payload
:
{
sourceModel
},
callback
:
data
=>
{
set
Elements
(
data
||
[]);
getRelAttrByModel
();
set
Loading
(
false
)
setCurrentRelations
(
data
||
[])
},
error
:
()
=>
{
setLoading
(
false
)
}
});
}
const
getRelAttrByModel
=
()
=>
{
const
onDelete
=
()
=>
{
modal
.
confirm
({
title
:
'提示!'
,
content
:
'您确定要删除该来源模型名称吗?'
,
onOk
:
()
=>
{
dispatch
({
type
:
'assetmanage.getRelAttrByModel'
,
callback
:
data
=>
{
let
_fieldsValue
=
{};
(
data
||
[]).
forEach
(
item
=>
{
_fieldsValue
[
item
.
elementId
]
=
{
model
:
item
.
model
,
modelValue
:
item
.
model
,
attrName
:
item
.
attrName
||
''
,
attrCnName
:
item
.
attrCnName
||
''
};
})
form
.
setFieldsValue
(
_fieldsValue
);
type
:
'assetmanage.deleteRelAttrBySourceModel'
,
payload
:
{
params
:
{
sourceModel
}
},
callback
:
()
=>
{
showMessage
(
'success'
,
'删除成功'
)
onChange
?.(
'delete'
)
},
error
:
()
=>
{
}
});
}
});
}
const
onOk
=
async
()
=>
{
const
onOk
=
async
()
=>
{
try
{
const
row
=
await
form
.
validateFields
();
...
...
@@ -189,13 +189,17 @@ const AttributeRelationModal = (props) => {
setConfirmLoading
(
true
);
dispatch
({
type
:
'assetmanage.saveEleAndAttrRel'
,
type
:
'assetmanage.saveEleAndAttrRel
WithSourceModel
'
,
payload
:
{
data
:
newRels
data
:
newRels
,
params
:
{
sourceModel
:
row
.
sourceModel
,
}
},
callback
:
data
=>
{
reset
();
onCancel
&&
onCancel
();
showMessage
(
'success'
,
sourceModel
?
'更新成功'
:
'新增成功'
)
setConfirmLoading
(
false
);
onChange
?.(
'update'
,
row
.
sourceModel
)
},
error
:
()
=>
{
setConfirmLoading
(
false
);
...
...
@@ -208,11 +212,6 @@ const AttributeRelationModal = (props) => {
}
}
const
reset
=
()
=>
{
setConfirmLoading
(
false
);
form
.
resetFields
();
}
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
...
...
@@ -224,28 +223,35 @@ const AttributeRelationModal = (props) => {
},
};
return
(
<
Modal
forceRender
title=
{
'资产属性关联'
}
visible=
{
visible
}
width=
{
600
}
onCancel=
{
()
=>
{
reset
();
onCancel
&&
onCancel
()
}
}
footer=
{
return
<
Spin
spinning=
{
loading
}
>
<
div
className=
'mb-3'
style=
{
{
textAlign
:
'right'
}
}
>
<
Space
>
<
Button
onClick=
{
()
=>
{
reset
();
onCancel
&&
onCancel
();
}
}
>
返回
</
Button
>
<
Button
type=
"primary"
onClick=
{
onOk
}
loading=
{
confirmLoading
}
>
确定
</
Button
>
</
Space
>
{
sourceModel
&&
<
Button
type=
"primary"
danger
onClick=
{
()
=>
onDelete
()
}
>
删除
</
Button
>
}
<
Button
type=
"primary"
onClick=
{
()
=>
onOk
()
}
loading=
{
confirmLoading
}
>
确定
</
Button
>
</
Space
>
</
div
>
<
Form
form=
{
form
}
style=
{
{
maxHeight
:
400
,
overflow
:
'auto'
}
}
{
...
formItemLayout
}
>
<
Form
.
Item
label=
'来源模型名称'
name=
'sourceModel'
rules=
{
[{
required
:
true
,
message
:
'请输入来源名称'
}]
}
>
<
div
style=
{
{
maxHeight
:
500
,
overflow
:
'auto'
}
}
>
<
Form
form=
{
form
}
{
...
formItemLayout
}
>
<
Select
allowClear
placeholder=
'请选择来源模型名称'
disabled=
{
sourceModel
}
>
{
supportSourceModelsName
?.
map
((
name
,
index
)
=>
{
return
<
Select
.
Option
key=
{
index
}
value=
{
name
}
>
{
name
}
</
Select
.
Option
>
})
}
</
Select
>
</
Form
.
Item
>
{
(
elements
||
[]).
map
((
element
,
index
)
=>
{
return
(
...
...
@@ -262,7 +268,159 @@ const AttributeRelationModal = (props) => {
})
}
</
Form
>
</
div
>
{
contextHolder
}
</
Spin
>
}
const
AttributeRelationModal
=
(
props
)
=>
{
const
{
visible
,
onCancel
}
=
props
;
const
[
supportSourceModelsName
,
setSupportSourceModelsName
]
=
useState
()
const
[
loadingSourceModels
,
setLoadingSourceModels
]
=
useState
(
false
)
const
[
sourceModels
,
setSourceModels
]
=
useState
()
const
[
metadataModelTreeData
,
setMetadataModelTreeData
]
=
useState
([]);
const
[
elements
,
setElements
]
=
useState
([]);
const
[
activeKey
,
setActiveKey
]
=
useState
();
const
activeKeyRef
=
useRef
();
useEffect
(()
=>
{
if
(
visible
)
{
getSupportSourceModelsName
();
getSourceModels
();
loadElementWithoutCustom
();
getMetadataModelTree
();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
visible
])
const
tabData
=
useMemo
(()
=>
{
return
[...
sourceModels
||
[],
AddSourceModelName
]
},
[
sourceModels
])
const
getSupportSourceModelsName
=
()
=>
{
dispatch
({
type
:
'assetmanage.listSupportSourceModels'
,
callback
:
(
data
)
=>
{
console
.
log
(
'data'
,
data
)
setSupportSourceModelsName
(
data
||
[])
},
})
}
const
getSourceModels
=
()
=>
{
setLoadingSourceModels
(
true
)
dispatch
({
type
:
'assetmanage.listSourceModels'
,
callback
:
(
data
)
=>
{
setLoadingSourceModels
(
false
)
setSourceModels
(
data
||
[])
if
(
!
activeKeyRef
.
current
)
{
activeKeyRef
.
current
=
data
?.
length
>
0
?
data
[
0
]
:
AddSourceModelName
setActiveKey
(
data
?.
length
>
0
?
data
[
0
]
:
AddSourceModelName
)
}
else
if
(
activeKeyRef
.
current
!==
activeKey
)
{
setActiveKey
(
activeKeyRef
.
current
)
}
},
error
:
()
=>
{
setLoadingSourceModels
(
false
)
}
})
}
const
getMetadataModelTree
=
()
=>
{
dispatch
({
type
:
'assetmanage.getMetadataModelTree'
,
callback
:
data
=>
{
let
newData
=
[...
data
];
function
recursion
(
_data
,
superKey
=
''
)
{
if
((
_data
||
[]).
length
===
0
)
return
;
(
_data
||
[]).
forEach
(
item
=>
{
item
.
title
=
item
.
nodeName
||
''
;
item
.
value
=
superKey
+
'/'
+
(
item
.
nodeName
||
''
);
recursion
(
item
.
children
,
item
.
value
);
})
}
recursion
(
newData
);
setMetadataModelTreeData
(
newData
||
[]);
},
error
:
()
=>
{
}
});
}
const
loadElementWithoutCustom
=
()
=>
{
dispatch
({
type
:
'assetmanage.loadElementWithoutCustom'
,
callback
:
data
=>
{
setElements
(
data
||
[]);
},
error
:
()
=>
{
}
});
}
const
onTabsChange
=
(
value
)
=>
{
activeKeyRef
.
current
=
value
setActiveKey
(
value
)
}
const
onRelationChange
=
(
type
,
value
)
=>
{
if
(
type
===
'delete'
)
{
activeKeyRef
.
current
=
undefined
getSourceModels
()
}
else
if
(
type
===
'update'
)
{
activeKeyRef
.
current
=
value
getSourceModels
()
}
}
const
reset
=
()
=>
{
setActiveKey
(
undefined
);
}
return
(
<
Modal
forceRender
title=
{
'资产属性关联'
}
visible=
{
visible
}
width=
{
1000
}
onCancel=
{
()
=>
{
reset
();
onCancel
?.();
}
}
footer=
{
<
Space
>
<
Button
onClick=
{
()
=>
{
reset
();
onCancel
?.();
}
}
>
取消
</
Button
>
</
Space
>
}
>
<
Tabs
tabPosition=
'left'
activeKey=
{
activeKey
}
onChange=
{
onTabsChange
}
>
{
tabData
?.
map
((
item
,
i
)
=>
{
return
<
Tabs
.
TabPane
tab=
{
item
}
key=
{
item
}
>
<
AttributeRelationWithSourceModel
elements=
{
elements
}
supportSourceModelsName=
{
supportSourceModelsName
}
metadataModelTreeData=
{
metadataModelTreeData
}
sourceModel=
{
item
===
AddSourceModelName
?
undefined
:
item
}
activeKey=
{
activeKey
}
onChange=
{
onRelationChange
}
/>
</
Tabs
.
TabPane
>
})
}
</
Tabs
>
</
Modal
>
);
}
...
...
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