Commit 573cedac by zhaochengxiang

🉑可取消编辑模型

parent e53e80b1
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Form, Button } from 'antd'; import { Form, Button, Space } from 'antd';
import ImportAction from './ImportAction'; import ImportAction from './ImportAction';
import { dispatchLatest } from '../../../../model'; import { dispatchLatest } from '../../../../model';
...@@ -8,7 +8,7 @@ import { Action, CatalogId, ModelerId, Hints, ModelerData } from '../../../../ut ...@@ -8,7 +8,7 @@ import { Action, CatalogId, ModelerId, Hints, ModelerData } from '../../../../ut
const EditModel = (props) => { const EditModel = (props) => {
const [ actionData, setActionData ] = useState({ action: '', catalogId: '', modelerId: '', hints: [], roughModelerData: {} }); const [ actionData, setActionData ] = useState({ action: '', catalogId: '', modelerId: '', hints: [], roughModelerData: null });
const [ modelerData, setModelerData ] = useState({}); const [ modelerData, setModelerData ] = useState({});
const [ terms, setTerms ] = useState([]); const [ terms, setTerms ] = useState([]);
...@@ -30,7 +30,7 @@ const EditModel = (props) => { ...@@ -30,7 +30,7 @@ const EditModel = (props) => {
_hints = _hintsStr.split(','); _hints = _hintsStr.split(',');
} }
let _roughModelerData = {}; let _roughModelerData = null;
if ((_modelerDataStr||'') !== '') { if ((_modelerDataStr||'') !== '') {
_roughModelerData = JSON.parse(_modelerDataStr); _roughModelerData = JSON.parse(_modelerDataStr);
} }
...@@ -93,6 +93,10 @@ const EditModel = (props) => { ...@@ -93,6 +93,10 @@ const EditModel = (props) => {
setActionData({ ...actionData, action: 'edit' }); setActionData({ ...actionData, action: 'edit' });
} }
const cancelEdit = () => {
setActionData({ ...actionData, action: 'detail' });
}
const onActionChange = (data) => { const onActionChange = (data) => {
setModelerData(data); setModelerData(data);
} }
...@@ -106,10 +110,10 @@ const EditModel = (props) => { ...@@ -106,10 +110,10 @@ const EditModel = (props) => {
title = '模型详情'; title = '模型详情';
} }
let actionBtn = null; let actionsBtn = null;
if (action==='add' || action==='edit') { if (action==='add') {
actionBtn = ( actionsBtn = (
<Button <Button
type='primary' type='primary'
onClick={save} onClick={save}
...@@ -118,12 +122,27 @@ const EditModel = (props) => { ...@@ -118,12 +122,27 @@ const EditModel = (props) => {
保存 保存
</Button> </Button>
) )
} else if (action==='detail') { } else if (action === 'detail') {
actionBtn = ( actionsBtn = (
<Button type='primary' onClick={edit} > <Button type='primary' onClick={edit} >
编辑 编辑
</Button> </Button>
); );
} else if (action === 'edit') {
actionsBtn = (
<Space>
<Button onClick={cancelEdit} >
取消
</Button>
<Button
type='primary'
onClick={save}
loading={confirmLoading}
>
保存
</Button>
</Space>
)
} }
return ( return (
...@@ -143,7 +162,7 @@ const EditModel = (props) => { ...@@ -143,7 +162,7 @@ const EditModel = (props) => {
}} }}
> >
<span style={{ fontSize: 16, fontWeight: 'bold', color: '#000' }}>{title}</span> <span style={{ fontSize: 16, fontWeight: 'bold', color: '#000' }}>{title}</span>
{actionBtn} {actionsBtn}
</div> </div>
<div className='position-absolute' style={{ top: 64, width: '100%' }}> <div className='position-absolute' style={{ top: 64, width: '100%' }}>
<div className='position-relative' style={{ margin: 15 }}> <div className='position-relative' style={{ margin: 15 }}>
......
...@@ -50,11 +50,11 @@ const ImportAction = (props) => { ...@@ -50,11 +50,11 @@ const ImportAction = (props) => {
getDraftUsingDDL((data.constraints||[]).length>0?data.constraints[0]:{}, {} ,ddl); getDraftUsingDDL((data.constraints||[]).length>0?data.constraints[0]:{}, {} ,ddl);
} else if ((modelerId||'')!=='') { } else if ((modelerId||'')!=='') {
getCurrentDataModel(); getCurrentDataModel();
} else if (roughModelerData !== {}) { } else if (roughModelerData) {
setLoading(false); setLoading(false);
getExtraData(roughModelerData); getExtraData(roughModelerData);
} else { } else {
setLoading(false); getDraft((data.constraints||[]).length>0?data.constraints[0]:{}, {} ,[]);
} }
} else if(action === 'edit' || action === 'detail') { } else if(action === 'edit' || action === 'detail') {
getCurrentDataModel(); getCurrentDataModel();
......
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