Commit c957e96b by zhaochengxiang

excel复制粘贴导入

parent 498353d0
import React from 'react';
import { Input } from 'antd';
class ImportExcelCopy extends React.Component {
constructor() {
super();
this.state = {
inputValue: ''
};
}
onInputChange = (e) => {
const { onChange } = this.props;
this.setState({ inputValue: e.target.value }, () => {
onChange && onChange(e.target.value.split('\n').filter(value => value!==''));
});
}
render() {
const { inputValue } = this.state;
return (
<Input.TextArea
value={inputValue||''}
onChange={this.onInputChange}
autoSize={{minRows:4,maxRows:20}} >
</Input.TextArea>
)
}
}
export default ImportExcelCopy;
\ No newline at end of file
......@@ -3,6 +3,7 @@ import { Modal, Radio, Button, Form } from 'antd';
// import ImportLog from './ImportLog';
import ImportExcel from './ImportExcel';
import ImportExcelCopy from './ImportExcelCopy';
import ImportMetadata from './ImportMetadata';
import ImportAction from './ImportAction';
......@@ -12,19 +13,20 @@ import { showMessage } from '../../../../util';
const modes = [
{
title: 'Excel导入',
key: 'excel'
},
{
title: 'Excel复制粘贴',
key: 'excel-copy',
},
// {
// title: 'Excel复制粘贴',
// },
// {
// title: 'Erwin',
// key: 'erwin',
// },
// {
// title: '元数据输入',
// key: 'metadata',
// },
// {
// title: '数据模型输入',
// }
]
const ImportModal = (props) => {
......@@ -70,7 +72,7 @@ const ImportModal = (props) => {
return;
}
if (step===1 && radioValue===0) {
if (step===1 && radioValue==='excel') {
if ((excelFiles||[]).length === 0) {
showMessage('warn', '请先选择文件上传');
} else {
......@@ -91,6 +93,16 @@ const ImportModal = (props) => {
}
return;
} else if (step===1 && radioValue==='excel-copy') {
if ((hints||[]).length === 0) {
showMessage('warn', '请先从Excel文件中复制内容');
} else {
setStep(step+1);
}
return;
}
setStep(step+1);
......@@ -160,14 +172,22 @@ const ImportModal = (props) => {
setExcelFiles(files||[]);
}
const onImportExcelCopyChange = (data) => {
setHints(data||[]);
}
let title = '';
if (action === 'add') {
if (step === 0) {
title = '创建方式';
} else if (step === 1 && radioValue===0) {
} else if (step===1 && radioValue==='excel') {
title = 'excel导入';
} else if (step === 2 && radioValue===0) {
} else if (step===1 && radioValue==='excel-copy') {
title = 'excel复制粘贴导入';
} else if (step===2 && radioValue==='excel') {
title = '模型创建-excel导入';
} else if (step===2 && radioValue=== 'excel-copy') {
title = '模型创建-excel复制粘贴导入';
}
} else if (action === 'edit') {
title = '模型编辑';
......@@ -257,7 +277,7 @@ const ImportModal = (props) => {
{
modes && modes.map((mode, index) => {
return (
<Radio key={index} value={index}>
<Radio key={index} value={mode.key||''}>
{ mode.title||'' }
</Radio>
);
......@@ -268,19 +288,16 @@ const ImportModal = (props) => {
</>
}
{
step===1 && radioValue===0 && <ImportExcel onChange={onImportExcelChange} />
}
{
step===1 && radioValue===1 && <></>
step===1 && radioValue==='excel' && <ImportExcel onChange={onImportExcelChange} />
}
{
step===1 && radioValue===2 && <></>
step===1 && radioValue==='excel-copy' && <ImportExcelCopy onChange={onImportExcelCopyChange} />
}
{
step===1 && radioValue===3 && <ImportMetadata />
step===1 && radioValue==='erwin' && <></>
}
{
step===1 && radioValue===4 && <></>
step===1 && radioValue==='metadata' && <ImportMetadata />
}
{
step===2 && <ImportAction hints={hints} onChange={onActionChange} action={action} modelerId={modelerId} form={form} />
......
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