@steedos-widgets/amis-object 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.
@@ -1862,8 +1862,8 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
1862
1862
  /*
1863
1863
  * @Author: baozhoutao@steedos.com
1864
1864
  * @Date: 2022-11-01 15:49:58
1865
- * @LastEditors: baozhoutao@steedos.com
1866
- * @LastEditTime: 2022-11-08 16:39:40
1865
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1866
+ * @LastEditTime: 2023-03-25 17:22:00
1867
1867
  * @Description:
1868
1868
  */
1869
1869
 
@@ -1907,6 +1907,10 @@ const getSchema$3 = async (uiSchema, ctx) => {
1907
1907
  actionType: "dialog",
1908
1908
  dialog: {
1909
1909
  type: "dialog",
1910
+ "data": {
1911
+ "&": "$$",
1912
+ "$master": "$$"
1913
+ },
1910
1914
  title: title,
1911
1915
  bodyClassName: "",
1912
1916
  body: [formSchema],
@@ -1929,6 +1933,12 @@ const getSchema$3 = async (uiSchema, ctx) => {
1929
1933
  };
1930
1934
  };
1931
1935
 
1936
+ /*
1937
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
1938
+ * @Date: 2023-03-22 09:31:21
1939
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1940
+ * @LastEditTime: 2023-03-25 22:41:27
1941
+ */
1932
1942
  const getSchema$2 = (uiSchema)=>{
1933
1943
  return {
1934
1944
  "type": "service",
@@ -1979,6 +1989,16 @@ const getSchema$2 = (uiSchema)=>{
1979
1989
  "objectName": `${uiSchema.name}`,
1980
1990
  "__deletedRecord": true
1981
1991
  }
1992
+ },
1993
+ {
1994
+ "actionType": "broadcast",
1995
+ "args": {
1996
+ "eventName": "@data.changed.${masterObjectName}"
1997
+ },
1998
+ "data": {
1999
+ "objectName": "${masterObjectName}"
2000
+ },
2001
+ "expression": "${masterObjectName}"
1982
2002
  }
1983
2003
  ]
1984
2004
  }
@@ -4328,6 +4348,15 @@ async function lookupToAmisPicker(field, readonly, ctx){
4328
4348
  `;
4329
4349
  source.adaptor = `
4330
4350
  const enable_tree = ${refObjectConfig.enable_tree};
4351
+ const op = api.data.$self.op;
4352
+ if(!_.isEmpty(op)){
4353
+ // op不为空,表示处于字段初始编辑状态,不是点击后出现弹窗状态。
4354
+ const rows = _.map(payload.data.rows, (item)=>{
4355
+ return _.pick(item, ["${referenceTo.labelField.name}", "${referenceTo.valueField.name}"]);
4356
+ })
4357
+ payload.data.rows = rows;
4358
+ return payload;
4359
+ }
4331
4360
  if(enable_tree){
4332
4361
  const records = payload.data.rows;
4333
4362
  const treeRecords = [];
@@ -6204,6 +6233,16 @@ async function getObjectForm(objectSchema, ctx){
6204
6233
  "data": {
6205
6234
  "objectName": `${objectSchema.name}`
6206
6235
  }
6236
+ },
6237
+ {
6238
+ "actionType": "broadcast",
6239
+ "args": {
6240
+ "eventName": "@data.changed.${$master.masterObjectName}"
6241
+ },
6242
+ "data": {
6243
+ "objectName": "${$master.masterObjectName}"
6244
+ },
6245
+ "expression": "${$master.masterObjectName}"
6207
6246
  }
6208
6247
  ]
6209
6248
  }
@@ -6995,7 +7034,7 @@ async function getCalendarApi(mainObject, fields, options) {
6995
7034
  const searchableFields = [];
6996
7035
  let { filter, sort, top, setDataToComponentId = '' } = options;
6997
7036
 
6998
- if(!top){
7037
+ if (!top) {
6999
7038
  // 日历请求不翻页
7000
7039
  top = 200;
7001
7040
  }
@@ -7121,7 +7160,8 @@ async function getCalendarApi(mainObject, fields, options) {
7121
7160
  title: n["${calendarOptions.textExpr}"],
7122
7161
  start: n["${calendarOptions.startDateExpr}"],
7123
7162
  end: n["${calendarOptions.endDateExpr}"],
7124
- allDay: n["${calendarOptions.allDayExpr}"]
7163
+ allDay: n["${calendarOptions.allDayExpr}"],
7164
+ extendedProps: n
7125
7165
  }
7126
7166
  });
7127
7167
  const successCallback = selfData.successCallback;
