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
532e3f96
Commit
532e3f96
authored
Apr 22, 2024
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资源属性关联
parent
5e398889
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
258 additions
and
118 deletions
+258
-118
assetmanage.js
src/model/assetmanage.js
+12
-4
dataassetmanager.js
src/service/dataassetmanager.js
+12
-4
AttributeRelationModal.jsx
...w/Manage/AssetManage/Component/AttributeRelationModal.jsx
+233
-109
FilterElementModal.jsx
src/view/Manage/AssetManage/Component/FilterElementModal.jsx
+1
-1
No files found.
src/model/assetmanage.js
View file @
532e3f96
...
...
@@ -204,6 +204,10 @@ export function* recoveryFromRecycleBin(payload) {
return
yield
call
(
service
.
recoveryFromRecycleBin
,
payload
);
}
export
function
*
listSourceModels
(
payload
)
{
return
yield
call
(
service
.
listSourceModels
,
payload
);
}
export
function
*
getMetadataModelTree
()
{
return
yield
call
(
service
.
getMetadataModelTree
);
}
...
...
@@ -216,12 +220,16 @@ export function* loadElementWithoutCustom(payload) {
return
yield
call
(
service
.
loadElementWithoutCustom
,
payload
);
}
export
function
*
saveEleAndAttrRel
(
payload
)
{
return
yield
call
(
service
.
saveEleAndAttrRel
,
payload
);
export
function
*
getRelAttrBySourceModel
(
payload
)
{
return
yield
call
(
service
.
getRelAttrBySourceModel
,
payload
);
}
export
function
*
saveEleAndAttrRelWithSourceModel
(
payload
)
{
return
yield
call
(
service
.
saveEleAndAttrRelWithSourceModel
,
payload
);
}
export
function
*
getRelAttrBy
Model
(
payload
)
{
return
yield
call
(
service
.
getRelAttrBy
Model
,
payload
);
export
function
*
deleteRelAttrBySource
Model
(
payload
)
{
return
yield
call
(
service
.
deleteRelAttrBySource
Model
,
payload
);
}
export
function
*
fillElementValueBeforeCreate
(
payload
)
{
...
...
src/service/dataassetmanager.js
View file @
532e3f96
...
...
@@ -220,6 +220,10 @@ export function getPersonalCustomDirecotryChild(payload) {
return
GetJSON
(
"/dataassetmanager/directoryApi/getPersonalCustomChildByParentId"
,
payload
);
}
export
function
listSourceModels
(
payload
){
return
GetJSON
(
"/dataassetmanager/eleAndAttrApi/listSourceModels"
,
payload
);
}
export
function
getMetadataModelTree
()
{
return
GetJSON
(
"/metadatarepo/rest/model/tree"
);
}
...
...
@@ -232,12 +236,16 @@ export function loadElementWithoutCustom(payload) {
return
GetJSON
(
"/dataassetmanager/eleAndAttrApi/loadElementWithoutCustom"
,
payload
);
}
export
function
saveEleAndAttrRel
(
payload
)
{
return
PostJSON
(
"/dataassetmanager/eleAndAttrApi/saveEleAndAttrRel"
,
payload
);
export
function
getRelAttrBySourceModel
(
payload
)
{
return
GetJSON
(
"/dataassetmanager/eleAndAttrApi/getRelAttrBySourceModel"
,
payload
);
}
export
function
saveEleAndAttrRelWithSourceModel
(
payload
)
{
return
PostJSON
(
"/dataassetmanager/eleAndAttrApi/saveEleAndAttrRelWithSourceModel"
,
payload
);
}
export
function
getRelAttrBy
Model
(
payload
)
{
return
PostJSON
(
"/dataassetmanager/eleAndAttrApi/
getRelAttrBy
Model"
,
payload
);
export
function
deleteRelAttrBySource
Model
(
payload
)
{
return
PostJSON
(
"/dataassetmanager/eleAndAttrApi/
delEleAndAttrRelWithSource
Model"
,
payload
);
}
export
function
fillElementValueBeforeCreate
(
payload
)
{
...
...
src/view/Manage/AssetManage/Component/AttributeRelationModal.jsx
View file @
532e3f96
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Modal
,
Form
,
TreeSelect
,
Select
,
Space
,
Button
,
Row
,
Col
,
}
from
'antd'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
AssetManageReference
,
ResourceManageReference
}
from
'../../../../util/constant'
;
import
React
,
{
useEffect
,
useMemo
,
useRef
,
useState
}
from
'react'
;
import
{
Modal
,
Form
,
TreeSelect
,
Select
,
Space
,
Button
,
Row
,
Col
,
Tabs
,
Spin
,
Input
,
message
}
from
'antd'
;
import
{
getAssetType
,
getAssetTypeName
}
from
'../../../../util'
;
import
{
AssetManageReference
}
from
'../../../../util/constant'
;
import
{
dispatch
}
from
'../../../../model'
;
const
AddSourceModelName
=
'新增数据来源'
const
MetaModelSelect
=
({
value
=
{},
metaModelTreeData
=
[],
onChange
,
...
restProps
})
=>
{
const
[
attributes
,
setAttributes
]
=
useState
([]);
...
...
@@ -60,7 +61,7 @@ const MetaModelSelect = ({ value = {}, metaModelTreeData = [], onChange, ...rest
error
:
()
=>
{
setLoading
(
false
);
}
})
;
})
}
//value有可能为空
...
...
@@ -100,90 +101,78 @@ const MetaModelSelect = ({ value = {}, metaModelTreeData = [], onChange, ...rest
);
}
const
AttributeRelationModal
=
(
props
)
=>
{
const
{
visible
,
onCancel
,
type
=
AssetManageReference
}
=
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
([]);
console
.
log
(
'sourceModel'
,
sourceModel
)
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
);
})
}
recursion
(
newData
);
setMetadataModelTreeData
(
newData
||
[]);
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
||
''
};
})
loadElementWithoutCustom
();
},
error
:
()
=>
{
}
});
}
form
.
setFieldsValue
(
newFiledsValue
);
}
},
[
currentRelations
,
elements
])
const
loadElementWithoutCustom
=
()
=>
{
const
getRelAttrBySourceModel
=
()
=>
{
setLoading
(
true
)
dispatch
({
type
:
'assetmanage.
loadElementWithoutCustom
'
,
type
:
'assetmanage.
getRelAttrBySourceModel
'
,
payload
:
{
dataAssetType
:
getAssetType
(
type
)
sourceModel
},
callback
:
data
=>
{
set
Elements
(
data
||
[]
);
getRelAttrByModel
(
);
set
Loading
(
false
);
setCurrentRelations
(
data
||
[]
);
},
error
:
()
=>
{
setLoading
(
false
);
}
})
;
})
}
const
getRelAttrByModel
=
()
=>
{
dispatch
({
type
:
'assetmanage.getRelAttrByModel'
,
payload
:
{
params
:
{
dataAssetType
:
getAssetType
(
type
),
}
},
callback
:
data
=>
{
let
_fieldsValue
=
{};
(
data
||
[]).
forEach
(
item
=>
{
_fieldsValue
[
item
.
elementId
]
=
{
model
:
item
.
model
,
modelValue
:
item
.
model
,
attrName
:
item
.
attrName
||
''
,
attrCnName
:
item
.
attrCnName
||
''
};
const
onDelete
=
()
=>
{
modal
.
confirm
({
title
:
'提示!'
,
content
:
'您确定要删除该来源模型名称吗?'
,
onOk
:
()
=>
{
dispatch
({
type
:
'assetmanage.deleteRelAttrBySourceModel'
,
payload
:
{
params
:
{
sourceModel
,
}
},
callback
:
data
=>
{
message
.
success
(
'删除成功'
)
onChange
?.(
'delete'
)
}
})
form
.
setFieldsValue
(
_fieldsValue
);
},
error
:
()
=>
{
}
});
}
const
onOk
=
async
()
=>
{
const
onOk
=
async
()
=>
{
try
{
const
row
=
await
form
.
validateFields
();
...
...
@@ -197,35 +186,30 @@ const AttributeRelationModal = (props) => {
}
setConfirmLoading
(
true
);
dispatch
({
type
:
'assetmanage.saveEleAndAttrRel'
,
type
:
'assetmanage.saveEleAndAttrRel
WithSourceModel
'
,
payload
:
{
data
:
newRels
,
params
:
{
dataAssetType
:
getAssetType
(
type
)
sourceModel
:
row
.
sourceModel
,
isAdd
:
sourceModel
?
false
:
true
,
}
},
callback
:
data
=>
{
reset
();
onCancel
&&
onCancel
();
setConfirmLoading
(
false
);
message
.
success
(
sourceModel
?
'更新成功'
:
'新增成功'
);
onChange
?.(
'update'
,
row
.
sourceModel
);
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
});
})
}
catch
(
errInfo
)
{
console
.
log
(
'Validate Failed:'
,
errInfo
);
setConfirmLoading
(
false
);
}
}
const
reset
=
()
=>
{
setConfirmLoading
(
false
);
form
.
resetFields
();
}
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
...
...
@@ -237,45 +221,185 @@ const AttributeRelationModal = (props) => {
},
};
return
<
Spin
spinning=
{
loading
}
>
<
div
style=
{
{
textAlign
:
'right'
,
marginBottom
:
15
}
}
>
<
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
:
'请输入来源名称'
}]
}
>
<
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
(
<
Form
.
Item
label=
{
element
.
name
||
''
}
name=
{
element
.
id
||
''
}
key=
{
index
}
>
<
MetaModelSelect
metaModelTreeData=
{
metadataModelTreeData
}
/>
</
Form
.
Item
>
);
})
}
</
Form
>
{
contextHolder
}
</
Spin
>
}
const
AttributeRelationModal
=
(
props
)
=>
{
const
{
visible
,
type
=
AssetManageReference
,
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
)
{
getSourceModels
();
loadElementWithoutCustom
();
getMetadataModelTree
();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
visible
])
const
tabData
=
useMemo
(()
=>
{
return
[...
sourceModels
||
[],
AddSourceModelName
]
},
[
sourceModels
])
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
);
setSupportSourceModelsName
((
newData
||
[]).
map
(
item
=>
item
.
nodeName
));
setMetadataModelTreeData
(
newData
||
[]);
}
})
}
const
loadElementWithoutCustom
=
()
=>
{
dispatch
({
type
:
'assetmanage.loadElementWithoutCustom'
,
payload
:
{
dataAssetType
:
getAssetType
(
type
),
},
callback
:
data
=>
{
setElements
(
data
||
[]);
}
})
}
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=
{
`${getAssetTypeName(type)}属性关联`
}
visible=
{
visible
}
width=
{
600
}
width=
'80%'
centered
destroyOnClose
onCancel=
{
()
=>
{
reset
();
onCancel
&&
onCancel
()
onCancel
?.();
}
}
footer=
{
<
Space
>
<
Button
onClick=
{
()
=>
{
reset
();
onCancel
&&
onCancel
();
}
}
>
返回
</
Button
>
<
Button
type=
"primary"
onClick=
{
onOk
}
loading=
{
confirmLoading
}
>
确定
</
Button
>
</
Space
>
}
footer=
{
null
}
>
<
div
style=
{
{
maxHeight
:
500
,
overflow
:
'auto'
}
}
>
<
Form
form=
{
form
}
{
...
formItemLayout
}
>
{
(
elements
||
[]).
map
((
element
,
index
)
=>
{
return
(
<
Form
.
Item
label=
{
element
.
name
||
''
}
name=
{
element
.
id
||
''
}
key=
{
index
}
>
<
MetaModelSelect
metaModelTreeData=
{
metadataModelTreeData
}
/>
</
Form
.
Item
>
);
})
}
</
Form
>
</
div
>
<
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
>
);
}
...
...
src/view/Manage/AssetManage/Component/FilterElementModal.jsx
View file @
532e3f96
...
...
@@ -166,7 +166,7 @@ const FilterElementModal = (props) => {
return
(
<
Modal
forceRender
centered
forceRender
visible=
{
visible
}
title=
{
type
===
'global'
?
`${getAssetTypeName(reference)}属性管理`
:
'可见列设置'
}
width=
{
520
}
...
...
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