amis-core 3.1.1 → 3.3.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.js +1 -1
- package/esm/RootRenderer.d.ts +1 -1
- package/esm/RootRenderer.js +3 -3
- package/esm/SchemaRenderer.js +6 -2
- package/esm/Scoped.d.ts +4 -1
- package/esm/Scoped.js +9 -5
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.d.ts +4 -24
- package/esm/WithRootStore.js +12 -4
- package/esm/WithStore.js +23 -16
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +70 -45
- package/esm/actions/AjaxAction.d.ts +6 -8
- package/esm/actions/AjaxAction.js +20 -18
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.d.ts +1 -2
- package/esm/actions/CmptAction.js +47 -32
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +3 -2
- package/esm/actions/DialogAction.d.ts +2 -0
- package/esm/actions/DialogAction.js +39 -23
- package/esm/actions/DrawerAction.js +4 -4
- 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/StatusAction.d.ts +15 -0
- package/esm/actions/StatusAction.js +49 -0
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/index.d.ts +1 -0
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +3 -2
- package/esm/components/PopOver.js +3 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +3 -1
- package/esm/index.js +16 -14
- package/esm/locale.js +1 -1
- package/esm/polyfills.d.ts +3 -0
- package/esm/polyfills.js +18 -0
- package/esm/renderers/Form.d.ts +7 -7
- package/esm/renderers/Form.js +182 -128
- package/esm/renderers/Item.d.ts +82 -77
- package/esm/renderers/Item.js +90 -74
- package/esm/renderers/Options.js +1 -2
- 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 +4 -24
- package/esm/renderers/wrapControl.js +140 -88
- package/esm/store/app.js +42 -4
- package/esm/store/combo.d.ts +564 -1892
- package/esm/store/combo.js +9 -2
- package/esm/store/crud.d.ts +4 -2
- package/esm/store/crud.js +17 -4
- package/esm/store/form.d.ts +182 -882
- package/esm/store/form.js +83 -81
- package/esm/store/formItem.d.ts +6 -2
- package/esm/store/formItem.js +19 -3
- package/esm/store/iRenderer.js +3 -2
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +1 -0
- package/esm/store/list.js +8 -2
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.js +3 -2
- package/esm/store/service.js +17 -12
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +604 -2020
- package/esm/store/table.js +86 -56
- package/esm/store/table2.d.ts +49 -0
- package/esm/store/table2.js +37 -4
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +22 -5
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.d.ts +3 -2
- package/esm/utils/DataSchema.js +27 -7
- package/esm/utils/DataScope.d.ts +10 -3
- package/esm/utils/DataScope.js +50 -12
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +2 -2
- package/esm/utils/api.js +152 -112
- package/esm/utils/arraySlice.d.ts +1 -0
- package/esm/utils/arraySlice.js +76 -0
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +29 -19
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.d.ts +2 -0
- package/esm/utils/debug.js +34 -7
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +4 -1
- 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.d.ts +0 -1
- package/esm/utils/formula.js +6 -9
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +19 -2
- package/esm/utils/helper.js +69 -10
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.d.ts +4 -2
- package/esm/utils/icon.js +3 -2
- package/esm/utils/image.js +1 -1
- package/esm/utils/index.d.ts +2 -0
- package/esm/utils/isPureVariable.js +1 -1
- 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/math.d.ts +3 -0
- package/esm/utils/math.js +52 -0
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +18 -9
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.d.ts +7 -0
- package/esm/utils/object.js +13 -2
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +2 -2
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.d.ts +1 -1
- package/esm/utils/renderer-event.js +14 -6
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.js +1 -1
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
- 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.js +1 -1
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +10 -7
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +11 -8
- package/lib/SchemaRenderer.js +13 -6
- package/lib/Scoped.d.ts +4 -1
- package/lib/Scoped.js +19 -13
- package/lib/StatusScoped.js +5 -2
- package/lib/WithRootStore.d.ts +4 -24
- package/lib/WithRootStore.js +15 -4
- package/lib/WithStore.js +27 -17
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +70 -45
- package/lib/actions/AjaxAction.d.ts +6 -8
- package/lib/actions/AjaxAction.js +20 -18
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.d.ts +1 -2
- package/lib/actions/CmptAction.js +47 -32
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +9 -5
- package/lib/actions/DialogAction.d.ts +2 -0
- package/lib/actions/DialogAction.js +39 -23
- package/lib/actions/DrawerAction.js +4 -4
- 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/StatusAction.d.ts +15 -0
- package/lib/actions/StatusAction.js +53 -0
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/index.d.ts +1 -0
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/LazyComponent.js +12 -14
- package/lib/components/Overlay.js +15 -14
- package/lib/components/PopOver.js +12 -10
- package/lib/env.js +4 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +11 -9
- package/lib/index.d.ts +3 -1
- package/lib/index.js +26 -19
- package/lib/locale.js +6 -3
- package/lib/polyfills.d.ts +3 -0
- package/lib/polyfills.js +20 -0
- package/lib/renderers/Form.d.ts +7 -7
- package/lib/renderers/Form.js +194 -135
- package/lib/renderers/Item.d.ts +82 -77
- package/lib/renderers/Item.js +126 -104
- package/lib/renderers/Options.js +10 -5
- 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 +4 -24
- package/lib/renderers/wrapControl.js +143 -88
- package/lib/store/app.js +44 -3
- package/lib/store/combo.d.ts +564 -1892
- package/lib/store/combo.js +9 -2
- package/lib/store/crud.d.ts +4 -2
- package/lib/store/crud.js +17 -4
- package/lib/store/form.d.ts +182 -882
- package/lib/store/form.js +81 -79
- package/lib/store/formItem.d.ts +6 -2
- package/lib/store/formItem.js +19 -3
- package/lib/store/iRenderer.js +9 -5
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +1 -0
- package/lib/store/list.js +8 -2
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.js +9 -5
- package/lib/store/service.js +17 -12
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +604 -2020
- package/lib/store/table.js +85 -55
- package/lib/store/table2.d.ts +49 -0
- package/lib/store/table2.js +36 -3
- package/lib/theme.js +6 -3
- package/lib/types.d.ts +22 -5
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.d.ts +3 -2
- package/lib/utils/DataSchema.js +27 -7
- package/lib/utils/DataScope.d.ts +10 -3
- package/lib/utils/DataScope.js +50 -11
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +2 -2
- package/lib/utils/api.js +151 -111
- package/lib/utils/arraySlice.d.ts +1 -0
- package/lib/utils/arraySlice.js +80 -0
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +8 -6
- package/lib/utils/dataMapping.js +29 -19
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.d.ts +2 -0
- package/lib/utils/debug.js +61 -33
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +10 -5
- 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.d.ts +0 -1
- package/lib/utils/formula.js +6 -10
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +19 -2
- package/lib/utils/helper.js +70 -9
- package/lib/utils/highlight.js +8 -9
- package/lib/utils/icon.d.ts +4 -2
- package/lib/utils/icon.js +12 -10
- package/lib/utils/image.js +1 -1
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/isPureVariable.js +1 -1
- 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/math.d.ts +3 -0
- package/lib/utils/math.js +58 -0
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +18 -9
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.d.ts +7 -0
- package/lib/utils/object.js +13 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +7 -3
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.d.ts +1 -1
- package/lib/utils/renderer-event.js +13 -5
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.js +1 -1
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
- 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.js +1 -1
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/package.json +9 -4
package/esm/store/form.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { __generator, __assign, __read, __spreadArray } from 'tslib';
|
|
7
7
|
import { types, flow, isAlive, getEnv } from 'mobx-state-tree';
|
|
8
8
|
import debounce from 'lodash/debounce';
|
|
9
9
|
import throttle from 'lodash/throttle';
|
|
@@ -11,7 +11,7 @@ import toPairs from 'lodash/toPairs';
|
|
|
11
11
|
import pick from 'lodash/pick';
|
|
12
12
|
import { ServiceStore } from './service.js';
|
|
13
13
|
import { ServerError } from '../utils/errors.js';
|
|
14
|
-
import { isEmpty, difference, mapObject } from '../utils/helper.js';
|
|
14
|
+
import { isEmpty, difference, ValidateError, mapObject } from '../utils/helper.js';
|
|
15
15
|
import isEqual from 'lodash/isEqual';
|
|
16
16
|
import flatten from 'lodash/flatten';
|
|
17
17
|
import find from 'lodash/find';
|
|
@@ -48,7 +48,7 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
48
48
|
if (current.storeType === 'FormItemStore') {
|
|
49
49
|
formItems.push(current);
|
|
50
50
|
}
|
|
51
|
-
else {
|
|
51
|
+
else if (!['ComboStore', 'TableStore', 'FormStore'].includes(current.storeType)) {
|
|
52
52
|
pool.push.apply(pool, __spreadArray([], __read(current.children), false));
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -61,30 +61,11 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
61
61
|
get items() {
|
|
62
62
|
return getItems();
|
|
63
63
|
},
|
|
64
|
-
/**
|
|
65
|
-
* 相对于 items(), 只收集直接子formItem
|
|
66
|
-
* 避免 子form 表单项的重复验证
|
|
67
|
-
*/
|
|
68
|
-
get directItems() {
|
|
69
|
-
var formItems = [];
|
|
70
|
-
// 查找孩子节点中是 formItem 的表单项
|
|
71
|
-
var pool = self.children.concat();
|
|
72
|
-
while (pool.length) {
|
|
73
|
-
var current = pool.shift();
|
|
74
|
-
if (current.storeType === 'FormItemStore') {
|
|
75
|
-
formItems.push(current);
|
|
76
|
-
}
|
|
77
|
-
else if (!['ComboStore', 'TableStore'].includes(current.storeType)) {
|
|
78
|
-
pool.push.apply(pool, __spreadArray([], __read(current.children), false));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return formItems;
|
|
82
|
-
},
|
|
83
64
|
/** 获取InputGroup的子元素 */
|
|
84
65
|
get inputGroupItems() {
|
|
85
66
|
var _a, _b;
|
|
86
67
|
var formItems = {};
|
|
87
|
-
var children =
|
|
68
|
+
var children = this.items.concat();
|
|
88
69
|
while (children.length) {
|
|
89
70
|
var current = children.shift();
|
|
90
71
|
if (current.inputGroupControl && ((_a = current.inputGroupControl) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
@@ -154,11 +135,27 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
154
135
|
self.updateData(values, tag, replace);
|
|
155
136
|
// 如果数据域中有数据变化,就都reset一下,去掉之前残留的验证消息
|
|
156
137
|
self.items.forEach(function (item) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
138
|
+
if (item.extraName) {
|
|
139
|
+
var value = [
|
|
140
|
+
getVariable(values, item.name, false),
|
|
141
|
+
getVariable(values, item.extraName, false)
|
|
142
|
+
];
|
|
143
|
+
if (value.some(function (item) { return item !== undefined; }) &&
|
|
144
|
+
!isEqual(value, item.tmpValue)) {
|
|
145
|
+
var origin_1 = item.splitExtraValue(item.tmpValue);
|
|
146
|
+
item.changeTmpValue(value.map(function (item, idx) { return item !== null && item !== void 0 ? item : origin_1[idx]; }), 'dataChanged');
|
|
147
|
+
item.changeEmitedValue(undefined);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
var value = getVariable(values, item.name, false);
|
|
152
|
+
if (value !== undefined && value !== item.tmpValue) {
|
|
153
|
+
item.changeTmpValue(value, 'dataChanged');
|
|
154
|
+
item.changeEmitedValue(undefined);
|
|
155
|
+
}
|
|
160
156
|
}
|
|
161
157
|
item.reset();
|
|
158
|
+
item.validateOnChange && item.validate(self.data);
|
|
162
159
|
});
|
|
163
160
|
// 同步 options
|
|
164
161
|
syncOptions();
|
|
@@ -270,33 +267,33 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
270
267
|
}
|
|
271
268
|
var saveRemote = flow(function saveRemote(api, data, options) {
|
|
272
269
|
var ret, json, ret, e_1, ret, result;
|
|
273
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
270
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
274
271
|
if (options === void 0) { options = {}; }
|
|
275
|
-
return __generator(this, function (
|
|
276
|
-
switch (
|
|
272
|
+
return __generator(this, function (_r) {
|
|
273
|
+
switch (_r.label) {
|
|
277
274
|
case 0:
|
|
278
275
|
clearRestError();
|
|
279
|
-
|
|
276
|
+
_r.label = 1;
|
|
280
277
|
case 1:
|
|
281
|
-
|
|
278
|
+
_r.trys.push([1, 12, , 15]);
|
|
282
279
|
options = __assign({ method: 'post' }, options);
|
|
283
280
|
if (!(options && options.beforeSend)) return [3 /*break*/, 4];
|
|
284
281
|
ret = options.beforeSend(data);
|
|
285
282
|
if (!(ret && ret.then)) return [3 /*break*/, 3];
|
|
286
283
|
return [4 /*yield*/, ret];
|
|
287
284
|
case 2:
|
|
288
|
-
ret =
|
|
289
|
-
|
|
285
|
+
ret = _r.sent();
|
|
286
|
+
_r.label = 3;
|
|
290
287
|
case 3:
|
|
291
288
|
if (ret === false) {
|
|
292
289
|
return [2 /*return*/];
|
|
293
290
|
}
|
|
294
|
-
|
|
291
|
+
_r.label = 4;
|
|
295
292
|
case 4:
|
|
296
293
|
self.markSaving(true);
|
|
297
294
|
return [4 /*yield*/, getEnv(self).fetcher(api, data, options)];
|
|
298
295
|
case 5:
|
|
299
|
-
json =
|
|
296
|
+
json = _r.sent();
|
|
300
297
|
// 失败也同样修改数据,如果有数据的话。
|
|
301
298
|
if (!isEmpty(json.data) || json.ok) {
|
|
302
299
|
self.updatedAt = Date.now();
|
|
@@ -317,24 +314,24 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
317
314
|
throw new ServerError(self.msg, json);
|
|
318
315
|
case 6:
|
|
319
316
|
updateSavedData();
|
|
320
|
-
ret = options
|
|
317
|
+
ret = (_h = options === null || options === void 0 ? void 0 : options.onSuccess) === null || _h === void 0 ? void 0 : _h.call(options, json, json.data);
|
|
321
318
|
if (!(ret === null || ret === void 0 ? void 0 : ret.then)) return [3 /*break*/, 8];
|
|
322
319
|
return [4 /*yield*/, ret];
|
|
323
320
|
case 7:
|
|
324
|
-
ret =
|
|
325
|
-
|
|
321
|
+
ret = _r.sent();
|
|
322
|
+
_r.label = 8;
|
|
326
323
|
case 8:
|
|
327
|
-
if (!((
|
|
324
|
+
if (!((_j = ret === null || ret === void 0 ? void 0 : ret.cbResult) === null || _j === void 0 ? void 0 : _j.then)) return [3 /*break*/, 10];
|
|
328
325
|
return [4 /*yield*/, ret.cbResult];
|
|
329
326
|
case 9:
|
|
330
|
-
|
|
331
|
-
|
|
327
|
+
_r.sent();
|
|
328
|
+
_r.label = 10;
|
|
332
329
|
case 10:
|
|
333
330
|
self.markSaving(false);
|
|
334
|
-
self.updateMessage((
|
|
331
|
+
self.updateMessage((_o = (_m = (_l = (_k = api === null || api === void 0 ? void 0 : api.messages) === null || _k === void 0 ? void 0 : _k.success) !== null && _l !== void 0 ? _l : json.msg) !== null && _m !== void 0 ? _m : (options.successMessage === 'saveSuccess'
|
|
335
332
|
? json.defaultMsg
|
|
336
|
-
: self.__(options && options.successMessage))) !== null &&
|
|
337
|
-
if (!((
|
|
333
|
+
: self.__(options && options.successMessage))) !== null && _o !== void 0 ? _o : json.defaultMsg);
|
|
334
|
+
if (!((_p = ret === null || ret === void 0 ? void 0 : ret.dispatcher) === null || _p === void 0 ? void 0 : _p.prevented)) {
|
|
338
335
|
self.msg &&
|
|
339
336
|
getEnv(self).notify('success', self.msg, json.msgTimeout !== undefined
|
|
340
337
|
? {
|
|
@@ -346,19 +343,19 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
346
343
|
return [2 /*return*/, json.data];
|
|
347
344
|
case 11: return [3 /*break*/, 15];
|
|
348
345
|
case 12:
|
|
349
|
-
e_1 =
|
|
346
|
+
e_1 = _r.sent();
|
|
350
347
|
self.markSaving(false);
|
|
351
348
|
ret = options && options.onFailed && options.onFailed(e_1.response || {});
|
|
352
349
|
if (!(ret === null || ret === void 0 ? void 0 : ret.then)) return [3 /*break*/, 14];
|
|
353
350
|
return [4 /*yield*/, ret];
|
|
354
351
|
case 13:
|
|
355
|
-
ret =
|
|
356
|
-
|
|
352
|
+
ret = _r.sent();
|
|
353
|
+
_r.label = 14;
|
|
357
354
|
case 14:
|
|
358
355
|
if (!isAlive(self) || self.disposed) {
|
|
359
356
|
return [2 /*return*/];
|
|
360
357
|
}
|
|
361
|
-
if ((
|
|
358
|
+
if ((_q = ret === null || ret === void 0 ? void 0 : ret.dispatcher) === null || _q === void 0 ? void 0 : _q.prevented) {
|
|
362
359
|
return [2 /*return*/];
|
|
363
360
|
}
|
|
364
361
|
if (e_1.type === 'ServerError') {
|
|
@@ -427,8 +424,8 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
427
424
|
trailing: false,
|
|
428
425
|
leading: true
|
|
429
426
|
});
|
|
430
|
-
var submit = flow(function submit(fn, hooks, failedMessage, validateErrCb) {
|
|
431
|
-
var
|
|
427
|
+
var submit = flow(function submit(fn, hooks, failedMessage, validateErrCb, throwErrors) {
|
|
428
|
+
var diff, result;
|
|
432
429
|
return __generator(this, function (_a) {
|
|
433
430
|
switch (_a.label) {
|
|
434
431
|
case 0:
|
|
@@ -436,53 +433,35 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
436
433
|
self.submiting = true;
|
|
437
434
|
_a.label = 1;
|
|
438
435
|
case 1:
|
|
439
|
-
_a.trys.push([1, ,
|
|
440
|
-
return [4 /*yield*/, validate(hooks)];
|
|
436
|
+
_a.trys.push([1, , 5, 6]);
|
|
437
|
+
return [4 /*yield*/, validate(hooks, undefined, true, failedMessage, validateErrCb)];
|
|
441
438
|
case 2:
|
|
442
|
-
|
|
443
|
-
if (!
|
|
444
|
-
self.items.some(function (item) {
|
|
445
|
-
return item.errorData.some(function (e) { return e.tag !== 'remote'; });
|
|
446
|
-
})) ||
|
|
447
|
-
self.restError.length)) return [3 /*break*/, 5];
|
|
448
|
-
msg = failedMessage !== null && failedMessage !== void 0 ? failedMessage : self.__('Form.validateFailed');
|
|
449
|
-
dispatcher = validateErrCb && validateErrCb();
|
|
450
|
-
if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.then)) return [3 /*break*/, 4];
|
|
451
|
-
return [4 /*yield*/, dispatcher];
|
|
452
|
-
case 3:
|
|
453
|
-
dispatcher = _a.sent();
|
|
454
|
-
_a.label = 4;
|
|
455
|
-
case 4:
|
|
456
|
-
if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
|
|
457
|
-
msg && toastValidateError(msg);
|
|
458
|
-
}
|
|
459
|
-
throw new Error(msg);
|
|
460
|
-
case 5:
|
|
461
|
-
if (!fn) return [3 /*break*/, 7];
|
|
439
|
+
_a.sent();
|
|
440
|
+
if (!fn) return [3 /*break*/, 4];
|
|
462
441
|
diff = difference(self.data, self.pristine);
|
|
463
442
|
return [4 /*yield*/, fn(createObject(createObject(self.data.__super, {
|
|
464
443
|
diff: diff,
|
|
465
444
|
__diff: diff,
|
|
466
445
|
pristine: self.pristine
|
|
467
446
|
}), self.data))];
|
|
468
|
-
case
|
|
447
|
+
case 3:
|
|
469
448
|
result = _a.sent();
|
|
470
449
|
return [2 /*return*/, result !== null && result !== void 0 ? result : self.data];
|
|
471
|
-
case
|
|
472
|
-
case
|
|
450
|
+
case 4: return [2 /*return*/, self.data];
|
|
451
|
+
case 5:
|
|
473
452
|
self.submiting = false;
|
|
474
453
|
return [7 /*endfinally*/];
|
|
475
|
-
case
|
|
454
|
+
case 6: return [2 /*return*/];
|
|
476
455
|
}
|
|
477
456
|
});
|
|
478
457
|
});
|
|
479
|
-
var validate = flow(function validate(hooks, forceValidate) {
|
|
480
|
-
var items, i, len, item, i, len;
|
|
458
|
+
var validate = flow(function validate(hooks, forceValidate, throwErrors, failedMessage, validateErrCb) {
|
|
459
|
+
var items, i, len, item, i, len, msg, dispatcher;
|
|
481
460
|
return __generator(this, function (_a) {
|
|
482
461
|
switch (_a.label) {
|
|
483
462
|
case 0:
|
|
484
463
|
self.validated = true;
|
|
485
|
-
items = self.
|
|
464
|
+
items = self.items.concat();
|
|
486
465
|
i = 0, len = items.length;
|
|
487
466
|
_a.label = 1;
|
|
488
467
|
case 1:
|
|
@@ -533,7 +512,30 @@ var FormStore = ServiceStore.named('FormStore')
|
|
|
533
512
|
case 7:
|
|
534
513
|
i++;
|
|
535
514
|
return [3 /*break*/, 5];
|
|
536
|
-
case 8:
|
|
515
|
+
case 8:
|
|
516
|
+
if (!!self.valid) return [3 /*break*/, 12];
|
|
517
|
+
if (!(self.items.some(function (item) {
|
|
518
|
+
return item.errorData.some(function (e) { return e.tag !== 'remote'; });
|
|
519
|
+
}) ||
|
|
520
|
+
self.restError.length)) return [3 /*break*/, 11];
|
|
521
|
+
msg = failedMessage !== null && failedMessage !== void 0 ? failedMessage : self.__('Form.validateFailed');
|
|
522
|
+
dispatcher = validateErrCb && validateErrCb();
|
|
523
|
+
if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.then)) return [3 /*break*/, 10];
|
|
524
|
+
return [4 /*yield*/, dispatcher];
|
|
525
|
+
case 9:
|
|
526
|
+
dispatcher = _a.sent();
|
|
527
|
+
_a.label = 10;
|
|
528
|
+
case 10:
|
|
529
|
+
if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
|
|
530
|
+
msg && toastValidateError(msg);
|
|
531
|
+
}
|
|
532
|
+
_a.label = 11;
|
|
533
|
+
case 11:
|
|
534
|
+
if (throwErrors) {
|
|
535
|
+
throw new ValidateError(failedMessage || self.__('Form.validateFailed'), self.errors);
|
|
536
|
+
}
|
|
537
|
+
_a.label = 12;
|
|
538
|
+
case 12: return [2 /*return*/, self.valid];
|
|
537
539
|
}
|
|
538
540
|
});
|
|
539
541
|
});
|
package/esm/store/formItem.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const FormItemStore: import("mobx-state-tree").IModelType<{
|
|
|
17
17
|
isValueSchemaExp: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
18
18
|
tmpValue: import("mobx-state-tree").IType<any, any, any>;
|
|
19
19
|
emitedValue: import("mobx-state-tree").IType<any, any, any>;
|
|
20
|
+
changeMotivation: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
20
21
|
rules: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
21
22
|
messages: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
22
23
|
errorData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
|
|
@@ -25,6 +26,7 @@ export declare const FormItemStore: import("mobx-state-tree").IModelType<{
|
|
|
25
26
|
rule: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
26
27
|
}, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>, [undefined]>;
|
|
27
28
|
name: import("mobx-state-tree").ISimpleType<string>;
|
|
29
|
+
extraName: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
28
30
|
itemId: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
29
31
|
unsetValueOnInvisible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
30
32
|
itemsRef: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").ISimpleType<string>>, [undefined]>;
|
|
@@ -71,10 +73,12 @@ export declare const FormItemStore: import("mobx-state-tree").IModelType<{
|
|
|
71
73
|
readonly errClassNames: string;
|
|
72
74
|
readonly lastSelectValue: string;
|
|
73
75
|
getSelectedOptions: (value?: any, nodeValueArray?: any[] | undefined) => any[];
|
|
76
|
+
splitExtraValue(value: any): any[];
|
|
74
77
|
} & {
|
|
75
78
|
focus: () => void;
|
|
76
79
|
blur: () => void;
|
|
77
|
-
config: ({ required, unique, value, isValueSchemaExp, rules, messages, delimiter, multiple, valueField, labelField, joinValues, extractValue, type, id, selectFirst, autoFill, clearValueOnHidden, validateApi, maxLength, minLength, validateOnChange, label, inputGroupControl }: {
|
|
80
|
+
config: ({ extraName, required, unique, value, isValueSchemaExp, rules, messages, delimiter, multiple, valueField, labelField, joinValues, extractValue, type, id, selectFirst, autoFill, clearValueOnHidden, validateApi, maxLength, minLength, validateOnChange, label, inputGroupControl }: {
|
|
81
|
+
extraName?: string | undefined;
|
|
78
82
|
required?: boolean | undefined;
|
|
79
83
|
unique?: boolean | undefined;
|
|
80
84
|
value?: any;
|
|
@@ -131,7 +135,7 @@ export declare const FormItemStore: import("mobx-state-tree").IModelType<{
|
|
|
131
135
|
resetValidationStatus: (tag?: string) => void;
|
|
132
136
|
openDialog: (schema: any, ctx: any, callback?: ((ret?: any) => void) | undefined) => void;
|
|
133
137
|
closeDialog: (result?: any) => void;
|
|
134
|
-
changeTmpValue: (value: any) => void;
|
|
138
|
+
changeTmpValue: (value: any, changeReason?: 'initialValue' | 'formInited' | 'dataChanged' | 'formulaChanged' | 'controlled' | 'input' | 'defaultValue') => void;
|
|
135
139
|
changeEmitedValue: (value: any) => void;
|
|
136
140
|
addSubFormItem: (item: IFormItemStore) => void;
|
|
137
141
|
removeSubFormItem: (item: IFormItemStore) => void;
|
package/esm/store/formItem.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -40,10 +40,12 @@ var FormItemStore = StoreNode.named('FormItemStore')
|
|
|
40
40
|
isValueSchemaExp: types.optional(types.boolean, false),
|
|
41
41
|
tmpValue: types.frozen(),
|
|
42
42
|
emitedValue: types.frozen(),
|
|
43
|
+
changeMotivation: 'input',
|
|
43
44
|
rules: types.optional(types.frozen(), {}),
|
|
44
45
|
messages: types.optional(types.frozen(), {}),
|
|
45
46
|
errorData: types.optional(types.array(ErrorDetail), []),
|
|
46
47
|
name: types.string,
|
|
48
|
+
extraName: '',
|
|
47
49
|
itemId: '',
|
|
48
50
|
unsetValueOnInvisible: false,
|
|
49
51
|
itemsRef: types.optional(types.array(types.string), []),
|
|
@@ -166,6 +168,15 @@ var FormItemStore = StoreNode.named('FormItemStore')
|
|
|
166
168
|
}
|
|
167
169
|
});
|
|
168
170
|
return selectedOptions;
|
|
171
|
+
},
|
|
172
|
+
splitExtraValue: function (value) {
|
|
173
|
+
var delimiter = self.delimiter || ',';
|
|
174
|
+
var values = Array.isArray(value)
|
|
175
|
+
? value
|
|
176
|
+
: typeof value === 'string'
|
|
177
|
+
? value.split(delimiter || ',')
|
|
178
|
+
: [];
|
|
179
|
+
return values;
|
|
169
180
|
}
|
|
170
181
|
};
|
|
171
182
|
})
|
|
@@ -174,10 +185,11 @@ var FormItemStore = StoreNode.named('FormItemStore')
|
|
|
174
185
|
var dialogCallbacks = new SimpleMap();
|
|
175
186
|
var loadAutoUpdateCancel = null;
|
|
176
187
|
function config(_a) {
|
|
177
|
-
var required = _a.required, unique = _a.unique; _a.value; var isValueSchemaExp = _a.isValueSchemaExp, rules = _a.rules, messages = _a.messages, delimiter = _a.delimiter, multiple = _a.multiple, valueField = _a.valueField, labelField = _a.labelField, joinValues = _a.joinValues, extractValue = _a.extractValue, type = _a.type, id = _a.id, selectFirst = _a.selectFirst, autoFill = _a.autoFill, clearValueOnHidden = _a.clearValueOnHidden, validateApi = _a.validateApi, maxLength = _a.maxLength, minLength = _a.minLength, validateOnChange = _a.validateOnChange, label = _a.label, inputGroupControl = _a.inputGroupControl;
|
|
188
|
+
var extraName = _a.extraName, required = _a.required, unique = _a.unique; _a.value; var isValueSchemaExp = _a.isValueSchemaExp, rules = _a.rules, messages = _a.messages, delimiter = _a.delimiter, multiple = _a.multiple, valueField = _a.valueField, labelField = _a.labelField, joinValues = _a.joinValues, extractValue = _a.extractValue, type = _a.type, id = _a.id, selectFirst = _a.selectFirst, autoFill = _a.autoFill, clearValueOnHidden = _a.clearValueOnHidden, validateApi = _a.validateApi, maxLength = _a.maxLength, minLength = _a.minLength, validateOnChange = _a.validateOnChange, label = _a.label, inputGroupControl = _a.inputGroupControl;
|
|
178
189
|
if (typeof rules === 'string') {
|
|
179
190
|
rules = str2rules(rules);
|
|
180
191
|
}
|
|
192
|
+
typeof extraName !== 'undefined' && (self.extraName = extraName);
|
|
181
193
|
typeof type !== 'undefined' && (self.type = type);
|
|
182
194
|
typeof id !== 'undefined' && (self.itemId = id);
|
|
183
195
|
typeof messages !== 'undefined' && (self.messages = messages);
|
|
@@ -839,8 +851,12 @@ var FormItemStore = StoreNode.named('FormItemStore')
|
|
|
839
851
|
setTimeout(function () { return callback(result); }, 200);
|
|
840
852
|
}
|
|
841
853
|
}
|
|
842
|
-
function changeTmpValue(value
|
|
854
|
+
function changeTmpValue(value, changeReason // 默认值
|
|
855
|
+
) {
|
|
843
856
|
self.tmpValue = value;
|
|
857
|
+
if (changeReason) {
|
|
858
|
+
self.changeMotivation = changeReason;
|
|
859
|
+
}
|
|
844
860
|
}
|
|
845
861
|
function changeEmitedValue(value) {
|
|
846
862
|
self.emitedValue = value;
|
package/esm/store/iRenderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -29,8 +29,8 @@ import 'classnames';
|
|
|
29
29
|
import 'lodash/isObject';
|
|
30
30
|
import 'lodash/isString';
|
|
31
31
|
import 'lodash/isBoolean';
|
|
32
|
-
import 'lodash';
|
|
33
32
|
import '../utils/image.js';
|
|
33
|
+
import 'lodash/isEqual';
|
|
34
34
|
import '../actions/Action.js';
|
|
35
35
|
import 'lodash/debounce';
|
|
36
36
|
import 'lodash/cloneDeep';
|
|
@@ -42,6 +42,7 @@ import 'uncontrollable';
|
|
|
42
42
|
import 'hoist-non-react-statics';
|
|
43
43
|
import '../utils/validations.js';
|
|
44
44
|
import '../utils/resolveCondition.js';
|
|
45
|
+
import 'mobx';
|
|
45
46
|
import '../utils/Animation.js';
|
|
46
47
|
|
|
47
48
|
var iRendererStore = StoreNode.named('iRendererStore')
|
package/esm/store/index.js
CHANGED
package/esm/store/list.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ export declare const ListStore: import("mobx-state-tree").IModelType<{
|
|
|
80
80
|
draggable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
81
81
|
dragging: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
82
82
|
multiple: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
83
|
+
strictMode: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
83
84
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
84
85
|
itemCheckableOn: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
85
86
|
itemDraggableOn: import("mobx-state-tree").IType<string | undefined, string, string>;
|
package/esm/store/list.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -78,6 +78,7 @@ var ListStore = iRendererStore
|
|
|
78
78
|
draggable: false,
|
|
79
79
|
dragging: false,
|
|
80
80
|
multiple: true,
|
|
81
|
+
strictMode: false,
|
|
81
82
|
selectable: false,
|
|
82
83
|
itemCheckableOn: '',
|
|
83
84
|
itemDraggableOn: '',
|
|
@@ -131,6 +132,7 @@ var ListStore = iRendererStore
|
|
|
131
132
|
config.selectable === void 0 || (self.selectable = config.selectable);
|
|
132
133
|
config.draggable === void 0 || (self.draggable = config.draggable);
|
|
133
134
|
config.multiple === void 0 || (self.multiple = config.multiple);
|
|
135
|
+
config.strictMode === void 0 || (self.strictMode = config.strictMode);
|
|
134
136
|
config.hideCheckToggler === void 0 ||
|
|
135
137
|
(self.hideCheckToggler = config.hideCheckToggler);
|
|
136
138
|
if (typeof config.orderBy !== 'undefined') {
|
|
@@ -169,7 +171,11 @@ var ListStore = iRendererStore
|
|
|
169
171
|
self.selectedItems.push(item);
|
|
170
172
|
}
|
|
171
173
|
else if (find(selected, function (a) {
|
|
172
|
-
|
|
174
|
+
var selectValue = a[valueField || 'value'];
|
|
175
|
+
var itemValue = item.pristine[valueField || 'value'];
|
|
176
|
+
return self.strictMode
|
|
177
|
+
? selectValue === itemValue
|
|
178
|
+
: selectValue == itemValue;
|
|
173
179
|
})) {
|
|
174
180
|
self.selectedItems.push(item);
|
|
175
181
|
}
|
package/esm/store/manager.js
CHANGED
package/esm/store/modal.js
CHANGED
package/esm/store/node.js
CHANGED
package/esm/store/pagination.js
CHANGED
package/esm/store/root.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -26,8 +26,8 @@ import '../utils/filter.js';
|
|
|
26
26
|
import 'lodash/isObject';
|
|
27
27
|
import 'lodash/isString';
|
|
28
28
|
import 'lodash/isBoolean';
|
|
29
|
-
import 'lodash';
|
|
30
29
|
import '../utils/image.js';
|
|
30
|
+
import 'lodash/isEqual';
|
|
31
31
|
import '../actions/Action.js';
|
|
32
32
|
import 'lodash/debounce';
|
|
33
33
|
import 'lodash/cloneDeep';
|
|
@@ -40,6 +40,7 @@ import 'uncontrollable';
|
|
|
40
40
|
import 'hoist-non-react-statics';
|
|
41
41
|
import '../utils/validations.js';
|
|
42
42
|
import '../utils/resolveCondition.js';
|
|
43
|
+
import 'mobx';
|
|
43
44
|
import '../utils/Animation.js';
|
|
44
45
|
|
|
45
46
|
var RootStore = ServiceStore.named('RootStore')
|
package/esm/store/service.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -94,7 +94,7 @@ var ServiceStore = iRendererStore
|
|
|
94
94
|
reInitData(data_1, replace);
|
|
95
95
|
self.hasRemoteData = true;
|
|
96
96
|
if (!(options && options.onSuccess)) return [3 /*break*/, 4];
|
|
97
|
-
ret = options.onSuccess(json);
|
|
97
|
+
ret = options.onSuccess(json, data_1);
|
|
98
98
|
if (!(ret && ret.then)) return [3 /*break*/, 4];
|
|
99
99
|
return [4 /*yield*/, ret];
|
|
100
100
|
case 3:
|
|
@@ -171,7 +171,7 @@ var ServiceStore = iRendererStore
|
|
|
171
171
|
return [3 /*break*/, 5];
|
|
172
172
|
case 2:
|
|
173
173
|
if (!(options && options.onSuccess)) return [3 /*break*/, 4];
|
|
174
|
-
ret = options.onSuccess(json);
|
|
174
|
+
ret = options.onSuccess(json, json.data);
|
|
175
175
|
if (!(ret && ret.then)) return [3 /*break*/, 4];
|
|
176
176
|
return [4 /*yield*/, ret];
|
|
177
177
|
case 3:
|
|
@@ -242,7 +242,7 @@ var ServiceStore = iRendererStore
|
|
|
242
242
|
throw new ServerError(self.msg, json);
|
|
243
243
|
case 4:
|
|
244
244
|
if (!(options && options.onSuccess)) return [3 /*break*/, 6];
|
|
245
|
-
ret = options.onSuccess(json);
|
|
245
|
+
ret = options.onSuccess(json, json.data);
|
|
246
246
|
if (!(ret && ret.then)) return [3 /*break*/, 6];
|
|
247
247
|
return [4 /*yield*/, ret];
|
|
248
248
|
case 5:
|
|
@@ -287,12 +287,12 @@ var ServiceStore = iRendererStore
|
|
|
287
287
|
});
|
|
288
288
|
var fetchSchema = flow(function fetchSchema(api, data, options) {
|
|
289
289
|
var json, env, e_4, env, message;
|
|
290
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
290
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
291
291
|
if (options === void 0) { options = {}; }
|
|
292
|
-
return __generator(this, function (
|
|
293
|
-
switch (
|
|
292
|
+
return __generator(this, function (_j) {
|
|
293
|
+
switch (_j.label) {
|
|
294
294
|
case 0:
|
|
295
|
-
|
|
295
|
+
_j.trys.push([0, 2, , 3]);
|
|
296
296
|
options = __assign(__assign({ method: 'post' }, options), { cancelExecutor: function (executor) { return (fetchSchemaCancel = executor); } });
|
|
297
297
|
if (fetchSchemaCancel) {
|
|
298
298
|
fetchSchemaCancel();
|
|
@@ -313,7 +313,7 @@ var ServiceStore = iRendererStore
|
|
|
313
313
|
}
|
|
314
314
|
return [4 /*yield*/, getEnv(self).fetcher(api, data, options)];
|
|
315
315
|
case 1:
|
|
316
|
-
json =
|
|
316
|
+
json = _j.sent();
|
|
317
317
|
fetchSchemaCancel = null;
|
|
318
318
|
if (!json.ok) {
|
|
319
319
|
updateMessage((_d = (_c = (_b = (_a = api === null || api === void 0 ? void 0 : api.messages) === null || _a === void 0 ? void 0 : _a.failed) !== null && _b !== void 0 ? _b : json.msg) !== null && _c !== void 0 ? _c : (options && options.errorMessage)) !== null && _d !== void 0 ? _d : self.__('fetchFailed'), true);
|
|
@@ -330,12 +330,17 @@ var ServiceStore = iRendererStore
|
|
|
330
330
|
json.data = replaceText(json.data, env.replaceText, env.replaceTextIgnoreKeys);
|
|
331
331
|
self.schema = Array.isArray(json.data)
|
|
332
332
|
? json.data
|
|
333
|
-
:
|
|
333
|
+
: Object.assign(((_e = json.data) === null || _e === void 0 ? void 0 : _e.type)
|
|
334
|
+
? {}
|
|
335
|
+
: {
|
|
336
|
+
type: 'wrapper',
|
|
337
|
+
wrap: false
|
|
338
|
+
}, normalizeApiResponseData(json.data));
|
|
334
339
|
self.schemaKey = '' + Date.now();
|
|
335
340
|
isObject(json.data.data) &&
|
|
336
341
|
self.updateData(json.data.data, undefined, !!api.replaceData);
|
|
337
342
|
}
|
|
338
|
-
updateMessage((
|
|
343
|
+
updateMessage((_h = (_g = (_f = api === null || api === void 0 ? void 0 : api.messages) === null || _f === void 0 ? void 0 : _f.success) !== null && _g !== void 0 ? _g : json.msg) !== null && _h !== void 0 ? _h : (options && options.successMessage));
|
|
339
344
|
// 配置了获取成功提示后提示,默认是空不会提示。
|
|
340
345
|
options &&
|
|
341
346
|
options.successMessage &&
|
|
@@ -344,7 +349,7 @@ var ServiceStore = iRendererStore
|
|
|
344
349
|
self.initializing = false;
|
|
345
350
|
return [2 /*return*/, json.data];
|
|
346
351
|
case 2:
|
|
347
|
-
e_4 =
|
|
352
|
+
e_4 = _j.sent();
|
|
348
353
|
env = getEnv(self);
|
|
349
354
|
self.initializing = false;
|
|
350
355
|
if (!isAlive(self) || self.disposed) {
|
package/esm/store/status.js
CHANGED