@steedos-widgets/amis-lib 6.10.24 → 6.10.26
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 +205 -58
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +205 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +213 -202
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/calendar.d.ts +7 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -3622,7 +3622,7 @@ function getBatchDelete(objectName){
|
|
|
3622
3622
|
const DEFAULT_CALENDAR_OPTIONS = {
|
|
3623
3623
|
startDateExpr: "start",
|
|
3624
3624
|
endDateExpr: "end",
|
|
3625
|
-
allDayExpr: "is_all_day",
|
|
3625
|
+
// allDayExpr: "is_all_day",
|
|
3626
3626
|
textExpr: "name"
|
|
3627
3627
|
};
|
|
3628
3628
|
|
|
@@ -3760,7 +3760,8 @@ async function getCalendarApi(mainObject, fields, options) {
|
|
|
3760
3760
|
start: n["${calendarOptions.startDateExpr}"],
|
|
3761
3761
|
end: n["${calendarOptions.endDateExpr}"],
|
|
3762
3762
|
allDay: n["${calendarOptions.allDayExpr}"],
|
|
3763
|
-
extendedProps: n
|
|
3763
|
+
extendedProps: n,
|
|
3764
|
+
resourceId: n["${calendarOptions.groups?.[0]}"]
|
|
3764
3765
|
}
|
|
3765
3766
|
});
|
|
3766
3767
|
const successCallback = selfData.successCallback;
|
|
@@ -3807,7 +3808,7 @@ function getCalendarRecordSaveApi(object, calendarOptions) {
|
|
|
3807
3808
|
};
|
|
3808
3809
|
const saveDataTpl = `
|
|
3809
3810
|
const formData = api.data.$;
|
|
3810
|
-
const objectName = ${object.name}
|
|
3811
|
+
const objectName = "${object.name}";
|
|
3811
3812
|
let query = \`mutation{record: \${objectName}__update(id: "\${formData.${idFieldName}}", doc: {__saveData}){${idFieldName}}}\`;
|
|
3812
3813
|
delete formData.${idFieldName};
|
|
3813
3814
|
let __saveData = JSON.stringify(JSON.stringify(formData));
|
|
@@ -3838,6 +3839,81 @@ function getCalendarRecordSaveApi(object, calendarOptions) {
|
|
|
3838
3839
|
};
|
|
3839
3840
|
}
|
|
3840
3841
|
|
|
3842
|
+
|
|
3843
|
+
function getCalendarResourcesApi(objectSchema, calendarOptions) {
|
|
3844
|
+
const { groups, resources } = calendarOptions;
|
|
3845
|
+
const { color, filters } = resources || {};
|
|
3846
|
+
const groupFieldName = groups[0];
|
|
3847
|
+
const groupField = objectSchema.fields[groupFieldName];
|
|
3848
|
+
let groupObjectName = groupField?.reference_to;
|
|
3849
|
+
if (!groupObjectName){
|
|
3850
|
+
return {};
|
|
3851
|
+
}
|
|
3852
|
+
const fetchFields = [objectSchema.NAME_FIELD_KEY || 'name'];
|
|
3853
|
+
if (color) {
|
|
3854
|
+
fetchFields.push(color);
|
|
3855
|
+
}
|
|
3856
|
+
return {
|
|
3857
|
+
url: `/api/v1/${groupObjectName}?fields=${JSON.stringify(fetchFields)}&filters=${JSON.stringify(filters || [])}`,
|
|
3858
|
+
adaptor: function (payload, response, api, context) {
|
|
3859
|
+
const items = payload?.data?.items || [];
|
|
3860
|
+
const resources = items.map(item => ({
|
|
3861
|
+
id: item._id,
|
|
3862
|
+
title: item.name,
|
|
3863
|
+
eventColor: item.color
|
|
3864
|
+
}));
|
|
3865
|
+
context.successCallback(resources);
|
|
3866
|
+
return payload;
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
|
|
3871
|
+
async function getEventClickActions(options) {
|
|
3872
|
+
const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });
|
|
3873
|
+
let recordId = "${event.id}";
|
|
3874
|
+
const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
|
|
3875
|
+
"recordId": recordId,
|
|
3876
|
+
"data": {
|
|
3877
|
+
...recordPage.schema.data,
|
|
3878
|
+
"_inDrawer": true, // 用于判断是否在抽屉中
|
|
3879
|
+
"recordLoaded": false, // 重置数据加载状态
|
|
3880
|
+
"objectName": options.objectName,
|
|
3881
|
+
}
|
|
3882
|
+
}) : {
|
|
3883
|
+
"type": "steedos-record-detail",
|
|
3884
|
+
"objectApiName": options.objectName,
|
|
3885
|
+
"recordId": recordId,
|
|
3886
|
+
"showBackButton": false,
|
|
3887
|
+
"showButtons": true,
|
|
3888
|
+
"data": {
|
|
3889
|
+
"_inDrawer": true, // 用于判断是否在抽屉中
|
|
3890
|
+
"recordLoaded": false, // 重置数据加载状态
|
|
3891
|
+
}
|
|
3892
|
+
};
|
|
3893
|
+
return [
|
|
3894
|
+
{
|
|
3895
|
+
"actionType": "drawer",
|
|
3896
|
+
"drawer": {
|
|
3897
|
+
"type": "drawer",
|
|
3898
|
+
"title": " ",
|
|
3899
|
+
"headerClassName": "hidden",
|
|
3900
|
+
"size": "lg",
|
|
3901
|
+
"width": window.drawerWidth || "70%",
|
|
3902
|
+
"bodyClassName": "p-0 m-0 bg-gray-100",
|
|
3903
|
+
"closeOnEsc": true,
|
|
3904
|
+
"closeOnOutside": true,
|
|
3905
|
+
"resizable": true,
|
|
3906
|
+
"actions": [],
|
|
3907
|
+
"body": [
|
|
3908
|
+
drawerRecordDetailSchema
|
|
3909
|
+
],
|
|
3910
|
+
"className": "steedos-record-detail-drawer app-popover"
|
|
3911
|
+
},
|
|
3912
|
+
"preventDefault": true
|
|
3913
|
+
}
|
|
3914
|
+
]
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3841
3917
|
/**
|
|
3842
3918
|
* 列表视图Calendar amisSchema
|
|
3843
3919
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -3857,6 +3933,11 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
3857
3933
|
calendarOptions.allDayExpr,
|
|
3858
3934
|
calendarOptions.textExpr
|
|
3859
3935
|
];
|
|
3936
|
+
const groups = calendarOptions.groups;
|
|
3937
|
+
const groupFieldName = groups?.[0];
|
|
3938
|
+
if (groupFieldName) {
|
|
3939
|
+
titleFields.push(groupFieldName);
|
|
3940
|
+
}
|
|
3860
3941
|
let fields = [];
|
|
3861
3942
|
each(titleFields, function (n) {
|
|
3862
3943
|
if (objectSchema.fields[n]) {
|
|
@@ -3920,9 +4001,10 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
3920
4001
|
doc["${calendarOptions.endDateExpr}"] = data.end;
|
|
3921
4002
|
doc["${calendarOptions.allDayExpr}"] = data.allDay;
|
|
3922
4003
|
doc["${calendarOptions.textExpr}"] = data.title;
|
|
4004
|
+
if (data.resource) {
|
|
4005
|
+
doc["${groupFieldName}"] = data.resource.id;
|
|
4006
|
+
}
|
|
3923
4007
|
// ObjectForm会认作用域下的变量值
|
|
3924
|
-
// TODO: 待组件支持initValues属性后应该改掉,不应该通过data直接传值
|
|
3925
|
-
// TODO: 全天事件属性传入doc了但是没有生效,需要手动在ObjectForm中勾选全天事件
|
|
3926
4008
|
const title = "${i18next__default.t('frontend_form_new')} ${objectSchema.label}";
|
|
3927
4009
|
doAction(
|
|
3928
4010
|
{
|
|
@@ -3959,39 +4041,6 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
3959
4041
|
});
|
|
3960
4042
|
`;
|
|
3961
4043
|
|
|
3962
|
-
const onEventClickScript = `
|
|
3963
|
-
const data = event.data;
|
|
3964
|
-
const eventData = data.event;
|
|
3965
|
-
const appId = data.appId;
|
|
3966
|
-
const objectName = data.objectName;
|
|
3967
|
-
const eventId = data.event && data.event.id;
|
|
3968
|
-
doAction({
|
|
3969
|
-
"actionType": "link",
|
|
3970
|
-
"args": {
|
|
3971
|
-
"link": "/app/" + appId + "/" + objectName + "/view/" + eventId
|
|
3972
|
-
}
|
|
3973
|
-
});
|
|
3974
|
-
// doAction({
|
|
3975
|
-
// "actionType": "dialog",
|
|
3976
|
-
// "dialog": {
|
|
3977
|
-
// "type": "dialog",
|
|
3978
|
-
// "title": "",
|
|
3979
|
-
// "body": [
|
|
3980
|
-
// {
|
|
3981
|
-
// "type": "steedos-record-detail",
|
|
3982
|
-
// "objectApiName": "\${objectName}",
|
|
3983
|
-
// "recordId": data.event && data.event.id
|
|
3984
|
-
// }
|
|
3985
|
-
// ],
|
|
3986
|
-
// "closeOnEsc": false,
|
|
3987
|
-
// "closeOnOutside": false,
|
|
3988
|
-
// "showCloseButton": true,
|
|
3989
|
-
// "size": "lg",
|
|
3990
|
-
// "actions": []
|
|
3991
|
-
// }
|
|
3992
|
-
// });
|
|
3993
|
-
`;
|
|
3994
|
-
|
|
3995
4044
|
const recordId = "${event.id}";
|
|
3996
4045
|
const recordPermissionsApi = getCalendarRecordPermissionsApi(objectSchema, recordId);
|
|
3997
4046
|
const recordSaveApi = getCalendarRecordSaveApi(objectSchema, calendarOptions);
|
|
@@ -4008,6 +4057,21 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
4008
4057
|
businessHours.endTime = `${calendarOptions.endDayHour}:00`;
|
|
4009
4058
|
}
|
|
4010
4059
|
|
|
4060
|
+
const moreEvents = {};
|
|
4061
|
+
if (groupFieldName) {
|
|
4062
|
+
moreEvents.getRresources = {
|
|
4063
|
+
"weight": 0,
|
|
4064
|
+
"actions": [
|
|
4065
|
+
{
|
|
4066
|
+
"actionType": "ajax",
|
|
4067
|
+
"args": {
|
|
4068
|
+
"api": getCalendarResourcesApi(objectSchema, calendarOptions)
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
]
|
|
4072
|
+
};
|
|
4073
|
+
}
|
|
4074
|
+
|
|
4011
4075
|
// api.trackExpression="\\\${additionalFilters}";
|
|
4012
4076
|
const onEvent = {
|
|
4013
4077
|
"getEvents": {
|
|
@@ -4052,19 +4116,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
4052
4116
|
},
|
|
4053
4117
|
"eventClick": {
|
|
4054
4118
|
"weight": 0,
|
|
4055
|
-
"actions":
|
|
4056
|
-
{
|
|
4057
|
-
"actionType": "custom",
|
|
4058
|
-
"script": onEventClickScript
|
|
4059
|
-
},
|
|
4060
|
-
// amis 升级到 3.2后,以下的"actionType": "link"方式拿不到appId和objectName了
|
|
4061
|
-
// {
|
|
4062
|
-
// "actionType": "link",
|
|
4063
|
-
// "args": {
|
|
4064
|
-
// "link": "/app/${appId}/${objectName}/view/${event.id}"
|
|
4065
|
-
// }
|
|
4066
|
-
// }
|
|
4067
|
-
]
|
|
4119
|
+
"actions": await getEventClickActions({objectName: objectSchema.name, appId: options.appId, formFactor: options.formFactor})
|
|
4068
4120
|
},
|
|
4069
4121
|
"eventAdd": {
|
|
4070
4122
|
"weight": 0,
|
|
@@ -4103,7 +4155,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
4103
4155
|
"api": recordSaveApi,
|
|
4104
4156
|
"messages": {
|
|
4105
4157
|
"success": objectSchema.label + i18next__default.t('frontend_message_modification_successful'),
|
|
4106
|
-
"failed": objectSchema.label +
|
|
4158
|
+
// "failed": objectSchema.label + i18next.t('frontend_message_modification_failed') //不可以设置请求失败错误信息,否则上面接收适配器中返回的错误信息不会显示
|
|
4107
4159
|
}
|
|
4108
4160
|
}
|
|
4109
4161
|
}
|
|
@@ -4146,7 +4198,8 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
4146
4198
|
"actionType": "setValue",
|
|
4147
4199
|
}
|
|
4148
4200
|
]
|
|
4149
|
-
}
|
|
4201
|
+
},
|
|
4202
|
+
...moreEvents
|
|
4150
4203
|
};
|
|
4151
4204
|
|
|
4152
4205
|
Object.assign(onEvent, options.onEvent);
|
|
@@ -4178,6 +4231,25 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
4178
4231
|
}
|
|
4179
4232
|
}
|
|
4180
4233
|
|
|
4234
|
+
if (!___default.isEmpty(calendarOptions.groups)) {
|
|
4235
|
+
const headerToolbarViews = "prev,next today resourceTimelineMonth,resourceTimelineWeek,resourceTimelineDay,listWeek";
|
|
4236
|
+
const groupField = objectSchema.fields[groupFieldName];
|
|
4237
|
+
let groupObjectName = groupField?.reference_to;
|
|
4238
|
+
let groupHeaderTitle = "资源";
|
|
4239
|
+
if (groupObjectName){
|
|
4240
|
+
const groupObjectConfig = getUISchemaSync(groupObjectName);
|
|
4241
|
+
groupHeaderTitle = groupObjectConfig?.label || groupHeaderTitle;
|
|
4242
|
+
}
|
|
4243
|
+
Object.assign(config, {
|
|
4244
|
+
// "height": "auto",
|
|
4245
|
+
initialView: 'resourceTimelineWeek',
|
|
4246
|
+
resourceAreaHeaderContent: groupHeaderTitle,
|
|
4247
|
+
"headerToolbar": {
|
|
4248
|
+
"right": headerToolbarViews
|
|
4249
|
+
}
|
|
4250
|
+
});
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4181
4253
|
const amisSchema = {
|
|
4182
4254
|
"type": "steedos-fullcalendar",
|
|
4183
4255
|
"label": "",
|
|
@@ -7541,7 +7613,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
7541
7613
|
"actions": [
|
|
7542
7614
|
{
|
|
7543
7615
|
"actionType": "custom",
|
|
7544
|
-
"script": "const data = event.data; window.open(`/app/${data.app_id}/${data.objectName}/view/${data.recordId}?side_object=${data.side_object}&side_listview_id=${data.side_listview_id}`)"
|
|
7616
|
+
"script": "const data = event.data; window.open(`/app/${data.app_id || '-'}/${data.objectName}/view/${data.recordId}?side_object=${data.side_object}&side_listview_id=${data.side_listview_id}`)"
|
|
7545
7617
|
}
|
|
7546
7618
|
]
|
|
7547
7619
|
}
|
|
@@ -10330,7 +10402,7 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
|
|
|
10330
10402
|
* @Author: baozhoutao@steedos.com
|
|
10331
10403
|
* @Date: 2022-07-05 15:55:39
|
|
10332
10404
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
10333
|
-
* @LastEditTime: 2025-
|
|
10405
|
+
* @LastEditTime: 2025-12-02 15:56:17
|
|
10334
10406
|
* @Description:
|
|
10335
10407
|
*/
|
|
10336
10408
|
|
|
@@ -10529,6 +10601,80 @@ async function getFormSchema(objectName, ctx) {
|
|
|
10529
10601
|
};
|
|
10530
10602
|
}
|
|
10531
10603
|
|
|
10604
|
+
/**
|
|
10605
|
+
* 合并 calendar_ 开头的属性与 options 属性,以 options 属性为优先。
|
|
10606
|
+
* @param {object} listView 列表视图配置对象
|
|
10607
|
+
* @returns {object} 合并后的日历配置选项
|
|
10608
|
+
*/
|
|
10609
|
+
function getCalendarOptions(listView) {
|
|
10610
|
+
const calendarDefaults = {};
|
|
10611
|
+
|
|
10612
|
+
if (listView.calendar_start_field) {
|
|
10613
|
+
calendarDefaults.startDateExpr = listView.calendar_start_field;
|
|
10614
|
+
}
|
|
10615
|
+
if (listView.calendar_end_field) {
|
|
10616
|
+
calendarDefaults.endDateExpr = listView.calendar_end_field;
|
|
10617
|
+
}
|
|
10618
|
+
if (listView.calendar_all_day_field) {
|
|
10619
|
+
calendarDefaults.allDayExpr = listView.calendar_all_day_field;
|
|
10620
|
+
}
|
|
10621
|
+
if (listView.calendar_text_field) {
|
|
10622
|
+
calendarDefaults.textExpr = listView.calendar_text_field;
|
|
10623
|
+
}
|
|
10624
|
+
|
|
10625
|
+
if (listView.calendar_current_view) {
|
|
10626
|
+
calendarDefaults.currentView = listView.calendar_current_view;
|
|
10627
|
+
}
|
|
10628
|
+
// if (listView.calendar_views) {
|
|
10629
|
+
// calendarDefaults.views = listView.calendar_views;
|
|
10630
|
+
// }
|
|
10631
|
+
|
|
10632
|
+
if (listView.calendar_group_field) {
|
|
10633
|
+
calendarDefaults.groups = [listView.calendar_group_field];
|
|
10634
|
+
}
|
|
10635
|
+
|
|
10636
|
+
const resourceDefaults = {};
|
|
10637
|
+
if (listView.calendar_resource_color_field) {
|
|
10638
|
+
resourceDefaults.color = listView.calendar_resource_color_field;
|
|
10639
|
+
}
|
|
10640
|
+
if (listView.calendar_resource_filters) {
|
|
10641
|
+
resourceDefaults.filters = listView.calendar_resource_filters;
|
|
10642
|
+
}
|
|
10643
|
+
if (listView.calendar_resource_sort) {
|
|
10644
|
+
resourceDefaults.sort = listView.calendar_resource_sort;
|
|
10645
|
+
}
|
|
10646
|
+
|
|
10647
|
+
if (Object.keys(resourceDefaults).length > 0) {
|
|
10648
|
+
calendarDefaults.resources = resourceDefaults;
|
|
10649
|
+
}
|
|
10650
|
+
|
|
10651
|
+
// 第一次合并:将 calendarDefaults 作为默认值,listView.options 作为高优先级配置
|
|
10652
|
+
let mergedOptions = {
|
|
10653
|
+
...calendarDefaults,
|
|
10654
|
+
...listView.options
|
|
10655
|
+
};
|
|
10656
|
+
|
|
10657
|
+
// 第二次合并:深度合并 'resources' 属性(如果两者都有定义)
|
|
10658
|
+
// 确保 options 内部的 resources 属性优先于 calendar_resource_... 属性
|
|
10659
|
+
const defaultResources = calendarDefaults.resources;
|
|
10660
|
+
const optionResources = listView.options?.resources;
|
|
10661
|
+
|
|
10662
|
+
if (defaultResources && optionResources) {
|
|
10663
|
+
mergedOptions.resources = {
|
|
10664
|
+
...defaultResources, // 默认的资源属性(如 color)
|
|
10665
|
+
...optionResources // options中指定的资源属性(如 sort)
|
|
10666
|
+
};
|
|
10667
|
+
}
|
|
10668
|
+
|
|
10669
|
+
if (listView.type !== "timeline") {
|
|
10670
|
+
// 只有资源视图才显示分资源分组的模式
|
|
10671
|
+
delete mergedOptions.groups;
|
|
10672
|
+
delete mergedOptions.resources;
|
|
10673
|
+
}
|
|
10674
|
+
|
|
10675
|
+
return mergedOptions;
|
|
10676
|
+
}
|
|
10677
|
+
|
|
10532
10678
|
// 获取只读页面 recordId 已废弃, 函数签名保持不变, 但recordId变量不可再使用, 请使用运行时的${recordId}
|
|
10533
10679
|
async function getViewSchema(objectName, recordId, ctx) {
|
|
10534
10680
|
const uiSchema = await getUISchema(objectName);
|
|
@@ -10583,14 +10729,15 @@ async function getListSchema(
|
|
|
10583
10729
|
let listviewFilter = getListViewFilter(listView);
|
|
10584
10730
|
let listview_filters = listView && listView._filters;
|
|
10585
10731
|
// 返回 calendar 组件
|
|
10586
|
-
if(listView.type === "calendar"){
|
|
10732
|
+
if(listView.type === "calendar" || listView.type === "timeline"){
|
|
10733
|
+
const calendarOptions = getCalendarOptions(listView);
|
|
10587
10734
|
const amisSchema = {
|
|
10588
10735
|
"type": "steedos-object-calendar",
|
|
10589
10736
|
"objectApiName": objectName,
|
|
10590
10737
|
"filters": listviewFilter,
|
|
10591
10738
|
"filtersFunction": listview_filters,
|
|
10592
10739
|
"sort": sort,
|
|
10593
|
-
...
|
|
10740
|
+
...calendarOptions
|
|
10594
10741
|
};
|
|
10595
10742
|
return {
|
|
10596
10743
|
uiSchema,
|
|
@@ -18366,7 +18513,7 @@ const getTdField = async (field, fieldsCount) => {
|
|
|
18366
18513
|
};
|
|
18367
18514
|
|
|
18368
18515
|
const getTdTitle = (field) => {
|
|
18369
|
-
const requiredOn = field.config?.amis
|
|
18516
|
+
const requiredOn = field.config?.amis?.requiredOn;
|
|
18370
18517
|
// console.log('getTdTitle', field.is_required , requiredOn, field);
|
|
18371
18518
|
return {
|
|
18372
18519
|
className: `td-title td-title-${field.type}`,
|