diff --git a/scss/layout/_layout.scss b/scss/layout/_layout.scss index 1abe0f7a0..d13dd1c15 100644 --- a/scss/layout/_layout.scss +++ b/scss/layout/_layout.scss @@ -248,10 +248,10 @@ body { @include media-breakpoint-up(md) { .#{$ns}Layout { &--boxed { - width: px2rem(750px); + width: px2rem(760px); &.#{$ns}Layout--headerFixed .#{$ns}Layout-header { - width: px2rem(750px); + width: px2rem(760px); } } @@ -488,10 +488,10 @@ body { @include media-breakpoint-up(lg) { .#{$ns}Layout { &--boxed { - width: px2rem(970px); + width: px2rem(980px); &.#{$ns}Layout--headerFixed .#{$ns}Layout-header { - width: px2rem(970px); + width: px2rem(980px); } } } @@ -500,10 +500,10 @@ body { @include media-breakpoint-up(xl) { .#{$ns}Layout { &--boxed { - width: px2rem(1170px); + width: px2rem(1180px); &.#{$ns}Layout--headerFixed .#{$ns}Layout-header { - width: px2rem(1170px); + width: px2rem(1180px); } } } diff --git a/src/renderers/Form/Combo.tsx b/src/renderers/Form/Combo.tsx index 3723ad4e5..a13720bda 100644 --- a/src/renderers/Form/Combo.tsx +++ b/src/renderers/Form/Combo.tsx @@ -127,7 +127,8 @@ export default class ComboControl extends React.Component { store, value, minLength, - maxLength + maxLength, + formItem } = this.props; store.config({ @@ -135,6 +136,8 @@ export default class ComboControl extends React.Component { maxLength, length: this.getValueAsArray().length }); + + formItem && formItem.setSubStore(store); } componentWillReceiveProps(nextProps:ComboProps) { @@ -155,6 +158,14 @@ export default class ComboControl extends React.Component { } } + componentWillUnmount() { + const { + formItem + } = this.props; + + formItem && formItem.setSubStore(null); + } + getValueAsArray(props = this.props) { const { flat, diff --git a/src/renderers/Form/index.tsx b/src/renderers/Form/index.tsx index f1c0ac12a..25974dca7 100644 --- a/src/renderers/Form/index.tsx +++ b/src/renderers/Form/index.tsx @@ -293,6 +293,12 @@ export default class Form extends React.Component { (this.handleChange as any).cancel(); this.asyncCancel && this.asyncCancel(); this.disposeOnValidate && this.disposeOnValidate(); + const store = this.props.store; + + if (store && store.parentStore && store.parentStore.storeType === 'ComboStore') { + const combo = store.parentStore as IComboStore; + combo.removeForm(store); + } } async onInit() { @@ -334,21 +340,24 @@ export default class Form extends React.Component { [initFinishedField || 'finished']: false }); - isEffectiveApi(initApi, store.data) && - store.fetchData(initApi, store.data, { - successMessage: fetchSuccess, - errorMessage: fetchFailed, - silent, - onSuccess: () => { - if (!isEffectiveApi(initAsyncApi, store.data) || store.data[initFinishedField || 'finished']) { - return; - } + isEffectiveApi(initApi, store.data) + ? store.fetchInitData(initApi, store.data, { + successMessage: fetchSuccess, + errorMessage: fetchFailed, + silent, + onSuccess: () => { + if (!isEffectiveApi(initAsyncApi, store.data) || store.data[initFinishedField || 'finished']) { + return; + } - return until(() => store.checkRemote(initAsyncApi, store.data) - , (ret:any) => ret && ret[initFinishedField || 'finished'] - , (cancel) => this.asyncCancel = cancel); - } - }).then(this.initInterval); + return until(() => store.checkRemote(initAsyncApi, store.data) + , (ret:any) => ret && ret[initFinishedField || 'finished'] + , (cancel) => this.asyncCancel = cancel); + } + }) + .then(this.initInterval) + .then(() => store.reset(undefined, false)) + : store.reset(); } receive(values:object) { @@ -599,7 +608,9 @@ export default class Form extends React.Component { }) .then(async (response) => { response && onChange && onChange(store.data, difference(store.data, store.pristine)); - store.validated && this.validate(true); + if (store.validated) { + await this.validate(true); + } if (action.feedback && isVisible(action.feedback, store.data)) { await this.openFeedback(action.feedback, store.data); diff --git a/src/renderers/Table.tsx b/src/renderers/Table.tsx index 82a6f5d15..74e7dd209 100644 --- a/src/renderers/Table.tsx +++ b/src/renderers/Table.tsx @@ -705,7 +705,7 @@ export default class Table extends React.Component { } @autobind - handleDragOver(e: DragEvent) { + handleDragOver(e: any) { if (!e.target) { return; } diff --git a/src/store/form.ts b/src/store/form.ts index b079484d3..1814794e5 100644 --- a/src/store/form.ts +++ b/src/store/form.ts @@ -336,11 +336,14 @@ export const FormStore = ServiceStore items.forEach(item => item.reset()); } - function reset(cb?: (data:any) => void) { - self.data = self.pristine; + function reset(cb?: (data:any) => void, resetData: boolean = true) { + if (resetData) { + self.data = self.pristine; + } // 值可能变了,重新验证一次。 self.validated = false; + self.submited = false; self.items.forEach(item => item.reset()); cb && cb(self.data); } diff --git a/src/store/formItem.ts b/src/store/formItem.ts index f5bdb307c..abf82cc52 100644 --- a/src/store/formItem.ts +++ b/src/store/formItem.ts @@ -31,6 +31,7 @@ import { import { IRendererStore } from "."; import { normalizeOptions } from "../components/Select"; import find = require('lodash/find'); +import { iRendererStore } from './iRenderer'; interface IOption { value?: string | number | null; @@ -486,8 +487,19 @@ export const FormItemStore = types self.loading = value; } + let subStore:any; + function setSubStore(store:any) { + subStore = store; + } + function reset() { self.validated = false; + + if (subStore && subStore.storeType === 'ComboStore') { + const combo = subStore as IComboStore; + combo.forms.forEach(form => form.reset()); + } + clearError(); } @@ -502,6 +514,7 @@ export const FormItemStore = types loadOptions, syncOptions, setLoading, + setSubStore, reset } });