@zhubangyun/lowcode-core 6.1.90 → 6.3.20
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/es/components/react-render/index.js +11 -1
- package/es/index.js +12 -34
- package/es/index.less +11 -0
- package/es/init/init.bar-height.d.ts +1 -0
- package/es/init/init.bar-height.js +37 -0
- package/es/init/init.mobile-class.d.ts +1 -0
- package/es/init/init.mobile-class.js +10 -0
- package/es/init/init.scroll-size.d.ts +5 -0
- package/es/init/init.scroll-size.js +26 -0
- package/es/style.js +1 -1
- package/es/utils/api/form-api/form-api.assemble-entity.d.ts +2 -0
- package/es/utils/api/form-api/form-api.assemble-entity.js +95 -0
- package/es/utils/api/form-api/form-api.entity-map.d.ts +12 -0
- package/es/utils/api/form-api/form-api.entity-map.js +50 -0
- package/es/utils/api/{form-api.utils.d.ts → form-api/form-api.utils.d.ts} +3 -2
- package/es/utils/api/{form-api.utils.js → form-api/form-api.utils.js} +41 -8
- package/es/utils/api/form-api.d.ts +1 -0
- package/es/utils/api/form-api.js +105 -30
- package/es/utils/api/index.js +3 -2
- package/es/utils/api/rest-api.d.ts +2 -1
- package/es/utils/api/schema-api.d.ts +2 -1
- package/es/utils/api/schema-api.js +1 -1
- package/es/utils/api/schema.util.d.ts +1 -0
- package/es/utils/api/schema.util.js +10 -0
- package/es/utils/cache/index.d.ts +0 -1
- package/es/utils/cache/index.js +58 -35
- package/es/utils/cache/index_db_cache.d.ts +9 -0
- package/es/utils/cache/index_db_cache.js +7 -0
- package/es/utils/common/SingletonInstanceMap.d.ts +2 -2
- package/es/utils/common/index.d.ts +1 -1
- package/es/utils/common/index.js +5 -1
- package/es/utils/data/index.d.ts +3 -1
- package/es/utils/data/index.js +10 -3
- package/es/utils/page/index.d.ts +1 -0
- package/es/utils/page/index.js +10 -6
- package/es/utils/page/page-create-element.d.ts +6 -0
- package/es/utils/page/page-create-element.js +23 -0
- package/es/utils/page/page-form-data-manager-group.js +8 -8
- package/es/utils/page/page-form-data-manager.js +8 -8
- package/es/utils/page/page-form.js +4 -6
- package/es/utils/page/page-layout.d.ts +2 -1
- package/es/utils/page/page-layout.js +23 -3
- package/es/utils/page/page-render.js +5 -6
- package/es/utils/page/page-schema-utils.js +2 -1
- package/es/utils/page/page-show.js +4 -4
- package/es/utils/page/print-form.d.ts +3 -2
- package/es/utils/page/print-form.js +193 -57
- package/es/utils/uni-bridge.d.ts +2 -0
- package/es/utils/uni-bridge.js +76 -36
- package/es/utils/util.common.d.ts +1 -1
- package/es/utils/util.common.js +1 -2
- package/lib/components/react-render/index.js +11 -1
- package/lib/index.js +12 -34
- package/lib/index.less +11 -0
- package/lib/init/init.bar-height.d.ts +1 -0
- package/lib/init/init.bar-height.js +42 -0
- package/lib/init/init.mobile-class.d.ts +1 -0
- package/lib/init/init.mobile-class.js +14 -0
- package/lib/init/init.scroll-size.d.ts +5 -0
- package/lib/init/init.scroll-size.js +31 -0
- package/lib/style.js +1 -1
- package/lib/utils/api/form-api/form-api.assemble-entity.d.ts +2 -0
- package/lib/utils/api/form-api/form-api.assemble-entity.js +99 -0
- package/lib/utils/api/form-api/form-api.entity-map.d.ts +12 -0
- package/lib/utils/api/form-api/form-api.entity-map.js +54 -0
- package/lib/utils/api/{form-api.utils.d.ts → form-api/form-api.utils.d.ts} +3 -2
- package/lib/utils/api/{form-api.utils.js → form-api/form-api.utils.js} +41 -7
- package/lib/utils/api/form-api.d.ts +1 -0
- package/lib/utils/api/form-api.js +104 -29
- package/lib/utils/api/index.js +3 -2
- package/lib/utils/api/rest-api.d.ts +2 -1
- package/lib/utils/api/schema-api.d.ts +2 -1
- package/lib/utils/api/schema-api.js +1 -1
- package/lib/utils/api/schema.util.d.ts +1 -0
- package/lib/utils/api/schema.util.js +11 -0
- package/lib/utils/cache/index.d.ts +0 -1
- package/lib/utils/cache/index.js +57 -34
- package/lib/utils/cache/index_db_cache.d.ts +9 -0
- package/lib/utils/cache/index_db_cache.js +11 -0
- package/lib/utils/common/SingletonInstanceMap.d.ts +2 -2
- package/lib/utils/common/index.d.ts +1 -1
- package/lib/utils/common/index.js +5 -1
- package/lib/utils/data/index.d.ts +3 -1
- package/lib/utils/data/index.js +10 -3
- package/lib/utils/page/index.d.ts +1 -0
- package/lib/utils/page/index.js +13 -7
- package/lib/utils/page/page-create-element.d.ts +6 -0
- package/lib/utils/page/page-create-element.js +29 -0
- package/lib/utils/page/page-form-data-manager-group.js +8 -8
- package/lib/utils/page/page-form-data-manager.js +8 -8
- package/lib/utils/page/page-form.js +4 -6
- package/lib/utils/page/page-layout.d.ts +2 -1
- package/lib/utils/page/page-layout.js +23 -3
- package/lib/utils/page/page-render.js +5 -6
- package/lib/utils/page/page-schema-utils.js +2 -1
- package/lib/utils/page/page-show.js +4 -4
- package/lib/utils/page/print-form.d.ts +3 -2
- package/lib/utils/page/print-form.js +193 -57
- package/lib/utils/uni-bridge.d.ts +2 -0
- package/lib/utils/uni-bridge.js +76 -36
- package/lib/utils/util.common.d.ts +1 -1
- package/lib/utils/util.common.js +2 -3
- package/package.json +5 -4
- package/es/utils/cache/schema.d.ts +0 -6
- package/es/utils/cache/schema.js +0 -14
- package/lib/utils/cache/schema.d.ts +0 -6
- package/lib/utils/cache/schema.js +0 -18
package/es/utils/api/form-api.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
4
|
import { RestApi } from "./rest-api";
|
|
6
|
-
import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api.utils";
|
|
5
|
+
import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api/form-api.utils";
|
|
7
6
|
import { formApi } from "../cache";
|
|
8
7
|
import { getSchemaFromCache } from "./schema-api";
|
|
9
|
-
import { uuid } from "../common";
|
|
8
|
+
import { uuid, uuidVersion } from "../common";
|
|
10
9
|
export function getFormApi(_x, _x2, _x3) {
|
|
11
10
|
return _getFormApi.apply(this, arguments);
|
|
12
11
|
}
|
|
13
12
|
function _getFormApi() {
|
|
14
|
-
_getFormApi = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
13
|
+
_getFormApi = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(formId, fieldId, mock) {
|
|
15
14
|
var key;
|
|
16
|
-
return _regeneratorRuntime.wrap(function (
|
|
17
|
-
while (1) switch (
|
|
15
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
16
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
18
17
|
case 0:
|
|
19
18
|
if (typeof mock != "boolean") {
|
|
20
19
|
if (typeof window.__mock == "boolean") {
|
|
@@ -24,16 +23,16 @@ function _getFormApi() {
|
|
|
24
23
|
key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
|
|
25
24
|
return !!key;
|
|
26
25
|
}).join("_");
|
|
27
|
-
return
|
|
26
|
+
return _context1.abrupt("return", formApi.getInstance(key, {
|
|
28
27
|
mock: mock,
|
|
29
28
|
fieldId: fieldId,
|
|
30
29
|
formId: formId
|
|
31
30
|
}));
|
|
32
31
|
case 1:
|
|
33
32
|
case "end":
|
|
34
|
-
return
|
|
33
|
+
return _context1.stop();
|
|
35
34
|
}
|
|
36
|
-
},
|
|
35
|
+
}, _callee1);
|
|
37
36
|
}));
|
|
38
37
|
return _getFormApi.apply(this, arguments);
|
|
39
38
|
}
|
|
@@ -137,7 +136,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
137
136
|
_proto.search = /*#__PURE__*/function () {
|
|
138
137
|
var _search = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(searchParams) {
|
|
139
138
|
var _searchParams, _searchParams2;
|
|
140
|
-
var params, config, res
|
|
139
|
+
var params, config, res;
|
|
141
140
|
return _regeneratorRuntime.wrap(function (_context3) {
|
|
142
141
|
while (1) switch (_context3.prev = _context3.next) {
|
|
143
142
|
case 0:
|
|
@@ -161,14 +160,11 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
161
160
|
searchParams.searchFields = handleFilterRules(((_searchParams2 = searchParams) === null || _searchParams2 === void 0 ? void 0 : _searchParams2.searchFields) || [], {
|
|
162
161
|
filterNullValue: true
|
|
163
162
|
});
|
|
164
|
-
config.params = _extends({}, params, searchParams);
|
|
165
163
|
_context3.next = 2;
|
|
166
|
-
return this.request.
|
|
164
|
+
return this.request.post("search", searchParams, config);
|
|
167
165
|
case 2:
|
|
168
166
|
res = _context3.sent;
|
|
169
|
-
|
|
170
|
-
start = Date.now();
|
|
171
|
-
assembleAssociationField(res.data, res.refs);
|
|
167
|
+
res.assembleTime = assembleAssociationField(res.data, res.refs);
|
|
172
168
|
console.debug("form.search:", res);
|
|
173
169
|
return _context3.abrupt("return", res);
|
|
174
170
|
case 3:
|
|
@@ -184,22 +180,59 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
184
180
|
}();
|
|
185
181
|
_proto.getById = /*#__PURE__*/function () {
|
|
186
182
|
var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
|
|
187
|
-
var res;
|
|
183
|
+
var searchId, url, res, _t;
|
|
188
184
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
189
185
|
while (1) switch (_context4.prev = _context4.next) {
|
|
190
186
|
case 0:
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
if (id) {
|
|
188
|
+
_context4.next = 1;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
return _context4.abrupt("return", {
|
|
192
|
+
success: false,
|
|
193
|
+
message: "数据Id不可为空!"
|
|
194
|
+
});
|
|
193
195
|
case 1:
|
|
196
|
+
searchId = id;
|
|
197
|
+
if (!id.startsWith("http")) {
|
|
198
|
+
_context4.next = 2;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
url = new URL(searchId);
|
|
202
|
+
searchId = url.searchParams.get("dataId");
|
|
203
|
+
if (searchId) {
|
|
204
|
+
_context4.next = 2;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
return _context4.abrupt("return", {
|
|
208
|
+
success: false,
|
|
209
|
+
message: "数据Id不可为空!"
|
|
210
|
+
});
|
|
211
|
+
case 2:
|
|
212
|
+
_context4.prev = 2;
|
|
213
|
+
uuidVersion(searchId);
|
|
214
|
+
_context4.next = 4;
|
|
215
|
+
break;
|
|
216
|
+
case 3:
|
|
217
|
+
_context4.prev = 3;
|
|
218
|
+
_t = _context4["catch"](2);
|
|
219
|
+
return _context4.abrupt("return", {
|
|
220
|
+
success: false,
|
|
221
|
+
message: "\u975E\u6CD5\u7684\u6570\u636EID:" + searchId
|
|
222
|
+
});
|
|
223
|
+
case 4:
|
|
224
|
+
_context4.next = 5;
|
|
225
|
+
return _RestApi.prototype.getById.call(this, searchId, options);
|
|
226
|
+
case 5:
|
|
194
227
|
res = _context4.sent;
|
|
195
|
-
assembleAssociationField(res.data, res.refs);
|
|
196
|
-
console.debug("
|
|
228
|
+
res.assembleTime = assembleAssociationField(res.data, res.refs);
|
|
229
|
+
console.debug("form.getById:", res);
|
|
197
230
|
return _context4.abrupt("return", res);
|
|
198
|
-
case
|
|
231
|
+
case 6:
|
|
199
232
|
case "end":
|
|
200
233
|
return _context4.stop();
|
|
201
234
|
}
|
|
202
|
-
}, _callee4, this);
|
|
235
|
+
}, _callee4, this, [[2, 3]]);
|
|
203
236
|
}));
|
|
204
237
|
function getById(_x6, _x7) {
|
|
205
238
|
return _getById.apply(this, arguments);
|
|
@@ -230,7 +263,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
230
263
|
};
|
|
231
264
|
});
|
|
232
265
|
}
|
|
233
|
-
assembleAssociationField(res.data, res.refs);
|
|
266
|
+
res.assembleTime = assembleAssociationField(res.data, res.refs);
|
|
234
267
|
console.debug("formApi.labelToValue", res);
|
|
235
268
|
return _context5.abrupt("return", res);
|
|
236
269
|
case 3:
|
|
@@ -295,30 +328,72 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
295
328
|
}
|
|
296
329
|
return update;
|
|
297
330
|
}();
|
|
298
|
-
_proto.
|
|
299
|
-
var
|
|
300
|
-
var
|
|
331
|
+
_proto.fieldFilters = /*#__PURE__*/function () {
|
|
332
|
+
var _fieldFilters = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(searchParams) {
|
|
333
|
+
var _searchParams3, _searchParams4;
|
|
334
|
+
var params, config;
|
|
301
335
|
return _regeneratorRuntime.wrap(function (_context9) {
|
|
302
336
|
while (1) switch (_context9.prev = _context9.next) {
|
|
303
337
|
case 0:
|
|
338
|
+
searchParams = searchParams || {};
|
|
304
339
|
params = {
|
|
305
340
|
formId: this.formId,
|
|
306
341
|
fieldId: this.fieldId
|
|
307
342
|
};
|
|
308
343
|
if (__mock) {
|
|
309
|
-
params.mock = true;
|
|
310
344
|
params.description = (this.title || "表单") + ".\u67E5\u8BE2";
|
|
311
345
|
}
|
|
312
|
-
|
|
346
|
+
config = {
|
|
313
347
|
params: params
|
|
314
|
-
}
|
|
348
|
+
};
|
|
349
|
+
_context9.next = 1;
|
|
350
|
+
return this.handleRequestConfig(config);
|
|
315
351
|
case 1:
|
|
352
|
+
searchParams.filterRules = handleFilterRules(((_searchParams3 = searchParams) === null || _searchParams3 === void 0 ? void 0 : _searchParams3.filterRules) || [], {
|
|
353
|
+
filterNullValue: false
|
|
354
|
+
});
|
|
355
|
+
searchParams.searchFields = handleFilterRules(((_searchParams4 = searchParams) === null || _searchParams4 === void 0 ? void 0 : _searchParams4.searchFields) || [], {
|
|
356
|
+
filterNullValue: true
|
|
357
|
+
});
|
|
358
|
+
_context9.next = 2;
|
|
359
|
+
return this.request.post("fieldFilters", searchParams, config);
|
|
360
|
+
case 2:
|
|
361
|
+
return _context9.abrupt("return", _context9.sent);
|
|
362
|
+
case 3:
|
|
316
363
|
case "end":
|
|
317
364
|
return _context9.stop();
|
|
318
365
|
}
|
|
319
366
|
}, _callee9, this);
|
|
320
367
|
}));
|
|
321
|
-
function
|
|
368
|
+
function fieldFilters(_x15) {
|
|
369
|
+
return _fieldFilters.apply(this, arguments);
|
|
370
|
+
}
|
|
371
|
+
return fieldFilters;
|
|
372
|
+
}();
|
|
373
|
+
_proto.serviceUpdate = /*#__PURE__*/function () {
|
|
374
|
+
var _serviceUpdate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(data, options) {
|
|
375
|
+
var params;
|
|
376
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
377
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
378
|
+
case 0:
|
|
379
|
+
params = {
|
|
380
|
+
formId: this.formId,
|
|
381
|
+
fieldId: this.fieldId
|
|
382
|
+
};
|
|
383
|
+
if (__mock) {
|
|
384
|
+
params.mock = true;
|
|
385
|
+
params.description = (this.title || "表单") + ".\u67E5\u8BE2";
|
|
386
|
+
}
|
|
387
|
+
return _context0.abrupt("return", this.request.post("serviceUpdate", data, {
|
|
388
|
+
params: params
|
|
389
|
+
}));
|
|
390
|
+
case 1:
|
|
391
|
+
case "end":
|
|
392
|
+
return _context0.stop();
|
|
393
|
+
}
|
|
394
|
+
}, _callee0, this);
|
|
395
|
+
}));
|
|
396
|
+
function serviceUpdate(_x16, _x17) {
|
|
322
397
|
return _serviceUpdate.apply(this, arguments);
|
|
323
398
|
}
|
|
324
399
|
return serviceUpdate;
|
package/es/utils/api/index.js
CHANGED
|
@@ -31,13 +31,14 @@ export function onFulfilled(res) {
|
|
|
31
31
|
export function onRejected(error) {
|
|
32
32
|
var _error$response = error.response,
|
|
33
33
|
status = _error$response.status,
|
|
34
|
-
statusText = _error$response.statusText
|
|
34
|
+
statusText = _error$response.statusText,
|
|
35
|
+
data = _error$response.data;
|
|
35
36
|
console.error("请求失败!", error);
|
|
36
37
|
if (status == 400) {
|
|
37
38
|
return error.response.data || {};
|
|
38
39
|
}
|
|
39
40
|
return {
|
|
40
41
|
success: false,
|
|
41
|
-
message: statusText
|
|
42
|
+
message: (data === null || data === void 0 ? void 0 : data.message) || statusText
|
|
42
43
|
};
|
|
43
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
-
export type ValueType = "value" | "field" | "express";
|
|
2
|
+
export type ValueType = "value" | "field" | "express" | "column";
|
|
3
3
|
export interface RestApiOptions {
|
|
4
4
|
/**
|
|
5
5
|
* 超时时间
|
|
@@ -106,6 +106,7 @@ export interface BaseResult<DataType> {
|
|
|
106
106
|
success: boolean;
|
|
107
107
|
message?: string;
|
|
108
108
|
requestId: string;
|
|
109
|
+
assembleTime: number;
|
|
109
110
|
refs?: Refs;
|
|
110
111
|
}
|
|
111
112
|
export interface Ref {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { OneResult } from "./rest-api";
|
|
2
|
+
import { Schema } from "./schema.util";
|
|
2
3
|
export declare function getSchema(pageId: string, mock?: boolean): Promise<OneResult<any>>;
|
|
3
|
-
export declare function getSchemaFromCache(pageId?: string, mock?: boolean):
|
|
4
|
+
export declare function getSchemaFromCache(pageId?: string, mock?: boolean): OneResult<Schema>;
|
|
@@ -11,7 +11,7 @@ function _getSchema() {
|
|
|
11
11
|
while (1) switch (_context.prev = _context.next) {
|
|
12
12
|
case 0:
|
|
13
13
|
mock = getMock(mock);
|
|
14
|
-
key = mock ? pageId + "
|
|
14
|
+
key = mock ? pageId + "_mock" : pageId;
|
|
15
15
|
_context.next = 1;
|
|
16
16
|
return schema.getInstance(key, {
|
|
17
17
|
mock: mock,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function forEachSchema(schema: Schema, callback: (child: Schema, index: number, children: any[]) => boolean): void;
|
|
7
7
|
export declare function findFormSchemas(schema: Schema): Schema[];
|
|
8
|
+
export declare function findLoadRefSchemas(schema: Schema): Schema[];
|
|
8
9
|
export declare function findFdmSchemas(schema?: Schema): Schema[];
|
|
9
10
|
export interface Schema {
|
|
10
11
|
componentName: string;
|
|
@@ -22,6 +22,16 @@ export function findFormSchemas(schema) {
|
|
|
22
22
|
});
|
|
23
23
|
return schemas;
|
|
24
24
|
}
|
|
25
|
+
export function findLoadRefSchemas(schema) {
|
|
26
|
+
var schemas = [];
|
|
27
|
+
forEachSchema(schema, function (child) {
|
|
28
|
+
if (["ProcessGroupField"].includes(child.componentName)) {
|
|
29
|
+
schemas.push(child);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
});
|
|
33
|
+
return schemas;
|
|
34
|
+
}
|
|
25
35
|
export function findFdmSchemas(schema) {
|
|
26
36
|
var schemas = [];
|
|
27
37
|
if (!schema) {
|
|
@@ -12,7 +12,6 @@ export declare class FormApiCache extends SingletonInstanceMap<RestFormApi<any>,
|
|
|
12
12
|
fieldId?: string;
|
|
13
13
|
mock?: boolean;
|
|
14
14
|
}> {
|
|
15
|
-
apiMap: Map<string, RestFormApi<any>>;
|
|
16
15
|
createInstance(key: string, options?: any): Promise<RestFormApi<any>>;
|
|
17
16
|
}
|
|
18
17
|
export declare const formApi: FormApiCache;
|
package/es/utils/cache/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
7
|
import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
|
|
5
8
|
import { apiRequest, RestFormApi } from "../api";
|
|
6
|
-
import { findFdmSchemas, findFormSchemas } from "../api/schema.util";
|
|
9
|
+
import { findFdmSchemas, findFormSchemas, findLoadRefSchemas } from "../api/schema.util";
|
|
7
10
|
export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
8
11
|
function SchemaCache() {
|
|
9
12
|
return _SingletonInstanceMap.apply(this, arguments) || this;
|
|
@@ -12,28 +15,24 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
|
12
15
|
var _proto = SchemaCache.prototype;
|
|
13
16
|
_proto.createInstance = /*#__PURE__*/function () {
|
|
14
17
|
var _createInstance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(key, options) {
|
|
15
|
-
var mock, pageId, schemaRes, schema, handleCommonSchema, permission, printTemplates, workflow, cloneSchema, _t;
|
|
18
|
+
var mock, pageId, params, schemaRes, schema, handleCommonSchema, permission, printTemplates, workflow, cloneSchema, refs, _iterator, _step, _ref$props, _ref$props$fieldProps, _ref$props$fieldProps2, ref, refPageId, _key, _t;
|
|
16
19
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
17
20
|
while (1) switch (_context.prev = _context.next) {
|
|
18
21
|
case 0:
|
|
19
22
|
mock = options.mock, pageId = options.pageId;
|
|
23
|
+
params = {};
|
|
24
|
+
if (mock) {
|
|
25
|
+
params.mock = mock;
|
|
26
|
+
}
|
|
20
27
|
_context.next = 1;
|
|
21
28
|
return apiRequest.get("pages/" + pageId + "/schema", {
|
|
22
|
-
params:
|
|
23
|
-
mock: mock
|
|
24
|
-
}
|
|
29
|
+
params: params
|
|
25
30
|
});
|
|
26
31
|
case 1:
|
|
27
32
|
schemaRes = _context.sent;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return _context.abrupt("return", schemaRes);
|
|
33
|
-
case 2:
|
|
34
|
-
schema = schemaRes.data;
|
|
35
|
-
if (!(schema != null && typeof schema == "object")) {
|
|
36
|
-
_context.next = 8;
|
|
33
|
+
schema = schemaRes === null || schemaRes === void 0 ? void 0 : schemaRes.data;
|
|
34
|
+
if (!schema) {
|
|
35
|
+
_context.next = 9;
|
|
37
36
|
break;
|
|
38
37
|
}
|
|
39
38
|
handleCommonSchema = function handleCommonSchema(schema) {
|
|
@@ -46,29 +45,29 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
|
46
45
|
permission = null; //处理打印
|
|
47
46
|
workflow = null;
|
|
48
47
|
if (location.pathname.startsWith("/print")) {
|
|
49
|
-
_context.next =
|
|
48
|
+
_context.next = 6;
|
|
50
49
|
break;
|
|
51
50
|
}
|
|
52
|
-
_context.next =
|
|
51
|
+
_context.next = 2;
|
|
53
52
|
return apiRequest.get("pages/" + pageId + "/permission");
|
|
54
|
-
case
|
|
53
|
+
case 2:
|
|
55
54
|
permission = _context.sent.data;
|
|
56
55
|
if (!((schema === null || schema === void 0 ? void 0 : schema.type) == "form")) {
|
|
57
|
-
_context.next =
|
|
56
|
+
_context.next = 6;
|
|
58
57
|
break;
|
|
59
58
|
}
|
|
60
|
-
_context.prev =
|
|
61
|
-
_context.next =
|
|
59
|
+
_context.prev = 3;
|
|
60
|
+
_context.next = 4;
|
|
62
61
|
return apiRequest.get("pages/" + pageId + "/printTemplates");
|
|
63
|
-
case
|
|
62
|
+
case 4:
|
|
64
63
|
printTemplates = _context.sent.data;
|
|
65
|
-
_context.next =
|
|
64
|
+
_context.next = 6;
|
|
66
65
|
break;
|
|
67
|
-
case
|
|
68
|
-
_context.prev =
|
|
69
|
-
_t = _context["catch"](
|
|
66
|
+
case 5:
|
|
67
|
+
_context.prev = 5;
|
|
68
|
+
_t = _context["catch"](3);
|
|
70
69
|
console.log(_t);
|
|
71
|
-
case
|
|
70
|
+
case 6:
|
|
72
71
|
findFormSchemas(schema).forEach(function (formSchema) {
|
|
73
72
|
handleCommonSchema(formSchema);
|
|
74
73
|
findFdmSchemas(formSchema.fdmSchema).forEach(function (fdmSchema) {
|
|
@@ -82,13 +81,43 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
|
82
81
|
fdmSchema.props.formElement = cloneSchema;
|
|
83
82
|
});
|
|
84
83
|
});
|
|
84
|
+
refs = findLoadRefSchemas(schema);
|
|
85
|
+
if (!refs.length) {
|
|
86
|
+
_context.next = 9;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
_iterator = _createForOfIteratorHelperLoose(refs);
|
|
90
|
+
case 7:
|
|
91
|
+
if ((_step = _iterator()).done) {
|
|
92
|
+
_context.next = 9;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
ref = _step.value;
|
|
96
|
+
refPageId = (_ref$props = ref.props) === null || _ref$props === void 0 ? void 0 : (_ref$props$fieldProps = _ref$props.fieldProps) === null || _ref$props$fieldProps === void 0 ? void 0 : (_ref$props$fieldProps2 = _ref$props$fieldProps.associationForm) === null || _ref$props$fieldProps2 === void 0 ? void 0 : _ref$props$fieldProps2.id;
|
|
97
|
+
if (!(typeof refPageId == "string" && refPageId !== pageId)) {
|
|
98
|
+
_context.next = 8;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (this.valueMap.has(refPageId)) {
|
|
102
|
+
_context.next = 8;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
_key = mock ? refPageId + "_mock" : refPageId;
|
|
106
|
+
_context.next = 8;
|
|
107
|
+
return this.getInstance(_key, {
|
|
108
|
+
mock: mock,
|
|
109
|
+
pageId: refPageId
|
|
110
|
+
});
|
|
85
111
|
case 8:
|
|
86
|
-
|
|
112
|
+
_context.next = 7;
|
|
113
|
+
break;
|
|
87
114
|
case 9:
|
|
115
|
+
return _context.abrupt("return", schemaRes);
|
|
116
|
+
case 10:
|
|
88
117
|
case "end":
|
|
89
118
|
return _context.stop();
|
|
90
119
|
}
|
|
91
|
-
}, _callee,
|
|
120
|
+
}, _callee, this, [[3, 5]]);
|
|
92
121
|
}));
|
|
93
122
|
function createInstance(_x, _x2) {
|
|
94
123
|
return _createInstance.apply(this, arguments);
|
|
@@ -100,13 +129,7 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
|
100
129
|
export var schema = new SchemaCache();
|
|
101
130
|
export var FormApiCache = /*#__PURE__*/function (_SingletonInstanceMap2) {
|
|
102
131
|
function FormApiCache() {
|
|
103
|
-
|
|
104
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
105
|
-
args[_key] = arguments[_key];
|
|
106
|
-
}
|
|
107
|
-
_this = _SingletonInstanceMap2.call.apply(_SingletonInstanceMap2, [this].concat(args)) || this;
|
|
108
|
-
_this.apiMap = new Map();
|
|
109
|
-
return _this;
|
|
132
|
+
return _SingletonInstanceMap2.apply(this, arguments) || this;
|
|
110
133
|
}
|
|
111
134
|
_inheritsLoose(FormApiCache, _SingletonInstanceMap2);
|
|
112
135
|
var _proto2 = FormApiCache.prototype;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare abstract class SingletonInstanceMap<Value, Options> {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
protected readonly valueMap: Map<string, Value>;
|
|
3
|
+
protected readonly lockMap: Map<string, boolean>;
|
|
4
4
|
getInstance(key: string, options: Options): Promise<Value>;
|
|
5
5
|
get(key: string): Value;
|
|
6
6
|
clear(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { loadPlugins } from "./LoadPlugins";
|
|
2
2
|
export declare function uuid(prefix?: string, separator?: string): string;
|
|
3
|
-
export declare function uuidVersion(id: string): number;
|
|
3
|
+
export declare function uuidVersion(id: string): number | false;
|
|
4
4
|
export declare function toArray(data: any): any[];
|
|
5
5
|
export declare function isLocalhost(): boolean;
|
|
6
6
|
export declare function isMobile(): boolean;
|
package/es/utils/common/index.js
CHANGED
package/es/utils/data/index.d.ts
CHANGED
package/es/utils/data/index.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
export function transformerId(value) {
|
|
1
|
+
export function transformerId(value, options) {
|
|
2
2
|
if (value == null) {
|
|
3
3
|
return null;
|
|
4
4
|
}
|
|
5
5
|
if (Array.isArray(value)) {
|
|
6
|
-
|
|
7
|
-
return
|
|
6
|
+
var values = value.map(function (item) {
|
|
7
|
+
return transformerId(item, options);
|
|
8
8
|
});
|
|
9
|
+
if (options !== null && options !== void 0 && options.includeNull) {
|
|
10
|
+
return values;
|
|
11
|
+
} else {
|
|
12
|
+
return values.filter(function (v) {
|
|
13
|
+
return !!v;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
9
16
|
}
|
|
10
17
|
if (typeof value == "object") {
|
|
11
18
|
return (value === null || value === void 0 ? void 0 : value.id) || (value === null || value === void 0 ? void 0 : value.value) || value;
|
package/es/utils/page/index.d.ts
CHANGED
package/es/utils/page/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { uniBridge } from "../uni-bridge";
|
|
4
|
+
export { createForm, getSchema } from "./page-create-element";
|
|
3
5
|
export { print, getFormPrintTemplates } from "./print-form";
|
|
4
6
|
export { showForm } from "./page-form";
|
|
5
7
|
export { showFormGroup } from "./page-form-group";
|
|
@@ -27,6 +29,7 @@ function _showLoading() {
|
|
|
27
29
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
28
30
|
while (1) switch (_context.prev = _context.next) {
|
|
29
31
|
case 0:
|
|
32
|
+
console.log("page.show.loading");
|
|
30
33
|
loading = document.getElementById("fullscreen-loading");
|
|
31
34
|
if (loading) {
|
|
32
35
|
loading.style.display = "flex";
|
|
@@ -87,14 +90,15 @@ function _openPage() {
|
|
|
87
90
|
url: url
|
|
88
91
|
});
|
|
89
92
|
case 1:
|
|
90
|
-
|
|
91
|
-
_context3.next = 3;
|
|
92
|
-
break;
|
|
93
|
+
return _context3.abrupt("return", _context3.sent);
|
|
93
94
|
case 2:
|
|
94
|
-
|
|
95
|
+
if (!isMobile) {
|
|
96
|
+
_context3.next = 3;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
return _context3.abrupt("return", uniBridge.navigateTo(url));
|
|
95
100
|
case 3:
|
|
96
|
-
|
|
97
|
-
return _context3.abrupt("return", page);
|
|
101
|
+
return _context3.abrupt("return", window.open(url, target));
|
|
98
102
|
case 4:
|
|
99
103
|
case "end":
|
|
100
104
|
return _context3.stop();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface PageCreateOptions {
|
|
3
|
+
formId: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function getSchema(pageId: string): import("../api/schema.util").Schema & import("../api/rest-api").IBaseEntity;
|
|
6
|
+
export declare function createForm(options: PageCreateOptions): JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["formId"];
|
|
4
|
+
import { getSchemaFromCache } from "../api/schema-api";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { ReactRender } from "../../components/react-render";
|
|
7
|
+
export function getSchema(pageId) {
|
|
8
|
+
var _getSchemaFromCache;
|
|
9
|
+
return (_getSchemaFromCache = getSchemaFromCache(pageId)) === null || _getSchemaFromCache === void 0 ? void 0 : _getSchemaFromCache.data;
|
|
10
|
+
}
|
|
11
|
+
export function createForm(options) {
|
|
12
|
+
var formId = options.formId,
|
|
13
|
+
restProps = _objectWithoutPropertiesLoose(options, _excluded);
|
|
14
|
+
var schemaRes = getSchemaFromCache(formId, window.__mock);
|
|
15
|
+
if (schemaRes !== null && schemaRes !== void 0 && schemaRes.success) {
|
|
16
|
+
var schema = schemaRes.data;
|
|
17
|
+
return /*#__PURE__*/React.createElement(ReactRender, _extends({
|
|
18
|
+
schema: schema,
|
|
19
|
+
components: window._components || window.components || window.__components
|
|
20
|
+
}, restProps));
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|