@steedos-widgets/amis-lib 1.1.3-beta.7 → 1.1.3

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