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