Combo 的 strictMode 优化
This commit is contained in:
parent
baf68d6b71
commit
7c9d037054
|
@ -35,7 +35,6 @@
|
|||
"dom-helpers": "3.3.1",
|
||||
"downshift": "3.1.4",
|
||||
"echarts": "^4.1.0",
|
||||
"fast-memoize": "2.5.1",
|
||||
"flv.js": "1.5.0",
|
||||
"froala-editor": "2.9.6",
|
||||
"history": "4.7.2",
|
||||
|
|
|
@ -21,18 +21,17 @@ import Select from '../../components/Select';
|
|||
import {dataMapping} from '../../utils/tpl-builtin';
|
||||
import {isEffectiveApi} from '../../utils/api';
|
||||
import {Alert2} from '../../components';
|
||||
import memoize from 'fast-memoize';
|
||||
import memoize from 'lodash/memoize';
|
||||
|
||||
const formatValue = memoize(
|
||||
(value: any, index: number, data: any) => {
|
||||
(strictMode: boolean, value: any, index: number, data: any) => {
|
||||
return createObject(
|
||||
extendObject(data, {index, __index: index, ...data}),
|
||||
value
|
||||
);
|
||||
},
|
||||
{
|
||||
serializer: (args: Array<any>) => JSON.stringify(args.slice(0, 2))
|
||||
}
|
||||
(strictMode: boolean, ...args: Array<any>) =>
|
||||
strictMode ? JSON.stringify(args.slice(0, 2)) : JSON.stringify(args)
|
||||
);
|
||||
|
||||
export interface Condition {
|
||||
|
@ -74,6 +73,7 @@ export interface ComboProps extends FormControlProps {
|
|||
tabsStyle: '' | 'line' | 'card' | 'radio';
|
||||
tabsLabelTpl?: string;
|
||||
lazyLoad?: boolean;
|
||||
strictMode?: boolean;
|
||||
messages?: {
|
||||
validateFailed?: string;
|
||||
minLengthValidateFailed?: string;
|
||||
|
@ -118,7 +118,8 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|||
'conditions',
|
||||
'tabsMode',
|
||||
'tabsStyle',
|
||||
'lazyLoad'
|
||||
'lazyLoad',
|
||||
'strictMode'
|
||||
];
|
||||
|
||||
subForms: Array<any> = [];
|
||||
|
@ -543,7 +544,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|||
}
|
||||
|
||||
formatValue(value: any, index: number) {
|
||||
const {flat, data, store} = this.props;
|
||||
const {flat, data, strictMode} = this.props;
|
||||
|
||||
if (flat) {
|
||||
value = {
|
||||
|
@ -553,7 +554,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|||
|
||||
value = value || this.defaultValue;
|
||||
|
||||
return formatValue(value, index, data);
|
||||
return formatValue(strictMode !== false, value, index, data);
|
||||
}
|
||||
|
||||
pickCondition(value: any): Condition | null {
|
||||
|
|
|
@ -93,7 +93,9 @@ export const ComboStore = iRendererStore
|
|||
}
|
||||
|
||||
function removeForm(form: IFormStore) {
|
||||
self.forms.remove(form);
|
||||
// form 可能再它自己销毁的是已经被移除了。因为调用的是 destroy,所以 self.forms 里面也被一起移除。
|
||||
// 再来尝试移除,会报错。
|
||||
self.forms.includes(form) && self.forms.remove(form);
|
||||
}
|
||||
|
||||
function setActiveKey(key: number) {
|
||||
|
|
|
@ -80,6 +80,10 @@ export function syncDataFromSuper(
|
|||
|
||||
if (superObject || prevSuperObject) {
|
||||
keys.forEach(key => {
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
((superObject && typeof superObject[key] !== 'undefined') ||
|
||||
(prevSuperObject && typeof prevSuperObject[key] !== 'undefined')) &&
|
||||
|
|
Loading…
Reference in New Issue