@@ -7194,7 +7234,7 @@ function getCalendarRecordSaveApi(object, calendarOptions) {
7194
7234
  return payload;
7195
7235
  `,
7196
7236
  headers: {
7197
- Authorization: "Bearer ${context.tenantId},${context.authToken}"
7237
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
7198
7238
  }
7199
7239
  };
7200
7240
  }
@@ -7213,9 +7253,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7213
7253
  calendarOptions = Object.assign({}, DEFAULT_CALENDAR_OPTIONS, ___default.omitBy(calendarOptions, ___default.isNil));
7214
7254
 
7215
7255
  const titleFields = calendarOptions.title || [
7216
- calendarOptions.startDateExpr,
7217
- calendarOptions.endDateExpr,
7218
- calendarOptions.allDayExpr,
7256
+ calendarOptions.startDateExpr,
7257
+ calendarOptions.endDateExpr,
7258
+ calendarOptions.allDayExpr,
7219
7259
  calendarOptions.textExpr
7220
7260
  ];
7221
7261
  let fields = [];
@@ -7239,9 +7279,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7239
7279
  }
7240
7280
  }
7241
7281
  let initialView = calendarOptions.currentView;
7242
- if(initialView){
7282
+ if (initialView) {
7243
7283
  // day, week, month, agenda
7244
- switch(initialView){
7284
+ switch (initialView) {
7245
7285
  case "day":
7246
7286
  initialView = "timeGridDay";
7247
7287
  break;
@@ -7348,19 +7388,154 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7348
7388
  const recordId = "${event.id}";
7349
7389
  const recordPermissionsApi = getCalendarRecordPermissionsApi(objectSchema, recordId);
7350
7390
  const recordSaveApi = getCalendarRecordSaveApi(objectSchema, calendarOptions);
7351
-
7391
+
7352
7392
  const businessHours = {
7353
- daysOfWeek: [ 1, 2, 3, 4, 5 ],
7393
+ daysOfWeek: [1, 2, 3, 4, 5],
7354
7394
  startTime: '08:00',
7355
7395
  endTime: '18:00',
7356
7396
  };
7357
- if(!___default.isEmpty(calendarOptions.startDayHour)){
7397
+ if (!___default.isEmpty(calendarOptions.startDayHour)) {
7358
7398
  businessHours.startTime = `${calendarOptions.startDayHour}:00`;
7359
7399
  }
7360
- if(!___default.isEmpty(calendarOptions.endDayHour)){
7400
+ if (!___default.isEmpty(calendarOptions.endDayHour)) {
7361
7401
  businessHours.endTime = `${calendarOptions.endDayHour}:00`;
7362
7402
  }
7363
-
7403
+
7404
+ const onEvent = {
7405
+ "getEvents": {
7406
+ "weight": 0,
7407
+ "actions": [
7408
+ {
7409
+ "componentId": "",
7410
+ "args": {
7411
+ },
7412
+ "actionType": "custom",
7413
+ "script": onGetEventsScript
7414
+ }
7415
+ ]
7416
+ },
7417
+ "select": {
7418
+ "weight": 0,
7419
+ "actions": [
7420
+ {
7421
+ "componentId": "",
7422
+ "args": {
7423
+ },
7424
+ "actionType": "custom",
7425
+ "script": onSelectScript
7426
+ }
7427
+ ]
7428
+ },
7429
+ "eventClick": {
7430
+ "weight": 0,
7431
+ "actions": [
7432
+ {
7433
+ "componentId": "",
7434
+ "args": {
7435
+ },
7436
+ "actionType": "custom",
7437
+ "script": onEventClickScript
7438
+ }
7439
+ ]
7440
+ },
7441
+ "eventAdd": {
7442
+ "weight": 0,
7443
+ "actions": [
7444
+ {
7445
+ "componentId": "",
7446
+ "args": {
7447
+ },
7448
+ "actionType": "custom",
7449
+ "script": "console.log('eventAdd'); console.log(event);"
7450
+ }
7451
+ ]
7452
+ },
7453
+ "eventChange": {
7454
+ "weight": 0,
7455
+ "actions": [
7456
+ {
7457
+ "actionType": 'ajax',
7458
+ "args": {
7459
+ "api": recordPermissionsApi
7460
+ }
7461
+ },
7462
+ {
7463
+ "actionType": "toast",
7464
+ "expression": "!event.data.editable",
7465
+ "args": {
7466
+ "msgType": "error",
7467
+ "msg": "您没有编辑该记录的权限!",
7468
+ "position": "top-center"
7469
+ }
7470
+ },
7471
+ {
7472
+ "actionType": 'ajax',
7473
+ "expression": "event.data.editable",
7474
+ "args": {
7475
+ "api": recordSaveApi,
7476
+ "messages": {
7477
+ "success": objectSchema.label + "修改成功",
7478
+ "failed": objectSchema.label + "修改失败!"
7479
+ }
7480
+ }
7481
+ }
7482
+ ]
7483
+ },
7484
+ "eventRemove": {
7485
+ "weight": 0,
7486
+ "actions": [
7487
+ {
7488
+ "componentId": "",
7489
+ "args": {
7490
+ },
7491
+ "actionType": "custom",
7492
+ "script": "console.log('eventRemove'); console.log(event);"
7493
+ }
7494
+ ]
7495
+ },
7496
+ "eventsSet": {
7497
+ "weight": 0,
7498
+ "actions": [
7499
+ {
7500
+ "componentId": "",
7501
+ "args": {
7502
+ },
7503
+ "actionType": "custom",
7504
+ "script": "console.log('eventsSet'); console.log(event);"
7505
+ }
7506
+ ]
7507
+ }
7508
+ };
7509
+
7510
+ Object.assign(onEvent, options.onEvent);
7511
+
7512
+ const config = options.config || {};
7513
+ if(config.eventContent && typeof config.eventContent === "string"){
7514
+ const hasReturn = /\breturn\b/.test(config.eventContent);
7515
+ if(hasReturn){
7516
+ try {
7517
+ // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7518
+ let fn = new Function("arg", config.eventContent);
7519
+ config.eventContent = fn;
7520
+ } catch (e) {
7521
+ console.warn(e);
7522
+ }
7523
+ }
7524
+ }
7525
+
7526
+ if(config.noEventsContent && typeof config.noEventsContent === "string"){
7527
+ const hasReturn = /\breturn\b/.test(config.noEventsContent);
7528
+ if(hasReturn){
7529
+ try {
7530
+ // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7531
+ let fn = new Function("arg", config.noEventsContent);
7532
+ config.noEventsContent = fn;
7533
+ } catch (e) {
7534
+ console.warn(e);
7535
+ }
7536
+ }
7537
+ }
7538
+
7364
7539
  const amisSchema = {
7365
7540
  "type": "steedos-fullcalendar",
7366
7541
  "label": "",
@@ -7370,135 +7545,8 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7370
7545
  "selectMirror": permissions.allowCreate,
7371
7546
  "initialView": initialView,
7372
7547
  "businessHours": businessHours,
7373
- "onEvent": {
7374
- "getEvents": {
7375
- "weight": 0,
7376
- "actions": [
7377
- {
7378
- "componentId": "",
7379
- "args": {
7380
- },
7381
- "actionType": "custom",
7382
- "script": onGetEventsScript
7383
- }
7384
- ]
7385
- },
7386
- "select": {
7387
- "weight": 0,
7388
- "actions": [
7389
- {
7390
- "componentId": "",
7391
- "args": {
7392
- },
7393
- "actionType": "custom",
7394
- "script": onSelectScript
7395
- }
7396
- ]
7397
- },
7398
- "eventClick": {
7399
- "weight": 0,
7400
- "actions": [
7401
- {
7402
- "componentId": "",
7403
- "args": {
7404
- },
7405
- "actionType": "custom",
7406
- "script": onEventClickScript
7407
- }
7408
- ]
7409
- },
7410
- "eventAdd": {
7411
- "weight": 0,
7412
- "actions": [
7413
- {
7414
- "componentId": "",
7415
- "args": {
7416
- },
7417
- "actionType": "custom",
7418
- "script": "console.log('eventAdd'); console.log(event);"
7419
- }
7420
- ]
7421
- },
7422
- "eventChange": {
7423
- "weight": 0,
7424
- "actions": [
7425
- {
7426
- "actionType": 'ajax',
7427
- "args": {
7428
- "api": recordPermissionsApi
7429
- }
7430
- },
7431
- {
7432
- "actionType": "toast",
7433
- "expression": "!event.data.editable",
7434
- "args": {
7435
- "msgType": "error",
7436
- "msg": "您没有编辑该记录的权限!",
7437
- "position": "top-center"
7438
- }
7439
- },
7440
- {
7441
- "actionType": 'ajax',
7442
- "expression": "event.data.editable",
7443
- "args": {
7444
- "api": recordSaveApi,
7445
- "messages": {
7446
- "success": objectSchema.label + "修改成功",
7447
- "failed": objectSchema.label + "修改失败!"
7448
- }
7449
- }
7450
- }
7451
- ]
7452
- },
7453
- "eventRemove": {
7454
- "weight": 0,
7455
- "actions": [
7456
- {
7457
- "componentId": "",
7458
- "args": {
7459
- },
7460
- "actionType": "custom",
7461
- "script": "console.log('eventRemove'); console.log(event);"
7462
- }
7463
- ]
7464
- },
7465
- "eventsSet": {
7466
- "weight": 0,
7467
- "actions": [
7468
- {
7469
- "componentId": "",
7470
- "args": {
7471
- },
7472
- "actionType": "custom",
7473
- "script": "console.log('eventsSet'); console.log(event);"
7474
- }
7475
- ]
7476
- },
7477
- "eventDidMount": {
7478
- "weight": 0,
7479
- "actions": [
7480
- {
7481
- "componentId": "",
7482
- "args": {
7483
- },
7484
- "actionType": "custom",
7485
- "script": "console.log('eventDidMount'); console.log(event);"
7486
- }
7487
- ]
7488
- },
7489
- "eventWillUnmount": {
7490
- "weight": 0,
7491
- "actions": [
7492
- {
7493
- "componentId": "",
7494
- "args": {
7495
- },
7496
- "actionType": "custom",
7497
- "script": "console.log('eventWillUnmount'); console.log(event);"
7498
- }
7499
- ]
7500
- },
7501
- }
7548
+ ...config,
7549
+ "onEvent": onEvent
7502
7550
  };
7503
7551
  return amisSchema;
7504
7552
  }
@@ -12062,11 +12110,12 @@ var AmisObjectTable = function (props) { return __awaiter(void 0, void 0, void 0
12062
12110
  }); };
12063
12111
 
12064
12112
  var AmisObjectCalendar = function (props) { return __awaiter(void 0, void 0, void 0, function () {
12065
- var top, sort, filters, filtersFunction, title, currentView, startDateExpr, endDateExpr, allDayExpr, textExpr, data, defaultData, _a, className, objectApiName, amisSchemaData, schema, uiSchema, amisSchema, serviceData;
12113
+ var top, sort, filters, filtersFunction, title, currentView, startDateExpr, endDateExpr, allDayExpr, textExpr, data, defaultData, _a, className, onEvent, config, objectApiName, amisSchemaData, schema, uiSchema, amisSchema, serviceData;
12066
12114
  return __generator(this, function (_b) {
12067
12115
  switch (_b.label) {
12068
12116
  case 0:
12069
- props.$schema, top = props.top, sort = props.sort, filters = props.filters, filtersFunction = props.filtersFunction, title = props.title, currentView = props.currentView, startDateExpr = props.startDateExpr, endDateExpr = props.endDateExpr, allDayExpr = props.allDayExpr, textExpr = props.textExpr, data = props.data, defaultData = props.defaultData, _a = props.className, className = _a === void 0 ? "" : _a;
12117
+ console.log("AmisObjectCalendar props", props);
12118
+ props.$schema, top = props.top, sort = props.sort, filters = props.filters, filtersFunction = props.filtersFunction, title = props.title, currentView = props.currentView, startDateExpr = props.startDateExpr, endDateExpr = props.endDateExpr, allDayExpr = props.allDayExpr, textExpr = props.textExpr, data = props.data, defaultData = props.defaultData, _a = props.className, className = _a === void 0 ? "" : _a, onEvent = props.onEvent, config = props.config;
12070
12119
  objectApiName = props.objectApiName || "events";
12071
12120
  amisSchemaData = Object.assign({}, data, defaultData);
12072
12121
  return [4 /*yield*/, getCalendarSchema(amisSchemaData.appId, objectApiName, {
@@ -12076,7 +12125,7 @@ var AmisObjectCalendar = function (props) { return __awaiter(void 0, void 0, voi
12076
12125
  endDateExpr: endDateExpr,
12077
12126
  allDayExpr: allDayExpr,
12078
12127
  textExpr: textExpr
12079
- }, { top: top, sort: sort, filter: filters, filtersFunction: filtersFunction })];
12128
+ }, { top: top, sort: sort, filter: filters, filtersFunction: filtersFunction, onEvent: onEvent, config: config })];
12080
12129
  case 1:
12081
12130
  schema = (_b.sent());
12082
12131
  uiSchema = schema.uiSchema;
@@ -13166,7 +13215,7 @@ var PageListView = function (props) { return __awaiter(void 0, void 0, void 0, f
13166
13215
  "showHeader": true,
13167
13216
  "showDisplayAs": (defaultFormFactor !== 'SMALL'),
13168
13217
  "formFactor": formFactor,
13169
- "className": (displayAs === 'split') ? 'w-full' : 'p-0 flex-1 overflow-hidden h-full sm:m-3 sm:mb-0 sm:border sm:shadow sm:rounded border-slate-300 border-solid bg-gray-100'
13218
+ "className": (displayAs === 'split') ? 'w-full' : 'p-0 flex-1 sm:m-3 sm:mb-0 sm:border sm:shadow sm:rounded border-slate-300 border-solid bg-gray-100'
13170
13219
  };
13171
13220
  defData = __assign$2(__assign$2({}, $schema.data), { objectName: objectApiName, listViewId: listViewId, listName: listviewId, appId: appId, formFactor: formFactor, displayAs: displayAs });
13172
13221
  return [2 /*return*/, {