@steedos-widgets/amis-lib 1.1.0 → 1.1.2

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
@@ -1502,8 +1502,8 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
1502
1502
  /*
1503
1503
  * @Author: baozhoutao@steedos.com
1504
1504
  * @Date: 2022-11-01 15:49:58
1505
- * @LastEditors: baozhoutao@steedos.com
1506
- * @LastEditTime: 2022-11-08 16:39:40
1505
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1506
+ * @LastEditTime: 2023-03-25 17:22:00
1507
1507
  * @Description:
1508
1508
  */
1509
1509
 
@@ -1547,6 +1547,10 @@ const getSchema$3 = async (uiSchema, ctx) => {
1547
1547
  actionType: "dialog",
1548
1548
  dialog: {
1549
1549
  type: "dialog",
1550
+ "data": {
1551
+ "&": "$$",
1552
+ "$master": "$$"
1553
+ },
1550
1554
  title: title,
1551
1555
  bodyClassName: "",
1552
1556
  body: [formSchema],
@@ -1569,6 +1573,12 @@ const getSchema$3 = async (uiSchema, ctx) => {
1569
1573
  };
1570
1574
  };
1571
1575
 
1576
+ /*
1577
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
1578
+ * @Date: 2023-03-22 09:31:21
1579
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1580
+ * @LastEditTime: 2023-03-25 22:41:27
1581
+ */
1572
1582
  const getSchema$2 = (uiSchema)=>{
1573
1583
  return {
1574
1584
  "type": "service",
@@ -1619,6 +1629,16 @@ const getSchema$2 = (uiSchema)=>{
1619
1629
  "objectName": `${uiSchema.name}`,
1620
1630
  "__deletedRecord": true
1621
1631
  }
1632
+ },
1633
+ {
1634
+ "actionType": "broadcast",
1635
+ "args": {
1636
+ "eventName": "@data.changed.${masterObjectName}"
1637
+ },
1638
+ "data": {
1639
+ "objectName": "${masterObjectName}"
1640
+ },
1641
+ "expression": "${masterObjectName}"
1622
1642
  }
1623
1643
  ]
1624
1644
  }
@@ -3968,6 +3988,15 @@ async function lookupToAmisPicker(field, readonly, ctx){
3968
3988
  `;
3969
3989
  source.adaptor = `
3970
3990
  const enable_tree = ${refObjectConfig.enable_tree};
3991
+ const op = api.data.$self.op;
3992
+ if(!_.isEmpty(op)){
3993
+ // op不为空,表示处于字段初始编辑状态,不是点击后出现弹窗状态。
3994
+ const rows = _.map(payload.data.rows, (item)=>{
3995
+ return _.pick(item, ["${referenceTo.labelField.name}", "${referenceTo.valueField.name}"]);
3996
+ })
3997
+ payload.data.rows = rows;
3998
+ return payload;
3999
+ }
3971
4000
  if(enable_tree){
3972
4001
  const records = payload.data.rows;
3973
4002
  const treeRecords = [];
@@ -5844,6 +5873,16 @@ async function getObjectForm(objectSchema, ctx){
5844
5873
  "data": {
5845
5874
  "objectName": `${objectSchema.name}`
5846
5875
  }
5876
+ },
5877
+ {
5878
+ "actionType": "broadcast",
5879
+ "args": {
5880
+ "eventName": "@data.changed.${$master.masterObjectName}"
5881
+ },
5882
+ "data": {
5883
+ "objectName": "${$master.masterObjectName}"
5884
+ },
5885
+ "expression": "${$master.masterObjectName}"
5847
5886
  }
5848
5887
  ]
5849
5888
  }
