Commit 573cedac by zhaochengxiang

🉑可取消编辑模型

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