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

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.esm.js CHANGED
@@ -1475,8 +1475,8 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
1475
1475
  /*
1476
1476
  * @Author: baozhoutao@steedos.com
1477
1477
  * @Date: 2022-11-01 15:49:58
1478
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1479
- * @LastEditTime: 2023-03-25 17:22:00
1478
+ * @LastEditors: baozhoutao@steedos.com
1479
+ * @LastEditTime: 2022-11-08 16:39:40
1480
1480
  * @Description:
1481
1481
  */
1482
1482
 
@@ -1520,10 +1520,6 @@ const getSchema$3 = async (uiSchema, ctx) => {
1520
1520
  actionType: "dialog",
1521
1521
  dialog: {
1522
1522
  type: "dialog",
1523
- "data": {
1524
- "&": "$$",
1525
- "$master": "$$"
1526
- },
1527
1523
  title: title,
1528
1524
  bodyClassName: "",
1529
1525
  body: [formSchema],
@@ -1546,12 +1542,6 @@ const getSchema$3 = async (uiSchema, ctx) => {
1546
1542
  };
1547
1543
  };
1548
1544
 
1549
- /*
1550
- * @Author: 殷亮辉 yinlianghui@hotoa.com
1551
- * @Date: 2023-03-22 09:31:21
1552
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1553
- * @LastEditTime: 2023-03-25 22:41:27
1554
- */
1555
1545
  const getSchema$2 = (uiSchema)=>{
1556
1546
  return {
1557
1547
  "type": "service",
@@ -1602,16 +1592,6 @@ const getSchema$2 = (uiSchema)=>{
1602
1592
  "objectName": `${uiSchema.name}`,
1603
1593
  "__deletedRecord": true
1604
1594
  }
1605
- },
1606
- {
1607
- "actionType": "broadcast",
1608
- "args": {
1609
- "eventName": "@data.changed.${masterObjectName}"
1610
- },
1611
- "data": {
1612
- "objectName": "${masterObjectName}"
1613
- },
1614
- "expression": "${masterObjectName}"
1615
1595
  }
1616
1596
  ]
1617
1597
  }
@@ -3961,15 +3941,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
3961
3941
  `;
3962
3942
  source.adaptor = `
3963
3943
  const enable_tree = ${refObjectConfig.enable_tree};
3964
- const op = api.data.$self.op;
3965
- if(!_.isEmpty(op)){
3966
- // op不为空,表示处于字段初始编辑状态,不是点击后出现弹窗状态。
3967
- const rows = _.map(payload.data.rows, (item)=>{
3968
- return _.pick(item, ["${referenceTo.labelField.name}", "${referenceTo.valueField.name}"]);
3969
- })
3970
- payload.data.rows = rows;
3971
- return payload;
3972
- }
3973
3944
  if(enable_tree){
3974
3945
  const records = payload.data.rows;
3975
3946
  const treeRecords = [];
@@ -5846,16 +5817,6 @@ async function getObjectForm(objectSchema, ctx){
5846
5817
  "data": {
5847
5818
  "objectName": `${objectSchema.name}`
5848
5819
  }
5849
- },
5850
- {
5851
- "actionType": "broadcast",
5852
- "args": {
5853
- "eventName": "@data.changed.${$master.masterObjectName}"
5854
- },
5855
- "data": {
5856
- "objectName": "${$master.masterObjectName}"
5857
- },
5858
- "expression": "${$master.masterObjectName}"
5859
5820
  }
5860
5821
  ]
5861
5822
  }
@@ -6647,7 +6608,7 @@ async function getCalendarApi(mainObject, fields, options) {
6647
6608
  const searchableFields = [];
6648
6609
  let { filter, sort, top, setDataToComponentId = '' } = options;
6649
6610
 
6650
- if (!top) {
6611
+ if(!top){
6651
6612
  // 日历请求不翻页
6652
6613
  top = 200;
6653
6614
  }
@@ -6773,8 +6734,7 @@ async function getCalendarApi(mainObject, fields, options) {
6773
6734
  title: n["${calendarOptions.textExpr}"],
6774
6735
  start: n["${calendarOptions.startDateExpr}"],
6775
6736
  end: n["${calendarOptions.endDateExpr}"],
6776
- allDay: n["${calendarOptions.allDayExpr}"],
6777
- extendedProps: n
6737
+ allDay: n["${calendarOptions.allDayExpr}"]
6778
6738
  }
6779
6739
  });
6780
6740
  const successCallback = selfData.successCallback;
