@steedos-widgets/amis-lib 3.6.13 → 6.3.0-beta.10
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 +145 -68
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +145 -68
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +50 -41
- package/dist/index.umd.js.map +1 -1
- package/dist/types/schema/standard_delete.amis.d.ts +1 -0
- package/dist/types/schema/standard_edit.amis.d.ts +13 -0
- package/dist/types/schema/standard_new.amis.d.ts +1 -1
- package/dist/types/standard/button.d.ts +15 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -570,10 +570,23 @@ function getNameTpl(field, ctx){
|
|
|
570
570
|
if(ctx && ctx.isLookup){
|
|
571
571
|
linkTarget = "target='_blank'";
|
|
572
572
|
}
|
|
573
|
+
let nameLabel = field.name;
|
|
574
|
+
//若字段类型是lookup,则按照相关表tpl的label规则显示;若是其它类型,则显示_display或字段本身的值
|
|
575
|
+
if (field.type == "lookup") {
|
|
576
|
+
if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
|
|
577
|
+
if(!field.isTableField){
|
|
578
|
+
nameLabel = `\${${field.name}__label}`;
|
|
579
|
+
}
|
|
580
|
+
} else {
|
|
581
|
+
nameLabel = `\${_display.${field.name}.label}`;
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
nameLabel = `\${_display.${field.name} || ${field.name}}`;
|
|
585
|
+
}
|
|
573
586
|
if(ctx.isRelated && window.innerWidth >= 768){
|
|
574
|
-
return `<a href="${href}" ${linkTarget} onclick="return false;">\${${
|
|
587
|
+
return `<a href="${href}" ${linkTarget} onclick="return false;">\${${nameLabel} | raw}</a>`
|
|
575
588
|
}else {
|
|
576
|
-
return `<a href="${href}" ${linkTarget}>\${${
|
|
589
|
+
return `<a href="${href}" ${linkTarget}>\${${nameLabel} | raw}</a>`
|
|
577
590
|
}
|
|
578
591
|
}
|
|
579
592
|
|
|
@@ -698,7 +711,7 @@ function getLocationTpl(field){
|
|
|
698
711
|
}
|
|
699
712
|
|
|
700
713
|
async function getFieldTpl (field, options){
|
|
701
|
-
if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
|
|
714
|
+
if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel && field.multiple !== true){
|
|
702
715
|
return getNameTpl(field, options)
|
|
703
716
|
}
|
|
704
717
|
switch (field.type) {
|
|
@@ -1072,7 +1085,7 @@ function getRecordPermissionsQuery(object, recordId, options){
|
|
|
1072
1085
|
function getApi$2 (isMobile){
|
|
1073
1086
|
if(isMobile);else {
|
|
1074
1087
|
// return __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + "/graphql"
|
|
1075
|
-
return `\${context.rootUrl}/graphql?reload=\${additionalFilters}`
|
|
1088
|
+
return `\${context.rootUrl}/graphql?reload=\${additionalFilters|join}`
|
|
1076
1089
|
}
|
|
1077
1090
|
}
|
|
1078
1091
|
|
|
@@ -2319,7 +2332,7 @@ async function getTableColumns(object, fields, options){
|
|
|
2319
2332
|
"title": " ",
|
|
2320
2333
|
"headerClassName": "hidden",
|
|
2321
2334
|
"size": "lg",
|
|
2322
|
-
"bodyClassName": "p-0 m-0",
|
|
2335
|
+
"bodyClassName": "p-0 m-0 bg-gray-100",
|
|
2323
2336
|
"closeOnEsc": true,
|
|
2324
2337
|
"closeOnOutside": true,
|
|
2325
2338
|
"resizable": true,
|
|
@@ -3255,6 +3268,19 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3255
3268
|
// })
|
|
3256
3269
|
|
|
3257
3270
|
var fieldNames = _$1.map(fields, function(n){return n.name});
|
|
3271
|
+
var nameField = object.fields[object.NAME_FIELD_KEY];
|
|
3272
|
+
let nameLabel = nameField && nameField.name;
|
|
3273
|
+
if (nameField && nameField.type == "lookup") {
|
|
3274
|
+
if(!nameField.reference_to && (nameField.optionsFunction || nameField._optionsFunction || nameField.options)){
|
|
3275
|
+
if(!nameField.isTableField){
|
|
3276
|
+
nameLabel = `record.${nameField.name}__label`;
|
|
3277
|
+
}
|
|
3278
|
+
} else {
|
|
3279
|
+
nameLabel = `record._display.${nameField.name}.label`;
|
|
3280
|
+
}
|
|
3281
|
+
} else if (nameField){
|
|
3282
|
+
nameLabel = `record._display.${nameField.name} || record.${nameField.name}`;
|
|
3283
|
+
}
|
|
3258
3284
|
return `
|
|
3259
3285
|
if(payload.data.data.length === 0){
|
|
3260
3286
|
var isEditor = !!${options && options.isEditor};
|
|
@@ -3296,8 +3322,7 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3296
3322
|
payload.data = data;
|
|
3297
3323
|
payload.data.__objectName = "${object.name}";
|
|
3298
3324
|
payload.data.record = record;
|
|
3299
|
-
|
|
3300
|
-
payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
|
|
3325
|
+
payload.data.NAME_FIELD_VALUE = ${nameLabel} || record.name;
|
|
3301
3326
|
payload.data._master = {
|
|
3302
3327
|
record: record,
|
|
3303
3328
|
objectName: "${object.name}",
|
|
@@ -4764,7 +4789,8 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
4764
4789
|
type: 'button',
|
|
4765
4790
|
actionType: 'confirm',
|
|
4766
4791
|
label: i18next.t('frontend_form_save'),
|
|
4767
|
-
primary: true
|
|
4792
|
+
primary: true,
|
|
4793
|
+
close: `object_actions_drawer_${uiSchema.name}`
|
|
4768
4794
|
},
|
|
4769
4795
|
]
|
|
4770
4796
|
}
|
|
@@ -4883,6 +4909,20 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
4883
4909
|
]
|
|
4884
4910
|
}
|
|
4885
4911
|
},
|
|
4912
|
+
"actions": [
|
|
4913
|
+
{
|
|
4914
|
+
type: 'button',
|
|
4915
|
+
actionType: 'cancel',
|
|
4916
|
+
label: i18next.t('frontend_form_cancel')
|
|
4917
|
+
},
|
|
4918
|
+
{
|
|
4919
|
+
type: 'button',
|
|
4920
|
+
actionType: 'confirm',
|
|
4921
|
+
label: i18next.t('frontend_form_save'),
|
|
4922
|
+
primary: true,
|
|
4923
|
+
close: `object_actions_drawer_${uiSchema.name}`
|
|
4924
|
+
},
|
|
4925
|
+
]
|
|
4886
4926
|
},
|
|
4887
4927
|
},
|
|
4888
4928
|
],
|
|
@@ -4964,7 +5004,8 @@ const getSchema$3 = (uiSchema)=>{
|
|
|
4964
5004
|
}
|
|
4965
5005
|
]
|
|
4966
5006
|
}
|
|
4967
|
-
}
|
|
5007
|
+
},
|
|
5008
|
+
"close": `object_actions_drawer_${uiSchema.name}`
|
|
4968
5009
|
}
|
|
4969
5010
|
],
|
|
4970
5011
|
"regions": [
|
|
@@ -8283,6 +8324,10 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
8283
8324
|
// const scope = event.context.scoped;
|
|
8284
8325
|
// 如果点击过顶部搜索栏表单的取消按钮,会把此处event.data.__super.__super.__super中的搜索表单项的所有字段设置为null
|
|
8285
8326
|
// 点击取消按钮后继续在表单项中输入过滤条件且最后没有点击回车按键或点击表单项搜索按钮的话,在快速搜索中点击回车按钮提交搜索会所顶部搜索表单中的字段值清空
|
|
8327
|
+
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
8328
|
+
if(!filterForm){
|
|
8329
|
+
return;
|
|
8330
|
+
}
|
|
8286
8331
|
let isLookup = event.data.isLookup;
|
|
8287
8332
|
let __lookupField = event.data.__lookupField;
|
|
8288
8333
|
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
@@ -8293,9 +8338,8 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
8293
8338
|
}
|
|
8294
8339
|
__changedFilterFormValuesKey += lookupTag;
|
|
8295
8340
|
}
|
|
8296
|
-
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
8297
8341
|
setTimeout(function(){
|
|
8298
|
-
filterForm.setValues(event.data[__changedFilterFormValuesKey]);
|
|
8342
|
+
filterForm && filterForm.setValues(event.data[__changedFilterFormValuesKey]);
|
|
8299
8343
|
}, 500);
|
|
8300
8344
|
`;
|
|
8301
8345
|
|
|
@@ -8896,10 +8940,6 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8896
8940
|
}
|
|
8897
8941
|
}
|
|
8898
8942
|
`;
|
|
8899
|
-
let autoFillHeight = true;
|
|
8900
|
-
if(options.isRelated || window.innerWidth < 768){
|
|
8901
|
-
autoFillHeight = false;
|
|
8902
|
-
}
|
|
8903
8943
|
|
|
8904
8944
|
body = Object.assign({}, table, {
|
|
8905
8945
|
type: 'crud',
|
|
@@ -8910,7 +8950,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8910
8950
|
keepItemSelectionOnPageChange: true,
|
|
8911
8951
|
api: await getTableApi(objectSchema, fields, options),
|
|
8912
8952
|
hiddenOn: options.tableHiddenOn,
|
|
8913
|
-
autoFillHeight
|
|
8953
|
+
// autoFillHeight,//autoFillHeight按amis规范默认为false,需要配置此属性时在各个组件层配置,比如列表视图组件那边传入此属性为true
|
|
8914
8954
|
className: `flex-auto ${crudClassName || ""}`,
|
|
8915
8955
|
// 这里不可以用动态className,因为它会把样式类加到.antd-Crud和.antd-Table.antd-Crud-body这两层div中,而子表列表中crudClassName中有hidden样式类会造成所有子表都不显示的bug
|
|
8916
8956
|
// className: {
|
|
@@ -9083,6 +9123,10 @@ async function getFormSchemaWithDataFilter(form, options = {}){
|
|
|
9083
9123
|
async function getObjectForm(objectSchema, ctx){
|
|
9084
9124
|
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
|
|
9085
9125
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
9126
|
+
//优先识别组件上的enableTabs属性,若不存在,则识别对象上定义的
|
|
9127
|
+
if (typeof ctx.enableTabs !== 'boolean') {
|
|
9128
|
+
ctx.enableTabs = objectSchema.enable_form_tabs;
|
|
9129
|
+
}
|
|
9086
9130
|
const fields = ___default.values(objectSchema.fields);
|
|
9087
9131
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
9088
9132
|
const formSchema = defaults && defaults.formSchema || {};
|
|
@@ -9176,7 +9220,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
9176
9220
|
|
|
9177
9221
|
async function getObjectDetail(objectSchema, recordId, ctx){
|
|
9178
9222
|
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
|
|
9179
|
-
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
9223
|
+
formDataFilter, onFormDataFilter, amisData, env, enableInitApi } = ctx;
|
|
9180
9224
|
const fields = ___default.values(objectSchema.fields);
|
|
9181
9225
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
9182
9226
|
const serviceId = `service_detail_page`;
|
|
@@ -9243,6 +9287,16 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
9243
9287
|
// }
|
|
9244
9288
|
};
|
|
9245
9289
|
|
|
9290
|
+
if(enableInitApi){
|
|
9291
|
+
amisSchema.api = await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx);
|
|
9292
|
+
// 开启初始化api请求时,如果不把recordLoaded默认设置为false,recordLoaded值会取RecordServic组件中的recordLoaded值
|
|
9293
|
+
// 这会造成表单内steedos field组件lookup字段中props.data取到的是RecordServic组件
|
|
9294
|
+
amisSchema.data = {
|
|
9295
|
+
...amisSchema.data,
|
|
9296
|
+
recordLoaded: false
|
|
9297
|
+
};
|
|
9298
|
+
}
|
|
9299
|
+
|
|
9246
9300
|
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
9247
9301
|
// console.log('getObjectDetail=====>', amisSchema);
|
|
9248
9302
|
return amisSchema;
|
|
@@ -9734,7 +9788,7 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
|
|
|
9734
9788
|
* @Author: baozhoutao@steedos.com
|
|
9735
9789
|
* @Date: 2022-07-05 15:55:39
|
|
9736
9790
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
9737
|
-
* @LastEditTime: 2024-
|
|
9791
|
+
* @LastEditTime: 2024-04-26 16:46:44
|
|
9738
9792
|
* @Description:
|
|
9739
9793
|
*/
|
|
9740
9794
|
|
|
@@ -9999,37 +10053,44 @@ async function getListSchema(
|
|
|
9999
10053
|
* 本次存储代码段
|
|
10000
10054
|
*/
|
|
10001
10055
|
try {
|
|
10002
|
-
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10056
|
+
const listViewPropsStoreKey = location.pathname + "/crud";
|
|
10057
|
+
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
10058
|
+
/**
|
|
10059
|
+
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
10060
|
+
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
10061
|
+
* __searchable__...:顶部放大镜搜索条件
|
|
10062
|
+
* filter:右侧过滤器
|
|
10063
|
+
* perPage:每页条数
|
|
10064
|
+
* page:当前页码
|
|
10065
|
+
* orderBy:排序字段
|
|
10066
|
+
* orderDir:排序方向
|
|
10067
|
+
*/
|
|
10068
|
+
if (localListViewProps) {
|
|
10069
|
+
localListViewProps = JSON.parse(localListViewProps);
|
|
10070
|
+
// localListViewProps.perPage = 3;
|
|
10071
|
+
let listSchema = {};
|
|
10072
|
+
if (localListViewProps.orderBy) {
|
|
10073
|
+
listSchema.orderBy = localListViewProps.orderBy;
|
|
10074
|
+
}
|
|
10075
|
+
if (localListViewProps.orderDir) {
|
|
10076
|
+
listSchema.orderDir = localListViewProps.orderDir;
|
|
10077
|
+
}
|
|
10024
10078
|
|
|
10025
|
-
|
|
10026
|
-
|
|
10079
|
+
if (localListViewProps.perPage) {
|
|
10080
|
+
listSchema.perPage = localListViewProps.perPage;
|
|
10081
|
+
}
|
|
10082
|
+
defaults.listSchema = defaultsDeep$1({}, listSchema, defaults.listSchema || {});
|
|
10027
10083
|
}
|
|
10028
|
-
defaults.listSchema = defaultsDeep$1({}, listSchema, defaults.listSchema || {});
|
|
10029
|
-
}
|
|
10030
10084
|
}
|
|
10031
10085
|
catch (ex) {
|
|
10032
|
-
|
|
10086
|
+
console.error("本地存储中crud参数解析异常:", ex);
|
|
10087
|
+
}
|
|
10088
|
+
|
|
10089
|
+
if (window.innerWidth > 768) {
|
|
10090
|
+
// 列表视图组件PC端高度自动计算实现满屏效果,手机端不需要满屏效果,所以不用autofillheight,且允许重写微页面中重新组件autoFillHeight属性
|
|
10091
|
+
defaults.listSchema = defaultsDeep$1({}, defaults.listSchema || {}, {
|
|
10092
|
+
autoFillHeight: true
|
|
10093
|
+
});
|
|
10033
10094
|
}
|
|
10034
10095
|
|
|
10035
10096
|
ctx.defaults = defaults;
|
|
@@ -10079,15 +10140,15 @@ async function getListSchema(
|
|
|
10079
10140
|
async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
|
|
10080
10141
|
let fields = [];
|
|
10081
10142
|
for (const column of columns) {
|
|
10143
|
+
let columnField, fieldName, displayName, filedInfo, rfUiSchema, rfFieldInfo;
|
|
10082
10144
|
if (isString(column)) {
|
|
10083
|
-
let columnField;
|
|
10084
10145
|
if (column.indexOf('.') > 0) {
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10146
|
+
fieldName = column.split('.')[0];
|
|
10147
|
+
displayName = column.split('.')[1];
|
|
10148
|
+
filedInfo = uiSchema.fields[fieldName];
|
|
10088
10149
|
if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)) {
|
|
10089
|
-
|
|
10090
|
-
|
|
10150
|
+
rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10151
|
+
rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10091
10152
|
columnField = Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx);
|
|
10092
10153
|
}else if(filedInfo && filedInfo.type === 'object'){
|
|
10093
10154
|
columnField = uiSchema.fields[column];
|
|
@@ -10111,14 +10172,13 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
|
|
|
10111
10172
|
}
|
|
10112
10173
|
|
|
10113
10174
|
} else if (isObject$1(column)) {
|
|
10114
|
-
let columnField;
|
|
10115
10175
|
if (column.field.indexOf('.') > 0) {
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10176
|
+
fieldName = column.field.split('.')[0];
|
|
10177
|
+
displayName = column.field.split('.')[1];
|
|
10178
|
+
filedInfo = uiSchema.fields[fieldName];
|
|
10119
10179
|
if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)) {
|
|
10120
|
-
|
|
10121
|
-
|
|
10180
|
+
rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10181
|
+
rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10122
10182
|
columnField = Object.assign({}, rfFieldInfo, ctx,
|
|
10123
10183
|
{ name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } },
|
|
10124
10184
|
{
|
|
@@ -10126,6 +10186,8 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
|
|
|
10126
10186
|
wrap: column.wrap // wrap = true 是没效果的
|
|
10127
10187
|
}
|
|
10128
10188
|
);
|
|
10189
|
+
} else if (filedInfo && filedInfo.type === 'object') {
|
|
10190
|
+
columnField = uiSchema.fields[column.field];
|
|
10129
10191
|
}
|
|
10130
10192
|
} else {
|
|
10131
10193
|
if (uiSchema.fields[column.field]) {
|
|
@@ -10260,7 +10322,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
10260
10322
|
};
|
|
10261
10323
|
const content = {
|
|
10262
10324
|
"type": "tabs",
|
|
10263
|
-
"className": "steedos-record-tabs bg-white p-4
|
|
10325
|
+
"className": "steedos-record-tabs bg-white p-4 m-2 border rounded",
|
|
10264
10326
|
"contentClassName": "bg-none",
|
|
10265
10327
|
"tabs": [
|
|
10266
10328
|
detailed
|
|
@@ -10336,6 +10398,10 @@ async function getRecordServiceSchema(objectName, appId, props = {}, body) {
|
|
|
10336
10398
|
data: {
|
|
10337
10399
|
"_master.objectName": "${objectName}",
|
|
10338
10400
|
"_master.recordId": "${recordId}",
|
|
10401
|
+
// 微页面设计器中用RecordServic组件包裹一个ObjectForm只读组件时,如果这里不把recordLoaded默认设置为false
|
|
10402
|
+
// recordLoaded值会取父作用域中已经被设置为true的值(比如父级有RecordServic组件,在加载完数据后,父作用域中recordLoaded值为true)
|
|
10403
|
+
// 这会造成表单内steedos field组件lookup字段中props.data取到的是父作用域中的数据
|
|
10404
|
+
"recordLoaded": false,
|
|
10339
10405
|
...(props.data || {})
|
|
10340
10406
|
},
|
|
10341
10407
|
"style": {
|
|
@@ -11224,7 +11290,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
11224
11290
|
});
|
|
11225
11291
|
|
|
11226
11292
|
// 把自动填充规则中依赖的字段也加到api请求中
|
|
11227
|
-
let autoFillMapping =
|
|
11293
|
+
let autoFillMapping = field.auto_fill_mapping;
|
|
11228
11294
|
if (autoFillMapping && autoFillMapping.length) {
|
|
11229
11295
|
autoFillMapping.forEach(function (item) {
|
|
11230
11296
|
if(!_$1.find(tableFields, function(f){
|
|
@@ -11374,7 +11440,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
11374
11440
|
// 如果当前元素不是数组,则处理该元素
|
|
11375
11441
|
// 下面正则用于匹配amis公式\${}
|
|
11376
11442
|
if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
|
|
11377
|
-
arr[i] = currentAmis.evaluate(arr[i], api.data.$);
|
|
11443
|
+
arr[i] = currentAmis.evaluate(arr[i], api.data.$self);
|
|
11378
11444
|
}
|
|
11379
11445
|
}
|
|
11380
11446
|
}
|
|
@@ -11696,7 +11762,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
11696
11762
|
];
|
|
11697
11763
|
|
|
11698
11764
|
// 把自动填充规则中依赖的字段也加到api请求中
|
|
11699
|
-
let autoFillMapping =
|
|
11765
|
+
let autoFillMapping = field.auto_fill_mapping;
|
|
11700
11766
|
if (autoFillMapping && autoFillMapping.length) {
|
|
11701
11767
|
autoFillMapping.forEach(function (item) {
|
|
11702
11768
|
queryFields.push(refObjectConfig.fields[item.from]);
|
|
@@ -11791,7 +11857,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
11791
11857
|
// 如果当前元素不是数组,则处理该元素
|
|
11792
11858
|
// 下面正则用于匹配amis公式\${}
|
|
11793
11859
|
if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
|
|
11794
|
-
arr[i] = currentAmis.evaluate(arr[i], api.data.$);
|
|
11860
|
+
arr[i] = currentAmis.evaluate(arr[i], api.data.$self);
|
|
11795
11861
|
}
|
|
11796
11862
|
}
|
|
11797
11863
|
}
|
|
@@ -11938,14 +12004,25 @@ async function getApi(object, recordId, fields, options){
|
|
|
11938
12004
|
}
|
|
11939
12005
|
|
|
11940
12006
|
async function getAutoFill(field, refObject) {
|
|
11941
|
-
let autoFillMapping =
|
|
12007
|
+
let autoFillMapping = field.auto_fill_mapping;
|
|
11942
12008
|
if (autoFillMapping && autoFillMapping.length) {
|
|
11943
12009
|
let fillMapping = {};
|
|
12010
|
+
if (field.multiple) {
|
|
12011
|
+
autoFillMapping.forEach(function (item) {
|
|
12012
|
+
//from的字段类型为lookup、master_detail、select时,需要保留数组格式;其他类型需要转变为字符串格式
|
|
12013
|
+
if (_$1.includes(["lookup","master_detail","select"], refObject.fields[item.from].type)) {
|
|
12014
|
+
fillMapping[item.to] = `\${items | pick:${item.from}}`;
|
|
12015
|
+
} else {
|
|
12016
|
+
fillMapping[item.to] = `\${items | pick:${item.from} | join}`;
|
|
12017
|
+
}
|
|
12018
|
+
});
|
|
12019
|
+
}else {
|
|
12020
|
+
autoFillMapping.forEach(function (item) {
|
|
12021
|
+
fillMapping[item.to] = `\${${item.from}}`;
|
|
12022
|
+
});
|
|
12023
|
+
}
|
|
11944
12024
|
// let fieldsForApi = [];
|
|
11945
|
-
|
|
11946
|
-
fillMapping[item.to] = `\${${item.from}}`;
|
|
11947
|
-
// fieldsForApi.push(item.from);
|
|
11948
|
-
});
|
|
12025
|
+
// fieldsForApi.push(item.from);
|
|
11949
12026
|
// let api = {
|
|
11950
12027
|
// // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
|
|
11951
12028
|
// "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
|
|
@@ -12047,7 +12124,7 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
12047
12124
|
amisSchema = _$1.defaultsDeep({}, pageAmisSchema, amisSchema);
|
|
12048
12125
|
}
|
|
12049
12126
|
}
|
|
12050
|
-
const autoFill = await getAutoFill(field);
|
|
12127
|
+
const autoFill = await getAutoFill(field, refObject);
|
|
12051
12128
|
if(autoFill){
|
|
12052
12129
|
amisSchema.autoFill = autoFill;
|
|
12053
12130
|
// 这里不配置initAutoFill值,按amis规则initAutoFill默认值为fillIfNotSet处理--需要amis sdk 版本 > 3.6.3-patch.6(不包括)版本
|