Commit 23a40bc6 by zhaochengxiang

增加衍生表接口

parent 193bd4ee
...@@ -317,3 +317,11 @@ export function* dataTypeList() { ...@@ -317,3 +317,11 @@ export function* dataTypeList() {
export function* bindingLoadRangeList(payload) { export function* bindingLoadRangeList(payload) {
return yield call(datamodelerService.bindingLoadRangeList, payload); return yield call(datamodelerService.bindingLoadRangeList, payload);
} }
export function* getInheritanceTypes() {
return yield call(datamodelerService.getInheritanceTypes);
}
export function* inheriteDataModel(payload) {
return yield call(datamodelerService.inheriteDataModel, payload);
}
\ No newline at end of file
...@@ -268,3 +268,11 @@ export function dataTypeList() { ...@@ -268,3 +268,11 @@ export function dataTypeList() {
export function bindingLoadRangeList(payload) { export function bindingLoadRangeList(payload) {
return GetJSON("/datamodeler/easyDataModelerDataType/bindingLoadRangeList", payload); return GetJSON("/datamodeler/easyDataModelerDataType/bindingLoadRangeList", payload);
} }
export function getInheritanceTypes() {
return PostJSON("/datamodeler/easyDataModelerInheritance/getInheritanceTypes");
}
export function inheriteDataModel(payload) {
return PostJSON("/datamodeler/easyDataModelerInheritance/inheriteDataModel", payload);
}
\ No newline at end of file
...@@ -4,3 +4,10 @@ export const EditModelContext = React.createContext({ ...@@ -4,3 +4,10 @@ export const EditModelContext = React.createContext({
attrIsEditingFunction: null, attrIsEditingFunction: null,
indexIsEditingFunction: null, indexIsEditingFunction: null,
}); });
export const EditInheritedModelContext = React.createContext({
createHistoryModel: false,
createZipperModel: false,
setInheriteState: null,
setInheriteData: null,
});
\ No newline at end of file
import React from "react"; import React, { useState, useEffect, useContext } from "react";
import { Modal, Space, Button, Form } from "antd"; import { Modal, Space, Button, Form } from "antd";
import ImportAction from "./ImportAction"; import ImportAction from "./ImportAction";
import { inheritanceHistoricalType, inheritanceZipperType } from "./ImportActionInherited";
import { EditInheritedModelContext } from "./ContextManage";
const FC = (props) => { const FC = (props) => {
const { visible, id, onCancel } = props; const { visible, modelerData, type, onCancel } = props;
const [_modelerData, setModelerData] = useState(undefined);
const [modifyModelerData, setModifyModelerData] = useState(undefined);
const [form] = Form.useForm(); const [form] = Form.useForm();
const { setInheriteData } = useContext(EditInheritedModelContext);
const onOk = () => { useEffect(() => {
if (visible) {
setModelerData(modelerData);
} else {
setModelerData(undefined);
}
}, [visible])
const onChange = (newModelerData) => {
setModifyModelerData(newModelerData);
}
const onOk = () => {
setInheriteData(type, modifyModelerData);
onCancel?.();
} }
return ( return (
...@@ -30,7 +49,7 @@ const FC = (props) => { ...@@ -30,7 +49,7 @@ const FC = (props) => {
overflow: 'auto' overflow: 'auto'
}} }}
> >
<ImportAction form={form} action='edit' modelerId={id} /> { visible && _modelerData && <ImportAction form={form} action='edit-inherite-modal' roughModelerData={_modelerData} onChange={onChange} /> }
</Modal> </Modal>
) )
} }
......
...@@ -10,6 +10,7 @@ import { getQueryParam, showMessage, showNotifaction } from '../../../../util'; ...@@ -10,6 +10,7 @@ import { getQueryParam, showMessage, showNotifaction } from '../../../../util';
import { Action, CatalogId, ModelerId, Hints, ModelerData, PermitCheckOut, Editable, StateId, VersionId, Holder, DDL, ReadOnly } from '../../../../util/constant'; import { Action, CatalogId, ModelerId, Hints, ModelerData, PermitCheckOut, Editable, StateId, VersionId, Holder, DDL, ReadOnly } from '../../../../util/constant';
import HistoryAndVersionDrawer from './HistoryAndVersionDrawer'; import HistoryAndVersionDrawer from './HistoryAndVersionDrawer';
import { EditModelContext } from './ContextManage'; import { EditModelContext } from './ContextManage';
import { inheritanceHistoricalType, inheritanceZipperType } from './ImportActionInherited';
import './EditModel.less'; import './EditModel.less';
...@@ -24,6 +25,9 @@ const EditModel = (props) => { ...@@ -24,6 +25,9 @@ const EditModel = (props) => {
const [ historyAndVersionDrawerVisible, setHistoryAndVersionDrawerVisible ] = useState(false); const [ historyAndVersionDrawerVisible, setHistoryAndVersionDrawerVisible ] = useState(false);
const [ autoTabKey, setAutoTabKey ] = useState(null); const [ autoTabKey, setAutoTabKey ] = useState(null);
const [createHistoryModel, setCreateHistoryModel] = useState(false);
const [createZipperModel, setCreateZipperModel] = useState(false);
const actionRef = useRef(''); const actionRef = useRef('');
const attrIsEditingRef = useRef(false); const attrIsEditingRef = useRef(false);
const indexIsEditingRef = useRef(false); const indexIsEditingRef = useRef(false);
...@@ -217,6 +221,11 @@ const EditModel = (props) => { ...@@ -217,6 +221,11 @@ const EditModel = (props) => {
} }
const editInherite = () => {
setActionData({ ...actionData, action: 'edit-inherite' });
actionRef.current = 'edit-inherite';
}
const edit = () => { const edit = () => {
setActionData({ ...actionData, action: 'edit' }); setActionData({ ...actionData, action: 'edit' });
actionRef.current = 'edit'; actionRef.current = 'edit';
...@@ -305,15 +314,20 @@ const EditModel = (props) => { ...@@ -305,15 +314,20 @@ const EditModel = (props) => {
<Space> <Space>
<Button type='primary' onClick={onHistory} danger >版本历史</Button> <Button type='primary' onClick={onHistory} danger >版本历史</Button>
{ {
(readOnly!=='true') && <Tooltip title={editTip}> (readOnly!=='true') && <Space>
<Button type='primary' onClick={editInherite} danger >
编辑历史存储形式
</Button>
<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 >
编辑 编辑
</Button> </Button>
</Tooltip> </Tooltip>
</Space>
} }
</Space> </Space>
); );
} else if (action === 'edit') { } else if (action === 'edit' || action === 'edit-inherite') {
actionsBtn = ( actionsBtn = (
<Space> <Space>
<Button onClick={cancelEdit} > <Button onClick={cancelEdit} >
......
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef, useContext } from 'react';
import { Spin } from 'antd'; import { Spin } from 'antd';
import LocalStorage from 'local-storage'; import LocalStorage from 'local-storage';
import ImportActionHeader from './ImportActionHeader'; import ImportActionHeader from './ImportActionHeader';
import ImportActionInherited from './ImportActionInherited'; import ImportActionInherited, { inheritanceHistoricalType, inheritanceZipperType } from './ImportActionInherited';
import { ImportActionTable } from './ImportActionTable'; import { ImportActionTable } from './ImportActionTable';
import ImportActionIndex from './ImportActionIndex'; import ImportActionIndex from './ImportActionIndex';
import { getQueryParam } from '../../../../util'; import { getQueryParam } from '../../../../util';
import { Action } from '../../../../util/constant'; import { Action } from '../../../../util/constant';
import { EditInheritedModelContext } from './ContextManage';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
const ImportAction = (props) => { const ImportAction = (props) => {
...@@ -24,6 +24,8 @@ const ImportAction = (props) => { ...@@ -24,6 +24,8 @@ const ImportAction = (props) => {
const [ supportedIndextypes, setSupportedIndextypes ] = useState([]); const [ supportedIndextypes, setSupportedIndextypes ] = useState([]);
const [ validateReports, setValidateReports ] = useState([]); const [ validateReports, setValidateReports ] = useState([]);
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
const [createHistoryModel, setCreateHistoryModel] = useState(false);
const [createZipperModel, setCreateZipperModel] = useState(false);
const mountRef = useRef(true); const mountRef = useRef(true);
const modelerDataRef = useRef(null); const modelerDataRef = useRef(null);
...@@ -57,8 +59,8 @@ const ImportAction = (props) => { ...@@ -57,8 +59,8 @@ const ImportAction = (props) => {
modelerDataRef.current = newModelerData; modelerDataRef.current = newModelerData;
} }
if (action !== 'edit-inherite') {
setLoading(true); setLoading(true);
dispatch({ dispatch({
type: 'datamodel.getAllConstraints', type: 'datamodel.getAllConstraints',
callback: data => { callback: data => {
...@@ -80,12 +82,19 @@ const ImportAction = (props) => { ...@@ -80,12 +82,19 @@ const ImportAction = (props) => {
} }
} else if(action === 'edit' || action === 'detail' || action ==='flow' || action === 'detail-version') { } else if(action === 'edit' || action === 'detail' || action ==='flow' || action === 'detail-version') {
getCurrentDataModel(); getCurrentDataModel();
} else if (action === 'edit-inherite-modal') {
setLoading(false);
getExtraData(roughModelerData);
} }
}, },
error: () => { error: () => {
setLoading(false); setLoading(false);
} }
}) })
} else {
setCreateHistoryModel((modelerData?.inherited?.historical)?true:false);
setCreateZipperModel((modelerData?.inherited?.zipper)?true:false);
}
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [action, hints, modelerId, ddl ]); }, [action, hints, modelerId, ddl ]);
...@@ -533,11 +542,50 @@ const ImportAction = (props) => { ...@@ -533,11 +542,50 @@ const ImportAction = (props) => {
return { partition: newPartition, easyDataModelerDistributionKey: newDistribution, easyDataModelerPrimaryKey: newPrimary, easyDataModelerIndices: newEasyDataModelerIndices, easyDataModelerSemiPrimaryKey: newSemiPrimary}; return { partition: newPartition, easyDataModelerDistributionKey: newDistribution, easyDataModelerPrimaryKey: newPrimary, easyDataModelerIndices: newEasyDataModelerIndices, easyDataModelerSemiPrimaryKey: newSemiPrimary};
} }
const setInheriteState = (type, value) => {
if (type === inheritanceHistoricalType) {
setCreateHistoryModel(value);
} else if (type === inheritanceZipperType) {
setCreateZipperModel(value);
}
}
const setInheriteData = (type, value) => {
if (type === inheritanceHistoricalType) {
const newModelerData = {...modelerData};
const newRealModelerData = {...modelerData};
if (newModelerData.inherited) {
newModelerData.inherited = {...newModelerData.inherited, historical: value}
newRealModelerData.inherited = {...newModelerData.inherited, historical: createHistoryModel?value:null}
setModelerData(newModelerData);
onChange?.(newRealModelerData);
}
} else if (type === inheritanceZipperType) {
const newModelerData = {...modelerData};
const newRealModelerData = {...modelerData};
if (newModelerData.inherited) {
newModelerData.inherited = {...newModelerData.inherited, zipper: value}
newRealModelerData.inherited = {...newModelerData.inherited, zipper: createZipperModel?value:null}
setModelerData(newModelerData);
onChange?.(newRealModelerData);
}
}
}
return ( return (
<EditInheritedModelContext.Provider value={{
createHistoryModel,
createZipperModel,
setInheriteState,
setInheriteData,
}}>
<Spin spinning={loading}> <Spin spinning={loading}>
<ImportActionHeader <ImportActionHeader
form={form} form={form}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'} editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'&&action!=='edit-inherite'}
modelerData={modelerData||{}} modelerData={modelerData||{}}
constraints={constraints} constraints={constraints}
templates={templates} templates={templates}
...@@ -548,7 +596,7 @@ const ImportAction = (props) => { ...@@ -548,7 +596,7 @@ const ImportAction = (props) => {
terms={terms} terms={terms}
supportedPartitionTypes={supportedPartitionTypes} supportedPartitionTypes={supportedPartitionTypes}
/> />
<ImportActionInherited /> <ImportActionInherited modelerData={modelerData} />
<ImportActionTable <ImportActionTable
modelerData={modelerData||{}} modelerData={modelerData||{}}
constraint={constraint} constraint={constraint}
...@@ -556,7 +604,7 @@ const ImportAction = (props) => { ...@@ -556,7 +604,7 @@ const ImportAction = (props) => {
validateReports={validateReports} validateReports={validateReports}
supportedDatatypes={supportedDatatypes} supportedDatatypes={supportedDatatypes}
onChange={onTableChange} onChange={onTableChange}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'} editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'&&action!=='edit-inherite'}
action={action} action={action}
originAction={getQueryParam(Action, props?.location?.search)} originAction={getQueryParam(Action, props?.location?.search)}
terms={terms} terms={terms}
...@@ -568,10 +616,11 @@ const ImportAction = (props) => { ...@@ -568,10 +616,11 @@ const ImportAction = (props) => {
types={supportedIndextypes} types={supportedIndextypes}
validateReports={validateReports} validateReports={validateReports}
onChange={onIndexChange} onChange={onIndexChange}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'} editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'&&action!=='edit-inherite'}
terms={terms} terms={terms}
/> />
</Spin> </Spin>
</EditInheritedModelContext.Provider>
); );
}; };
......
import React, { useState } from "react"; import React, { useState, useContext } 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";
export const inheritanceHistoricalType = 'historical';
export const inheritanceZipperType = 'zipper';
const FC = (props) => { const FC = (props) => {
const { modelerData } = props;
const [collapse, setCollapse] = useState(true); const [collapse, setCollapse] = useState(true);
const [activeKey, setActiveKey] = useState('history'); const [activeKey, setActiveKey] = useState(inheritanceHistoricalType);
const [generateHistory, setGenerateHistory] = useState(false); const { createHistoryModel, createZipperModel, setInheriteState } = useContext(EditInheritedModelContext);
const [generateZipper, setGenerateZipper] = useState(false);
return ( return (
<div className='model-import-action-inherited'> <div className='model-import-action-inherited'>
...@@ -32,22 +36,35 @@ const FC = (props) => { ...@@ -32,22 +36,35 @@ const FC = (props) => {
<Tabs.TabPane <Tabs.TabPane
tab={ tab={
<span> <span>
<Checkbox className='mr-2' onChange={(e) => { setGenerateHistory(e.target.checked); }}></Checkbox>历史表 <Checkbox
className='mr-2'
value={createHistoryModel}
onChange={(e) => {
setInheriteState(inheritanceHistoricalType, e.target.checked);
}}
>
</Checkbox>历史表
</span> </span>
} }
key='history' key={inheritanceHistoricalType}
> >
{ !collapse && <Preview /> } { !collapse && <Preview fromModelerData={modelerData} type={inheritanceHistoricalType} /> }
</Tabs.TabPane> </Tabs.TabPane>
<Tabs.TabPane <Tabs.TabPane
tab={ tab={
<span> <span>
<Checkbox className='mr-2' onChange={(e) => { setGenerateZipper(e.target.checked); }}></Checkbox>拉链表 <Checkbox
className='mr-2'
value={createZipperModel}
onChange={(e) => {
setInheriteState(inheritanceZipperType, e.target.checked);
}}
></Checkbox>拉链表
</span> </span>
} }
key='zipper' key={inheritanceZipperType}
> >
{ !collapse && <Preview /> } { !collapse && <Preview fromModelerData={modelerData} type={inheritanceZipperType} /> }
</Tabs.TabPane> </Tabs.TabPane>
</Tabs> </Tabs>
</div> </div>
......
import React, { useState } from "react"; 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";
const FC = (props) => { const FC = (props) => {
const [editInheritedParams, setEditInheritedParms] = useState({ visible: false, id: undefined }); const { fromModelerData, type } = props;
const { visible, id } = editInheritedParams;
const [modelerData, setModelerData] = useState(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}>
<Basic /> <Basic modelerData={modelerData} />
</Col> </Col>
<Col span={12}> <Col span={12}>
<div className='flex'> <div className='flex'>
<div className='mr-3' style={{ flex: 1 }}> <div className='mr-3' style={{ flex: 1 }}>
<Table /> <Table data={modelerData?.easyDataModelerDataModelAttributes} />
</div> </div>
<Button type='primary' size='small' onClick={() => { <Button type='primary' size='small' onClick={() => {
setEditInheritedParms({ visible: true, id: '643df3039e14e61e90acdfe7-1' }); setEditInheritedParms({ visible: true, modelerData });
}}>编辑</Button> }}>编辑</Button>
</div> </div>
</Col> </Col>
<EditInherited visible={visible} id={id} onCancel={() => { setEditInheritedParms({ visible: false, id: undefined }) }} /> <EditInherited
visible={editInheritedParams.visible}
type={type}
modelerData={editInheritedParams.modelerData}
onCancel={() => {
setEditInheritedParms({ visible: false, modelerData: undefined });
}}
/>
</Row> </Row>
) )
} }
export default FC; export default FC;
const Basic = () => { const Basic = ({ modelerData }) => {
return ( return (
<Row gutter={10}> <Row gutter={10}>
<Col className='mb-4' span={12}> <Col className='mb-4' span={12}>
<Tooltip title=''> <Tooltip title=''>
<Typography.Text ellipsis={true}> <Typography.Text ellipsis={true}>
中文名称:&nbsp;<Typography.Text></Typography.Text> 中文名称:&nbsp;<Typography.Text>{modelerData?.cnName}</Typography.Text>
</Typography.Text> </Typography.Text>
</Tooltip> </Tooltip>
</Col> </Col>
...@@ -93,7 +131,7 @@ const Basic = () => { ...@@ -93,7 +131,7 @@ const Basic = () => {
) )
} }
const Table = () => { const Table = ({ data }) => {
const cols = [ const cols = [
{ {
name: '序号', name: '序号',
...@@ -152,10 +190,7 @@ const Table = () => { ...@@ -152,10 +190,7 @@ const Table = () => {
<DataGrid <DataGrid
style={{ blockSize: 146 }} style={{ blockSize: 146 }}
columns={cols} columns={cols}
rows={Array.from({ length: 10000 }).map((_, i) => ({ rows={data||[]}
name: `test${i}`,
}))}
// rows={data||[]}
headerHeight={30} headerHeight={30}
rowHeight={36} rowHeight={36}
rowClassName={(row) => { rowClassName={(row) => {
......
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