@steedos-widgets/amis-object 1.1.0 → 1.1.1

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.
@@ -4328,6 +4328,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
4328
4328
  `;
4329
4329
  source.adaptor = `
4330
4330
  const enable_tree = ${refObjectConfig.enable_tree};
4331
+ const value = api.data.$self.value;
4332
+ if(!_.isEmpty(value)){
4333
+ // value 不为空值,表示返回当前选中节点信息
4334
+ return payload;
4335
+ }
4331
4336
  if(enable_tree){
4332
4337
  const records = payload.data.rows;
4333
4338
  const treeRecords = [];
@@ -6995,7 +7000,7 @@ async function getCalendarApi(mainObject, fields, options) {
6995
7000
  const searchableFields = [];
6996
7001
  let { filter, sort, top, setDataToComponentId = '' } = options;
6997
7002
 
6998
- if(!top){
7003
+ if (!top) {
6999
7004
  // 日历请求不翻页
7000
7005
  top = 200;
7001
7006
  }
@@ -7121,7 +7126,8 @@ async function getCalendarApi(mainObject, fields, options) {
7121
7126
  title: n["${calendarOptions.textExpr}"],
7122
7127
  start: n["${calendarOptions.startDateExpr}"],
7123
7128
  end: n["${calendarOptions.endDateExpr}"],
7124
- allDay: n["${calendarOptions.allDayExpr}"]
7129
+ allDay: n["${calendarOptions.allDayExpr}"],
7130
+ extendedProps: n
7125
7131
  }
7126
7132
  });
7127
7133
  const successCallback = selfData.successCallback;
@@ -7194,7 +7200,7 @@ function getCalendarRecordSaveApi(object, calendarOptions) {
7194
7200
  return payload;
7195
7201
  `,
7196
7202
  headers: {
7197
- Authorization: "Bearer ${context.tenantId},${context.authToken}"
7203
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
7198
7204
  }
7199
7205
  };
7200
7206
  }
@@ -7213,9 +7219,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7213
7219
  calendarOptions = Object.assign({}, DEFAULT_CALENDAR_OPTIONS, ___default.omitBy(calendarOptions, ___default.isNil));
7214
7220
 
7215
7221
  const titleFields = calendarOptions.title || [
7216
- calendarOptions.startDateExpr,
7217
- calendarOptions.endDateExpr,
7218
- calendarOptions.allDayExpr,
7222
+ calendarOptions.startDateExpr,
7223
+ calendarOptions.endDateExpr,
7224
+ calendarOptions.allDayExpr,
7219
7225
  calendarOptions.textExpr
7220
7226
  ];
7221
7227
  let fields = [];
@@ -7239,9 +7245,9 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7239
7245
  }
7240
7246
  }
7241
7247
  let initialView = calendarOptions.currentView;
7242
- if(initialView){
7248
+ if (initialView) {
7243
7249
  // day, week, month, agenda
7244
- switch(initialView){
7250
+ switch (initialView) {
7245
7251
  case "day":
7246
7252
  initialView = "timeGridDay";
7247
7253
  break;
@@ -7348,19 +7354,154 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7348
7354
  const recordId = "${event.id}";
7349
7355
  const recordPermissionsApi = getCalendarRecordPermissionsApi(objectSchema, recordId);
7350
7356
  const recordSaveApi = getCalendarRecordSaveApi(objectSchema, calendarOptions);
7351
-
7357
+
7352
7358
  const businessHours = {
7353
- daysOfWeek: [ 1, 2, 3, 4, 5 ],
7359
+ daysOfWeek: [1, 2, 3, 4, 5],
7354
7360
  startTime: '08:00',
7355
7361
  endTime: '18:00',
7356
7362
  };
7357
- if(!___default.isEmpty(calendarOptions.startDayHour)){
7363
+ if (!___default.isEmpty(calendarOptions.startDayHour)) {
7358
7364
  businessHours.startTime = `${calendarOptions.startDayHour}:00`;
7359
7365
  }
7360
- if(!___default.isEmpty(calendarOptions.endDayHour)){
7366
+ if (!___default.isEmpty(calendarOptions.endDayHour)) {
7361
7367
  businessHours.endTime = `${calendarOptions.endDayHour}:00`;
7362
7368
  }
7363
-
7369
+
7370
+ const onEvent = {
7371
+ "getEvents": {
7372
+ "weight": 0,
7373
+ "actions": [
7374
+ {
7375
+ "componentId": "",
7376
+ "args": {
7377
+ },
7378
+ "actionType": "custom",
7379
+ "script": onGetEventsScript
7380
+ }
7381
+ ]
7382
+ },
7383
+ "select": {
7384
+ "weight": 0,
7385
+ "actions": [
7386
+ {
7387
+ "componentId": "",
7388
+ "args": {
7389
+ },
7390
+ "actionType": "custom",
7391
+ "script": onSelectScript
7392
+ }
7393
+ ]
7394
+ },
7395
+ "eventClick": {
7396
+ "weight": 0,
7397
+ "actions": [
7398
+ {
7399
+ "componentId": "",
7400
+ "args": {
7401
+ },
7402
+ "actionType": "custom",
7403
+ "script": onEventClickScript
7404
+ }
7405
+ ]
7406
+ },
7407
+ "eventAdd": {
7408
+ "weight": 0,
7409
+ "actions": [
7410
+ {
7411
+ "componentId": "",
7412
+ "args": {
7413
+ },
7414
+ "actionType": "custom",
7415
+ "script": "console.log('eventAdd'); console.log(event);"
7416
+ }
7417
+ ]
7418
+ },
7419
+ "eventChange": {
7420
+ "weight": 0,
7421
+ "actions": [
7422
+ {
7423
+ "actionType": 'ajax',
7424
+ "args": {
7425
+ "api": recordPermissionsApi
7426
+ }
7427
+ },
7428
+ {
7429
+ "actionType": "toast",
7430
+ "expression": "!event.data.editable",
7431
+ "args": {
7432
+ "msgType": "error",
7433
+ "msg": "您没有编辑该记录的权限!",
7434
+ "position": "top-center"
7435
+ }
7436
+ },
7437
+ {
7438
+ "actionType": 'ajax',
7439
+ "expression": "event.data.editable",
7440
+ "args": {
7441
+ "api": recordSaveApi,
7442
+ "messages": {
7443
+ "success": objectSchema.label + "修改成功",
7444
+ "failed": objectSchema.label + "修改失败!"
7445
+ }
7446
+ }
7447
+ }
7448
+ ]
7449
+ },
7450
+ "eventRemove": {
7451
+ "weight": 0,
7452
+ "actions": [
7453
+ {
7454
+ "componentId": "",
7455
+ "args": {
7456
+ },
7457
+ "actionType": "custom",
7458
+ "script": "console.log('eventRemove'); console.log(event);"
7459
+ }
7460
+ ]
7461
+ },
7462
+ "eventsSet": {
7463
+ "weight": 0,
7464
+ "actions": [
7465
+ {
7466
+ "componentId": "",
7467
+ "args": {
7468
+ },
7469
+ "actionType": "custom",
7470
+ "script": "console.log('eventsSet'); console.log(event);"
7471
+ }
7472
+ ]
7473
+ }
7474
+ };
7475
+
7476
+ Object.assign(onEvent, options.onEvent);
7477
+
7478
+ const config = options.config || {};
7479
+ if(config.eventContent && typeof config.eventContent === "string"){
7480
+ const hasReturn = /\breturn\b/.test(config.eventContent);
7481
+ if(hasReturn){
7482
+ try {
7483
+ // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7484
+ let fn = new Function("arg", config.eventContent);
7485
+ config.eventContent = fn;
7486
+ } catch (e) {
7487
+ console.warn(e);
7488
+ }
7489
+ }
7490
+ }
7491
+
7492
+ if(config.noEventsContent && typeof config.noEventsContent === "string"){
7493
+ const hasReturn = /\breturn\b/.test(config.noEventsContent);
7494
+ if(hasReturn){
7495
+ try {
7496
+ // 如果是包括return语句的字符串,则按函数解析,见 https://fullcalendar.io/docs/content-injection
7497
+ let fn = new Function("arg", config.noEventsContent);
7498
+ config.noEventsContent = fn;
7499
+ } catch (e) {
7500
+ console.warn(e);
7501
+ }
7502
+ }
7503
+ }
7504
+
7364
7505
  const amisSchema = {
7365
7506
  "type": "steedos-fullcalendar",
7366
7507
  "label": "",
@@ -7370,135 +7511,8 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7370
7511
  "selectMirror": permissions.allowCreate,
7371
7512
  "initialView": initialView,
7372
7513
  "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
- }
7514
+ ...config,
7515
+ "onEvent": onEvent
7502
7516
  };
7503
7517
  return amisSchema;
7504
7518
  }
@@ -12062,11 +12076,12 @@ var AmisObjectTable = function (props) { return __awaiter(void 0, void 0, void 0
12062
12076
  }); };
12063
12077
 
12064
12078
  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;
12079
+ var top, sort, filters, filtersFunction, title, currentView, startDateExpr, endDateExpr, allDayExpr, textExpr, data, defaultData, _a, className, onEvent, config, objectApiName, amisSchemaData, schema, uiSchema, amisSchema, serviceData;
12066
12080
  return __generator(this, function (_b) {
12067
12081
  switch (_b.label) {
12068
12082
  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;
12083
+ console.log("AmisObjectCalendar props", props);
12084
+ 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
12085
  objectApiName = props.objectApiName || "events";
12071
12086
  amisSchemaData = Object.assign({}, data, defaultData);
12072
12087
  return [4 /*yield*/, getCalendarSchema(amisSchemaData.appId, objectApiName, {
@@ -12076,7 +12091,7 @@ var AmisObjectCalendar = function (props) { return __awaiter(void 0, void 0, voi
12076
12091
  endDateExpr: endDateExpr,
12077
12092
  allDayExpr: allDayExpr,
12078
12093
  textExpr: textExpr
12079
- }, { top: top, sort: sort, filter: filters, filtersFunction: filtersFunction })];
12094
+ }, { top: top, sort: sort, filter: filters, filtersFunction: filtersFunction, onEvent: onEvent, config: config })];
12080
12095
  case 1:
12081
12096
  schema = (_b.sent());
12082
12097
  uiSchema = schema.uiSchema;