@steedos-widgets/amis-lib 6.3.0-beta.15 → 6.3.0-beta.17
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 +124 -38
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +124 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +250 -238
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields/file.d.ts +82 -14
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1156,6 +1156,29 @@ function getAmisStaticFieldType(type, readonly, options){
|
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
1158
|
|
|
1159
|
+
/*
|
|
1160
|
+
* @Author: baozhoutao@steedos.com
|
|
1161
|
+
* @Date: 2022-07-13 15:18:03
|
|
1162
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
1163
|
+
* @LastEditTime: 2023-04-11 10:34:26
|
|
1164
|
+
* @Description:
|
|
1165
|
+
*/
|
|
1166
|
+
|
|
1167
|
+
async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
|
|
1168
|
+
const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
|
|
1169
|
+
const page = await fetchAPI(api);
|
|
1170
|
+
if (page && page.schema) {
|
|
1171
|
+
page.schema = JSON.parse(page.schema);
|
|
1172
|
+
if(page.schema.data){
|
|
1173
|
+
delete page.schema.data.recordId;
|
|
1174
|
+
delete page.schema.data.objectName;
|
|
1175
|
+
delete page.schema.data.context;
|
|
1176
|
+
delete page.schema.data.global;
|
|
1177
|
+
}
|
|
1178
|
+
return page;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1159
1182
|
/*
|
|
1160
1183
|
* @Author: baozhoutao@steedos.com
|
|
1161
1184
|
* @Date: 2022-10-28 14:15:09
|
|
@@ -1179,9 +1202,74 @@ const getAmisFieldType$1 = (steedosField, readonly)=>{
|
|
|
1179
1202
|
return getAmisStaticFieldType(steedosField.type === 'avatar' ? 'image' : steedosField.type, readonly, {multiple: steedosField.multiple});
|
|
1180
1203
|
};
|
|
1181
1204
|
|
|
1182
|
-
|
|
1205
|
+
async function getLookupLinkOnClick(field, options) {
|
|
1206
|
+
const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });
|
|
1207
|
+
|
|
1208
|
+
const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
|
|
1209
|
+
"recordId": "${value}",
|
|
1210
|
+
"data": {
|
|
1211
|
+
...recordPage.schema.data,
|
|
1212
|
+
"_inDrawer": true, // 用于判断是否在抽屉中
|
|
1213
|
+
"recordLoaded": false, // 重置数据加载状态
|
|
1214
|
+
"objectName": options.objectName,
|
|
1215
|
+
}
|
|
1216
|
+
}) : {
|
|
1217
|
+
"type": "steedos-record-detail",
|
|
1218
|
+
"objectApiName": options.objectName,
|
|
1219
|
+
"recordId": "${value}",
|
|
1220
|
+
"showBackButton": false,
|
|
1221
|
+
"showButtons": true,
|
|
1222
|
+
"data": {
|
|
1223
|
+
"_inDrawer": true, // 用于判断是否在抽屉中
|
|
1224
|
+
"recordLoaded": false, // 重置数据加载状态
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
return {
|
|
1228
|
+
"click": {
|
|
1229
|
+
"actions": [
|
|
1230
|
+
// {
|
|
1231
|
+
// "type": "custom",
|
|
1232
|
+
// "script": `
|
|
1233
|
+
// let fileRecordId = url.match(${regFileRecordId})[2];
|
|
1234
|
+
// console.log('fileRecordId:',fileRecordId);
|
|
1235
|
+
// event.data.recordId = fileRecordId;
|
|
1236
|
+
// `,
|
|
1237
|
+
// },
|
|
1238
|
+
{
|
|
1239
|
+
"actionType": "drawer",
|
|
1240
|
+
"drawer": {
|
|
1241
|
+
"type": "drawer",
|
|
1242
|
+
"title": " ",
|
|
1243
|
+
"headerClassName": "hidden",
|
|
1244
|
+
"size": "lg",
|
|
1245
|
+
"bodyClassName": "p-0 m-0 bg-gray-100",
|
|
1246
|
+
"closeOnEsc": true,
|
|
1247
|
+
"closeOnOutside": true,
|
|
1248
|
+
"resizable": true,
|
|
1249
|
+
"actions": [],
|
|
1250
|
+
"body": [
|
|
1251
|
+
drawerRecordDetailSchema
|
|
1252
|
+
],
|
|
1253
|
+
"className": "steedos-record-detail-drawer app-popover"
|
|
1254
|
+
},
|
|
1255
|
+
"preventDefault": true
|
|
1256
|
+
}
|
|
1257
|
+
]
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
const getAmisFileReadonlySchema = async (steedosField,ctx)=>{
|
|
1183
1263
|
const type = steedosField.type;
|
|
1264
|
+
const { appId, formFactor } = ctx.amisData || {};
|
|
1184
1265
|
const amisFieldType = getAmisFieldType$1(steedosField, true);
|
|
1266
|
+
|
|
1267
|
+
let lookupATagClick = 'onclick="return false;"';
|
|
1268
|
+
|
|
1269
|
+
if(window.innerWidth < 768){
|
|
1270
|
+
lookupATagClick = "";
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1185
1273
|
if(_.includes(['avatar','image'], type)){
|
|
1186
1274
|
return {
|
|
1187
1275
|
type: amisFieldType,
|
|
@@ -1216,13 +1304,34 @@ const getAmisFileReadonlySchema = (steedosField)=>{
|
|
|
1216
1304
|
}
|
|
1217
1305
|
}
|
|
1218
1306
|
} : {
|
|
1219
|
-
type: amisFieldType,
|
|
1220
|
-
tpl: `
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1307
|
+
// type: amisFieldType,
|
|
1308
|
+
// tpl: `
|
|
1309
|
+
// <% let fileData = data._display.${steedosField.name}; if (fileData) { %>
|
|
1310
|
+
// <% if(!Array.isArray(fileData)){ fileData = [fileData]} %>
|
|
1311
|
+
// <% fileData.forEach(function(item) { %>
|
|
1312
|
+
// <a href='<%= item.url %>' target='_self' class='block'><%= item.name %></a>
|
|
1313
|
+
// <% });} %>`
|
|
1314
|
+
"type": "control",
|
|
1315
|
+
"body": {
|
|
1316
|
+
type: 'each',
|
|
1317
|
+
placeholder: "",
|
|
1318
|
+
// className: `steedos-field-lookup-each flex flex-wrap gap-2`,
|
|
1319
|
+
source: `\${_display.${steedosField.name}|asArray}`,
|
|
1320
|
+
items: {
|
|
1321
|
+
type: 'static',
|
|
1322
|
+
labelClassName: "hidden",
|
|
1323
|
+
label: false,
|
|
1324
|
+
className: 'm-0',
|
|
1325
|
+
tpl: `<a href="/app/-/cfs_files_filerecord/view/\${value}" ${lookupATagClick}>\${name}</a>`,
|
|
1326
|
+
// tpl: "<%= item.name >",
|
|
1327
|
+
// onEvent: window.innerWidth < 768 ? null : REFERENCE_VALUE_ITEM_ONCLICK
|
|
1328
|
+
onEvent: window.innerWidth < 768 ? null : await getLookupLinkOnClick(steedosField, {
|
|
1329
|
+
appId,
|
|
1330
|
+
objectName: "cfs_files_filerecord",
|
|
1331
|
+
formFactor
|
|
1332
|
+
})
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1226
1335
|
}
|
|
1227
1336
|
}
|
|
1228
1337
|
};
|
|
@@ -1284,8 +1393,8 @@ const getAmisFileEditSchema = (steedosField)=>{
|
|
|
1284
1393
|
return convertData;
|
|
1285
1394
|
};
|
|
1286
1395
|
|
|
1287
|
-
const getAmisFileSchema = (steedosField, readonly)=>{
|
|
1288
|
-
return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
|
|
1396
|
+
const getAmisFileSchema = async (steedosField, readonly, ctx)=>{
|
|
1397
|
+
return readonly ? await getAmisFileReadonlySchema(steedosField,ctx) : getAmisFileEditSchema(steedosField);
|
|
1289
1398
|
};
|
|
1290
1399
|
|
|
1291
1400
|
var frontend_field_group_generalization$1 = "General";
|
|
@@ -1680,29 +1789,6 @@ i18next
|
|
|
1680
1789
|
}
|
|
1681
1790
|
});
|
|
1682
1791
|
|
|
1683
|
-
/*
|
|
1684
|
-
* @Author: baozhoutao@steedos.com
|
|
1685
|
-
* @Date: 2022-07-13 15:18:03
|
|
1686
|
-
* @LastEditors: baozhoutao@steedos.com
|
|
1687
|
-
* @LastEditTime: 2023-04-11 10:34:26
|
|
1688
|
-
* @Description:
|
|
1689
|
-
*/
|
|
1690
|
-
|
|
1691
|
-
async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
|
|
1692
|
-
const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
|
|
1693
|
-
const page = await fetchAPI(api);
|
|
1694
|
-
if (page && page.schema) {
|
|
1695
|
-
page.schema = JSON.parse(page.schema);
|
|
1696
|
-
if(page.schema.data){
|
|
1697
|
-
delete page.schema.data.recordId;
|
|
1698
|
-
delete page.schema.data.objectName;
|
|
1699
|
-
delete page.schema.data.context;
|
|
1700
|
-
delete page.schema.data.global;
|
|
1701
|
-
}
|
|
1702
|
-
return page;
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
1792
|
async function getQuickEditSchema(object, columnField, options){
|
|
1707
1793
|
let field = object.fields[columnField.name];
|
|
1708
1794
|
//判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
|
|
@@ -11588,8 +11674,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
11588
11674
|
const isAllowCreate = refObjectConfig.permissions.allowCreate;
|
|
11589
11675
|
const isCreate = _$1.isBoolean(field.create) ? field.create : true;
|
|
11590
11676
|
// lookup字段配置过滤条件就强制不显示新建按钮
|
|
11591
|
-
let
|
|
11592
|
-
if (isAllowCreate && isCreate && !
|
|
11677
|
+
let hasFilters = !_$1.isEmpty(field.filters) || !!field.filtersFunction || !!field._filtersFunction;
|
|
11678
|
+
if (isAllowCreate && isCreate && !hasFilters) {
|
|
11593
11679
|
const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
|
|
11594
11680
|
new_button.align = "right";
|
|
11595
11681
|
// 保持快速搜索放在最左侧,新建按钮往里插,而不是push到最后
|
|
@@ -13034,13 +13120,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
13034
13120
|
};
|
|
13035
13121
|
break;
|
|
13036
13122
|
case 'avatar':
|
|
13037
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
13123
|
+
convertData = await getAmisFileSchema(field, readonly, ctx);
|
|
13038
13124
|
break;
|
|
13039
13125
|
case 'image':
|
|
13040
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
13126
|
+
convertData = await getAmisFileSchema(field, readonly, ctx);
|
|
13041
13127
|
break;
|
|
13042
13128
|
case 'file':
|
|
13043
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
13129
|
+
convertData = await getAmisFileSchema(field, readonly, ctx);
|
|
13044
13130
|
break;
|
|
13045
13131
|
case 'formula':
|
|
13046
13132
|
if(readonly){
|