Commit 11de4519 by zhaochengxiang

word导入逻辑修改

parent 72e477cb
......@@ -130,7 +130,7 @@ export function uploadWordTemplate(payload) {
}
export function importWordGenerateModel(payload) {
return PostFile("/datamodeler/easyDataModelerExport/word", payload);
return PostFile("/datamodeler/easyDataModelerExport/word/draft", payload);
}
export function validateDataModel(payload) {
......
......@@ -7,3 +7,4 @@ export const Action = 'action';
export const CatalogId = 'cid';
export const ModelerId = 'mid';
export const Hints = 'hints';
export const ModelerData = 'mdata';
\ No newline at end of file
......@@ -4,17 +4,17 @@ import { Form, Button } from 'antd';
import ImportAction from './ImportAction';
import { dispatchLatest } from '../../../../model';
import { getQueryParam, showMessage } from '../../../../util';
import { Action, CatalogId, ModelerId, Hints } from '../../../../util/constant';
import { Action, CatalogId, ModelerId, Hints, ModelerData } from '../../../../util/constant';
const EditModel = (props) => {
const [ actionData, setActionData ] = useState({ action: '', catalogId: '', modelerId: '', hints: [] });
const [ actionData, setActionData ] = useState({ action: '', catalogId: '', modelerId: '', hints: [], roughModelerData: {} });
const [ modelerData, setModelerData ] = useState({});
const [ terms, setTerms ] = useState([]);
const [ confirmLoading, setConfirmLoading ] = useState(false);
const { action, catalogId, modelerId, hints } = actionData;
const { action, catalogId, modelerId, hints, roughModelerData } = actionData;
const [form] = Form.useForm();
......@@ -23,13 +23,19 @@ const EditModel = (props) => {
const _catalogId = getQueryParam(CatalogId, props.location.search);
const _modelerId = getQueryParam(ModelerId, props.location.search);
const _hintsStr = getQueryParam(Hints, props.location.search);
const _modelerDataStr = getQueryParam(ModelerData, props.location.search)
let _hints = [];
if ((_hintsStr||'') !== '') {
_hints = _hintsStr.split(',');
}
setActionData({ action: _action, catalogId: _catalogId, modelerId: _modelerId, hints: _hints });
let _roughModelerData = {};
if ((_modelerDataStr||'') !== '') {
_roughModelerData = JSON.parse(_modelerDataStr);
}
setActionData({ action: _action, catalogId: _catalogId, modelerId: _modelerId, hints: _hints, roughModelerData: _roughModelerData });
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
......@@ -141,7 +147,7 @@ const EditModel = (props) => {
</div>
<div className='position-absolute' style={{ top: 64, width: '100%' }}>
<div className='position-relative' style={{ margin: 15 }}>
<ImportAction hints={hints} onChange={onActionChange} action={action} modelerId={modelerId} form={form} terms={terms} />
<ImportAction hints={hints} onChange={onActionChange} action={action} modelerId={modelerId} form={form} terms={terms} roughModelerData={roughModelerData} />
</div>
</div>
</div>
......
......@@ -98,7 +98,7 @@ class ExportDDLModal extends React.Component {
this.setState({ loadingDatabases: false, databases: data, filterDatabases: _filterData, currentDatabaseId: ((_filterData||[]).length>0)?_filterData[0]._id:'' }, () => {
if ((_filterData||[]).length>0) {
this.getSchemas(_filterData[0]);
this.getSchemas(_filterData[0]?._id);
} else {
this.setState({ schemas: [], currentSchemaId: '' });
}
......@@ -111,12 +111,12 @@ class ExportDDLModal extends React.Component {
})
}
getSchemas = (db) => {
getSchemas = (dbId) => {
this.setState({ loadingSchemas: true }, () => {
dispatch({
type: 'datamodel.getSchemasByDatasourceId',
payload: {
parentId: db._id||''
parentId: dbId||''
},
callback: data => {
this.setState({ loadingSchemas: false, schemas: data, currentSchemaId: (data||[]).length>0?data[0]._id:'' });
......
......@@ -8,7 +8,7 @@ import ImportActionIndex from './ImportActionIndex';
import { dispatch } from '../../../../model';
const ImportAction = (props) => {
const { action, hints, onChange, form, modelerId, terms, ddl } = props;
const { action, hints, onChange, form, modelerId, terms, ddl, roughModelerData } = props;
const [ constraints, setConstraints ] = useState([]);
const [ constraint, setConstraint ] = useState({});
......@@ -21,7 +21,7 @@ const ImportAction = (props) => {
useEffect(() =>{
if ((action||'')==='' || (action==='add'&&(hints||[]).length===0&&(ddl||'').length===0&&(modelerId||'')==='')) return;
if ((action||'')==='' || (action==='add'&&(hints||[]).length===0&&(ddl||'').length===0&&(modelerId||'')===''&&roughModelerData==={})) return;
//初始化form状态
if (action==='add'||action==='edit') {
......@@ -50,6 +50,8 @@ const ImportAction = (props) => {
getDraftUsingDDL((data.constraints||[]).length>0?data.constraints[0]:{}, {} ,ddl);
} else if ((modelerId||'')!=='') {
getCurrentDataModel();
} else if (roughModelerData !== {}) {
getExtraData(roughModelerData);
}
} else if(action === 'edit' || action === 'detail') {
getCurrentDataModel();
......@@ -144,6 +146,15 @@ const ImportAction = (props) => {
callback: data => {
setLoading(false);
getExtraData(data);
},
error: () => {
setLoading(false);
}
})
}
const getExtraData = (data) => {
setModelerData(data||{});
setConstraint(data.easyDataModelerModelingConstraint||{});
setTemplate(data.easyDataModelerModelingTemplate||{});
......@@ -161,11 +172,6 @@ const ImportAction = (props) => {
}
validateDataModel(data||{});
},
error: () => {
setLoading(false);
}
})
}
const onConstraintChange = (value) => {
......
......@@ -724,7 +724,7 @@ const ImportActionTable = (props) => {
const sourceOnClick = (id) => {
const timestamp = new Date().getTime();
if (id.indexOf('Column=')) {
if (id.split('=').length>=3) {
window.open(`/center-home/menu/metasearch?id=${id}&timestamp=${timestamp}`);
} else {
window.open(`/center-home/menu/datastandard?id=${id}&timestamp=${timestamp}`);
......
......@@ -52,7 +52,7 @@ const ImportWordModal = (props) => {
if (reference==='stock') {
onCancel(true);
} else {
onCancel(true, data?.result, data?.firstId);
onCancel(false, data||[]);
}
}
},
......
import React, { useState, useEffect, useRef } from "react";
import { Space, Button, Tooltip, Modal, Select, Input, Divider } from 'antd';
import { Space, Button, Tooltip, Modal, Select, Input, Divider, Pagination } from 'antd';
import { EditOutlined, ReconciliationOutlined, DeleteOutlined } from '@ant-design/icons';
import SmoothScroll from 'smooth-scroll';
import ProTable from "@ant-design/pro-table";
import { Resizable } from 'react-resizable';
import { dispatchLatest } from '../../../../model';
import { showMessage, getQueryParam } from '../../../../util';
import { showMessage, getQueryParam, paginate } from '../../../../util';
import { AnchorId, AnchorTimestamp } from '../../../../util/constant';
import './ModelTable.less';
......@@ -108,6 +108,9 @@ const ModelTable = (props) => {
}
]);
const [ pagination, setPagination ] = useState( { pageNum: 1, pageSize: 20 } );
const { pageNum, pageSize } = pagination;
const [modal, contextHolder] = Modal.useModal();
const anchorId = getQueryParam(AnchorId, props.location.search);
......@@ -117,10 +120,11 @@ const ModelTable = (props) => {
useEffect(() => {
setPagination({ pageNum: 1, pageSize: 20 });
setSelectedRowKeys([]);
onSelect && onSelect([]);
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ catalogId ]);
}, [ catalogId, keyword ]);
useEffect(() => {
......@@ -290,6 +294,8 @@ const ModelTable = (props) => {
</div>
);
const _data = paginate(data||[], pageNum, pageSize);
return (
<div className='model-table'>
<ProTable
......@@ -301,7 +307,7 @@ const ModelTable = (props) => {
rowSelection={rowSelection}
columns={columns||[]}
rowKey={'id'}
dataSource={data||[]}
dataSource={_data||[]}
pagination={false}
options={{
density: true,
......@@ -320,6 +326,23 @@ const ModelTable = (props) => {
]}
sticky
/>
<Pagination
className="text-center mt-3"
showSizeChanger
showQuickJumper
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum, pageSize: _pageSize || 20 });
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum || 1, pageSize: _pageSize });
}}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={(data||[]).length}
pageSizeOptions={[10,20]}
showTotal={total => `共 ${total} 条`}
/>
{ contextHolder }
</div>
);
......
@import '../../../../variables.less';
.model-table {
.yy-table {
height: calc(100vh - @header-height - @pm-4 - @pm-3 - @pm-3 - 37px - 37px - 48px - @pm-3) !important;
height: calc(100vh - @header-height - @pm-4 - @pm-3 - @pm-3 - 37px - 37px - 48px - @pm-3 - 42px) !important;
overflow: auto !important;
}
......
......@@ -13,7 +13,7 @@ import ExportDDLModal from './Component/ExportDDLModal';
import RecatalogModal from './Component/RecatalogModal';
import { showMessage, showNotifaction } from '../../../util';
import { dispatch } from '../../../model';
import { Action, CatalogId, ModelerId, Hints } from '../../../util/constant';
import { Action, CatalogId, ModelerId, Hints, ModelerData } from '../../../util/constant';
import { AppContext } from '../../../App';
import './index.less';
......@@ -344,19 +344,26 @@ class Model extends React.Component {
});
}
onImportWordModalCancel = (refresh = false, result = '', id = '') => {
onImportWordModalCancel = (refresh = false, datas = []) => {
const { catalogId } = this.state;
this.setState({ importWordModalVisible: false });
refresh && this.onTableChange();
if ((result||'')!=='') {
showMessage('info', result);
if ((datas||[]).length > 0) {
if ((datas||[]).length > 5) {
showMessage('info', '最多只能同时编辑5条信息');
}
if ((id||'')!=='') {
setTimeout(() => {
window.open(`/data-govern/data-model-action?${Action}=add&${CatalogId}=${catalogId}&${ModelerId}=${id}`);
datas.slice(0, 5).forEach(data => {
window.open(`/data-govern/data-model-action?${Action}=add&${CatalogId}=${catalogId}&${ModelerData}=${JSON.stringify(data)}`, '_blank');
})
}, 1000);
}
}
......
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