Commit 499e49d3 by zhaochengxiang

修改模型bug

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