@steedos-widgets/amis-lib 1.1.11 → 1.1.12
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/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +18 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +18 -31
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/api.d.ts +4 -0
- package/dist/types/lib/converter/amis/index.d.ts +4 -0
- package/dist/types/lib/objects.d.ts +4 -0
- package/dist/types/lib/page_init.d.ts +4 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$1 from 'lodash';
|
|
2
|
-
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, keys, sortBy, compact, toArray, mergeWith, isBoolean, omitBy, isNil, isString, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, has, filter, startsWith } from 'lodash';
|
|
2
|
+
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, keys, sortBy, compact, toArray, mergeWith, isBoolean, omitBy, isNil, isString, union, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, has, filter, startsWith } from 'lodash';
|
|
3
3
|
import { Router as Router$1, getSteedosAuth as getSteedosAuth$1, lookupToAmis as lookupToAmis$1, fetchAPI as fetchAPI$1 } from '@steedos-widgets/amis-lib';
|
|
4
4
|
import isPlainObject from 'lodash/isPlainObject';
|
|
5
5
|
|
|
@@ -5463,12 +5463,12 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
5463
5463
|
if(uiSchema.form){
|
|
5464
5464
|
try{
|
|
5465
5465
|
var objectFormConfig = JSON.parse(uiSchema.form);
|
|
5466
|
-
|
|
5467
|
-
if(
|
|
5468
|
-
|
|
5466
|
+
var formInitialValuesFun = objectFormConfig.initialValues;
|
|
5467
|
+
if(formInitialValuesFun){
|
|
5468
|
+
formInitialValuesFun = new Function("return " + formInitialValuesFun)();
|
|
5469
5469
|
}
|
|
5470
|
-
if(typeof
|
|
5471
|
-
initialValues =
|
|
5470
|
+
if(typeof formInitialValuesFun === "function"){
|
|
5471
|
+
initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global})
|
|
5472
5472
|
}
|
|
5473
5473
|
}
|
|
5474
5474
|
catch(ex){
|
|
@@ -5485,12 +5485,15 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
5485
5485
|
}
|
|
5486
5486
|
// data下的变量需要在保存接口(getSaveApi)中被删除。
|
|
5487
5487
|
payload.data = {
|
|
5488
|
-
initialValues
|
|
5489
|
-
editFormInited: true
|
|
5488
|
+
...initialValues
|
|
5490
5489
|
}
|
|
5491
5490
|
${options.initApiAdaptor || ''}
|
|
5492
5491
|
return payload;
|
|
5493
5492
|
`,
|
|
5493
|
+
responseData: {
|
|
5494
|
+
initialValues: "$$",
|
|
5495
|
+
editFormInited: true
|
|
5496
|
+
},
|
|
5494
5497
|
data: data,
|
|
5495
5498
|
headers: {
|
|
5496
5499
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -6447,13 +6450,17 @@ async function getTableApi(mainObject, fields, options){
|
|
|
6447
6450
|
let valueField = mainObject.key_field || '_id';
|
|
6448
6451
|
const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
|
|
6449
6452
|
api.data.$term = "$term";
|
|
6453
|
+
api.data.term = "$term";
|
|
6450
6454
|
api.data.$self = "$$";
|
|
6455
|
+
api.data.self = "$$";
|
|
6451
6456
|
api.data.filter = "$filter";
|
|
6452
6457
|
api.data.loaded = "${loaded}";
|
|
6453
6458
|
api.data.listViewId = "${listViewId}";
|
|
6454
6459
|
api.requestAdaptor = `
|
|
6455
6460
|
// selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
|
|
6456
6461
|
let selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
6462
|
+
// 保留一份初始data,以供自定义发送适配器中获取原始数据。
|
|
6463
|
+
const data = _.cloneDeep(api.data);
|
|
6457
6464
|
try{
|
|
6458
6465
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
6459
6466
|
const listViewId = api.data.listViewId;
|
|
@@ -6613,28 +6620,8 @@ async function getTableApi(mainObject, fields, options){
|
|
|
6613
6620
|
|
|
6614
6621
|
if(enable_tree){
|
|
6615
6622
|
const records = payload.data.rows;
|
|
6616
|
-
const
|
|
6617
|
-
|
|
6618
|
-
if(!childrenIds){
|
|
6619
|
-
return;
|
|
6620
|
-
}
|
|
6621
|
-
const children = _.filter(records, (record)=>{
|
|
6622
|
-
return _.includes(childrenIds, record._id)
|
|
6623
|
-
});
|
|
6624
|
-
_.each(children, (item)=>{
|
|
6625
|
-
if(item.children){
|
|
6626
|
-
item.children = getChildren(records, item.children)
|
|
6627
|
-
}
|
|
6628
|
-
})
|
|
6629
|
-
return children;
|
|
6630
|
-
}
|
|
6631
|
-
|
|
6632
|
-
_.each(records, (record)=>{
|
|
6633
|
-
if(!record.parent){
|
|
6634
|
-
treeRecords.push(Object.assign({}, record, {children: getChildren(records, record.children)}));
|
|
6635
|
-
}
|
|
6636
|
-
});
|
|
6637
|
-
payload.data.rows = treeRecords;
|
|
6623
|
+
const getTreeOptions = SteedosUI.getTreeOptions
|
|
6624
|
+
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
6638
6625
|
}
|
|
6639
6626
|
|
|
6640
6627
|
|
|
@@ -7327,7 +7314,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
7327
7314
|
* @Author: baozhoutao@steedos.com
|
|
7328
7315
|
* @Date: 2022-07-05 15:55:39
|
|
7329
7316
|
* @LastEditors: Please set LastEditors
|
|
7330
|
-
* @LastEditTime: 2023-04-
|
|
7317
|
+
* @LastEditTime: 2023-04-18 19:13:30
|
|
7331
7318
|
* @Description:
|
|
7332
7319
|
*/
|
|
7333
7320
|
|
|
@@ -7424,7 +7411,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7424
7411
|
mainRelated[arr[0]] = arr[1];
|
|
7425
7412
|
}
|
|
7426
7413
|
}else {
|
|
7427
|
-
const details = mainObjectUiSchema.details || [];
|
|
7414
|
+
const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
|
|
7428
7415
|
for (const detail of details) {
|
|
7429
7416
|
const arr = detail.split(".");
|
|
7430
7417
|
mainRelated[arr[0]] = arr[1];
|