@@ -6635,7 +6674,7 @@ async function getCalendarApi(mainObject, fields, options) {
6635
6674
  const searchableFields = [];
6636
6675
  let { filter, sort, top, setDataToComponentId = '' } = options;
6637
6676
 
6638
- if(!top){
6677
+ if (!top) {
6639
6678
  // 日历请求不翻页
6640
6679
  top = 200;
6641
6680
  }
@@ -6761,7 +6800,8 @@ async function getCalendarApi(mainObject, fields, options) {
6761
6800
  title: n["${calendarOptions.textExpr}"],
6762
6801
  start: n["${calendarOptions.startDateExpr}"],
6763
6802
  end: n["${calendarOptions.endDateExpr}"],
6764
- allDay: n["${calendarOptions.allDayExpr}"]
6803
+ allDay: n["${calendarOptions.allDayExpr}"],
6804
+ extendedProps: n
6765
6805
  }
6766
6806
  });
6767
6807
  const successCallback = selfData.successCallback;
@@ -6834,7 +6874,7 @@ function getCalendarRecordSaveApi(object, calendarOptions) {
6834
6874
  return payload;
6835
6875
  `,
6836
6876
  headers: {
6837
- Authorization: "Bearer ${context.tenantId},${context.authToken}"
6877
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
6838
6878
  }
6839
6879
  };
6840
6880
  }
@@ -6853,9 +6893,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6853
6893
  calendarOptions = Object.assign({}, DEFAULT_CALENDAR_OPTIONS, _$1.omitBy(calendarOptions, _$1.isNil));
6854
6894
 
6855
6895
  const titleFields = calendarOptions.title || [
6856
- calendarOptions.startDateExpr,
6857
- calendarOptions.endDateExpr,
6858
- calendarOptions.allDayExpr,
6896
+ calendarOptions.startDateExpr,
6897
+ calendarOptions.endDateExpr,
6898
+ calendarOptions.allDayExpr,
6859
6899
  calendarOptions.textExpr
6860
6900
  ];
6861
6901
  let fields = [];
@@ -6879,9 +6919,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6879
6919
  }
6880
6920
  }
6881
6921
  let initialView = calendarOptions.currentView;
6882
- if(initialView){
6922
+ if (initialView) {
6883
6923
  // day, week, month, agenda
6884
- switch(initialView){
6924
+ switch (initialView) {
6885
6925
  case "day":
6886
6926
  initialView = "timeGridDay";
6887
6927
  break;
@@ -6988,19 +7028,154 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6988
7028
  const recordId = "${event.id}";
6989
7029
  const recordPermissionsApi = getCalendarRecordPermissionsApi(objectSchema, recordId);
6990
7030
  const recordSaveApi = getCalendarRecordSaveApi(objectSchema, calendarOptions);
6991
-
7031
+
6992
7032
  const businessHours = {
6993
- daysOfWeek: [ 1, 2, 3, 4, 5 ],
7033
+ daysOfWeek: [1, 2, 3, 4, 5],
6994
7034
  startTime: '08:00',
6995
7035
  endTime: '18:00',
6996
7036
  };
6997
- if(!_$1.isEmpty(calendarOptions.startDayHour)){
7037
+ if (!_$1.isEmpty(calendarOptions.startDayHour)) {
6998
7038
  businessHours.startTime = `${calendarOptions.startDayHour}:00`;
6999
7039
  }
7000
- if(!_$1.isEmpty(calendarOptions.endDayHour)){
7040
+ if (!_$1.isEmpty(calendarOptions.endDayHour)) {
7001
7041
  businessHours.endTime = `${calendarOptions.endDayHour}:00`;
7002
7042
  }
7003
-
7043
+
7044
+ const onEvent = {
7045
+ "getEvents": {
7046
+ "weight": 0,
7047
+ "actions": [
7048
+ {
7049
+ "componentId": "",
7050
+ "args": {
7051
+ },
7052
+ "actionType": "custom",
7053
+ "script": onGetEventsScript
7054
+ }
7055
+ ]
7056
+ },
7057
+ "select": {
7058
+ "weight": 0,
7059
+ "actions": [
7060
+ {
7061
+ "componentId": "",
7062
+ "args": {
7063
+ },
7064
+ "actionType": "custom",
7065
+ "script": onSelectScript
7066
+ }
7067
+ ]
7068
+ },
7069
+ "eventClick": {
7070
+ "weight": 0,
7071
+ "actions": [
7072
+ {
7073
+ "componentId": "",
7074
+ "args": {
7075
+ },
7076
+ "actionType": "custom",
7077
+ "script": onEventClickScript
7078
+ }
7079
+ ]
7080
+ },
7081
+ "eventAdd": {
7082
+ "weight": 0,
7083
+ "actions": [
7084
+ {
7085
+ "componentId": "",
7086
+ "args": {
7087
+ },
7088
+ "actionType": "custom",
7089
+ "script": "console.log('eventAdd'); console.log(event);"
7090
+ }
7091
+ ]
7092
+ },
7093
+ "eventChange": {
7094
+ "weight": 0,
7095
+ "actions": [
7096
+ {
7097
+ "actionType": 'ajax',
7098
+ "args": {
7099
+ "api": recordPermissionsApi
7100
+ }
7101
+ },
7102
+ {
7103
+ "actionType": "toast",
7104
+ "expression": "!event.data.editable",
7105
+ "args": {
7106
+ "msgType": "error",
7107
+ "msg": "您没有编辑该记录的权限!",
7108
+ "position": "top-center"
7109
+ }
7110
+ },
7111
+ {
7112
+ "actionType": 'ajax',
7113
+ "expression": "event.data.editable",
7114
+ "args": {
7115
+ "api": recordSaveApi,
7116
+ "messages": {
7117
+ "success": objectSchema.label + "修改成功",
7118
+ "failed": objectSchema.label + "修改失败!"
7119
+ }
7120
+ }
7121
+ }
7122
+ ]
7123
+ },
7124
+ "eventRemove": {
7125
+ "weight": 0,
7126
+ "actions": [
7127
+ {
7128
+ "componentId": "",
7129
+ "args": {
7130
+ },
7131
+ "actionType": "custom",
7132
+ "script": "console.log('eventRemove'); console.log(event);"
7133
+ }
7134
+ ]
7135
+ },
7136
+ "eventsSet": {
7137
+ "weight": 0,
7138
+ "actions": [
7139
+ {
7140
+ "componentId": "",
7141
+ "args": {
7142
+ },
7143
+ "actionType": "custom",
7144
+ "script": "console.log('eventsSet'); console.log(event);"
7145
+ }
7146
+ ]
7147
+ }
7148
+ };
7149
+
7150
+ Object.assign(onEvent, options.onEvent);
7151
+
7152
+ const config = options.config || {};
7153
+ if(config.eventContent && typeof config.eventContent === "string"){
7154
+ const hasReturn = /\breturn\b/.test(config.eventContent);
7155
+ if(hasReturn){
7156
+ try {
7157
+ // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7158
+ let fn = new Function("arg", config.eventContent);
7159
+ config.eventContent = fn;
7160
+ } catch (e) {
7161
+ console.warn(e);
7162
+ }
7163
+ }
7164
+ }
7165
+
7166
+ if(config.noEventsContent && typeof config.noEventsContent === "string"){
7167
+ const hasReturn = /\breturn\b/.test(config.noEventsContent);
7168
+ if(hasReturn){
7169
+ try {
7170
+ // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7171
+ let fn = new Function("arg", config.noEventsContent);
7172
+ config.noEventsContent = fn;
7173
+ } catch (e) {
7174
+ console.warn(e);
7175
+ }
7176
+ }
7177
+ }
7178
+
7004
7179
  const amisSchema = {
7005
7180
  "type": "steedos-fullcalendar",
7006
7181
  "label": "",
@@ -7010,135 +7185,8 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7010
7185
  "selectMirror": permissions.allowCreate,
7011
7186
  "initialView": initialView,
7012
7187
  "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
- }
7188
+ ...config,
7189
+ "onEvent": onEvent
7142
7190
  };
7143
7191
  return amisSchema;
7144
7192
  }