diff --git a/package.json b/package.json index d5264abe..7c85cd0b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/renderers/Form/Combo.tsx b/src/renderers/Form/Combo.tsx index 331f997d..e0b14d85 100644 --- a/src/renderers/Form/Combo.tsx +++ b/src/renderers/Form/Combo.tsx @@ -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) => JSON.stringify(args.slice(0, 2)) - } + (strictMode: boolean, ...args: Array) => + 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 { 'conditions', 'tabsMode', 'tabsStyle', - 'lazyLoad' + 'lazyLoad', + 'strictMode' ]; subForms: Array = []; @@ -543,7 +544,7 @@ export default class ComboControl extends React.Component { } 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 { value = value || this.defaultValue; - return formatValue(value, index, data); + return formatValue(strictMode !== false, value, index, data); } pickCondition(value: any): Condition | null { diff --git a/src/store/combo.ts b/src/store/combo.ts index 38f259ed..5f695c38 100644 --- a/src/store/combo.ts +++ b/src/store/combo.ts @@ -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) { diff --git a/src/utils/helper.ts b/src/utils/helper.ts index 3e8eac2f..20c12b95 100644 --- a/src/utils/helper.ts +++ b/src/utils/helper.ts @@ -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')) &&