@steedos-widgets/amis-lib 1.1.0 → 1.1.1

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/index.cjs.js CHANGED
@@ -3968,6 +3968,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
3968
3968
  `;
3969
3969
  source.adaptor = `
3970
3970
  const enable_tree = ${refObjectConfig.enable_tree};
3971
+ const value = api.data.$self.value;
3972
+ if(!_.isEmpty(value)){
3973
+ // value 不为空值,表示返回当前选中节点信息
3974
+ return payload;
3975
+ }
3971
3976
  if(enable_tree){
3972
3977
  const records = payload.data.rows;
3973
3978
  const treeRecords = [];
@@ -6635,7 +6640,7 @@ async function getCalendarApi(mainObject, fields, options) {
6635
6640
  const searchableFields = [];
6636
6641
  let { filter, sort, top, setDataToComponentId = '' } = options;
6637
6642
 
6638
- if(!top){
6643
+ if (!top) {
6639
6644
  // 日历请求不翻页
6640
6645
  top = 200;
6641
6646
  }
@@ -6761,7 +6766,8 @@ async function getCalendarApi(mainObject, fields, options) {
6761
6766
  title: n["${calendarOptions.textExpr}"],
6762
6767
  start: n["${calendarOptions.startDateExpr}"],
6763
6768
  end: n["${calendarOptions.endDateExpr}"],
6764
- allDay: n["${calendarOptions.allDayExpr}"]
6769
+ allDay: n["${calendarOptions.allDayExpr}"],
6770
+ extendedProps: n
6765
6771
  }
6766
6772
  });
6767
6773
  const successCallback = selfData.successCallback;
@@ -6834,7 +6840,7 @@ function getCalendarRecordSaveApi(object, calendarOptions) {
6834
6840
  return payload;
6835
6841
  `,
6836
6842
  headers: {
6837
- Authorization: "Bearer ${context.tenantId},${context.authToken}"
6843
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
6838
6844
  }
6839
6845
  };
6840
6846
  }
@@ -6853,9 +6859,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6853
6859
  calendarOptions = Object.assign({}, DEFAULT_CALENDAR_OPTIONS, _$1.omitBy(calendarOptions, _$1.isNil));
6854
6860
 
6855
6861
  const titleFields = calendarOptions.title || [
6856
- calendarOptions.startDateExpr,
6857
- calendarOptions.endDateExpr,
6858
- calendarOptions.allDayExpr,
6862
+ calendarOptions.startDateExpr,
6863
+ calendarOptions.endDateExpr,
6864
+ calendarOptions.allDayExpr,
6859
6865
  calendarOptions.textExpr
6860
6866
  ];
6861
6867
  let fields = [];
@@ -6879,9 +6885,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6879
6885
  }
6880
6886
  }
6881
6887
  let initialView = calendarOptions.currentView;
6882
- if(initialView){
6888
+ if (initialView) {
6883
6889
  // day, week, month, agenda
6884
- switch(initialView){
6890
+ switch (initialView) {
6885
6891
  case "day":
6886
6892
  initialView = "timeGridDay";
6887
6893
  break;
@@ -6988,19 +6994,154 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6988
6994
  const recordId = "${event.id}";
6989
6995
  const recordPermissionsApi = getCalendarRecordPermissionsApi(objectSchema, recordId);
6990
6996
  const recordSaveApi = getCalendarRecordSaveApi(objectSchema, calendarOptions);
6991
-
6997
+
6992
6998
  const businessHours = {
6993
- daysOfWeek: [ 1, 2, 3, 4, 5 ],
6999
+ daysOfWeek: [1, 2, 3, 4, 5],
6994
7000
  startTime: '08:00',
6995
7001
  endTime: '18:00',
6996
7002
  };
6997
- if(!_$1.isEmpty(calendarOptions.startDayHour)){
7003
+ if (!_$1.isEmpty(calendarOptions.startDayHour)) {
6998
7004
  businessHours.startTime = `${calendarOptions.startDayHour}:00`;
6999
7005
  }
7000
- if(!_$1.isEmpty(calendarOptions.endDayHour)){
7006
+ if (!_$1.isEmpty(calendarOptions.endDayHour)) {
7001
7007
  businessHours.endTime = `${calendarOptions.endDayHour}:00`;
7002
7008
  }
7003
-
7009
+
7010
+ const onEvent = {
7011
+ "getEvents": {
7012
+ "weight": 0,
7013
+ "actions": [
7014
+ {
7015
+ "componentId": "",
7016
+ "args": {
7017
+ },
7018
+ "actionType": "custom",
7019
+ "script": onGetEventsScript
7020
+ }
7021
+ ]
7022
+ },
7023
+ "select": {
7024
+ "weight": 0,
7025
+ "actions": [
7026
+ {
7027
+ "componentId": "",
7028
+ "args": {
7029
+ },
7030
+ "actionType": "custom",
7031
+ "script": onSelectScript
7032
+ }
7033
+ ]
7034
+ },
7035
+ "eventClick": {
7036
+ "weight": 0,
7037
+ "actions": [
7038
+ {
7039
+ "componentId": "",
7040
+ "args": {
7041
+ },
7042
+ "actionType": "custom",
7043
+ "script": onEventClickScript
7044
+ }
7045
+ ]
7046
+ },
7047
+ "eventAdd": {
7048
+ "weight": 0,
7049
+ "actions": [
7050
+ {
7051
+ "componentId": "",
7052
+ "args": {
7053
+ },
7054
+ "actionType": "custom",
7055
+ "script": "console.log('eventAdd'); console.log(event);"
7056
+ }
7057
+ ]
7058
+ },
7059
+ "eventChange": {
7060
+ "weight": 0,
7061
+ "actions": [
7062
+ {
7063
+ "actionType": 'ajax',
7064
+ "args": {
7065
+ "api": recordPermissionsApi
7066
+ }
7067
+ },
7068
+ {
7069
+ "actionType": "toast",
7070
+ "expression": "!event.data.editable",
7071
+ "args": {
7072
+ "msgType": "error",
7073
+ "msg": "您没有编辑该记录的权限!",
7074
+ "position": "top-center"
7075
+ }
7076
+ },
7077
+ {
7078
+ "actionType": 'ajax',
7079
+ "expression": "event.data.editable",
7080
+ "args": {
7081
+ "api": recordSaveApi,
7082
+ "messages": {
7083
+ "success": objectSchema.label + "修改成功",
7084
+ "failed": objectSchema.label + "修改失败!"
7085
+ }
7086
+ }
7087
+ }
7088
+ ]
7089
+ },
7090
+ "eventRemove": {
7091
+ "weight": 0,
7092
+ "actions": [
7093
+ {
7094
+ "componentId": "",
7095
+ "args": {
7096
+ },
7097
+ "actionType": "custom",
7098
+ "script": "console.log('eventRemove'); console.log(event);"
7099
+ }
7100
+ ]
7101
+ },
7102
+ "eventsSet": {
7103
+ "weight": 0,
7104
+ "actions": [
7105
+ {
7106
+ "componentId": "",
7107
+ "args": {
7108
+ },
7109
+ "actionType": "custom",
7110
+ "script": "console.log('eventsSet'); console.log(event);"
7111
+ }
7112
+ ]
7113
+ }
7114
+ };
7115
+
7116
+ Object.assign(onEvent, options.onEvent);
7117
+
7118
+ const config = options.config || {};
7119
+ if(config.eventContent && typeof config.eventContent === "string"){
7120
+ const hasReturn = /\breturn\b/.test(config.eventContent);
7121
+ if(hasReturn){
7122
+ try {
7123
+ // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7124
+ let fn = new Function("arg", config.eventContent);
7125
+ config.eventContent = fn;
7126
+ } catch (e) {
7127
+ console.warn(e);
7128
+ }
7129
+ }
7130
+ }
7131
+
7132
+ if(config.noEventsContent && typeof config.noEventsContent === "string"){
7133
+ const hasReturn = /\breturn\b/.test(config.noEventsContent);
7134
+ if(hasReturn){
7135
+ try {
7136
+ // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7137
+ let fn = new Function("arg", config.noEventsContent);
7138
+ config.noEventsContent = fn;
7139
+ } catch (e) {
7140
+ console.warn(e);
7141
+ }
7142
+ }
7143
+ }
7144
+
7004
7145
  const amisSchema = {
7005
7146
  "type": "steedos-fullcalendar",
7006
7147
  "label": "",
@@ -7010,135 +7151,8 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7010
7151
  "selectMirror": permissions.allowCreate,
7011
7152
  "initialView": initialView,
7012
7153
  "businessHours": businessHours,
7013
- "onEvent": {
7014
- "getEvents": {
7015
- "weight": 0,
7016
- "actions": [
7017
- {
7018
- "componentId": "",
7019
- "args": {
7020
- },
7021
- "actionType": "custom",
7022
- "script": onGetEventsScript
7023
- }
7024
- ]
7025
- },
7026
- "select": {
7027
- "weight": 0,
7028
- "actions": [
7029
- {
7030
- "componentId": "",
7031
- "args": {
7032
- },
7033
- "actionType": "custom",
7034
- "script": onSelectScript
7035
- }
7036
- ]
7037
- },
7038
- "eventClick": {
7039
- "weight": 0,
7040
- "actions": [
7041
- {
7042
- "componentId": "",
7043
- "args": {
7044
- },
7045
- "actionType": "custom",
7046
- "script": onEventClickScript
7047
- }
7048
- ]
7049
- },
7050
- "eventAdd": {
7051
- "weight": 0,
7052
- "actions": [
7053
- {
7054
- "componentId": "",
7055
- "args": {
7056
- },
7057
- "actionType": "custom",
7058
- "script": "console.log('eventAdd'); console.log(event);"
7059
- }
7060
- ]
7061
- },
7062
- "eventChange": {
7063
- "weight": 0,
7064
- "actions": [
7065
- {
7066
- "actionType": 'ajax',
7067
- "args": {
7068
- "api": recordPermissionsApi
7069
- }
7070
- },
7071
- {
7072
- "actionType": "toast",
7073
- "expression": "!event.data.editable",
7074
- "args": {
7075
- "msgType": "error",
7076
- "msg": "您没有编辑该记录的权限!",
7077
- "position": "top-center"
7078
- }
7079
- },
7080
- {
7081
- "actionType": 'ajax',
7082
- "expression": "event.data.editable",
7083
- "args": {
7084
- "api": recordSaveApi,
7085
- "messages": {
7086
- "success": objectSchema.label + "修改成功",
7087
- "failed": objectSchema.label + "修改失败!"
7088
- }
7089
- }
7090
- }
7091
- ]
7092
- },
7093
- "eventRemove": {
7094
- "weight": 0,
7095
- "actions": [
7096
- {
7097
- "componentId": "",
7098
- "args": {
7099
- },
7100
- "actionType": "custom",
7101
- "script": "console.log('eventRemove'); console.log(event);"
7102
- }
7103
- ]
7104
- },
7105
- "eventsSet": {
7106
- "weight": 0,
7107
- "actions": [
7108
- {
7109
- "componentId": "",
7110
- "args": {
7111
- },
7112
- "actionType": "custom",
7113
- "script": "console.log('eventsSet'); console.log(event);"
7114
- }
7115
- ]
7116
- },
7117
- "eventDidMount": {
7118
- "weight": 0,
7119
- "actions": [
7120
- {
7121
- "componentId": "",
7122
- "args": {
7123
- },
7124
- "actionType": "custom",
7125
- "script": "console.log('eventDidMount'); console.log(event);"
7126
- }
7127
- ]
7128
- },
7129
- "eventWillUnmount": {
7130
- "weight": 0,
7131
- "actions": [
7132
- {
7133
- "componentId": "",
7134
- "args": {
7135
- },
7136
- "actionType": "custom",
7137
- "script": "console.log('eventWillUnmount'); console.log(event);"
7138
- }
7139
- ]
7140
- },
7141
- }
7154
+ ...config,
7155
+ "onEvent": onEvent
7142
7156
  };
7143
7157
  return amisSchema;
7144
7158
  }