Commit 499e49d3 by zhaochengxiang

修改模型bug

parent e9ae7962
......@@ -358,7 +358,7 @@ const EditModel = (props) => {
</div>
<div className='edit-container'>
<div className='edit-container-card'>
<ImportAction hints={hints} onChange={onActionChange} action={action} modelerId={modelerId} ddl={ddl} form={form} terms={terms} roughModelerData={roughModelerData} permitCheckOut={permitCheckOut} stateId={stateId} versionId={versionId} autoTabKey={autoTabKey} {...props} />
<ImportAction hints={hints} onChange={onActionChange} action={action} modelerId={modelerId} catalogId={catalogId} ddl={ddl} form={form} terms={terms} roughModelerData={roughModelerData} permitCheckOut={permitCheckOut} stateId={stateId} versionId={versionId} autoTabKey={autoTabKey} {...props} />
</div>
</div>
<div className='edit-footer'>
......
......@@ -11,7 +11,7 @@ import { Action } from '../../../../util/constant';
import { dispatch } from '../../../../model';
const ImportAction = (props) => {
const { action, hints, onChange, form, modelerId, terms, ddl, roughModelerData, versionId, permitCheckOut } = props;
const { action, hints, onChange, form, modelerId, terms, ddl, roughModelerData, versionId, permitCheckOut, catalogId } = props;
const [ constraints, setConstraints ] = useState([]);
const [ constraint, setConstraint ] = useState({});
......@@ -96,7 +96,8 @@ const ImportAction = (props) => {
data: {
hints: _hints,
modelerModelingConstraint: _constraint,
easyDataModelerModelingTemplate: _template
easyDataModelerModelingTemplate: _template,
dataCatalogId: catalogId,
}
},
callback: data => {
......@@ -265,16 +266,17 @@ const ImportAction = (props) => {
let currentTemplate = null;
(templates||[]).forEach((_template, index) => {
if (_template.name === value) {
if (_template.cnName === value) {
currentTemplate = _template;
}
});
form.setFieldsValue({
easyDataModelerModelingTemplate: currentTemplate||{}
easyDataModelerModelingTemplate: currentTemplate||{},
tableType: value
});
const newModelerData = {...modelerData, easyDataModelerModelingTemplate: currentTemplate };
const newModelerData = {...modelerData, easyDataModelerModelingTemplate: currentTemplate, tableType: currentTemplate ? currentTemplate.cnName : value };
setModelerData(newModelerData);
modelerDataRef.current = newModelerData;
......@@ -282,8 +284,10 @@ const ImportAction = (props) => {
onChange && onChange(newModelerData);
setTemplate(currentTemplate);
if (currentTemplate) {
getConsult(newModelerData);
}
}
const getSupportedDatatypes = () => {
dispatch({
......
import React, { useState, useEffect, useMemo } from 'react';
import { Form, Input, Row, Col, Descriptions, Select, AutoComplete, Button, Divider, Tooltip } from 'antd';
import React, { useState, useEffect, useMemo, useRef } from 'react';
import { Form, Input, Row, Col, Descriptions, Select, AutoComplete, Button, Divider, Tooltip, Checkbox, Space } from 'antd';
import { DownOutlined, UpOutlined } from '@ant-design/icons';
import { highlightSearchContentByTerms, generateUUID } from '../../../../util';
......@@ -81,20 +81,45 @@ const ConstraintSelect = ({ value = {}, constraints = [], onChange, ...restProps
)
}
const TemplateSelect = ({ value = {}, templates = [], onChange, ...restProps }) => {
const TemplateSelect = ({ value = '', modelerData = undefined, templates = [], onChange, ...restProps }) => {
const mountRef = useRef(true);
const [isCustom, setIsCustom] = useState(false);
useEffect(() => {
if (mountRef.current) {
if (value && !modelerData?.easyDataModelerModelingTemplate?.name) {
setIsCustom(true);
} else {
setIsCustom(false);
}
}
mountRef.current = false;
}, [modelerData])
return (
<Select
<span style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
{
isCustom ? <Input
placeholder='请输入数据表类型'
allowClear
defaultValue={modelerData?.tableType}
onChange={(e) => {
onChange?.(e.target.value);
}}
style={{ flex: 1 }}
/> : <Select
onChange={onChange}
value={value?.name || undefined}
defaultValue={value || undefined}
placeholder='请选择数据表类型'
allowClear
style={{ flex: 1 }}
{...restProps}
>
{
(templates||[]) && templates.map((template, index) => {
return (
<Option key={index} value={template.name||''} >
<Option key={index} value={template.cnName||''} >
<Tooltip title={template.remark}>
{template.cnName}
</Tooltip>
......@@ -103,6 +128,12 @@ const TemplateSelect = ({ value = {}, templates = [], onChange, ...restProps })
})
}
</Select>
}
<Checkbox className='ml-3' checked={isCustom} onChange={(e) => {
setIsCustom(e.target.checked);
onChange?.('');
}}>自定义</Checkbox>
</span>
)
}
......@@ -125,8 +156,6 @@ const AttributesSelect = ({ value = [], modelerData, onChange, mode = 'multiple'
})
}
console.log('currentAttributes', currentAttributes)
triggerChange(currentAttributes);
}
......@@ -520,7 +549,6 @@ const ImportActionHeader = (props) => {
}
const onValuesChange = (changedValues, allValues) => {
onChange && onChange(changedValues, allValues);
//有手动编辑过英文名称并且有内容的情况下, 不能通过编辑中文名称自动翻译
......@@ -561,7 +589,7 @@ const ImportActionHeader = (props) => {
>
<h2 className='mr-3' style={{ marginBottom: 0 }}>基本信息</h2>
{
!editable && (onlyShowRequireChange ? <Button type='primary' size='small' onClick={onOnlyShowRequireChange}>展开<DownOutlined /></Button> : <Button type='primary' size='small' onClick={onOnlyShowRequireChange}>收起<UpOutlined /></Button>)
(onlyShowRequireChange ? <Button type='primary' size='small' onClick={onOnlyShowRequireChange}>展开<DownOutlined /></Button> : <Button type='primary' size='small' onClick={onOnlyShowRequireChange}>收起<UpOutlined /></Button>)
}
</div>
{
......@@ -615,15 +643,20 @@ const ImportActionHeader = (props) => {
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="数据表类型"
name="easyDataModelerModelingTemplate"
rules={[{ required: false, message: '请选择数据表类型!' }]}
name="tableType"
rules={[{ required: true, message: '请选择数据表类型!' }]}
>
<TemplateSelect
modelerData={modelerData}
templates={templates}
onChange={onTemplateChange}
/>
</Form.Item>
</Col>
</Row>
{
!onlyShowRequireChange && <React.Fragment>
<Divider style={{ margin: '0 0 15px' }} />
<Row gutter={10}>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
......@@ -728,7 +761,8 @@ const ImportActionHeader = (props) => {
</Form.Item>
</Col>
</Row>
</Row>
</React.Fragment>
}
</Form>
) : (
<React.Fragment>
......@@ -752,7 +786,7 @@ const ImportActionHeader = (props) => {
</Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>规范</div>} >{modelerData.easyDataModelerModelingConstraint?(modelerData.easyDataModelerModelingConstraint.cnName||''):''}</Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>数据内容</div>}>{highlightSearchContentByTerms(modelerData.remark||'', terms)}</Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>数据表类型</div>} >{modelerData.easyDataModelerModelingTemplate?(modelerData.easyDataModelerModelingTemplate.cnName||''):''}</Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>数据表类型</div>} >{modelerData.tableType}</Descriptions.Item>
</Descriptions>
{
!onlyShowRequireChange && <Divider style={{ margin: '0 0 15px' }} />
......
......@@ -19,6 +19,7 @@ import { AttentionSvg, UnAttentionSvg } from './ModelSvg';
import { EditModelContext } from './ContextManage';
import './ImportActionTable.less';
import 'react-contexify/dist/ReactContexify.css';
const { Option } = Select;
......@@ -365,7 +366,7 @@ export const ImportActionTable = (props) => {
title: 'Not Null',
width: 80,
dataIndex: 'notNull',
editable: (type==='model'?true:false),
editable: true,
render: (notNull, record, index) => {
if (!notNull) {
return '-';
......@@ -1115,7 +1116,11 @@ export const ImportActionTable = (props) => {
col.dataIndex==='foreignKey'
) {
inputType = 'check';
} else if (col.dataIndex === 'remark') {
} else if (
col.dataIndex === 'remark' ||
col.dataIndex === 'definition' ||
col.dataIndex === 'valueRange'
) {
inputType = 'textarea';
} else if (col.dataIndex === 'datatype') {
inputType = 'datatype';
......
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