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