Commit 42d01639 by zhaochengxiang

快速创建

parent 67d63047
import React from 'react';
import { Input } from 'antd';
import { Input, Row, Col, Descriptions } from 'antd';
class ImportExcelCopy extends React.Component {
constructor() {
super();
this.state = {
inputValue: ''
inputValue: '',
translateValues: []
};
}
componentDidUpdate(preProps, preState) {
const { visible } = this.props;
if (!visible && visible !== preProps.visible) {
this.setState({ inputValue: '' });
this.setState({ inputValue: '', translateValues: [] });
}
}
onInputChange = (e) => {
const { onChange } = this.props;
this.setState({ inputValue: e.target.value }, () => {
onChange && onChange(e.target.value.replace(/[,,,_ ]/g,'\n').split('\n').filter(value => value!==''&&value!==' '));
const _translateValues = e.target.value.replace(/[,,,_ ]/g,'\n').split('\n').filter(value => value!==''&&value!==' ');
onChange && onChange(_translateValues);
this.setState({ translateValues: _translateValues });
});
}
render() {
const { inputValue } = this.state;
const { inputValue, translateValues } = this.state;
const _placeholder = '支持两种方式创建\n方式一: Excel内容复制粘贴(模型名称和中文字段名)\n方式二: 手动输入模型名称和中文字段';
let _attrsStr = '';
translateValues.forEach((item, index) => {
if (index === 0) {
_attrsStr = '';
} else if (index === 1) {
_attrsStr = item;
} else {
_attrsStr += `,${item}`;
}
})
return (
<Input.TextArea
value={inputValue||''}
onChange={this.onInputChange}
autoSize={{minRows:4,maxRows:20}}
placeholder={_placeholder}
>
</Input.TextArea>
<Row gutter={(translateValues.length>0)?10: 0}>
<Col span={(translateValues.length>0)?14: 24}>
<Input.TextArea
value={inputValue||''}
onChange={this.onInputChange}
autoSize={{minRows:4,maxRows:20}}
placeholder={_placeholder}
>
</Input.TextArea>
</Col>
{
(translateValues.length>0) && <Col span={10}>
<Descriptions className='excel-copy-descritpion' column={1} size='small'>
<Descriptions.Item label='模型名称'>
{ translateValues[0] }
</Descriptions.Item>
{
_attrsStr.length>0 && <Descriptions.Item label='字段名称'>
{ _attrsStr }
</Descriptions.Item>
}
</Descriptions>
</Col>
}
</Row>
)
}
}
......
......@@ -8,15 +8,16 @@ import ImportExcelCopy from './ImportExcelCopy';
import { dispatchLatest } from '../../../../model';
const importModes = [
{ name: '快速创建', key: 'excel-copy' },
{ name: '空白创建', key: 'no-condition' },
{ name: 'Word导入', key: 'word' },
{ name: 'Excel导入', key: 'excel' },
{ name: 'Excel复制粘贴', key: 'excel-copy' },
]
const ImportModal = (props) => {
const { view, catalogId, visible, onCancel, onCancelByWord } = props;
const [ modeKey, setModeKey ] = useState('');
const [ modeKey, setModeKey ] = useState('excel-copy');
const [ hints, setHints ] = useState([]);
const [ confirmLoading, setConfirmLoading ] = useState(false);
......@@ -73,7 +74,10 @@ const ImportModal = (props) => {
reset();
onCancel && onCancel(false, true, hints||[]);
}
} else if (modeKey==='no-condition') {
reset();
onCancel && onCancel(false, true, []);
}
} catch (errInfo) {
console.log('Validate Failed:', errInfo);
......@@ -87,8 +91,8 @@ const ImportModal = (props) => {
}
const reset = () => {
form.resetFields();
setModeKey('');
form.setFieldsValue({mode: 'excel-copy'});
setModeKey('excel-copy');
setHints([]);
setConfirmLoading(false);
}
......@@ -119,7 +123,7 @@ const ImportModal = (props) => {
forceRender
visible={visible}
title='新建模型'
width={520}
width={540}
onCancel={cancel}
footer={footer}
>
......@@ -133,6 +137,7 @@ const ImportModal = (props) => {
message: '请选择新建方式',
},
]}
initialValue={modeKey}
>
<Radio.Group onChange={onModeChange} value={modeKey}>
{
......
......@@ -38,4 +38,10 @@
.yy-descriptions-item-label, .yy-descriptions-item-content {
color: #fff !important;
}
}
.excel-copy-descritpion {
.yy-descriptions-row > td {
padding-bottom: 0px !important;
}
}
\ No newline at end of file
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