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,7 +284,9 @@ const ImportAction = (props) => { ...@@ -282,7 +284,9 @@ const ImportAction = (props) => {
onChange && onChange(newModelerData); onChange && onChange(newModelerData);
setTemplate(currentTemplate); setTemplate(currentTemplate);
getConsult(newModelerData); if (currentTemplate) {
getConsult(newModelerData);
}
} }
const getSupportedDatatypes = () => { const getSupportedDatatypes = () => {
......
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,28 +81,59 @@ const ConstraintSelect = ({ value = {}, constraints = [], onChange, ...restProps ...@@ -81,28 +81,59 @@ 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' }}>
onChange={onChange} {
value={value?.name || undefined} isCustom ? <Input
placeholder='请选择数据表类型' placeholder='请输入数据表类型'
allowClear allowClear
{...restProps} defaultValue={modelerData?.tableType}
> onChange={(e) => {
{ onChange?.(e.target.value);
(templates||[]) && templates.map((template, index) => { }}
return ( style={{ flex: 1 }}
<Option key={index} value={template.name||''} > /> : <Select
<Tooltip title={template.remark}> onChange={onChange}
{template.cnName} defaultValue={value || undefined}
</Tooltip> placeholder='请选择数据表类型'
</Option> allowClear
); style={{ flex: 1 }}
}) {...restProps}
} >
</Select> {
(templates||[]) && templates.map((template, index) => {
return (
<Option key={index} value={template.cnName||''} >
<Tooltip title={template.remark}>
{template.cnName}
</Tooltip>
</Option>
);
})
}
</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,120 +643,126 @@ const ImportActionHeader = (props) => { ...@@ -615,120 +643,126 @@ 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 gutter={10}>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="技术主键"
name="easyDataModelerPrimaryKey"
>
<AttributesSelect modelerData={modelerData} mode='tags' />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="数据平台"
name="dataResidence"
>
<Input placeholder='描述数据表落地的数据平台及数据库' />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="数据情况"
name="dataCircumstances"
>
<Input placeholder='描述数据表中数据的更新频率、每日增量情况、数据量级和历史数据' />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="分布键"
name="easyDataModelerDistributionKey"
>
<AttributesSelect modelerData={modelerData} />
</Form.Item>
</Col>
{/* <Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="数据类型"
name=""
tooltip={etlTableTypeRemark}
>
<Select allowClear placeholder='请选择数据类型'>
{
Object.keys(etlTableTypeData).map((item, index) => <Option key={index} value={item}>
{item}
</Option>)
}
</Select>
</Form.Item>
</Col> */}
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="更新时间"
name="dataUpdatingTiming"
>
<UpdateSelect placeholder='描述数据表的更新时间点'/>
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="分区键"
name="partition"
>
<PartitionSelect modelerData={modelerData} partitionTypes={supportedPartitionTypes} />
</Form.Item>
</Col>
{/* <Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="绑定加载范围"
name=""
tooltip={etlLoadRemark}
>
<Select allowClear placeholder='请选择绑定加载范围'>
{
// Object.keys(etlTableTypeData).map((item, index) => <Option key={index} value={item}>
// {item}
// </Option>)
}
</Select>
</Form.Item>
</Col> */}
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="维护历史"
name="maintenanceRecords"
>
<TextArea rows={3} disabled={true} />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="类主键"
name="easyDataModelerSemiPrimaryKey"
>
<AttributesSelect modelerData={modelerData} mode='tags' />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="加载方式"
name="dataLoadingStrategy"
>
<LoadSelect />
</Form.Item>
</Col>
</Row>
</Row> </Row>
{
!onlyShowRequireChange && <React.Fragment>
<Divider style={{ margin: '0 0 15px' }} />
<Row gutter={10}>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="技术主键"
name="easyDataModelerPrimaryKey"
>
<AttributesSelect modelerData={modelerData} mode='tags' />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="数据平台"
name="dataResidence"
>
<Input placeholder='描述数据表落地的数据平台及数据库' />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="数据情况"
name="dataCircumstances"
>
<Input placeholder='描述数据表中数据的更新频率、每日增量情况、数据量级和历史数据' />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="分布键"
name="easyDataModelerDistributionKey"
>
<AttributesSelect modelerData={modelerData} />
</Form.Item>
</Col>
{/* <Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="数据类型"
name=""
tooltip={etlTableTypeRemark}
>
<Select allowClear placeholder='请选择数据类型'>
{
Object.keys(etlTableTypeData).map((item, index) => <Option key={index} value={item}>
{item}
</Option>)
}
</Select>
</Form.Item>
</Col> */}
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="更新时间"
name="dataUpdatingTiming"
>
<UpdateSelect placeholder='描述数据表的更新时间点'/>
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="分区键"
name="partition"
>
<PartitionSelect modelerData={modelerData} partitionTypes={supportedPartitionTypes} />
</Form.Item>
</Col>
{/* <Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="绑定加载范围"
name=""
tooltip={etlLoadRemark}
>
<Select allowClear placeholder='请选择绑定加载范围'>
{
// Object.keys(etlTableTypeData).map((item, index) => <Option key={index} value={item}>
// {item}
// </Option>)
}
</Select>
</Form.Item>
</Col> */}
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="维护历史"
name="maintenanceRecords"
>
<TextArea rows={3} disabled={true} />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="类主键"
name="easyDataModelerSemiPrimaryKey"
>
<AttributesSelect modelerData={modelerData} mode='tags' />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item
label="加载方式"
name="dataLoadingStrategy"
>
<LoadSelect />
</Form.Item>
</Col>
</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