Commit d3182212 by zhaochengxiang

衍生表

parent 9976ac60
...@@ -314,10 +314,12 @@ const EditModel = (props) => { ...@@ -314,10 +314,12 @@ const EditModel = (props) => {
<Space> <Space>
<Button type='primary' onClick={onHistory} danger >版本历史</Button> <Button type='primary' onClick={onHistory} danger >版本历史</Button>
{ {
(readOnly!=='true') && <Space> readOnly!=='true' && <Space>
<Button type='primary' onClick={editInherite} danger > {
!modelerData?.final && <Button type='primary' onClick={editInherite} danger >
编辑历史存储形式 编辑历史存储形式
</Button> </Button>
}
<Tooltip title={editTip}> <Tooltip title={editTip}>
<Button type='primary' onClick={edit} disabled={(stateId==='4')?!permitCheckOut:!editable} danger > <Button type='primary' onClick={edit} disabled={(stateId==='4')?!permitCheckOut:!editable} danger >
编辑 编辑
......
...@@ -610,7 +610,7 @@ const ImportAction = (props) => { ...@@ -610,7 +610,7 @@ const ImportAction = (props) => {
terms={terms} terms={terms}
supportedPartitionTypes={supportedPartitionTypes} supportedPartitionTypes={supportedPartitionTypes}
/> />
<ImportActionInherited modelerData={modelerData} /> <ImportActionInherited modelerData={modelerData} editable={action==='edit-inherite'} />
<ImportActionTable <ImportActionTable
modelerData={modelerData||{}} modelerData={modelerData||{}}
constraint={constraint} constraint={constraint}
......
import React, { useState, useContext } from "react"; import React, { useState, useContext, useEffect } from "react";
import { Button, Tabs, Checkbox } from "antd"; import { Button, Tabs, Checkbox } from "antd";
import { DownOutlined, UpOutlined } from "@ant-design/icons"; import { DownOutlined, UpOutlined } from "@ant-design/icons";
import Preview from './InheritedPreview'; import Preview from './InheritedPreview';
import { EditInheritedModelContext } from "./ContextManage"; import { EditInheritedModelContext } from "./ContextManage";
import { dispatch } from '../../../../model';
import { Action, CatalogId, ModelerId, Hints, ModelerData, PermitCheckOut, Editable, StateId, Holder, DDL, DataModelerRoleReader, ReadOnly } from '../../../../util/constant';
export const inheritanceHistoricalType = 'historical'; export const inheritanceHistoricalType = 'historical';
export const inheritanceZipperType = 'zipper'; export const inheritanceZipperType = 'zipper';
const FC = (props) => { const FC = (props) => {
const { modelerData } = props; const { modelerData, editable } = props;
const [collapse, setCollapse] = useState(true); const [collapse, setCollapse] = useState(true);
const [activeKey, setActiveKey] = useState(inheritanceHistoricalType); const [activeKey, setActiveKey] = useState(inheritanceHistoricalType);
const { createHistoryModel, createZipperModel, setInheriteState } = useContext(EditInheritedModelContext); const [relationModelerDatas, setRelationModelerDatas] = useState([]);
const [historicalModelerData, setHistoricalModelerData] = useState(undefined);
const [zipperModelerData, setZipperModelerData] = useState(undefined);
const { createHistoryModel, createZipperModel, setInheriteState, setInheriteData } = useContext(EditInheritedModelContext);
useEffect(() => {
if (!editable) {
if (modelerData?.final) {
getDataModel();
} else {
const newRelationModelerDatas = [];
if (modelerData?.inherited?.historical) {
newRelationModelerDatas.push(modelerData?.inherited?.historical);
}
if (modelerData?.inherited?.zipper) {
newRelationModelerDatas.push(modelerData?.inherited?.zipper);
}
setRelationModelerDatas(newRelationModelerDatas);
}
} else {
if (modelerData) {
if (modelerData.inherited?.historical) {
setHistoricalModelerData(modelerData.inherited?.historical);
} else {
getInheriteDataModel(inheritanceHistoricalType);
}
if (modelerData.inherited?.zipper) {
setZipperModelerData(modelerData.inherited?.zipper);
} else {
getInheriteDataModel(inheritanceZipperType);
}
}
}
}, [editable, modelerData])
const getInheriteDataModel = (type) => {
dispatch({
type: 'datamodel.inheriteDataModel',
payload: {
params: {
id: modelerData.id,
inheritanceTypeName: type
}
},
callback: data => {
if (type === inheritanceHistoricalType) {
setHistoricalModelerData(data);
setInheriteData(inheritanceHistoricalType, data);
} else if (type === inheritanceZipperType) {
setZipperModelerData(data);
setInheriteData(inheritanceZipperType, data);
}
}
})
}
const getDataModel = () => {
dispatch({
type: 'datamodel.getDataModel',
payload: {
id: modelerData?.inheritedFrom
},
callback: data => {
const newRelationModelerDatas = [];
newRelationModelerDatas.push(data);
if (modelerData?.inheritedFromType === inheritanceHistoricalType && modelerData?.othersInheritedFromSameOrigin?.zipper) {
newRelationModelerDatas.push(modelerData?.othersInheritedFromSameOrigin?.zipper);
}
setRelationModelerDatas(newRelationModelerDatas);
}
})
}
return ( return (
<div className='model-import-action-inherited'> <div className='model-import-action-inherited'>
<div className='mb-3'> <div className='mb-3'>
<Tabs {
editable ? <Tabs
activeKey={activeKey} activeKey={activeKey}
onChange={(key) => { setActiveKey(key); }} onChange={(key) => { setActiveKey(key); }}
tabBarExtraContent={{ tabBarExtraContent={{
...@@ -48,7 +124,7 @@ const FC = (props) => { ...@@ -48,7 +124,7 @@ const FC = (props) => {
} }
key={inheritanceHistoricalType} key={inheritanceHistoricalType}
> >
{ !collapse && <Preview fromModelerData={modelerData} type={inheritanceHistoricalType} /> } { !collapse && <Preview modelerData={modelerData} type={inheritanceHistoricalType} /> }
</Tabs.TabPane> </Tabs.TabPane>
<Tabs.TabPane <Tabs.TabPane
tab={ tab={
...@@ -64,9 +140,17 @@ const FC = (props) => { ...@@ -64,9 +140,17 @@ const FC = (props) => {
} }
key={inheritanceZipperType} key={inheritanceZipperType}
> >
{ !collapse && <Preview fromModelerData={modelerData} type={inheritanceZipperType} /> } { !collapse && <Preview modelerData={modelerData} type={inheritanceZipperType} /> }
</Tabs.TabPane> </Tabs.TabPane>
</Tabs> </Tabs> : <div className='flex' style={{ alignItems: 'center' }}>
<h2 className='mr-3' style={{ marginBottom: 0 }}>历史存储形式</h2>
{
relationModelerDatas?.map((item, index) => <a className='mr-3' key={index} onClick={() => {
window.open(`/data-govern/data-model-action?${Action}=detail&${ModelerId}=${item.id}&${PermitCheckOut}=${item.permitCheckOut||false}&${Editable}=${item.editable||false}&${StateId}=${item.state?.id||''}&${Holder}=${item.holder||''}&${ReadOnly}=false`);
}}>{item.cnName}</a>)
}
</div>
}
</div> </div>
</div> </div>
) )
......
...@@ -2,42 +2,13 @@ import React, { useEffect, useState } from "react"; ...@@ -2,42 +2,13 @@ import React, { useEffect, useState } from "react";
import { Row, Col, Tooltip, Typography, Space, Button } from "antd"; import { Row, Col, Tooltip, Typography, Space, Button } from "antd";
import DataGrid from '../../VirtualTable'; import DataGrid from '../../VirtualTable';
import EditInherited from './EditInherited'; import EditInherited from './EditInherited';
import { dispatch } from '../../../../model';
import { inheritanceHistoricalType, inheritanceZipperType } from "./ImportActionInherited"; import { inheritanceHistoricalType, inheritanceZipperType } from "./ImportActionInherited";
const FC = (props) => { const FC = (props) => {
const { fromModelerData, type } = props; const { modelerData, type } = props;
const [modelerData, setModelerData] = useState(undefined);
const [editInheritedParams, setEditInheritedParms] = useState({ visible: false, modelerData: undefined }); const [editInheritedParams, setEditInheritedParms] = useState({ visible: false, modelerData: undefined });
useEffect(() => {
if (fromModelerData) {
if (type === inheritanceHistoricalType && fromModelerData.inherited?.historical) {
setModelerData(fromModelerData.inherited?.historical);
} else if (type === inheritanceZipperType && fromModelerData.inherited?.zipper) {
setModelerData(fromModelerData.inherited?.zipper);
} else {
getInheriteDataModel();
}
}
}, [fromModelerData])
const getInheriteDataModel = () => {
dispatch({
type: 'datamodel.inheriteDataModel',
payload: {
params: {
id: fromModelerData.id,
inheritanceTypeName: type
}
},
callback: data => {
setModelerData(data);
}
})
}
return ( return (
<Row> <Row>
<Col span={12}> <Col span={12}>
......
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