Commit 6b3d874f by zhaochengxiang

增加提示

parent a4fb5a9b
...@@ -73,7 +73,7 @@ export class GetSession extends React.Component { ...@@ -73,7 +73,7 @@ export class GetSession extends React.Component {
export const Assert = function (arg, msg) { export const Assert = function (arg, msg) {
if (!arg) { if (!arg) {
message.warning(msg) this.showMessage('warn', msg);
throw msg throw msg
} }
} }
...@@ -96,3 +96,20 @@ export const generateUUID = function() { ...@@ -96,3 +96,20 @@ export const generateUUID = function() {
}); });
return uuid; return uuid;
} }
export const showMessage = function(action, content) {
//https://github.com/ant-design/ant-design/issues/22269
message.config({ prefixCls: "yy-message" });
if (action === 'success') {
message.success(content);
}
if (action === 'error') {
message.error(content);
}
if (action === 'info') {
message.info(content);
}
if (action === 'warn') {
message.warn(content);
}
}
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Modal, Radio, Button, Form } from 'antd'; import { Modal, Radio, Button, Form, message } from 'antd';
import ImportLog from './ImportLog'; import ImportLog from './ImportLog';
import ImportExcel from './ImportExcel'; import ImportExcel from './ImportExcel';
...@@ -7,6 +7,7 @@ import ImportMetadata from './ImportMetadata'; ...@@ -7,6 +7,7 @@ import ImportMetadata from './ImportMetadata';
import ImportAction from './ImportAction'; import ImportAction from './ImportAction';
import { dispatchLatest } from '../../../../model'; import { dispatchLatest } from '../../../../model';
import { showMessage } from '../../../../util';
const modes = [ const modes = [
{ {
...@@ -47,15 +48,26 @@ const ImportModal = (props) => { ...@@ -47,15 +48,26 @@ const ImportModal = (props) => {
const next = () => { const next = () => {
if (step===0) {
if (radioValue === '') {
showMessage('warn', '请先选择创建方式');
} else {
setStep(step+1);
}
return;
}
if (step===1 && radioValue===0) { if (step===1 && radioValue===0) {
if ((excelFiles||[]).length === 0) { if ((excelFiles||[]).length === 0) {
showMessage('warn', '请先选择文件上传');
} else { } else {
setConfirmLoading(true); setConfirmLoading(true);
dispatchLatest({ dispatchLatest({
type: 'datamodel.extractExcelContent', type: 'datamodel.extractExcelContent',
payload: { fileList: excelFiles }, payload: { fileList: excelFiles },
callback: data => { callback: data => {
setExcelFiles([]);
setConfirmLoading(false); setConfirmLoading(false);
setHints(data||[]); setHints(data||[]);
setStep(step+1); setStep(step+1);
...@@ -92,6 +104,7 @@ const ImportModal = (props) => { ...@@ -92,6 +104,7 @@ const ImportModal = (props) => {
}, },
callback: () => { callback: () => {
setConfirmLoading(false); setConfirmLoading(false);
reset();
onCancel && onCancel(true); onCancel && onCancel(true);
} }
}) })
...@@ -104,6 +117,18 @@ const ImportModal = (props) => { ...@@ -104,6 +117,18 @@ const ImportModal = (props) => {
} }
const reset = () => {
setStep(0);
setRadioValue('');
setExcelFiles([]);
setHints([]);
setModelerData({});
setConfirmLoading(false);
if (form && form.resetFields) {
form.resetFields();
}
}
const onActionChange = (data) => { const onActionChange = (data) => {
setModelerData(data); setModelerData(data);
} }
...@@ -130,6 +155,7 @@ const ImportModal = (props) => { ...@@ -130,6 +155,7 @@ const ImportModal = (props) => {
destroyOnClose destroyOnClose
onCancel={() => { onCancel={() => {
setStep(0); setStep(0);
reset();
onCancel && onCancel(); onCancel && onCancel();
}} }}
footer={[ footer={[
......
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