mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 21:19:01 +08:00
去除无效函数
This commit is contained in:
parent
9c219f4164
commit
6abd5038b8
@ -10,7 +10,7 @@ import {
|
||||
isObjectShallowModified,
|
||||
noop,
|
||||
isVisible,
|
||||
getVariable, isObject,
|
||||
getVariable
|
||||
} from '../utils/helper';
|
||||
import {observer} from 'mobx-react';
|
||||
import partition = require('lodash/partition');
|
||||
@ -279,23 +279,23 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
||||
action.redirect && action.blank && env.jumpTo(filter(action.redirect, data), action);
|
||||
|
||||
return isEffectiveApi(action.api, data) &&
|
||||
store
|
||||
.saveRemote(action.api, data, {
|
||||
successMessage: (action.messages && action.messages.success) || (messages && messages.saveSuccess),
|
||||
errorMessage: (action.messages && action.messages.failed) || (messages && messages.saveFailed),
|
||||
})
|
||||
.then(async (payload: object) => {
|
||||
const data = createObject(ctx, payload);
|
||||
store
|
||||
.saveRemote(action.api, data, {
|
||||
successMessage: (action.messages && action.messages.success) || (messages && messages.saveSuccess),
|
||||
errorMessage: (action.messages && action.messages.failed) || (messages && messages.saveFailed),
|
||||
})
|
||||
.then(async (payload: object) => {
|
||||
const data = createObject(ctx, payload);
|
||||
|
||||
if (action.feedback && isVisible(action.feedback, data)) {
|
||||
await this.openFeedback(action.feedback, data);
|
||||
stopAutoRefreshWhenModalIsOpen && clearTimeout(this.timer);
|
||||
}
|
||||
if (action.feedback && isVisible(action.feedback, data)) {
|
||||
await this.openFeedback(action.feedback, data);
|
||||
stopAutoRefreshWhenModalIsOpen && clearTimeout(this.timer);
|
||||
}
|
||||
|
||||
action.redirect && !action.blank && env.jumpTo(filter(action.redirect, data), action);
|
||||
action.reload ? this.reloadTarget(action.reload, data) : this.search(undefined, undefined, true);
|
||||
})
|
||||
.catch(() => {});
|
||||
action.redirect && !action.blank && env.jumpTo(filter(action.redirect, data), action);
|
||||
action.reload ? this.reloadTarget(action.reload, data) : this.search(undefined, undefined, true);
|
||||
})
|
||||
.catch(() => {});
|
||||
} else if (pickerMode && (action.actionType === 'confirm' || action.actionType === 'submit')) {
|
||||
return Promise.resolve({
|
||||
items: store.selectedItems.concat(),
|
||||
|
@ -113,23 +113,23 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
||||
|
||||
setLoading(true);
|
||||
return autoComplete && isEffectiveApi(autoComplete, data) &&
|
||||
env
|
||||
.fetcher(autoComplete, {
|
||||
...data,
|
||||
term: input,
|
||||
value: input
|
||||
})
|
||||
.then(ret => {
|
||||
let options = ret.data && (ret.data as any).options || ret.data || [];
|
||||
this.cache[input] = options;
|
||||
let combinedOptions = this.mergeOptions(options);
|
||||
setOptions(combinedOptions);
|
||||
env
|
||||
.fetcher(autoComplete, {
|
||||
...data,
|
||||
term: input,
|
||||
value: input
|
||||
})
|
||||
.then(ret => {
|
||||
let options = ret.data && (ret.data as any).options || ret.data || [];
|
||||
this.cache[input] = options;
|
||||
let combinedOptions = this.mergeOptions(options);
|
||||
setOptions(combinedOptions);
|
||||
|
||||
return Promise.resolve({
|
||||
options: combinedOptions,
|
||||
});
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
return Promise.resolve({
|
||||
options: combinedOptions,
|
||||
});
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}
|
||||
|
||||
mergeOptions(options: Array<object>) {
|
||||
|
@ -527,30 +527,30 @@ export default class Form extends React.Component<FormProps, object> {
|
||||
});
|
||||
|
||||
return isEffectiveApi(action.api || api as Api, store.data) &&
|
||||
store
|
||||
.saveRemote(action.api || api as Api, values, {
|
||||
successMessage: saveSuccess,
|
||||
errorMessage: saveFailed,
|
||||
onSuccess: () => {
|
||||
if (!isEffectiveApi(finnalAsyncApi, store.data) || store.data[finishedField || 'finished']) {
|
||||
return;
|
||||
}
|
||||
store
|
||||
.saveRemote(action.api || api as Api, values, {
|
||||
successMessage: saveSuccess,
|
||||
errorMessage: saveFailed,
|
||||
onSuccess: () => {
|
||||
if (!isEffectiveApi(finnalAsyncApi, store.data) || store.data[finishedField || 'finished']) {
|
||||
return;
|
||||
}
|
||||
|
||||
return until(() => store.checkRemote(finnalAsyncApi as Api, store.data)
|
||||
, (ret:any) => ret && ret[finishedField || 'finished']
|
||||
, (cancel) => this.asyncCancel = cancel);
|
||||
}
|
||||
})
|
||||
.then(async (response) => {
|
||||
onSaved && onSaved(values, response);
|
||||
return until(() => store.checkRemote(finnalAsyncApi as Api, store.data)
|
||||
, (ret:any) => ret && ret[finishedField || 'finished']
|
||||
, (cancel) => this.asyncCancel = cancel);
|
||||
}
|
||||
})
|
||||
.then(async (response) => {
|
||||
onSaved && onSaved(values, response);
|
||||
|
||||
// submit 也支持 feedback
|
||||
if (action.feedback && isVisible(action.feedback, store.data)) {
|
||||
await this.openFeedback(action.feedback, store.data);
|
||||
}
|
||||
// submit 也支持 feedback
|
||||
if (action.feedback && isVisible(action.feedback, store.data)) {
|
||||
await this.openFeedback(action.feedback, store.data);
|
||||
}
|
||||
|
||||
return values;
|
||||
});
|
||||
return values;
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(values);
|
||||
@ -591,23 +591,23 @@ export default class Form extends React.Component<FormProps, object> {
|
||||
}
|
||||
|
||||
return isEffectiveApi(action.api, data) &&
|
||||
store
|
||||
.saveRemote(action.api as Api, data, {
|
||||
successMessage: action.messages && action.messages.success || saveSuccess,
|
||||
errorMessage: action.messages && action.messages.failed || saveFailed
|
||||
})
|
||||
.then(async (response) => {
|
||||
response && onChange && onChange(store.data, difference(store.data, store.pristine));
|
||||
store.validated && this.validate(true);
|
||||
store
|
||||
.saveRemote(action.api as Api, data, {
|
||||
successMessage: action.messages && action.messages.success || saveSuccess,
|
||||
errorMessage: action.messages && action.messages.failed || saveFailed
|
||||
})
|
||||
.then(async (response) => {
|
||||
response && onChange && onChange(store.data, difference(store.data, store.pristine));
|
||||
store.validated && this.validate(true);
|
||||
|
||||
if (action.feedback && isVisible(action.feedback, store.data)) {
|
||||
await this.openFeedback(action.feedback, store.data);
|
||||
}
|
||||
if (action.feedback && isVisible(action.feedback, store.data)) {
|
||||
await this.openFeedback(action.feedback, store.data);
|
||||
}
|
||||
|
||||
action.redirect && env.updateLocation(filter(action.redirect, store.data));
|
||||
action.reload && this.reloadTarget(action.reload, store.data);
|
||||
})
|
||||
.catch(() => { });
|
||||
action.redirect && env.updateLocation(filter(action.redirect, store.data));
|
||||
action.reload && this.reloadTarget(action.reload, store.data);
|
||||
})
|
||||
.catch(() => { });
|
||||
} else if (action.actionType === 'reload') {
|
||||
action.target && this.reloadTarget(action.target, data);
|
||||
} else if (onAction) {
|
||||
|
@ -3,12 +3,12 @@ import PropTypes from 'prop-types';
|
||||
import Scoped, {ScopedContext, IScopedContext} from '../Scoped';
|
||||
import {Renderer, RendererProps} from '../factory';
|
||||
import {ServiceStore, IServiceStore} from '../store/service';
|
||||
import {Api, SchemaNode, Schema, Action, ApiObject} from '../types';
|
||||
import {Api, SchemaNode, Schema, Action} from '../types';
|
||||
import {filter, evalExpression} from '../utils/tpl';
|
||||
import cx = require('classnames');
|
||||
import {observer} from 'mobx-react';
|
||||
import {createObject, until, isVisible} from '../utils/helper';
|
||||
import {buildApi, isValidApi, isApiOutdated, isEffectiveApi} from '../utils/api';
|
||||
import {isApiOutdated, isEffectiveApi} from '../utils/api';
|
||||
import {IFormStore} from '../store/form';
|
||||
|
||||
export type TabProps = Schema & {
|
||||
|
Loading…
Reference in New Issue
Block a user