Commit a1b9c621 by zhaochengxiang

模型增加ddl导入

parent 4c0028c8
...@@ -102,6 +102,10 @@ export function* getDraft(payload) { ...@@ -102,6 +102,10 @@ export function* getDraft(payload) {
return yield call(datamodelerService.draft, payload); return yield call(datamodelerService.draft, payload);
} }
export function* getDraftUsingDDL(payload) {
return yield call(datamodelerService.draftUsingDDL, payload);
}
export function* getConsult(payload) { export function* getConsult(payload) {
return yield call(datamodelerService.consult, payload); return yield call(datamodelerService.consult, payload);
} }
......
...@@ -53,6 +53,10 @@ export function draft(payload) { ...@@ -53,6 +53,10 @@ export function draft(payload) {
return PostJSON("/datamodeler/easyDataModelerDesign/draft", payload); return PostJSON("/datamodeler/easyDataModelerDesign/draft", payload);
} }
export function draftUsingDDL(payload) {
return PostJSON("/datamodeler/easyDataModelerDesign/draftUsingDDL", payload);
}
//切换模版或者规范时调用 //切换模版或者规范时调用
export function consult(payload) { export function consult(payload) {
return PostJSON("/datamodeler/easyDataModelerDesign/consult", payload); return PostJSON("/datamodeler/easyDataModelerDesign/consult", payload);
......
...@@ -74,6 +74,12 @@ const FilterElement = (props) => { ...@@ -74,6 +74,12 @@ const FilterElement = (props) => {
(elements||[]).forEach(element => { (elements||[]).forEach(element => {
_selectedKeys.push(element.id||''); _selectedKeys.push(element.id||'');
}); });
} else {
(elements||[]).forEach(element => {
if ((element.name||'')==='中文名称') {
_selectedKeys.push(element.id||'');
}
});
} }
setSelectedKeys(_selectedKeys); setSelectedKeys(_selectedKeys);
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Modal, Select, Form, Input, Divider, Space, Button, Upload } from 'antd'; import { Modal, Select, Form, Input, Divider, Space, Button, Switch, TimePicker } from 'antd';
import { UploadOutlined } from '@ant-design/icons'; import moment from 'moment';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { showMessage } from '../../../../util'; import { showMessage } from '../../../../util';
...@@ -11,6 +11,7 @@ const ScheduleAction = (props) => { ...@@ -11,6 +11,7 @@ const ScheduleAction = (props) => {
const { action, id, form, tid } = props; const { action, id, form, tid } = props;
const [ schedule, setSchedule ] = useState({}); const [ schedule, setSchedule ] = useState({});
const [ currentExeCycleType, setCurrentExeCycleType ] = useState(null);
useEffect(() => { useEffect(() => {
reset(); reset();
...@@ -41,11 +42,54 @@ const ScheduleAction = (props) => { ...@@ -41,11 +42,54 @@ const ScheduleAction = (props) => {
id id
}, },
callback: data => { callback: data => {
function compare(val1, val2) {
var a = val1.seq;
var b = val2.seq;
return (a - b);
}
(data?.targetParameters||[]).sort(compare);
(data?.scheduleParameters||[]).sort(compare);
setSchedule(data||{}); setSchedule(data||{});
setFormFiledsValue(data||{});
} }
}) })
} }
const getCurrentExeCycleType = (data) => {
(data?.scheduleParameters||[]).forEach(item => {
if (item.name === 'exeCycleType') {
setCurrentExeCycleType(item.value);
}
});
}
const setFormFiledsValue = (data) => {
let _fieldsValue = {};
(data?.targetParameters||[]).forEach(item => {
_fieldsValue[item.name||''] = item.value||'';
if (item.selectMode === 'switch') {
_fieldsValue[item.name||''] = (item.value==="1") ? true: false;
} else if (item.selectMode === 'timePicker') {
_fieldsValue[item.name||''] = moment(item.value, 'HH:mm:ss');
}
});
(data?.scheduleParameters||[]).forEach(item => {
_fieldsValue[item.name||''] = item.value||'';
if (item.selectMode === 'switch') {
_fieldsValue[item.name||''] = (item.value==="1") ? true: false;
} else if (item.selectMode === 'timePicker') {
_fieldsValue[item.name||''] = moment(item.value, 'HH:mm:ss');
}
});
form.setFieldsValue(_fieldsValue);
}
const reset =() => { const reset =() => {
form.resetFields(); form.resetFields();
} }
...@@ -61,6 +105,46 @@ const ScheduleAction = (props) => { ...@@ -61,6 +105,46 @@ const ScheduleAction = (props) => {
}, },
}; };
const formItemBody = (item) => {
if (item.selectMode === 'switch') {
return <Switch />;
}
if (item.selectMode === 'singleSelect') {
const _datas = [];
if (item.name === 'exeDay') {
} else {
for (var key in item.selectItemMap) {
_datas.push({key, value: item.selectItemMap[key]});
}
}
return (
<Select>
{
_datas.map((_data, index) => {
return (
<Select.Option key={index} value={_data.key}>{_data.value}</Select.Option>
);
})
}
</Select>
);
}
if (item.selectMode === 'timePicker') {
return <TimePicker />;
}
return (
item.show ? <Input placeholder={item.explain||''} />
: <Input.Password placeholder={item.explain||''} visibilityToggle={false} />
)
}
return ( return (
<Form {...formItemLayout} form={form}> <Form {...formItemLayout} form={form}>
{ {
...@@ -70,9 +154,24 @@ const ScheduleAction = (props) => { ...@@ -70,9 +154,24 @@ const ScheduleAction = (props) => {
label={item.cnName||''} label={item.cnName||''}
name={item.name||''} name={item.name||''}
key={index} key={index}
rules={[{ required: item.required, message: '必填项', type: (item.selectMode==='timePicker')?'object': 'string'}]}
valuePropName={(item.selectMode==='switch')? 'checked': 'value'}
>
{ formItemBody(item) }
</Form.Item>
)
})
}
{
schedule && (schedule.scheduleParameters||[]).map((item, index) => {
return (
<Form.Item
label={item.cnName||''}
name={item.name||''}
key={index}
rules={[{ required: item.required, message: '必填项'}]} rules={[{ required: item.required, message: '必填项'}]}
> >
{ ( item.show ? <Input placeholder={item.explain||''} /> : <Input.Password placeholder={item.explain||''} visibilityToggle={false} /> ) } { formItemBody(item) }
</Form.Item> </Form.Item>
) )
}) })
......
...@@ -8,7 +8,7 @@ import ImportActionIndex from './ImportActionIndex'; ...@@ -8,7 +8,7 @@ import ImportActionIndex from './ImportActionIndex';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
const ImportAction = (props) => { const ImportAction = (props) => {
const { action, hints, onChange, form, modelerId, terms } = props; const { action, hints, onChange, form, modelerId, terms, ddl } = props;
const [ constraints, setConstraints ] = useState([]); const [ constraints, setConstraints ] = useState([]);
const [ constraint, setConstraint ] = useState({}); const [ constraint, setConstraint ] = useState({});
...@@ -21,7 +21,7 @@ const ImportAction = (props) => { ...@@ -21,7 +21,7 @@ const ImportAction = (props) => {
useEffect(() =>{ useEffect(() =>{
if (action==='add' && (hints||[]).length === 0) return; if (action==='add' && (hints||[]).length===0 && (ddl||'').length===0) return;
//初始化form状态 //初始化form状态
if (action==='add'||action==='edit') { if (action==='add'||action==='edit') {
...@@ -46,7 +46,11 @@ const ImportAction = (props) => { ...@@ -46,7 +46,11 @@ const ImportAction = (props) => {
if (action === 'add') { if (action === 'add') {
setConstraint((data.constraints||[]).length>0?data.constraints[0]:{}); setConstraint((data.constraints||[]).length>0?data.constraints[0]:{});
setTemplate({}); setTemplate({});
getDraft((data.constraints||[]).length>0?data.constraints[0]:{}, {} ,hints); if ((hints||[]).length>0) {
getDraft((data.constraints||[]).length>0?data.constraints[0]:{}, {} ,hints);
} else if ((ddl||'').length>0) {
getDraftUsingDDL((data.constraints||[]).length>0?data.constraints[0]:{}, {} ,ddl);
}
} else if(action === 'edit' || action === 'detail') { } else if(action === 'edit' || action === 'detail') {
getCurrentDataModel(); getCurrentDataModel();
} }
...@@ -56,7 +60,7 @@ const ImportAction = (props) => { ...@@ -56,7 +60,7 @@ 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, ddl ]);
const getDraft = (_constraint, _template, _hints) => { const getDraft = (_constraint, _template, _hints) => {
dispatch({ dispatch({
...@@ -83,6 +87,31 @@ const ImportAction = (props) => { ...@@ -83,6 +87,31 @@ const ImportAction = (props) => {
}) })
} }
const getDraftUsingDDL = (_constraint, _template, _ddl) => {
dispatch({
type: 'datamodel.getDraftUsingDDL',
payload: {
data: {
ddl: _ddl,
modelerModelingConstraint: _constraint,
easyDataModelerModelingTemplate: _template
}
},
callback: data => {
setModelerData(data||{});
form.setFieldsValue({
cnName: data.cnName||'',
name: data.name||'',
remark: data.remark||'',
easyDataModelerModelingConstraint: data.easyDataModelerModelingConstraint||'',
easyDataModelerModelingTemplate: data.easyDataModelerModelingTemplate||''
});
onChange && onChange(data||{});
getSupportedDatatypes();
}
})
}
const getConsult = (data) => { const getConsult = (data) => {
dispatch({ dispatch({
type: 'datamodel.getConsult', type: 'datamodel.getConsult',
......
import React from 'react';
import { Input } from 'antd';
class ImportDDL extends React.Component {
constructor() {
super();
this.state = {
inputValue: ''
};
}
componentDidUpdate(preProps, preState) {
const { visible } = this.props;
if (!visible && visible !== preProps.visible) {
this.setState({ inputValue: '' });
}
}
onInputChange = (e) => {
const { onChange } = this.props;
this.setState({ inputValue: e.target.value }, () => {
onChange && onChange(e.target.value);
});
}
render() {
const { inputValue } = this.state;
const _placeholder = '支持两种方式创建\n方式一: DDL内容复制粘贴\n方式二: 手动输入DDL';
return (
<Input.TextArea
value={inputValue||''}
onChange={this.onInputChange}
autoSize={{minRows:4,maxRows:20}}
placeholder={_placeholder}
>
</Input.TextArea>
)
}
}
export default ImportDDL;
\ No newline at end of file
...@@ -4,6 +4,7 @@ import { Modal, Button, Form } from 'antd'; ...@@ -4,6 +4,7 @@ import { Modal, Button, Form } from 'antd';
// import ImportLog from './ImportLog'; // import ImportLog from './ImportLog';
import ImportExcel from './ImportExcel'; import ImportExcel from './ImportExcel';
import ImportExcelCopy from './ImportExcelCopy'; import ImportExcelCopy from './ImportExcelCopy';
import ImportDDL from './ImportDDL';
import ImportMetadata from './ImportMetadata'; import ImportMetadata from './ImportMetadata';
import ImportAction from './ImportAction'; import ImportAction from './ImportAction';
...@@ -15,6 +16,7 @@ const ImportModal = (props) => { ...@@ -15,6 +16,7 @@ const ImportModal = (props) => {
const [ step, setStep ] = useState(0); const [ step, setStep ] = useState(0);
const [ excelFiles, setExcelFiles ] = useState([]); const [ excelFiles, setExcelFiles ] = useState([]);
const [ hints, setHints ] = useState([]); const [ hints, setHints ] = useState([]);
const [ ddl, setDDL ] = useState('');
const [ modelerData, setModelerData ] = useState({}); const [ modelerData, setModelerData ] = useState({});
const [ confirmLoading, setConfirmLoading ] = useState(false); const [ confirmLoading, setConfirmLoading ] = useState(false);
const [ terms, setTerms ] = useState([]); const [ terms, setTerms ] = useState([]);
...@@ -68,6 +70,16 @@ const ImportModal = (props) => { ...@@ -68,6 +70,16 @@ const ImportModal = (props) => {
return; return;
} else if (step===0 && addMode==='ddl') {
if ((ddl||[]).length === 0) {
showMessage('warn', '请先输入ddl');
} else {
setStep(step+1);
}
return;
} }
setStep(step+1); setStep(step+1);
...@@ -125,6 +137,7 @@ const ImportModal = (props) => { ...@@ -125,6 +137,7 @@ const ImportModal = (props) => {
setStep(0); setStep(0);
setExcelFiles([]); setExcelFiles([]);
setHints([]); setHints([]);
setDDL('');
setModelerData({}); setModelerData({});
setConfirmLoading(false); setConfirmLoading(false);
} }
...@@ -141,16 +154,24 @@ const ImportModal = (props) => { ...@@ -141,16 +154,24 @@ const ImportModal = (props) => {
setHints(data||[]); setHints(data||[]);
} }
const onImportDDLChange = (data) => {
setDDL(data);
}
let title = ''; let title = '';
if (action === 'add') { if (action === 'add') {
if (step===0 && addMode==='excel') { if (step===0 && addMode==='excel') {
title = 'Excel导入'; title = 'Excel导入';
} else if (step===0 && addMode==='excel-copy') { } else if (step===0 && addMode==='excel-copy') {
title = 'Excel复制粘贴导入'; title = 'Excel复制粘贴导入';
} else if (step===0 && addMode==='ddl') {
title = 'DDL导入';
} else if (step===1 && addMode==='excel') { } else if (step===1 && addMode==='excel') {
title = '模型创建-Excel导入'; title = '模型创建-Excel导入';
} else if (step===1 && addMode=== 'excel-copy') { } else if (step===1 && addMode=== 'excel-copy') {
title = '模型创建-Excel复制粘贴导入'; title = '模型创建-Excel复制粘贴导入';
} else if (step===1 && addMode==='ddl') {
title = '模型创建-DDL导入';
} }
} else if (action === 'edit') { } else if (action === 'edit') {
title = '模型编辑'; title = '模型编辑';
...@@ -246,6 +267,13 @@ const ImportModal = (props) => { ...@@ -246,6 +267,13 @@ const ImportModal = (props) => {
</div> </div>
) )
} }
{
addMode==='ddl' && (
<div style={{ display: step===0?'':'none' }}>
<ImportDDL onChange={onImportDDLChange} {...props} />
</div>
)
}
{ {
step===0 && addMode==='erwin' && <></> step===0 && addMode==='erwin' && <></>
} }
...@@ -253,7 +281,7 @@ const ImportModal = (props) => { ...@@ -253,7 +281,7 @@ const ImportModal = (props) => {
step===0 && addMode==='metadata' && <ImportMetadata /> step===0 && addMode==='metadata' && <ImportMetadata />
} }
{ {
step===1 && <ImportAction hints={hints} onChange={onActionChange} action={action} modelerId={modelerId} form={form} terms={terms} /> step===1 && <ImportAction hints={hints} ddl={ddl} onChange={onActionChange} action={action} modelerId={modelerId} form={form} terms={terms} />
} }
</> </>
</Modal> </Modal>
......
...@@ -123,6 +123,16 @@ class Model extends React.Component { ...@@ -123,6 +123,16 @@ class Model extends React.Component {
this.setState({ importModalVisible: true, importModalAction: 'add', importModalAddMode: 'excel-copy' }); this.setState({ importModalVisible: true, importModalAction: 'add', importModalAddMode: 'excel-copy' });
} }
onImportDDLBtnClick = () => {
const { catalogId } = this.state;
if (!catalogId || catalogId==='') {
showMessage('info', '请先选择目录');
return;
}
this.setState({ importModalVisible: true, importModalAction: 'add', importModalAddMode: 'ddl' });
}
onExportDDLBtnClick = () => { onExportDDLBtnClick = () => {
const { selectModelerIds, tableData } = this.state; const { selectModelerIds, tableData } = this.state;
if ((selectModelerIds||[]).length === 0) { if ((selectModelerIds||[]).length === 0) {
...@@ -266,6 +276,7 @@ class Model extends React.Component { ...@@ -266,6 +276,7 @@ class Model extends React.Component {
<span>模型创建:</span> <span>模型创建:</span>
<Button type="primary" onClick={this.onImportExcelBtnClick}>Excel导入</Button> <Button type="primary" onClick={this.onImportExcelBtnClick}>Excel导入</Button>
<Button type="primary" onClick={this.onImportExcelCopyBtnClick}>Excel复制粘贴</Button> <Button type="primary" onClick={this.onImportExcelCopyBtnClick}>Excel复制粘贴</Button>
<Button type="primary" onClick={this.onImportDDLBtnClick}>DDL导入</Button>
</Space> </Space>
<Space> <Space>
<span>模型导出:</span> <span>模型导出:</span>
......
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