Commit 922fb667 by zhaochengxiang

资产关联元数据

parent a1cef66a
...@@ -6,6 +6,7 @@ import MetadataInfo from './MetadataInfo'; ...@@ -6,6 +6,7 @@ import MetadataInfo from './MetadataInfo';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { highlightSearchContentByTerms, showMessage } from '../../../../util'; import { highlightSearchContentByTerms, showMessage } from '../../../../util';
import { unfoldedElements } from '../util'; import { unfoldedElements } from '../util';
import { AppContext } from '../../../../App';
const AssetAction = (props) => { const AssetAction = (props) => {
...@@ -174,6 +175,26 @@ const AssetAction = (props) => { ...@@ -174,6 +175,26 @@ const AssetAction = (props) => {
setFullScreen(!fullScreen); setFullScreen(!fullScreen);
} }
//选中元数据后 内容回填.
const fillElementValueBeforeCreate = (mid = metadataId) => {
dispatch({
type: 'assetmanage.fillElementValueBeforeCreate',
payload: {
params: {
metadataIds: mid
}
},
callback: data => {
let _fieldsValue = {};
(data||[]).forEach(element => {
_fieldsValue[element.name] = element.value;
})
form.setFieldsValue(_fieldsValue);
}
})
}
const formItemLayout = { const formItemLayout = {
labelCol: { labelCol: {
xs: { span: 24 }, xs: { span: 24 },
...@@ -261,7 +282,21 @@ const AssetAction = (props) => { ...@@ -261,7 +282,21 @@ const AssetAction = (props) => {
<div style={{ padding: 10 }}> <div style={{ padding: 10 }}>
{ {
(currentAction==='add'||currentAction==='edit') ? <Form {...formItemLayout} form={form}> (currentAction==='add'||currentAction==='edit') ? <Form {...formItemLayout} form={form}>
<AppContext.Consumer>
{ {
value => {
value?.onGlobalStateChange&&value?.onGlobalStateChange((state, prev) => {
if (state.message === 'data-govern-show-metadata-list-callback-message') {
setMetadataId(state.data?.metadataId||'');
form?.setFieldsValue({ '资产项': state.data?.metadataInfoJson||'' });
if ((state.data?.metadataId||'') !== '') {
fillElementValueBeforeCreate(state.data?.metadataId||'');
}
}
});
return (
(sameAttributeElements||[]).map((element, _index) => { (sameAttributeElements||[]).map((element, _index) => {
return ( return (
<Form.Item <Form.Item
...@@ -274,7 +309,9 @@ const AssetAction = (props) => { ...@@ -274,7 +309,9 @@ const AssetAction = (props) => {
</Form.Item> </Form.Item>
); );
}) })
} );
}}
</AppContext.Consumer>
</Form> : <Descriptions column={1}> </Form> : <Descriptions column={1}>
{ {
(sameAttributeElements||[]).map((item, index) => { (sameAttributeElements||[]).map((item, index) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment