amis-core 2.9.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/Root.d.ts +89 -4
- package/esm/Root.js +15 -4
- package/esm/RootRenderer.d.ts +3 -1
- package/esm/RootRenderer.js +9 -3
- package/esm/SchemaRenderer.d.ts +4 -2
- package/esm/SchemaRenderer.js +32 -24
- package/esm/Scoped.d.ts +8 -0
- package/esm/Scoped.js +20 -5
- package/esm/StatusScoped.d.ts +58 -0
- package/esm/StatusScoped.js +54 -0
- package/esm/WithRootStore.d.ts +2 -2
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +6 -2
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +19 -5
- package/esm/actions/AjaxAction.js +1 -1
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +8 -7
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +4 -4
- package/esm/actions/DialogAction.d.ts +16 -2
- package/esm/actions/DialogAction.js +23 -7
- package/esm/actions/DrawerAction.js +1 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/components/CustomStyle.d.ts +13 -0
- package/esm/components/CustomStyle.js +18 -0
- package/esm/components/LazyComponent.d.ts +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.d.ts +3 -3
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.d.ts +2 -2
- package/esm/components/PopOver.js +1 -1
- package/esm/env.d.ts +10 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -5
- package/esm/factory.d.ts +5 -3
- package/esm/factory.js +3 -3
- package/esm/index.d.ts +11 -4
- package/esm/index.js +55 -33
- package/esm/locale.d.ts +2 -2
- package/esm/locale.js +10 -3
- package/esm/renderers/Form.d.ts +3 -2
- package/esm/renderers/Form.js +216 -180
- package/esm/renderers/Item.d.ts +55 -41
- package/esm/renderers/Item.js +30 -19
- package/esm/renderers/Options.js +11 -4
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +1 -1
- package/esm/renderers/wrapControl.d.ts +2 -2
- package/esm/renderers/wrapControl.js +13 -16
- package/esm/store/app.d.ts +1 -0
- package/esm/store/app.js +1 -1
- package/esm/store/combo.d.ts +3 -0
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.d.ts +2 -0
- package/esm/store/crud.js +31 -9
- package/esm/store/form.d.ts +1 -0
- package/esm/store/form.js +10 -4
- package/esm/store/formItem.js +2 -2
- package/esm/store/iRenderer.d.ts +1 -0
- package/esm/store/iRenderer.js +54 -13
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +1 -0
- package/esm/store/list.js +7 -3
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.d.ts +1 -0
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.d.ts +1 -0
- package/esm/store/pagination.js +2 -2
- package/esm/store/root.d.ts +4 -6
- package/esm/store/root.js +53 -24
- package/esm/store/service.d.ts +1 -0
- package/esm/store/service.js +1 -1
- package/esm/store/status.d.ts +12 -0
- package/esm/store/status.js +38 -0
- package/esm/store/table.d.ts +28 -23
- package/esm/store/table.js +26 -5
- package/esm/store/table2.d.ts +7 -6
- package/esm/store/table2.js +27 -23
- package/esm/theme.d.ts +1 -1
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +7 -1
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.d.ts +3 -5
- package/esm/utils/DataScope.js +88 -31
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.js +14 -5
- package/esm/utils/attachmentAdpator.js +2 -2
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +1 -1
- package/esm/utils/date.d.ts +7 -0
- package/esm/utils/date.js +34 -2
- package/esm/utils/debug.js +4 -4
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.d.ts +3 -0
- package/esm/utils/dom.js +47 -10
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +2 -2
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +3 -3
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +9 -2
- package/esm/utils/helper.js +52 -20
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.d.ts +6 -1
- package/esm/utils/icon.js +6 -1
- package/esm/utils/image.js +1 -1
- package/esm/utils/isPureVariable.js +3 -3
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/memoryParse.d.ts +17 -0
- package/esm/utils/memoryParse.js +26 -0
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +4 -2
- package/esm/utils/object.d.ts +2 -0
- package/esm/utils/object.js +27 -2
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +1 -1
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.js +35 -32
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.d.ts +1 -0
- package/esm/utils/resolveCondition.js +19 -4
- package/esm/utils/resolveVariable.js +4 -3
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +23 -5
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +1 -1
- package/esm/utils/style-helper.d.ts +12 -4
- package/esm/utils/style-helper.js +96 -19
- package/esm/utils/style.js +2 -2
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.d.ts +2 -1
- package/esm/utils/tpl-builtin.js +19 -2
- package/esm/utils/tpl-lodash.js +3 -2
- package/esm/utils/tpl.d.ts +2 -0
- package/esm/utils/tpl.js +24 -2
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.d.ts +4 -1
- package/esm/utils/validations.js +27 -12
- package/lib/Root.d.ts +89 -4
- package/lib/Root.js +15 -4
- package/lib/RootRenderer.d.ts +3 -1
- package/lib/RootRenderer.js +8 -2
- package/lib/SchemaRenderer.d.ts +4 -2
- package/lib/SchemaRenderer.js +32 -23
- package/lib/Scoped.d.ts +8 -0
- package/lib/Scoped.js +20 -4
- package/lib/StatusScoped.d.ts +58 -0
- package/lib/StatusScoped.js +63 -0
- package/lib/WithRootStore.d.ts +2 -2
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +6 -2
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +19 -5
- package/lib/actions/AjaxAction.js +1 -1
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +8 -7
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +4 -4
- package/lib/actions/DialogAction.d.ts +16 -2
- package/lib/actions/DialogAction.js +23 -7
- package/lib/actions/DrawerAction.js +1 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/components/CustomStyle.d.ts +13 -0
- package/lib/components/CustomStyle.js +22 -0
- package/lib/components/LazyComponent.d.ts +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.d.ts +3 -3
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.d.ts +2 -2
- package/lib/components/PopOver.js +1 -1
- package/lib/env.d.ts +10 -2
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -5
- package/lib/factory.d.ts +5 -3
- package/lib/factory.js +3 -3
- package/lib/index.d.ts +11 -4
- package/lib/index.js +61 -23
- package/lib/locale.d.ts +2 -2
- package/lib/locale.js +10 -3
- package/lib/renderers/Form.d.ts +3 -2
- package/lib/renderers/Form.js +215 -179
- package/lib/renderers/Item.d.ts +55 -41
- package/lib/renderers/Item.js +30 -19
- package/lib/renderers/Options.js +11 -4
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +1 -1
- package/lib/renderers/wrapControl.d.ts +2 -2
- package/lib/renderers/wrapControl.js +12 -15
- package/lib/store/app.d.ts +1 -0
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +3 -0
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.d.ts +2 -0
- package/lib/store/crud.js +31 -9
- package/lib/store/form.d.ts +1 -0
- package/lib/store/form.js +10 -4
- package/lib/store/formItem.js +2 -2
- package/lib/store/iRenderer.d.ts +1 -0
- package/lib/store/iRenderer.js +53 -12
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +1 -0
- package/lib/store/list.js +7 -3
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.d.ts +1 -0
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.d.ts +1 -0
- package/lib/store/pagination.js +2 -2
- package/lib/store/root.d.ts +4 -6
- package/lib/store/root.js +52 -23
- package/lib/store/service.d.ts +1 -0
- package/lib/store/service.js +1 -1
- package/lib/store/status.d.ts +12 -0
- package/lib/store/status.js +42 -0
- package/lib/store/table.d.ts +28 -23
- package/lib/store/table.js +26 -5
- package/lib/store/table2.d.ts +7 -6
- package/lib/store/table2.js +27 -23
- package/lib/theme.d.ts +1 -1
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +7 -1
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.d.ts +3 -5
- package/lib/utils/DataScope.js +86 -29
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.js +13 -4
- package/lib/utils/attachmentAdpator.js +2 -2
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/dataMapping.js +1 -1
- package/lib/utils/date.d.ts +7 -0
- package/lib/utils/date.js +34 -1
- package/lib/utils/debug.js +4 -4
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.d.ts +3 -0
- package/lib/utils/dom.js +48 -9
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.js +1 -1
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.js +2 -2
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +3 -3
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +9 -2
- package/lib/utils/helper.js +53 -19
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.d.ts +6 -1
- package/lib/utils/icon.js +6 -1
- package/lib/utils/image.js +1 -1
- package/lib/utils/isPureVariable.js +3 -3
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/memoryParse.d.ts +17 -0
- package/lib/utils/memoryParse.js +30 -0
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +4 -2
- package/lib/utils/object.d.ts +2 -0
- package/lib/utils/object.js +28 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +1 -1
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.js +35 -32
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.d.ts +1 -0
- package/lib/utils/resolveCondition.js +19 -3
- package/lib/utils/resolveVariable.js +3 -2
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +22 -3
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +1 -1
- package/lib/utils/style-helper.d.ts +12 -4
- package/lib/utils/style-helper.js +101 -18
- package/lib/utils/style.js +2 -2
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.d.ts +2 -1
- package/lib/utils/tpl-builtin.js +19 -2
- package/lib/utils/tpl-lodash.js +3 -2
- package/lib/utils/tpl.d.ts +2 -0
- package/lib/utils/tpl.js +24 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.d.ts +4 -1
- package/lib/utils/validations.js +27 -12
- package/package.json +3 -3
package/esm/renderers/Form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ import { promisify, isEmpty, until, noop, difference, isVisible, repeatCount, qs
|
|
|
14
14
|
import debounce from 'lodash/debounce';
|
|
15
15
|
import flatten from 'lodash/flatten';
|
|
16
16
|
import find from 'lodash/find';
|
|
17
|
-
import { ScopedContext } from '../Scoped.js';
|
|
17
|
+
import { filterTarget, ScopedContext } from '../Scoped.js';
|
|
18
18
|
import 'amis-formula';
|
|
19
19
|
import 'moment';
|
|
20
20
|
import { isObject, createObject, cloneObject } from '../utils/object.js';
|
|
@@ -54,6 +54,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
54
54
|
_this.reload = _this.reload.bind(_this);
|
|
55
55
|
_this.silentReload = _this.silentReload.bind(_this);
|
|
56
56
|
_this.initInterval = _this.initInterval.bind(_this);
|
|
57
|
+
_this.dispatchInited = _this.dispatchInited.bind(_this);
|
|
57
58
|
_this.blockRouting = _this.blockRouting.bind(_this);
|
|
58
59
|
_this.beforePageUnload = _this.beforePageUnload.bind(_this);
|
|
59
60
|
var store = props.store, canAccessSuperData = props.canAccessSuperData, persistData = props.persistData, simpleMode = props.simpleMode;
|
|
@@ -136,6 +137,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
136
137
|
return until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, initCheckInterval);
|
|
137
138
|
}
|
|
138
139
|
})
|
|
140
|
+
.then(this.dispatchInited)
|
|
139
141
|
.then(this.initInterval)
|
|
140
142
|
.then(this.onInit);
|
|
141
143
|
}
|
|
@@ -155,7 +157,9 @@ var Form = /** @class */ (function (_super) {
|
|
|
155
157
|
store[store.hasRemoteData ? 'fetchData' : 'fetchInitData'](props.initApi, store.data, {
|
|
156
158
|
successMessage: fetchSuccess,
|
|
157
159
|
errorMessage: fetchFailed
|
|
158
|
-
})
|
|
160
|
+
})
|
|
161
|
+
.then(this.dispatchInited)
|
|
162
|
+
.then(this.initInterval);
|
|
159
163
|
}
|
|
160
164
|
};
|
|
161
165
|
Form.prototype.componentWillUnmount = function () {
|
|
@@ -170,6 +174,27 @@ var Form = /** @class */ (function (_super) {
|
|
|
170
174
|
window.removeEventListener('beforeunload', this.beforePageUnload);
|
|
171
175
|
(_a = this.unBlockRouting) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
172
176
|
};
|
|
177
|
+
Form.prototype.dispatchInited = function (value) {
|
|
178
|
+
var _a;
|
|
179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
+
var _b, data, store, dispatchEvent;
|
|
181
|
+
return __generator(this, function (_c) {
|
|
182
|
+
switch (_c.label) {
|
|
183
|
+
case 0:
|
|
184
|
+
_b = this.props, data = _b.data, store = _b.store, dispatchEvent = _b.dispatchEvent;
|
|
185
|
+
if (store.fetching) {
|
|
186
|
+
return [2 /*return*/];
|
|
187
|
+
}
|
|
188
|
+
// 派发init事件,参数为初始化数据
|
|
189
|
+
return [4 /*yield*/, dispatchEvent('inited', createObject(data, __assign(__assign({}, value === null || value === void 0 ? void 0 : value.data), { responseData: (_a = value === null || value === void 0 ? void 0 : value.data) !== null && _a !== void 0 ? _a : {}, responseStatus: store.error ? 1 : 0, responseMsg: store.msg })))];
|
|
190
|
+
case 1:
|
|
191
|
+
// 派发init事件,参数为初始化数据
|
|
192
|
+
_c.sent();
|
|
193
|
+
return [2 /*return*/, value];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
};
|
|
173
198
|
Form.prototype.blockRouting = function () {
|
|
174
199
|
var store = this.props.store;
|
|
175
200
|
var _a = this.props, promptPageLeaveMessage = _a.promptPageLeaveMessage, promptPageLeave = _a.promptPageLeave;
|
|
@@ -186,11 +211,11 @@ var Form = /** @class */ (function (_super) {
|
|
|
186
211
|
};
|
|
187
212
|
Form.prototype.onInit = function () {
|
|
188
213
|
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
-
var _a, onInit, store, persistData, submitOnInit,
|
|
214
|
+
var _a, onInit, store, persistData, submitOnInit, data, initedAt, hooks;
|
|
190
215
|
return __generator(this, function (_b) {
|
|
191
216
|
switch (_b.label) {
|
|
192
217
|
case 0:
|
|
193
|
-
_a = this.props, onInit = _a.onInit, store = _a.store, persistData = _a.persistData, submitOnInit = _a.submitOnInit,
|
|
218
|
+
_a = this.props, onInit = _a.onInit, store = _a.store, persistData = _a.persistData, submitOnInit = _a.submitOnInit, _a.dispatchEvent;
|
|
194
219
|
if (!isAlive(store)) {
|
|
195
220
|
return [2 /*return*/];
|
|
196
221
|
}
|
|
@@ -215,12 +240,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
215
240
|
store.getLocalPersistData();
|
|
216
241
|
data = cloneObject(store.data);
|
|
217
242
|
}
|
|
218
|
-
|
|
219
|
-
case 2:
|
|
220
|
-
dispatcher = _b.sent();
|
|
221
|
-
if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
|
|
222
|
-
onInit && onInit(data, this.props);
|
|
223
|
-
}
|
|
243
|
+
onInit && onInit(data, this.props);
|
|
224
244
|
submitOnInit &&
|
|
225
245
|
this.handleAction(undefined, {
|
|
226
246
|
type: 'submit'
|
|
@@ -255,12 +275,23 @@ var Form = /** @class */ (function (_super) {
|
|
|
255
275
|
return until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); });
|
|
256
276
|
}
|
|
257
277
|
})
|
|
258
|
-
.then(function (result) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
278
|
+
.then(function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
// 派发初始化接口请求完成事件
|
|
283
|
+
return [4 /*yield*/, this.dispatchInited(result)];
|
|
284
|
+
case 1:
|
|
285
|
+
// 派发初始化接口请求完成事件
|
|
286
|
+
_a.sent();
|
|
287
|
+
if (result === null || result === void 0 ? void 0 : result.ok) {
|
|
288
|
+
this.initInterval(result);
|
|
289
|
+
store.reset(undefined, false);
|
|
290
|
+
}
|
|
291
|
+
return [2 /*return*/];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}); })
|
|
264
295
|
: store.reset(undefined, false);
|
|
265
296
|
};
|
|
266
297
|
Form.prototype.receive = function (values, name, replace) {
|
|
@@ -443,14 +474,15 @@ var Form = /** @class */ (function (_super) {
|
|
|
443
474
|
};
|
|
444
475
|
};
|
|
445
476
|
Form.prototype.handleAction = function (e, action, data, throwErrors, delegate) {
|
|
477
|
+
var _a, _b;
|
|
446
478
|
if (throwErrors === void 0) { throwErrors = false; }
|
|
447
479
|
return __awaiter(this, void 0, void 0, function () {
|
|
448
|
-
var
|
|
480
|
+
var _c, store, onSubmit, api, asyncApi, finishedField, checkInterval, _d, saveSuccess, saveFailed, resetAfterSubmit, clearAfterSubmit, onAction, onSaved, onReset, onFinished, onFailed, redirect, reload, target, env, onChange, clearPersistDataAfterSubmit, trimValues, dispatchEvent, __, fields, validationRes, dispatcher, _e, dispatchEvent_1, onEvent, submitEvent, dispatcher;
|
|
449
481
|
var _this = this;
|
|
450
|
-
return __generator(this, function (
|
|
451
|
-
switch (
|
|
482
|
+
return __generator(this, function (_f) {
|
|
483
|
+
switch (_f.label) {
|
|
452
484
|
case 0:
|
|
453
|
-
|
|
485
|
+
_c = this.props, store = _c.store, onSubmit = _c.onSubmit, api = _c.api, asyncApi = _c.asyncApi, finishedField = _c.finishedField, checkInterval = _c.checkInterval, _d = _c.messages, saveSuccess = _d.saveSuccess, saveFailed = _d.saveFailed, resetAfterSubmit = _c.resetAfterSubmit, clearAfterSubmit = _c.clearAfterSubmit, onAction = _c.onAction, onSaved = _c.onSaved, onReset = _c.onReset, onFinished = _c.onFinished, onFailed = _c.onFailed, redirect = _c.redirect, reload = _c.reload, target = _c.target, env = _c.env, onChange = _c.onChange, clearPersistDataAfterSubmit = _c.clearPersistDataAfterSubmit, trimValues = _c.trimValues, dispatchEvent = _c.dispatchEvent, __ = _c.translate;
|
|
454
486
|
// 做动作之前,先把数据同步一下。
|
|
455
487
|
this.flush();
|
|
456
488
|
if (trimValues) {
|
|
@@ -469,11 +501,11 @@ var Form = /** @class */ (function (_super) {
|
|
|
469
501
|
}); });
|
|
470
502
|
return [4 /*yield*/, store.validateFields(fields)];
|
|
471
503
|
case 1:
|
|
472
|
-
validationRes =
|
|
504
|
+
validationRes = _f.sent();
|
|
473
505
|
if (!!validationRes) return [3 /*break*/, 3];
|
|
474
506
|
return [4 /*yield*/, dispatchEvent('validateError', this.props.data)];
|
|
475
507
|
case 2:
|
|
476
|
-
dispatcher =
|
|
508
|
+
dispatcher = _f.sent();
|
|
477
509
|
if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
|
|
478
510
|
env.notify('error', __('Form.validateFailed'));
|
|
479
511
|
}
|
|
@@ -482,147 +514,158 @@ var Form = /** @class */ (function (_super) {
|
|
|
482
514
|
case 3:
|
|
483
515
|
/** 重置validated状态,保证submit时触发表单中的校验项 */
|
|
484
516
|
store.clearErrors();
|
|
485
|
-
|
|
517
|
+
_f.label = 4;
|
|
486
518
|
case 4:
|
|
487
|
-
if (action.type === 'submit' ||
|
|
519
|
+
if (!(action.type === 'submit' ||
|
|
488
520
|
action.actionType === 'submit' ||
|
|
489
521
|
action.actionType === 'confirm' ||
|
|
490
522
|
action.actionType === 'reset-and-submit' ||
|
|
491
|
-
action.actionType === 'clear-and-submit')
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
dispatcher: dispatcher
|
|
549
|
-
}];
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
}); },
|
|
553
|
-
onFailed: function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
554
|
-
var dispatcher;
|
|
555
|
-
return __generator(this, function (_a) {
|
|
556
|
-
switch (_a.label) {
|
|
557
|
-
case 0: return [4 /*yield*/, dispatchEvent('submitFail', createObject(this.props.data, { error: result }))];
|
|
558
|
-
case 1:
|
|
559
|
-
dispatcher = _a.sent();
|
|
523
|
+
action.actionType === 'clear-and-submit')) return [3 /*break*/, 6];
|
|
524
|
+
_e = this.props, dispatchEvent_1 = _e.dispatchEvent, onEvent = _e.onEvent;
|
|
525
|
+
submitEvent = (_b = (_a = onEvent === null || onEvent === void 0 ? void 0 : onEvent.submit) === null || _a === void 0 ? void 0 : _a.actions) === null || _b === void 0 ? void 0 : _b.length;
|
|
526
|
+
return [4 /*yield*/, dispatchEvent_1('submit', this.props.data)];
|
|
527
|
+
case 5:
|
|
528
|
+
dispatcher = _f.sent();
|
|
529
|
+
if ((dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented) || submitEvent) {
|
|
530
|
+
return [2 /*return*/];
|
|
531
|
+
}
|
|
532
|
+
store.setCurrentAction(action);
|
|
533
|
+
if (action.actionType === 'reset-and-submit') {
|
|
534
|
+
store.reset(this.handleReset(action));
|
|
535
|
+
}
|
|
536
|
+
else if (action.actionType === 'clear-and-submit') {
|
|
537
|
+
store.clear(this.handleReset(action));
|
|
538
|
+
}
|
|
539
|
+
return [2 /*return*/, this.submit(function (values) {
|
|
540
|
+
var _a;
|
|
541
|
+
if (onSubmit && onSubmit(values, action) === false) {
|
|
542
|
+
return Promise.resolve(false);
|
|
543
|
+
}
|
|
544
|
+
// 走到这里代表校验成功了
|
|
545
|
+
dispatchEvent_1('validateSucc', _this.props.data);
|
|
546
|
+
if (target) {
|
|
547
|
+
_this.submitToTarget(filterTarget(target, values), values);
|
|
548
|
+
dispatchEvent_1('submitSucc', createObject(_this.props.data, values));
|
|
549
|
+
}
|
|
550
|
+
else if (action.actionType === 'reload') {
|
|
551
|
+
action.target &&
|
|
552
|
+
_this.reloadTarget(filterTarget(action.target, values), values);
|
|
553
|
+
}
|
|
554
|
+
else if (action.actionType === 'dialog') {
|
|
555
|
+
store.openDialog(data);
|
|
556
|
+
}
|
|
557
|
+
else if (action.actionType === 'drawer') {
|
|
558
|
+
store.openDrawer(data);
|
|
559
|
+
}
|
|
560
|
+
else if (isEffectiveApi(action.api || api, values)) {
|
|
561
|
+
var finnalAsyncApi_1 = action.asyncApi || asyncApi;
|
|
562
|
+
isEffectiveApi(finnalAsyncApi_1, store.data) &&
|
|
563
|
+
store.updateData((_a = {},
|
|
564
|
+
_a[finishedField || 'finished'] = false,
|
|
565
|
+
_a));
|
|
566
|
+
return store
|
|
567
|
+
.saveRemote(action.api || api, values, {
|
|
568
|
+
successMessage: saveSuccess,
|
|
569
|
+
errorMessage: saveFailed,
|
|
570
|
+
onSuccess: function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
571
|
+
var dispatcher, cbResult;
|
|
572
|
+
var _this = this;
|
|
573
|
+
return __generator(this, function (_a) {
|
|
574
|
+
switch (_a.label) {
|
|
575
|
+
case 0: return [4 /*yield*/, dispatchEvent_1('submitSucc', createObject(this.props.data, { result: result }))];
|
|
576
|
+
case 1:
|
|
577
|
+
dispatcher = _a.sent();
|
|
578
|
+
if (!isEffectiveApi(finnalAsyncApi_1, store.data) ||
|
|
579
|
+
store.data[finishedField || 'finished']) {
|
|
560
580
|
return [2 /*return*/, {
|
|
581
|
+
cbResult: null,
|
|
561
582
|
dispatcher: dispatcher
|
|
562
583
|
}];
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
584
|
+
}
|
|
585
|
+
cbResult = until(function () { return store.checkRemote(finnalAsyncApi_1, store.data); }, function (ret) { return ret && ret[finishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, checkInterval).then(function (value) {
|
|
586
|
+
// 派发asyncApiFinished事件
|
|
587
|
+
dispatchEvent_1('asyncApiFinished', store.data);
|
|
588
|
+
});
|
|
589
|
+
return [2 /*return*/, {
|
|
590
|
+
cbResult: cbResult,
|
|
591
|
+
dispatcher: dispatcher
|
|
592
|
+
}];
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}); },
|
|
596
|
+
onFailed: function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
597
|
+
var dispatcher;
|
|
569
598
|
return __generator(this, function (_a) {
|
|
570
599
|
switch (_a.label) {
|
|
571
|
-
case 0:
|
|
572
|
-
onSaved && onSaved(values, response);
|
|
573
|
-
feedback = action.feedback || this.props.feedback;
|
|
574
|
-
if (!(feedback && isVisible(feedback, store.data))) return [3 /*break*/, 2];
|
|
575
|
-
return [4 /*yield*/, this.openFeedback(feedback, store.data)];
|
|
600
|
+
case 0: return [4 /*yield*/, dispatchEvent_1('submitFail', createObject(this.props.data, { error: result }))];
|
|
576
601
|
case 1:
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
-
else if (feedback.skipRestOnConfirm && confirmed) {
|
|
583
|
-
throw new SkipOperation();
|
|
584
|
-
}
|
|
585
|
-
_a.label = 2;
|
|
586
|
-
case 2: return [2 /*return*/];
|
|
602
|
+
dispatcher = _a.sent();
|
|
603
|
+
return [2 /*return*/, {
|
|
604
|
+
dispatcher: dispatcher
|
|
605
|
+
}];
|
|
587
606
|
}
|
|
588
607
|
});
|
|
589
|
-
}); }
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
608
|
+
}); }
|
|
609
|
+
})
|
|
610
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
611
|
+
var feedback, confirmed;
|
|
612
|
+
return __generator(this, function (_a) {
|
|
613
|
+
switch (_a.label) {
|
|
614
|
+
case 0:
|
|
615
|
+
onSaved && onSaved(values, response);
|
|
616
|
+
feedback = action.feedback || this.props.feedback;
|
|
617
|
+
if (!(feedback && isVisible(feedback, store.data))) return [3 /*break*/, 2];
|
|
618
|
+
return [4 /*yield*/, this.openFeedback(feedback, store.data)];
|
|
619
|
+
case 1:
|
|
620
|
+
confirmed = _a.sent();
|
|
621
|
+
// 如果 feedback 配置了,取消就跳过原有逻辑。
|
|
622
|
+
if (feedback.skipRestOnCancel && !confirmed) {
|
|
623
|
+
throw new SkipOperation();
|
|
624
|
+
}
|
|
625
|
+
else if (feedback.skipRestOnConfirm && confirmed) {
|
|
626
|
+
throw new SkipOperation();
|
|
627
|
+
}
|
|
628
|
+
_a.label = 2;
|
|
629
|
+
case 2: return [2 /*return*/];
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
}); });
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
// type为submit,但是没有配api以及target时,只派发事件
|
|
636
|
+
dispatchEvent_1('submitSucc', createObject(_this.props.data, values));
|
|
637
|
+
}
|
|
638
|
+
return Promise.resolve(null);
|
|
639
|
+
})
|
|
640
|
+
.then(function (values) {
|
|
641
|
+
// 有可能 onSubmit return false 了,那么后面的就不应该再执行了。
|
|
642
|
+
if (values === false) {
|
|
643
|
+
return store.data;
|
|
644
|
+
}
|
|
645
|
+
if (onFinished && onFinished(values, action) === false) {
|
|
616
646
|
return values;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
647
|
+
}
|
|
648
|
+
resetAfterSubmit && store.reset(_this.handleReset(action));
|
|
649
|
+
clearAfterSubmit && store.clear(_this.handleReset(action));
|
|
650
|
+
clearPersistDataAfterSubmit && store.clearLocalPersistData();
|
|
651
|
+
if (action.redirect || redirect) {
|
|
652
|
+
var finalRedirect = filter(action.redirect || redirect, store.data);
|
|
653
|
+
finalRedirect && env.jumpTo(finalRedirect, action);
|
|
654
|
+
}
|
|
655
|
+
else if (action.reload || reload) {
|
|
656
|
+
_this.reloadTarget(filterTarget(action.reload || reload, store.data), store.data);
|
|
657
|
+
}
|
|
658
|
+
action.close && _this.closeTarget(action.close);
|
|
659
|
+
return values;
|
|
660
|
+
})
|
|
661
|
+
.catch(function (reason) {
|
|
662
|
+
onFailed && onFailed(reason, store.errors);
|
|
663
|
+
if (throwErrors) {
|
|
664
|
+
throw reason;
|
|
665
|
+
}
|
|
666
|
+
})];
|
|
667
|
+
case 6:
|
|
668
|
+
if (action.type === 'reset' || action.actionType === 'reset') {
|
|
626
669
|
store.setCurrentAction(action);
|
|
627
670
|
store.reset(onReset);
|
|
628
671
|
}
|
|
@@ -675,7 +718,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
675
718
|
redirect = action.redirect && filter(action.redirect, store.data);
|
|
676
719
|
redirect && env.jumpTo(redirect, action);
|
|
677
720
|
action.reload &&
|
|
678
|
-
this.reloadTarget(
|
|
721
|
+
this.reloadTarget(filterTarget(action.reload, store.data), store.data);
|
|
679
722
|
action.close && this.closeTarget(action.close);
|
|
680
723
|
return [2 /*return*/];
|
|
681
724
|
}
|
|
@@ -691,18 +734,19 @@ var Form = /** @class */ (function (_super) {
|
|
|
691
734
|
else if (action.actionType === 'reload') {
|
|
692
735
|
store.setCurrentAction(action);
|
|
693
736
|
if (action.target) {
|
|
694
|
-
this.reloadTarget(
|
|
737
|
+
this.reloadTarget(filterTarget(action.target, data), data);
|
|
695
738
|
}
|
|
696
739
|
else {
|
|
697
740
|
this.receive(data);
|
|
698
741
|
}
|
|
699
|
-
// action.target && this.reloadTarget(action.target, data);
|
|
742
|
+
// action.target && this.reloadTarget(filterTarget(action.target, data), data);
|
|
700
743
|
}
|
|
701
744
|
else if (onAction) {
|
|
702
745
|
// 不识别的丢给上层去处理。
|
|
703
746
|
return [2 /*return*/, onAction(e, action, data, throwErrors, delegate || this.context)];
|
|
704
747
|
}
|
|
705
|
-
|
|
748
|
+
_f.label = 7;
|
|
749
|
+
case 7: return [2 /*return*/];
|
|
706
750
|
}
|
|
707
751
|
});
|
|
708
752
|
});
|
|
@@ -1050,33 +1094,25 @@ var FormRenderer = /** @class */ (function (_super) {
|
|
|
1050
1094
|
return this.handleAction(undefined, action, data, throwErrors);
|
|
1051
1095
|
};
|
|
1052
1096
|
FormRenderer.prototype.handleAction = function (e, action, ctx, throwErrors, delegate) {
|
|
1053
|
-
var _a, _b;
|
|
1054
1097
|
if (throwErrors === void 0) { throwErrors = false; }
|
|
1055
1098
|
return __awaiter(this, void 0, void 0, function () {
|
|
1056
|
-
var
|
|
1057
|
-
return __generator(this, function (
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
return
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
target.doAction &&
|
|
1074
|
-
target.doAction(__assign(__assign({}, action), { target: undefined }), ctx, throwErrors));
|
|
1075
|
-
}))];
|
|
1076
|
-
}
|
|
1077
|
-
else {
|
|
1078
|
-
return [2 /*return*/, _super.prototype.handleAction.call(this, e, action, ctx, throwErrors, delegate)];
|
|
1079
|
-
}
|
|
1099
|
+
var scoped_1;
|
|
1100
|
+
return __generator(this, function (_a) {
|
|
1101
|
+
// 禁用了不要做任何动作。@先注释掉,会引起其他问题
|
|
1102
|
+
// if (this.props.disabled) {
|
|
1103
|
+
// return;
|
|
1104
|
+
// }
|
|
1105
|
+
if (action.target && action.actionType !== 'reload') {
|
|
1106
|
+
scoped_1 = this.context;
|
|
1107
|
+
return [2 /*return*/, Promise.all(action.target.split(',').map(function (name) {
|
|
1108
|
+
var target = scoped_1.getComponentByName(name);
|
|
1109
|
+
return (target &&
|
|
1110
|
+
target.doAction &&
|
|
1111
|
+
target.doAction(__assign(__assign({}, action), { target: undefined }), ctx, throwErrors));
|
|
1112
|
+
}))];
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
return [2 /*return*/, _super.prototype.handleAction.call(this, e, action, ctx, throwErrors, delegate)];
|
|
1080
1116
|
}
|
|
1081
1117
|
});
|
|
1082
1118
|
});
|