@@ -6847,7 +6807,7 @@ function getCalendarRecordSaveApi(object, calendarOptions) {
6847
6807
  return payload;
6848
6808
  `,
6849
6809
  headers: {
6850
- Authorization: "Bearer ${context.tenantId},${context.authToken}"
6810
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
6851
6811
  }
6852
6812
  };
6853
6813
  }
@@ -6866,9 +6826,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6866
6826
  calendarOptions = Object.assign({}, DEFAULT_CALENDAR_OPTIONS, omitBy(calendarOptions, isNil));
6867
6827
 
6868
6828
  const titleFields = calendarOptions.title || [
6869
- calendarOptions.startDateExpr,
6870
- calendarOptions.endDateExpr,
6871
- calendarOptions.allDayExpr,
6829
+ calendarOptions.startDateExpr,
6830
+ calendarOptions.endDateExpr,
6831
+ calendarOptions.allDayExpr,
6872
6832
  calendarOptions.textExpr
6873
6833
  ];
6874
6834
  let fields = [];
@@ -6892,9 +6852,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6892
6852
  }
6893
6853
  }
6894
6854
  let initialView = calendarOptions.currentView;
6895
- if (initialView) {
6855
+ if(initialView){
6896
6856
  // day, week, month, agenda
6897
- switch (initialView) {
6857
+ switch(initialView){
6898
6858
  case "day":
6899
6859
  initialView = "timeGridDay";
6900
6860
  break;
@@ -7001,154 +6961,19 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7001
6961
  const recordId = "${event.id}";
7002
6962
  const recordPermissionsApi = getCalendarRecordPermissionsApi(objectSchema, recordId);
7003
6963
  const recordSaveApi = getCalendarRecordSaveApi(objectSchema, calendarOptions);
7004
-
6964
+
7005
6965
  const businessHours = {
7006
- daysOfWeek: [1, 2, 3, 4, 5],
6966
+ daysOfWeek: [ 1, 2, 3, 4, 5 ],
7007
6967
  startTime: '08:00',
7008
6968
  endTime: '18:00',
7009
6969
  };
7010
- if (!isEmpty(calendarOptions.startDayHour)) {
6970
+ if(!isEmpty(calendarOptions.startDayHour)){
7011
6971
  businessHours.startTime = `${calendarOptions.startDayHour}:00`;
7012
6972
  }
7013
- if (!isEmpty(calendarOptions.endDayHour)) {
6973
+ if(!isEmpty(calendarOptions.endDayHour)){
7014
6974
  businessHours.endTime = `${calendarOptions.endDayHour}:00`;
7015
6975
  }
7016
-
7017
- const onEvent = {
7018
- "getEvents": {
7019
- "weight": 0,
7020
- "actions": [
7021
- {
7022
- "componentId": "",
7023
- "args": {
7024
- },
7025
- "actionType": "custom",
7026
- "script": onGetEventsScript
7027
- }
7028
- ]
7029
- },
7030
- "select": {
7031
- "weight": 0,
7032
- "actions": [
7033
- {
7034
- "componentId": "",
7035
- "args": {
7036
- },
7037
- "actionType": "custom",
7038
- "script": onSelectScript
7039
- }
7040
- ]
7041
- },
7042
- "eventClick": {
7043
- "weight": 0,
7044
- "actions": [
7045
- {
7046
- "componentId": "",
7047
- "args": {
7048
- },
7049
- "actionType": "custom",
7050
- "script": onEventClickScript
7051
- }
7052
- ]
7053
- },
7054
- "eventAdd": {
7055
- "weight": 0,
7056
- "actions": [
7057
- {
7058
- "componentId": "",
7059
- "args": {
7060
- },
7061
- "actionType": "custom",
7062
- "script": "console.log('eventAdd'); console.log(event);"
7063
- }
7064
- ]
7065
- },
7066
- "eventChange": {
7067
- "weight": 0,
7068
- "actions": [
7069
- {
7070
- "actionType": 'ajax',
7071
- "args": {
7072
- "api": recordPermissionsApi
7073
- }
7074
- },
7075
- {
7076
- "actionType": "toast",
7077
- "expression": "!event.data.editable",
7078
- "args": {
7079
- "msgType": "error",
7080
- "msg": "您没有编辑该记录的权限!",
7081
- "position": "top-center"
7082
- }
7083
- },
7084
- {
7085
- "actionType": 'ajax',
7086
- "expression": "event.data.editable",
7087
- "args": {
7088
- "api": recordSaveApi,
7089
- "messages": {
7090
- "success": objectSchema.label + "修改成功",
7091
- "failed": objectSchema.label + "修改失败!"
7092
- }
7093
- }
7094
- }
7095
- ]
7096
- },
7097
- "eventRemove": {
7098
- "weight": 0,
7099
- "actions": [
7100
- {
7101
- "componentId": "",
7102
- "args": {
7103
- },
7104
- "actionType": "custom",
7105
- "script": "console.log('eventRemove'); console.log(event);"
7106
- }
7107
- ]
7108
- },
7109
- "eventsSet": {
7110
- "weight": 0,
7111
- "actions": [
7112
- {
7113
- "componentId": "",
7114
- "args": {
7115
- },
7116
- "actionType": "custom",
7117
- "script": "console.log('eventsSet'); console.log(event);"
7118
- }
7119
- ]
7120
- }
7121
- };
7122
-
7123
- Object.assign(onEvent, options.onEvent);
7124
-
7125
- const config = options.config || {};
7126
- if(config.eventContent && typeof config.eventContent === "string"){
7127
- const hasReturn = /\breturn\b/.test(config.eventContent);
7128
- if(hasReturn){
7129
- try {
7130
- // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7131
- let fn = new Function("arg", config.eventContent);
7132
- config.eventContent = fn;
7133
- } catch (e) {
7134
- console.warn(e);
7135
- }
7136
- }
7137
- }
7138
-
7139
- if(config.noEventsContent && typeof config.noEventsContent === "string"){
7140
- const hasReturn = /\breturn\b/.test(config.noEventsContent);
7141
- if(hasReturn){
7142
- try {
7143
- // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7144
- let fn = new Function("arg", config.noEventsContent);
7145
- config.noEventsContent = fn;
7146
- } catch (e) {
7147
- console.warn(e);
7148
- }
7149
- }
7150
- }
7151
-
6976
+
7152
6977
  const amisSchema = {
7153
6978
  "type": "steedos-fullcalendar",
7154
6979
  "label": "",
@@ -7158,8 +6983,135 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7158
6983
  "selectMirror": permissions.allowCreate,
7159
6984
  "initialView": initialView,
7160
6985
  "businessHours": businessHours,
7161
- ...config,
7162
- "onEvent": onEvent
6986
+ "onEvent": {
6987
+ "getEvents": {
6988
+ "weight": 0,
6989
+ "actions": [
6990
+ {
6991
+ "componentId": "",
6992
+ "args": {
6993
+ },
6994
+ "actionType": "custom",
6995
+ "script": onGetEventsScript
6996
+ }
6997
+ ]
6998
+ },
6999
+ "select": {
7000
+ "weight": 0,
7001
+ "actions": [
7002
+ {
7003
+ "componentId": "",
7004
+ "args": {
7005
+ },
7006
+ "actionType": "custom",
7007
+ "script": onSelectScript
7008
+ }
7009
+ ]
7010
+ },
7011
+ "eventClick": {
7012
+ "weight": 0,
7013
+ "actions": [
7014
+ {
7015
+ "componentId": "",
7016
+ "args": {
7017
+ },
7018
+ "actionType": "custom",
7019
+ "script": onEventClickScript
7020
+ }
7021
+ ]
7022
+ },
7023
+ "eventAdd": {
7024
+ "weight": 0,
7025
+ "actions": [
7026
+ {
7027
+ "componentId": "",
7028
+ "args": {
7029
+ },
7030
+ "actionType": "custom",
7031
+ "script": "console.log('eventAdd'); console.log(event);"
7032
+ }
7033
+ ]
7034
+ },
7035
+ "eventChange": {
7036
+ "weight": 0,
7037
+ "actions": [
7038
+ {
7039
+ "actionType": 'ajax',
7040
+ "args": {
7041
+ "api": recordPermissionsApi
7042
+ }
7043
+ },
7044
+ {
7045
+ "actionType": "toast",
7046
+ "expression": "!event.data.editable",
7047
+ "args": {
7048
+ "msgType": "error",
7049
+ "msg": "您没有编辑该记录的权限!",
7050
+ "position": "top-center"
7051
+ }
7052
+ },
7053
+ {
7054
+ "actionType": 'ajax',
7055
+ "expression": "event.data.editable",
7056
+ "args": {
7057
+ "api": recordSaveApi,
7058
+ "messages": {
7059
+ "success": objectSchema.label + "修改成功",
7060
+ "failed": objectSchema.label + "修改失败!"
7061
+ }
7062
+ }
7063
+ }
7064
+ ]
7065
+ },
7066
+ "eventRemove": {
7067
+ "weight": 0,
7068
+ "actions": [
7069
+ {
7070
+ "componentId": "",
7071
+ "args": {
7072
+ },
7073
+ "actionType": "custom",
7074
+ "script": "console.log('eventRemove'); console.log(event);"
7075
+ }
7076
+ ]
7077
+ },
7078
+ "eventsSet": {
7079
+ "weight": 0,
7080
+ "actions": [
7081
+ {
7082
+ "componentId": "",
7083
+ "args": {
7084
+ },
7085
+ "actionType": "custom",
7086
+ "script": "console.log('eventsSet'); console.log(event);"
7087
+ }
7088
+ ]
7089
+ },
7090
+ "eventDidMount": {
7091
+ "weight": 0,
7092
+ "actions": [
7093
+ {
7094
+ "componentId": "",
7095
+ "args": {
7096
+ },
7097
+ "actionType": "custom",
7098
+ "script": "console.log('eventDidMount'); console.log(event);"
7099
+ }
7100
+ ]
7101
+ },
7102
+ "eventWillUnmount": {
7103
+ "weight": 0,
7104
+ "actions": [
7105
+ {
7106
+ "componentId": "",
7107
+ "args": {
7108
+ },
7109
+ "actionType": "custom",
7110
+ "script": "console.log('eventWillUnmount'); console.log(event);"
7111
+ }
7112
+ ]
7113
+ },
7114
+ }
7163
7115
  };
7164
7116
  return amisSchema;
7165
7117
  }