Commit 21c03651 by zhaochengxiang

模型增加模版

parent 7ba19260
...@@ -70,8 +70,11 @@ export function* extractExcelContent(payload) { ...@@ -70,8 +70,11 @@ export function* extractExcelContent(payload) {
return yield call(datamodelerService.extractExcelContent, payload); return yield call(datamodelerService.extractExcelContent, payload);
} }
export function* getAllConstraints() { export function* getAllConstraintsAndTemplates() {
return yield call(datamodelerService.constraints); const constraints = yield call(datamodelerService.constraints);
const templates = yield call(datamodelerService.templates);
return { constraints, templates };
} }
//获取初稿 //获取初稿
......
...@@ -31,6 +31,11 @@ export function constraints() { ...@@ -31,6 +31,11 @@ export function constraints() {
return GetJSON("/datamodeler/easyDataModelerConstraint/constraints"); return GetJSON("/datamodeler/easyDataModelerConstraint/constraints");
} }
//模版
export function templates() {
return GetJSON("/datamodeler/easyDataModelerConstraint/templates");
}
//创建初稿 //创建初稿
export function draft(payload) { export function draft(payload) {
return PostJSON("/datamodeler/easyDataModelerDesign/draft", payload); return PostJSON("/datamodeler/easyDataModelerDesign/draft", payload);
......
...@@ -14,6 +14,8 @@ const ImportAction = (props) => { ...@@ -14,6 +14,8 @@ const ImportAction = (props) => {
const [ constraints, setConstraints ] = useState([]); const [ constraints, setConstraints ] = useState([]);
const [ constraint, setConstraint ] = useState({}); const [ constraint, setConstraint ] = useState({});
const [ templates, setTemplates ] = useState([]);
const [ template, setTemplate ] = useState({});
const [ modelerData, setModelerData ] = useState(null); const [ modelerData, setModelerData ] = useState(null);
const [ supportedDatatypes, setSupportedDatatypes ] = useState([]); const [ supportedDatatypes, setSupportedDatatypes ] = useState([]);
...@@ -37,12 +39,14 @@ const ImportAction = (props) => { ...@@ -37,12 +39,14 @@ const ImportAction = (props) => {
getCurrentDataModel(); getCurrentDataModel();
} else { } else {
dispatchLatest({ dispatchLatest({
type: 'datamodel.getAllConstraints', type: 'datamodel.getAllConstraintsAndTemplates',
callback: data => { callback: data => {
setConstraints(data||[]); setConstraints(data.constraints||[]);
setTemplates(data.templates||[]);
if (action === 'add') { if (action === 'add') {
setConstraint((data||[]).length>0?data[0]:{}); setConstraint((data.constraints||[]).length>0?data.constraints[0]:{});
getDraft((data||[]).length>0?data[0]:{}, hints); setTemplate((data.templates||[]).length>0?data.templates[0]:{});
getDraft((data.constraints||[]).length>0?data.constraints[0]:{}, (data.templates||[]).length>0?data.templates[0]:{} ,hints);
} else if(action === 'edit') { } else if(action === 'edit') {
getCurrentDataModel(); getCurrentDataModel();
} }
...@@ -52,13 +56,14 @@ const ImportAction = (props) => { ...@@ -52,13 +56,14 @@ const ImportAction = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [action, hints, modelerId ]); }, [action, hints, modelerId ]);
const getDraft = (_constraint, _hints) => { const getDraft = (_constraint, _template, _hints) => {
dispatchLatest({ dispatchLatest({
type: 'datamodel.getDraft', type: 'datamodel.getDraft',
payload: { payload: {
data: { data: {
hints: _hints, hints: _hints,
modelerModelingConstraint: _constraint modelerModelingConstraint: _constraint,
easyDataModelerModelingTemplate: _template
} }
}, },
callback: data => { callback: data => {
...@@ -112,7 +117,26 @@ const ImportAction = (props) => { ...@@ -112,7 +117,26 @@ const ImportAction = (props) => {
}); });
setConstraint(currentConstraint); setConstraint(currentConstraint);
getDraft(currentConstraint, _hints); getDraft(currentConstraint, template, _hints);
}
const onTemplateChange = (value) => {
let currentTemplate = null, _hints = [];
(templates||[]).forEach((_template, index) => {
if (_template.id === value) {
currentTemplate = _template;
}
});
(modelerData.easyDataModelerDataModelAttributes||[]).forEach((_attribute, index) => {
if (_attribute.name && _attribute.name!=='') {
_hints.push(_attribute.cnName);
}
});
setTemplate(currentTemplate);
getDraft(constraint, currentTemplate, _hints);
} }
const getSupportedDatatypes = () => { const getSupportedDatatypes = () => {
...@@ -145,6 +169,15 @@ const ImportAction = (props) => { ...@@ -145,6 +169,15 @@ const ImportAction = (props) => {
}) })
} }
</Select> </Select>
<Select className='ml-3' value={template.id?template.id:null} placeholder='请选择模版' style={{ minWidth: 100 }} onChange={onTemplateChange}>
{
(templates||[]).map((template, index) => {
return (
<Option key={index} value={template.id}>{ template.cnName||'' }</Option>
)
})
}
</Select>
</div> </div>
} }
<ImportActionHeader <ImportActionHeader
......
import React, { useState, useCallback, useRef, useEffect } from 'react'; import React, { useState, useCallback, useRef, useEffect } from 'react';
import { Table, Input, InputNumber, Form, Typography, Radio, Divider, Button, Popconfirm, Select, Row, Col } from 'antd'; import { Table, Input, InputNumber, Form, Typography, Radio, Divider, Button, Popconfirm, Select, Row, Col, Descriptions } from 'antd';
import { DndProvider, useDrag, useDrop } from 'react-dnd'; import { DndProvider, useDrag, useDrop } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend'; import { HTML5Backend } from 'react-dnd-html5-backend';
import update from 'immutability-helper'; import update from 'immutability-helper';
...@@ -424,24 +424,6 @@ const ImportActionTable = (props) => { ...@@ -424,24 +424,6 @@ const ImportActionTable = (props) => {
return columns; return columns;
} }
// const mergedColumns = columns.map((col) => {
// if (!col.editable) {
// return col;
// }
// return {
// ...col,
// onCell: (record) => ({
// record,
// inputType: 'text',
// dataIndex: col.dataIndex,
// title: col.title,
// editing: isEditing(record),
// datatypes: supportedDatatypes,
// }),
// };
// });
const moveRow = useCallback( const moveRow = useCallback(
(dragIndex, hoverIndex) => { (dragIndex, hoverIndex) => {
...@@ -505,7 +487,7 @@ const ImportActionTable = (props) => { ...@@ -505,7 +487,7 @@ const ImportActionTable = (props) => {
suggests && suggests.map((suggest, index) => { suggests && suggests.map((suggest, index) => {
return ( return (
<Radio key={index} value={index} className='mt-3' style={{ display: 'block' }}> <Radio key={index} value={index} className='mt-3' style={{ display: 'block' }}>
{`${suggest.name||''}`} {`中文名称: ${suggest.cnName||''} 英文名称: ${suggest.name||''} 描述: ${suggest.remark||''}`}
</Radio> </Radio>
) )
}) })
......
...@@ -82,6 +82,14 @@ const ModelTable = (props) => { ...@@ -82,6 +82,14 @@ const ModelTable = (props) => {
callback: () => { callback: () => {
showMessage('success', '模型删除成功'); showMessage('success', '模型删除成功');
onChange && onChange(); onChange && onChange();
const index = selectedRowKeys.findIndex((rowKey) => rowKey === record.id);
if (index !== -1) {
const newSelectedRowKeys = [...selectedRowKeys];
newSelectedRowKeys.splice(index, 1);
setSelectedRowKeys(newSelectedRowKeys);
onSelect && onSelect(newSelectedRowKeys);
}
} }
}) })
} }
......
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