Commit 23a40bc6 by zhaochengxiang

增加衍生表接口

parent 193bd4ee
......@@ -316,4 +316,12 @@ export function* dataTypeList() {
export function* 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
......@@ -267,4 +267,12 @@ export function dataTypeList() {
export function 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
......@@ -3,4 +3,11 @@ import React from 'react';
export const EditModelContext = React.createContext({
attrIsEditingFunction: null,
indexIsEditingFunction: null,
});
\ No newline at end of file
});
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 ImportAction from "./ImportAction";
import { inheritanceHistoricalType, inheritanceZipperType } from "./ImportActionInherited";
import { EditInheritedModelContext } from "./ContextManage";
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 { 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 (
......@@ -30,7 +49,7 @@ const FC = (props) => {
overflow: 'auto'
}}
>
<ImportAction form={form} action='edit' modelerId={id} />
{ visible && _modelerData && <ImportAction form={form} action='edit-inherite-modal' roughModelerData={_modelerData} onChange={onChange} /> }
</Modal>
)
}
......
......@@ -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 HistoryAndVersionDrawer from './HistoryAndVersionDrawer';
import { EditModelContext } from './ContextManage';
import { inheritanceHistoricalType, inheritanceZipperType } from './ImportActionInherited';
import './EditModel.less';
......@@ -24,6 +25,9 @@ const EditModel = (props) => {
const [ historyAndVersionDrawerVisible, setHistoryAndVersionDrawerVisible ] = useState(false);
const [ autoTabKey, setAutoTabKey ] = useState(null);
const [createHistoryModel, setCreateHistoryModel] = useState(false);
const [createZipperModel, setCreateZipperModel] = useState(false);
const actionRef = useRef('');
const attrIsEditingRef = useRef(false);
const indexIsEditingRef = useRef(false);
......@@ -217,6 +221,11 @@ const EditModel = (props) => {
}
const editInherite = () => {
setActionData({ ...actionData, action: 'edit-inherite' });
actionRef.current = 'edit-inherite';
}
const edit = () => {
setActionData({ ...actionData, action: 'edit' });
actionRef.current = 'edit';
......@@ -305,15 +314,20 @@ const EditModel = (props) => {
<Space>
<Button type='primary' onClick={onHistory} danger >版本历史</Button>
{
(readOnly!=='true') && <Tooltip title={editTip}>
<Button type='primary' onClick={edit} disabled={(stateId==='4')?!permitCheckOut:!editable} danger >
编辑
</Button>
</Tooltip>
(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>
</Tooltip>
</Space>
}
</Space>
);
} else if (action === 'edit') {
} else if (action === 'edit' || action === 'edit-inherite') {
actionsBtn = (
<Space>
<Button onClick={cancelEdit} >
......
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect, useRef, useContext } from 'react';
import { Spin } from 'antd';
import LocalStorage from 'local-storage';
import ImportActionHeader from './ImportActionHeader';
import ImportActionInherited from './ImportActionInherited';
import ImportActionInherited, { inheritanceHistoricalType, inheritanceZipperType } from './ImportActionInherited';
import { ImportActionTable } from './ImportActionTable';
import ImportActionIndex from './ImportActionIndex';
import { getQueryParam } from '../../../../util';
import { Action } from '../../../../util/constant';
import { EditInheritedModelContext } from './ContextManage';
import { dispatch } from '../../../../model';
const ImportAction = (props) => {
......@@ -24,6 +24,8 @@ const ImportAction = (props) => {
const [ supportedIndextypes, setSupportedIndextypes ] = useState([]);
const [ validateReports, setValidateReports ] = useState([]);
const [ loading, setLoading ] = useState(false);
const [createHistoryModel, setCreateHistoryModel] = useState(false);
const [createZipperModel, setCreateZipperModel] = useState(false);
const mountRef = useRef(true);
const modelerDataRef = useRef(null);
......@@ -57,35 +59,42 @@ const ImportAction = (props) => {
modelerDataRef.current = newModelerData;
}
setLoading(true);
dispatch({
type: 'datamodel.getAllConstraints',
callback: data => {
setConstraints(data);
if (action === 'add') {
// setConstraint(data?.length>0?data[0]:{});
// setTemplate({});
if ((hints||[]).length>0) {
getDraft(data?.length>0?data[0]:{}, {} ,hints);
} else if ((ddl||'').length>0) {
getDraftUsingDDL(data?.length>0?data[0]:{}, {} ,ddl);
} else if ((modelerId||'')!=='') {
if (action !== 'edit-inherite') {
setLoading(true);
dispatch({
type: 'datamodel.getAllConstraints',
callback: data => {
setConstraints(data);
if (action === 'add') {
// setConstraint(data?.length>0?data[0]:{});
// setTemplate({});
if ((hints||[]).length>0) {
getDraft(data?.length>0?data[0]:{}, {} ,hints);
} else if ((ddl||'').length>0) {
getDraftUsingDDL(data?.length>0?data[0]:{}, {} ,ddl);
} else if ((modelerId||'')!=='') {
getCurrentDataModel();
} else if (roughModelerData) {
setLoading(false);
getExtraData(roughModelerData);
} else {
getDraft(data?.length>0?data[0]:{}, {} ,[]);
}
} else if(action === 'edit' || action === 'detail' || action ==='flow' || action === 'detail-version') {
getCurrentDataModel();
} else if (roughModelerData) {
} else if (action === 'edit-inherite-modal') {
setLoading(false);
getExtraData(roughModelerData);
} else {
getDraft(data?.length>0?data[0]:{}, {} ,[]);
}
} else if(action === 'edit' || action === 'detail' || action ==='flow' || action === 'detail-version') {
getCurrentDataModel();
},
error: () => {
setLoading(false);
}
},
error: () => {
setLoading(false);
}
})
})
} else {
setCreateHistoryModel((modelerData?.inherited?.historical)?true:false);
setCreateZipperModel((modelerData?.inherited?.zipper)?true:false);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [action, hints, modelerId, ddl ]);
......@@ -533,45 +542,85 @@ const ImportAction = (props) => {
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 (
<Spin spinning={loading}>
<ImportActionHeader
form={form}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'}
modelerData={modelerData||{}}
constraints={constraints}
templates={templates}
validateReports={validateReports}
onTemplateChange={onTemplateChange}
onConstraintChange={onConstraintChange}
onChange={onHeaderChange}
terms={terms}
supportedPartitionTypes={supportedPartitionTypes}
/>
<ImportActionInherited />
<ImportActionTable
modelerData={modelerData||{}}
constraint={constraint}
template={template}
validateReports={validateReports}
supportedDatatypes={supportedDatatypes}
onChange={onTableChange}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'}
action={action}
originAction={getQueryParam(Action, props?.location?.search)}
terms={terms}
/>
<ImportActionIndex
modelerData={modelerData||{}}
constraint={constraint}
template={template}
types={supportedIndextypes}
validateReports={validateReports}
onChange={onIndexChange}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'}
terms={terms}
/>
</Spin>
<EditInheritedModelContext.Provider value={{
createHistoryModel,
createZipperModel,
setInheriteState,
setInheriteData,
}}>
<Spin spinning={loading}>
<ImportActionHeader
form={form}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'&&action!=='edit-inherite'}
modelerData={modelerData||{}}
constraints={constraints}
templates={templates}
validateReports={validateReports}
onTemplateChange={onTemplateChange}
onConstraintChange={onConstraintChange}
onChange={onHeaderChange}
terms={terms}
supportedPartitionTypes={supportedPartitionTypes}
/>
<ImportActionInherited modelerData={modelerData} />
<ImportActionTable
modelerData={modelerData||{}}
constraint={constraint}
template={template}
validateReports={validateReports}
supportedDatatypes={supportedDatatypes}
onChange={onTableChange}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'&&action!=='edit-inherite'}
action={action}
originAction={getQueryParam(Action, props?.location?.search)}
terms={terms}
/>
<ImportActionIndex
modelerData={modelerData||{}}
constraint={constraint}
template={template}
types={supportedIndextypes}
validateReports={validateReports}
onChange={onIndexChange}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'&&action!=='edit-inherite'}
terms={terms}
/>
</Spin>
</EditInheritedModelContext.Provider>
);
};
......
import React, { useState } from "react";
import React, { useState, useContext } from "react";
import { Button, Tabs, Checkbox } from "antd";
import { DownOutlined, UpOutlined } from "@ant-design/icons";
import Preview from './InheritedPreview';
import { EditInheritedModelContext } from "./ContextManage";
export const inheritanceHistoricalType = 'historical';
export const inheritanceZipperType = 'zipper';
const FC = (props) => {
const { modelerData } = props;
const [collapse, setCollapse] = useState(true);
const [activeKey, setActiveKey] = useState('history');
const [generateHistory, setGenerateHistory] = useState(false);
const [generateZipper, setGenerateZipper] = useState(false);
const [activeKey, setActiveKey] = useState(inheritanceHistoricalType);
const { createHistoryModel, createZipperModel, setInheriteState } = useContext(EditInheritedModelContext);
return (
<div className='model-import-action-inherited'>
......@@ -32,22 +36,35 @@ const FC = (props) => {
<Tabs.TabPane
tab={
<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>
}
key='history'
key={inheritanceHistoricalType}
>
{ !collapse && <Preview /> }
{ !collapse && <Preview fromModelerData={modelerData} type={inheritanceHistoricalType} /> }
</Tabs.TabPane>
<Tabs.TabPane
tab={
<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>
}
key='zipper'
key={inheritanceZipperType}
>
{ !collapse && <Preview /> }
{ !collapse && <Preview fromModelerData={modelerData} type={inheritanceZipperType} /> }
</Tabs.TabPane>
</Tabs>
</div>
......
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { Row, Col, Tooltip, Typography, Space, Button } from "antd";
import DataGrid from '../../VirtualTable';
import EditInherited from './EditInherited';
import { dispatch } from '../../../../model';
import { inheritanceHistoricalType, inheritanceZipperType } from "./ImportActionInherited";
const FC = (props) => {
const [editInheritedParams, setEditInheritedParms] = useState({ visible: false, id: undefined });
const { visible, id } = editInheritedParams;
const { fromModelerData, type } = props;
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 (
<Row>
<Col span={12}>
<Basic />
<Basic modelerData={modelerData} />
</Col>
<Col span={12}>
<div className='flex'>
<div className='mr-3' style={{ flex: 1 }}>
<Table />
<Table data={modelerData?.easyDataModelerDataModelAttributes} />
</div>
<Button type='primary' size='small' onClick={() => {
setEditInheritedParms({ visible: true, id: '643df3039e14e61e90acdfe7-1' });
setEditInheritedParms({ visible: true, modelerData });
}}>编辑</Button>
</div>
</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>
)
}
export default FC;
const Basic = () => {
const Basic = ({ modelerData }) => {
return (
<Row gutter={10}>
<Col className='mb-4' span={12}>
<Tooltip title=''>
<Typography.Text ellipsis={true}>
中文名称:&nbsp;<Typography.Text></Typography.Text>
中文名称:&nbsp;<Typography.Text>{modelerData?.cnName}</Typography.Text>
</Typography.Text>
</Tooltip>
</Col>
......@@ -93,7 +131,7 @@ const Basic = () => {
)
}
const Table = () => {
const Table = ({ data }) => {
const cols = [
{
name: '序号',
......@@ -152,10 +190,7 @@ const Table = () => {
<DataGrid
style={{ blockSize: 146 }}
columns={cols}
rows={Array.from({ length: 10000 }).map((_, i) => ({
name: `test${i}`,
}))}
// rows={data||[]}
rows={data||[]}
headerHeight={30}
rowHeight={36}
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