@steedos-widgets/amis-lib 1.2.6-beta.9 → 1.2.6

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.cjs.js CHANGED
@@ -1377,26 +1377,11 @@ const parseSingleExpression = function (func, formData, dataPath, global, userSe
1377
1377
  }
1378
1378
  };
1379
1379
 
1380
- /*
1381
- * @Author: baozhoutao@steedos.com
1382
- * @Date: 2022-08-04 10:42:49
1383
- * @LastEditors: baozhoutao@steedos.com
1384
- * @LastEditTime: 2022-08-25 10:28:47
1385
- * @Description:
1386
- */
1387
- var config = {
1388
- listView: {
1389
- newRecordMode: 'modal',
1390
- editRecordMode: 'modal',
1391
- perPage: 20
1392
- }
1393
- };
1394
-
1395
1380
  /*
1396
1381
  * @Author: baozhoutao@steedos.com
1397
1382
  * @Date: 2022-11-01 15:51:00
1398
- * @LastEditors: baozhoutao@steedos.com
1399
- * @LastEditTime: 2023-04-19 20:26:27
1383
+ * @LastEditors: Please set LastEditors
1384
+ * @LastEditTime: 2023-04-26 11:52:04
1400
1385
  * @Description:
1401
1386
  */
1402
1387
 
@@ -1488,7 +1473,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
1488
1473
  "schemaApi": {
1489
1474
  "data": {
1490
1475
  "isLookup": "${isLookup}",
1491
- "_master": "${_master}"
1476
+ "_master": "${_master}",
1477
+ "url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}"
1492
1478
  },
1493
1479
  "url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}",
1494
1480
  "method": "get",
@@ -1497,7 +1483,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
1497
1483
  "headers": {
1498
1484
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
1499
1485
  },
1500
- "requestAdaptor": "",
1486
+ "requestAdaptor": "return { ...api, url: api.body.url }",
1501
1487
  "adaptor": schemaApiAdaptor
1502
1488
  }
1503
1489
  }
@@ -2406,6 +2392,166 @@ const execute = (button, props) => {
2406
2392
 
2407
2393
  const executeButton = execute;
2408
2394
 
2395
+
2396
+ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
2397
+ const { name } = objectSchema;
2398
+ const buttons = getObjectDetailButtons(objectSchema, {});
2399
+ const moreButtons = getObjectDetailMoreButtons(objectSchema, {
2400
+ recordId: recordId,
2401
+ objectName: name
2402
+ });
2403
+ let amisButtonsSchema = ___default["default"].map(buttons, (button) => {
2404
+ return {
2405
+ type: 'steedos-object-button',
2406
+ name: button.name,
2407
+ objectName: button.objectName,
2408
+ visibleOn: getButtonVisibleOn$1(button),
2409
+ className: `button_${button.name}`
2410
+ }
2411
+ });
2412
+ let dropdownButtons = ___default["default"].map(moreButtons, (button) => {
2413
+ return {
2414
+ type: 'steedos-object-button',
2415
+ name: button.name,
2416
+ objectName: button.objectName,
2417
+ visibleOn: getButtonVisibleOn$1(button),
2418
+ }
2419
+ });
2420
+ return {
2421
+ buttons: amisButtonsSchema,
2422
+ moreButtons: dropdownButtons
2423
+ };
2424
+ };
2425
+
2426
+ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2427
+ const { buttons, moreButtons } = getObjectDetailHeaderButtons(objectSchema, recordId);
2428
+ if(ctx.formFactor === 'SMALL'){
2429
+ return {
2430
+ "type": "button",
2431
+ "icon": "fa fa-angle-down",
2432
+ "onEvent": {
2433
+ "click": {
2434
+ "actions": [
2435
+ {
2436
+ "actionType": "drawer",
2437
+ "drawer": {
2438
+ "type": "drawer",
2439
+ "title": "操作",
2440
+ "body": [
2441
+ {
2442
+ "type": "button-group",
2443
+ "id": "u:fd837823be5b",
2444
+ "vertical": true,
2445
+ "tiled": true,
2446
+ "buttons": [
2447
+ ...___default["default"].map(buttons, (button)=>{
2448
+ button.className += ' w-full';
2449
+ return button;
2450
+ }),
2451
+ ...___default["default"].map(moreButtons, (button)=>{
2452
+ button.className += ' w-full';
2453
+ return button;
2454
+ })
2455
+ ],
2456
+ "btnLevel": "enhance",
2457
+ "className": "w-full",
2458
+ "btnClassName": "w-full",
2459
+ "size": "lg"
2460
+ }
2461
+ ],
2462
+ "id": "u:9815f7366b9f",
2463
+ "position": "bottom",
2464
+ "closeOnOutside": true,
2465
+ "resizable": false,
2466
+ "className": "buttons-drawer",
2467
+ "bodyClassName": "m-none p-none",
2468
+ "actions": []
2469
+ }
2470
+ }
2471
+ ]
2472
+ }
2473
+ },
2474
+ "id": "u:ee7c7929e6ae"
2475
+ }
2476
+ }else {
2477
+ if(moreButtons.length > 0){
2478
+ const dropdownButtonsSchema = {
2479
+ type: "steedos-dropdown-button",
2480
+ label: "",
2481
+ buttons: moreButtons,
2482
+ className: 'slds-icon'
2483
+ };
2484
+ buttons.push(dropdownButtonsSchema);
2485
+ }
2486
+ return buttons;
2487
+ }
2488
+ };
2489
+
2490
+
2491
+ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
2492
+ const buttons = getListViewButtons(objectSchema, ctx);
2493
+ if(ctx.formFactor === 'SMALL'){
2494
+ return {
2495
+ "type": "button",
2496
+ "icon": "fa fa-angle-down",
2497
+ "onEvent": {
2498
+ "click": {
2499
+ "actions": [
2500
+ {
2501
+ "actionType": "drawer",
2502
+ "drawer": {
2503
+ "type": "drawer",
2504
+ "title": "操作",
2505
+ "body": [
2506
+ {
2507
+ "type": "button-group",
2508
+ "id": "u:fd837823be5b",
2509
+ "vertical": true,
2510
+ "tiled": true,
2511
+ "buttons": [
2512
+ ...___default["default"].map(buttons, (button)=>{
2513
+ return {
2514
+ type: 'steedos-object-button',
2515
+ name: button.name,
2516
+ objectName: button.objectName,
2517
+ visibleOn: getButtonVisibleOn$1(button),
2518
+ className: `button_${button.name} w-full`
2519
+ }
2520
+ })
2521
+ ],
2522
+ "btnLevel": "enhance",
2523
+ "className": "w-full",
2524
+ "btnClassName": "w-full",
2525
+ "size": "lg"
2526
+ }
2527
+ ],
2528
+ "id": "u:9815f7366b9f",
2529
+ "position": "bottom",
2530
+ "closeOnOutside": true,
2531
+ "resizable": false,
2532
+ "className": "buttons-drawer",
2533
+ "bodyClassName": "m-none p-none",
2534
+ "actions": []
2535
+ }
2536
+ }
2537
+ ]
2538
+ }
2539
+ },
2540
+ "id": "u:ee7c7929e6ae"
2541
+ }
2542
+ }else {
2543
+ return ___default["default"].map(buttons, (button) => {
2544
+ return {
2545
+ type: 'steedos-object-button',
2546
+ name: button.name,
2547
+ objectName: button.objectName,
2548
+ visibleOn: getButtonVisibleOn$1(button),
2549
+ className: `button_${button.name}`
2550
+ }
2551
+ });
2552
+ }
2553
+ };
2554
+
2409
2555
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2410
2556
  // const amisListViewId = `listview_${objectSchema.name}`;
2411
2557
  return {
@@ -2539,6 +2685,35 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2539
2685
  // }
2540
2686
  // listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
2541
2687
  `;
2688
+ const onResetScript = `
2689
+ const scope = event.context.scoped;
2690
+ var filterForm = scope.parent.parent.getComponents().find(function(n){
2691
+ return n.props.type === "form";
2692
+ });
2693
+ var filterFormValues = filterForm.getValues();
2694
+ var listView = scope.parent.parent.parent.getComponents().find(function(n){
2695
+ return n.props.type === "crud";
2696
+ });
2697
+ const removedValues = {};
2698
+ for(var k in filterFormValues){
2699
+ if(/^__searchable__/.test(k)){
2700
+ removedValues[k] = "";
2701
+ }
2702
+ }
2703
+ if(!event.data.isLookup){
2704
+ // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
2705
+ const listViewId = event.data.listViewId;
2706
+ const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
2707
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
2708
+ if(localListViewProps){
2709
+ localListViewProps = JSON.parse(localListViewProps);
2710
+ for(var k in localListViewProps){
2711
+ removedValues[k] = "";
2712
+ }
2713
+ }
2714
+ }
2715
+ listView.handleFilterSubmit(removedValues);
2716
+ `;
2542
2717
  const dataProviderInited = `
2543
2718
  const objectName = data.objectName;
2544
2719
  const isLookup = data.isLookup;
@@ -2732,6 +2907,21 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2732
2907
  }
2733
2908
  }
2734
2909
  },
2910
+ {
2911
+ "type": "button",
2912
+ "label": "重置",
2913
+ "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
2914
+ "onEvent": {
2915
+ "click": {
2916
+ "actions": [
2917
+ {
2918
+ "actionType": "custom",
2919
+ "script": onResetScript
2920
+ }
2921
+ ]
2922
+ }
2923
+ }
2924
+ },
2735
2925
  {
2736
2926
  "type": "button",
2737
2927
  "label": "设置搜索项",
@@ -2888,17 +3078,7 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
2888
3078
  }
2889
3079
  );
2890
3080
 
2891
- const buttons = getListViewButtons(objectSchema, {});
2892
- let amisButtonsSchema = _$1.map(buttons, (button) => {
2893
- return {
2894
- type: 'steedos-object-button',
2895
- name: button.name,
2896
- objectName: button.objectName,
2897
- visibleOn: getButtonVisibleOn$1(button),
2898
- className: `button_${button.name}`
2899
- }
2900
- });
2901
-
3081
+ let amisButtonsSchema = getObjectListViewButtonsSchemas(objectSchema, {formFactor: ctx.formFactor});
2902
3082
  const reg = new RegExp('_', 'g');
2903
3083
  const standardIcon = icon && icon.replace(reg, '-');
2904
3084
  return {
@@ -2931,8 +3111,8 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
2931
3111
  },
2932
3112
  {
2933
3113
  "type": "dropdown-button",
2934
- "className": "",
2935
- "label": "\${uiSchema.list_views[listName].label}",
3114
+ "className": "",
3115
+ "label": "\${listName ? uiSchema.list_views[listName].label : uiSchema.list_views[defaultListName].label}",
2936
3116
  "rightIcon": "fa fa-caret-down",
2937
3117
  "size": "sm",
2938
3118
  "hideCaret": true,
@@ -3080,7 +3260,10 @@ async function getObjectListHeaderFieldsFilterBar(objectSchema, listViewName, ct
3080
3260
  * @returns amisSchema
3081
3261
  */
3082
3262
  function getObjectListHeader$1(objectSchema, listViewName, ctx) {
3083
- let firstLineSchema = getObjectListHeaderFirstLine(objectSchema);
3263
+ if (!ctx) {
3264
+ ctx = {};
3265
+ }
3266
+ let firstLineSchema = getObjectListHeaderFirstLine(objectSchema, listViewName, ctx);
3084
3267
  let body = [firstLineSchema];
3085
3268
  let headerSchema = [{
3086
3269
  "type": "wrapper",
@@ -3101,35 +3284,11 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3101
3284
  const { showRecordTitle = true } = options || {};
3102
3285
  // console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
3103
3286
  const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
3104
- const buttons = getObjectDetailButtons(objectSchema, {});
3105
- const moreButtons = getObjectDetailMoreButtons(objectSchema, {
3106
- recordId: recordId,
3107
- objectName: name
3108
- });
3109
- let amisButtonsSchema = _$1.map(buttons, (button) => {
3110
- return {
3111
- type: 'steedos-object-button',
3112
- name: button.name,
3113
- objectName: button.objectName,
3114
- visibleOn: getButtonVisibleOn$1(button),
3115
- className: `button_${button.name}`
3116
- }
3117
- });
3118
- let dropdownButtons = _$1.map(moreButtons, (button) => {
3119
- return {
3120
- type: 'steedos-object-button',
3121
- name: button.name,
3122
- objectName: button.objectName,
3123
- visibleOn: getButtonVisibleOn$1(button),
3124
- }
3125
- });
3126
- const dropdownButtonsSchema = {
3127
- type: "steedos-dropdown-button",
3128
- label: "",
3129
- buttons: dropdownButtons,
3130
- className: 'slds-icon'
3131
- };
3132
- amisButtonsSchema.push(dropdownButtonsSchema);
3287
+
3288
+ let amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
3289
+
3290
+ // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
3291
+
3133
3292
  const reg = new RegExp('_', 'g');
3134
3293
  const standardIcon = icon && icon.replace(reg, '-');
3135
3294
 
@@ -3340,8 +3499,8 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
3340
3499
  "icon": "fa fa-table-columns",
3341
3500
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3342
3501
  "align": "right",
3343
- "visibleOn": "${formFactor !== 'SMALL'}",
3344
- "buttons": [
3502
+ "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
3503
+ "buttons": [
3345
3504
  {
3346
3505
  "label": "显示为",
3347
3506
  "children": buttons
@@ -3438,6 +3597,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3438
3597
  `;
3439
3598
  return [
3440
3599
  // "bulkActions",
3600
+ ...(headerToolbarItems || []),
3441
3601
  hiddenCount ? {} :{
3442
3602
  "type": "tpl",
3443
3603
  "tpl": "${count} 个项目"
@@ -3582,7 +3742,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3582
3742
  "list_view": "${uiSchema.list_views[listName]}",
3583
3743
  "appId": "${appId}",
3584
3744
  "global": "${global}",
3585
- "objectName": "${objectName}",
3745
+ "targetObjectName": "${objectName}",
3586
3746
  },
3587
3747
  "body": [
3588
3748
  {
@@ -3622,7 +3782,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3622
3782
  {
3623
3783
  "args": {
3624
3784
  // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3625
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3785
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3626
3786
  "blank": false
3627
3787
  },
3628
3788
  "actionType": "url",
@@ -3663,7 +3823,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3663
3823
  "data": {
3664
3824
  "&": "$$",
3665
3825
  "listName": "${listName}",
3666
- "objectName": "${objectName}",
3826
+ "targetObjectName": "${objectName}",
3667
3827
  "list_view": "${uiSchema.list_views[listName]}",
3668
3828
  "appId": "${appId}",
3669
3829
  "global": "${global}"
@@ -3706,7 +3866,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3706
3866
  "actions": [
3707
3867
  {
3708
3868
  "args": {
3709
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3869
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3710
3870
  "blank": false
3711
3871
  },
3712
3872
  "actionType": "url",
@@ -3742,7 +3902,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3742
3902
  "type": "dialog",
3743
3903
  "title": "重命名 列表视图",
3744
3904
  "data": {
3745
- "objectName": "${objectName}",
3905
+ "targetObjectName": "${objectName}",
3746
3906
  "recordId": "${uiSchema.list_views[listName]._id}",
3747
3907
  "appId": "${appId}"
3748
3908
  },
@@ -3763,7 +3923,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3763
3923
  "actions": [
3764
3924
  {
3765
3925
  "args": {
3766
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${name}",
3926
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
3767
3927
  "blank": false
3768
3928
  },
3769
3929
  "actionType": "url",
@@ -3837,6 +3997,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3837
3997
  "type": "dialog",
3838
3998
  "title": "过滤设置",
3839
3999
  "data": {
4000
+ "targetObjectName": "${objectName}",
3840
4001
  "objectName": "${objectName}",
3841
4002
  "recordId": "${uiSchema.list_views[listName]._id}",
3842
4003
  "listName": "${listName}",
@@ -3862,7 +4023,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3862
4023
  "actions": [
3863
4024
  {
3864
4025
  "args": {
3865
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4026
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
3866
4027
  "blank": false
3867
4028
  },
3868
4029
  "actionType": "url",
@@ -3900,6 +4061,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3900
4061
  "title": "显示的列",
3901
4062
  "data": {
3902
4063
  "&": "$$",
4064
+ "targetObjectName": "${objectName}",
3903
4065
  "objectName": "${objectName}",
3904
4066
  "recordId": "${uiSchema.list_views[listName]._id}",
3905
4067
  "listName": "${listName}",
@@ -3925,7 +4087,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3925
4087
  "actions": [
3926
4088
  {
3927
4089
  "args": {
3928
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4090
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
3929
4091
  "blank": false
3930
4092
  },
3931
4093
  "actionType": "url"
@@ -3961,6 +4123,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3961
4123
  "title": "弹框标题",
3962
4124
  "data": {
3963
4125
  "&": "$$",
4126
+ "targetObjectName": "${objectName}",
3964
4127
  "objectName": "${objectName}",
3965
4128
  "recordId": "${uiSchema.list_views[listName]._id}",
3966
4129
  "listName": "${listName}",
@@ -3986,7 +4149,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3986
4149
  "actions": [
3987
4150
  {
3988
4151
  "args": {
3989
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4152
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
3990
4153
  "blank": false
3991
4154
  },
3992
4155
  "actionType": "url"
@@ -4534,13 +4697,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
4534
4697
  var sort = orderBy + ' ' + orderDir;
4535
4698
  sort = orderBy ? sort : "${sort}";
4536
4699
  var allowSearchFields = ${JSON.stringify(searchableFields)};
4700
+ let fieldValue;
4537
4701
  if(api.data.$term){
4538
4702
  filters = [["name", "contains", "'+ api.data.$term +'"]];
4539
4703
  }else if(selfData.op === 'loadOptions' && selfData.value){
4540
4704
  if(selfData.value?.indexOf(',') > 0){
4541
- filters = [["${referenceTo.valueField.name}", "=", selfData.value.split(',')]];
4705
+ fieldValue = selfData.value.split(',');
4706
+ filters = [["${referenceTo.valueField.name}", "=", fieldValue]];
4542
4707
  }else{
4543
- filters = [["${referenceTo.valueField.name}", "=", selfData.value]];
4708
+ fieldValue = selfData.value;
4709
+ filters = [["${referenceTo.valueField.name}", "=", fieldValue]];
4544
4710
  }
4545
4711
  }
4546
4712
 
@@ -4594,6 +4760,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
4594
4760
  if(enable_tree){
4595
4761
  pageSize = 10000;
4596
4762
  }
4763
+ if(fieldValue && _.isArray(fieldValue) && fieldValue.length > pageSize){
4764
+ pageSize = fieldValue.length;
4765
+ }
4597
4766
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());
4598
4767
  return api;
4599
4768
  `;
@@ -4674,6 +4843,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
4674
4843
  ...ctx
4675
4844
  });
4676
4845
 
4846
+ pickerSchema.affixHeader = false;
4847
+
4677
4848
  var headerToolbarItems = [];
4678
4849
  const isMobile = window.innerWidth < 768;
4679
4850
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
@@ -4691,14 +4862,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
4691
4862
  pickerSchema.headerToolbar.push(new_button);
4692
4863
  }
4693
4864
  pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
4694
- //TODO: 等待放大镜bug修复,if会去掉,始终显示放大镜
4695
- if(referenceTo.objectName != "space_users" || field.reference_to_field != "user"){
4696
- if (ctx.filterVisible !== false) {
4697
- pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
4698
- isLookup: true,
4699
- ...ctx
4700
- });
4701
- }
4865
+ if (ctx.filterVisible !== false) {
4866
+ pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
4867
+ isLookup: true,
4868
+ ...ctx
4869
+ });
4702
4870
  }
4703
4871
  pickerSchema.data = Object.assign({}, pickerSchema.data, {
4704
4872
  "&": "$$",
@@ -4882,11 +5050,12 @@ async function lookupToAmisSelect(field, readonly, ctx){
4882
5050
  autoComplete: apiInfo,
4883
5051
  searchable: true,
4884
5052
  };
5053
+ //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
4885
5054
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
4886
5055
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
4887
5056
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
4888
5057
  <svg class='slds-icon slds-icon_x-small' aria-hidden='true'>
4889
- <use xlink:href='\${context.rootUrl}/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
5058
+ <use xlink:href='/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
4890
5059
  </svg>
4891
5060
  </span>
4892
5061
  </span>
@@ -4944,8 +5113,10 @@ async function lookupToAmis(field, readonly, ctx){
4944
5113
 
4945
5114
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
4946
5115
  if(ctx.idsDependOn || field.amis){
5116
+ // ids人员点选模式
4947
5117
  return await lookupToAmisIdsPicker(field, readonly, ctx);
4948
5118
  }
5119
+ // 左侧树右侧人员列表的下拉框模式,不再支持,而是执行下面的lookupToAmisPicker函数弹出选人窗口
4949
5120
  // return await lookupToAmisSelectUser(field, readonly, ctx);
4950
5121
  }
4951
5122
 
@@ -5046,6 +5217,9 @@ async function getIdsPickerSchema(field, readonly, ctx){
5046
5217
  top: top,
5047
5218
  ...ctx
5048
5219
  });
5220
+
5221
+ pickerSchema.affixHeader = false;
5222
+
5049
5223
  }
5050
5224
 
5051
5225
  const data = {
@@ -5075,7 +5249,6 @@ async function getIdsPickerSchema(field, readonly, ctx){
5075
5249
  if(readonly){
5076
5250
  data.tpl = await getLookupTpl(field, ctx);
5077
5251
  }
5078
-
5079
5252
  return data;
5080
5253
  }
5081
5254
 
@@ -5654,7 +5827,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
5654
5827
  convertData = {
5655
5828
  type: "editor",
5656
5829
  language: field.language,
5657
- // value: field.defaultValue || ''
5830
+ editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
5658
5831
  };
5659
5832
  break;
5660
5833
  case 'toggle':
@@ -5675,7 +5848,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
5675
5848
  columnsTogglable: false,
5676
5849
  strictMode:false,
5677
5850
  affixHeader: false, // 是否固定表头, 不固定表头, 否则form有y轴滚动条时, 表头会跟随滚动条滚动.
5678
- // needConfirm: true, 此属性设置为false后,导致table不能编辑。
5851
+ needConfirm: false,
5679
5852
  editable: !readonly,
5680
5853
  addable: !readonly,
5681
5854
  removable: !readonly,
@@ -5905,6 +6078,12 @@ function getReadonlyFormAdaptor(object, fields){
5905
6078
  // })
5906
6079
 
5907
6080
  return `
6081
+ if(payload.data.data.length === 0){
6082
+ return {
6083
+ status: 2,
6084
+ msg: "无法找到记录"
6085
+ }
6086
+ }
5908
6087
  if(payload.data.data){
5909
6088
  var data = payload.data.data[0];
5910
6089
  var gridAndObjectFieldsName = ${JSON.stringify(gridAndObjectFieldsName)};
@@ -6029,12 +6208,12 @@ function getScriptForRewriteValueForFileFields(fields){
6029
6208
  });
6030
6209
  }
6031
6210
  }else{
6032
- data[item] = {
6211
+ data[item] = [{
6033
6212
  value: fileFieldValue,
6034
6213
  name: fileFieldDisplayValue.name,
6035
6214
  url: fileFieldDisplayValue.url + "?download=true",
6036
6215
  state: "uploaded"
6037
- };
6216
+ }];
6038
6217
  }
6039
6218
  }
6040
6219
  })
@@ -6052,7 +6231,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
6052
6231
 
6053
6232
  return {
6054
6233
  method: "post",
6055
- url: getApi$2(),
6234
+ url: getApi$2() + '&objectName=${objectName}' ,
6056
6235
  // sendOn: "!!this.recordId",
6057
6236
  cache: API_CACHE,
6058
6237
  requestAdaptor: `
@@ -6358,7 +6537,7 @@ async function getObjectCRUD(objectSchema, fields, options){
6358
6537
  }),
6359
6538
  filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
6360
6539
  };
6361
- if(options.formFactor !== 'SMALL'){
6540
+ if(options.formFactor !== 'SMALL' || ["split"].indexOf(options.displayAs) == -1){
6362
6541
  Object.assign(bodyProps, {
6363
6542
  bulkActions: options.bulkActions != false ? bulkActions : false
6364
6543
  });
@@ -6572,7 +6751,8 @@ async function getObjectForm(objectSchema, ctx){
6572
6751
  "eventName": `@data.changed.${objectSchema.name}`
6573
6752
  },
6574
6753
  "data": {
6575
- "objectName": `${objectSchema.name}`
6754
+ "objectName": `${objectSchema.name}`,
6755
+ "displayAs": "${displayAs}"
6576
6756
  }
6577
6757
  },
6578
6758
  {
@@ -6672,7 +6852,8 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6672
6852
  data: {
6673
6853
  objectName: "${event.data.__objectName}",
6674
6854
  record: "${event.data.__record}"
6675
- }
6855
+ },
6856
+ expression: "${event.data.__response.error != true}"
6676
6857
  },
6677
6858
  {
6678
6859
  "actionType": "setValue",
@@ -6680,7 +6861,8 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6680
6861
  value: {
6681
6862
  "recordLoaded": true,
6682
6863
  }
6683
- }
6864
+ },
6865
+ expression: "${event.data.__response.error != true}"
6684
6866
  }
6685
6867
  ]
6686
6868
  }
@@ -6688,6 +6870,21 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6688
6870
  }
6689
6871
  }
6690
6872
 
6873
+ /*
6874
+ * @Author: baozhoutao@steedos.com
6875
+ * @Date: 2022-08-04 10:42:49
6876
+ * @LastEditors: baozhoutao@steedos.com
6877
+ * @LastEditTime: 2022-08-25 10:28:47
6878
+ * @Description:
6879
+ */
6880
+ var config = {
6881
+ listView: {
6882
+ newRecordMode: 'modal',
6883
+ editRecordMode: 'modal',
6884
+ perPage: 20
6885
+ }
6886
+ };
6887
+
6691
6888
  async function getTableColumns(fields, options){
6692
6889
  const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
6693
6890
  for (const field of fields) {
@@ -6761,6 +6958,13 @@ async function getTableColumns(fields, options){
6761
6958
  }else if(field.type === 'html'){
6762
6959
  type = 'markdown';
6763
6960
  }
6961
+ let className = "";
6962
+ if(field.type === 'textarea'){
6963
+ className = 'min-w-56';
6964
+ }
6965
+ if(field.wrap === false){
6966
+ className += " whitespace-nowrap";
6967
+ }
6764
6968
  if(!field.hidden && !field.extra){
6765
6969
  columns.push(Object.assign({}, {
6766
6970
  name: field.name,
@@ -6771,7 +6975,7 @@ async function getTableColumns(fields, options){
6771
6975
  type: type,
6772
6976
  tpl: tpl,
6773
6977
  toggled: field.toggled,
6774
- className: field.type === 'textarea' ? 'min-w-56 whitespace-pre-wrap textarea' : "whitespace-nowrap",
6978
+ className,
6775
6979
  html: field.type === 'html' ? true : null
6776
6980
  // toggled: true
6777
6981
  }, field.amis, {name: field.name}));
@@ -6896,8 +7100,9 @@ async function getMobileTableColumns(fields, options){
6896
7100
  const url = getNameTplUrl(nameField, options);
6897
7101
 
6898
7102
  const columnLines = getMobileLines(tpls);
6899
-
6900
- columns.push({
7103
+
7104
+
7105
+ let column = {
6901
7106
  name: nameField.name,
6902
7107
  label: nameField.label,
6903
7108
  sortable: nameField.sortable,
@@ -6906,13 +7111,66 @@ async function getMobileTableColumns(fields, options){
6906
7111
  actionType: "link",
6907
7112
  link: url,
6908
7113
  innerClassName: "steedos-listview-item block text-gray-500",
6909
- body:{
7114
+ body: {
6910
7115
  "type": "wrapper",
6911
7116
  "body": columnLines,
6912
7117
  "size": "none",
6913
7118
  "className": "p-1"
6914
7119
  }
6915
- });
7120
+ };
7121
+
7122
+ if(options.objectName === 'cms_files'){
7123
+ if(window.Meteor?.isCordova){
7124
+ column = {
7125
+ ...column,
7126
+ actionType: "",
7127
+ link: "",
7128
+ onEvent: {
7129
+ "click": {
7130
+ "actions": [
7131
+ {
7132
+ "script": `
7133
+ let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
7134
+ Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
7135
+ `,
7136
+ "actionType": "custom"
7137
+ }
7138
+ ],
7139
+ "weight": 0
7140
+ }
7141
+ }
7142
+ };
7143
+ }else {
7144
+ column = {
7145
+ ...column,
7146
+ actionType: "",
7147
+ link: "",
7148
+ onEvent: {
7149
+ "click": {
7150
+ "actions": [
7151
+ {
7152
+ "args": {
7153
+ "api": {
7154
+ "url": url,
7155
+ "method": "get",
7156
+ "headers": {
7157
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7158
+ }
7159
+ }
7160
+ },
7161
+ "actionType": "download"
7162
+ }
7163
+ ],
7164
+ "weight": 0
7165
+ }
7166
+ }
7167
+ };
7168
+ }
7169
+
7170
+ }
7171
+
7172
+ columns.push(column);
7173
+
6916
7174
 
6917
7175
  return columns;
6918
7176
  }
@@ -7031,7 +7289,7 @@ async function getTableSchema$1(fields, options){
7031
7289
  options = {};
7032
7290
  }
7033
7291
  let columns = [];
7034
- if(options.formFactor === 'SMALL'){
7292
+ if(options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1){
7035
7293
  columns = await getMobileTableColumns(fields, options);
7036
7294
  }
7037
7295
  else {
@@ -7234,7 +7492,11 @@ async function getTableApi(mainObject, fields, options){
7234
7492
  filters = systemFilters;
7235
7493
  };
7236
7494
  if(api.data.$self.additionalFilters){
7237
- userFilters.push(api.data.$self.additionalFilters)
7495
+ if(_.isString(api.data.$self.additionalFilters)){
7496
+ userFilters.push(eval(api.data.$self.additionalFilters))
7497
+ }else{
7498
+ userFilters.push(api.data.$self.additionalFilters)
7499
+ }
7238
7500
  }
7239
7501
 
7240
7502
  if(api.data.$self._isRelated){
@@ -7267,8 +7529,7 @@ async function getTableApi(mainObject, fields, options){
7267
7529
  if(_.isEmpty(filters)){
7268
7530
  filters = userFilters;
7269
7531
  }else{
7270
- filters.push('and');
7271
- filters.push(userFilters)
7532
+ filters = [filters, 'and', userFilters]
7272
7533
  }
7273
7534
  }
7274
7535
  api.data = {
@@ -7695,7 +7956,6 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7695
7956
  // ObjectForm会认作用域下的变量值
7696
7957
  // TODO: 待组件支持initValues属性后应该改掉,不应该通过data直接传值
7697
7958
  // TODO: 全天事件属性传入doc了但是没有生效,需要手动在ObjectForm中勾选全天事件
7698
- event.data = doc;
7699
7959
  const title = "新建 ${objectSchema.label}";
7700
7960
  doAction(
7701
7961
  {
@@ -7708,6 +7968,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7708
7968
  "type": "steedos-object-form",
7709
7969
  "objectApiName": "\${objectName}",
7710
7970
  "mode": "edit",
7971
+ "defaultData": doc,
7711
7972
  "onEvent": {
7712
7973
  "submitSucc": {
7713
7974
  "weight": 0,
@@ -8000,7 +8261,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
8000
8261
  * @Author: baozhoutao@steedos.com
8001
8262
  * @Date: 2022-07-05 15:55:39
8002
8263
  * @LastEditors: Please set LastEditors
8003
- * @LastEditTime: 2023-04-20 11:43:14
8264
+ * @LastEditTime: 2023-05-08 16:34:25
8004
8265
  * @Description:
8005
8266
  */
8006
8267
 
@@ -8254,7 +8515,7 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
8254
8515
  }
8255
8516
  function getRelatedListProps(uiSchema, listViewName, ctx) {
8256
8517
  if (ctx.columns) {
8257
- const sort = getListViewSort(ctx.sort);
8518
+ const sort = getListViewSort({sort: ctx.sort});
8258
8519
  let { filters , filtersFunction} = ctx;
8259
8520
  if(!filtersFunction && filters){
8260
8521
  filtersFunction = str2function(
@@ -8343,7 +8604,7 @@ async function getRelatedListSchema(
8343
8604
  * @Author: baozhoutao@steedos.com
8344
8605
  * @Date: 2022-07-05 15:55:39
8345
8606
  * @LastEditors: baozhoutao@steedos.com
8346
- * @LastEditTime: 2023-04-17 15:26:17
8607
+ * @LastEditTime: 2023-04-28 11:11:29
8347
8608
  * @Description:
8348
8609
  */
8349
8610
 
@@ -8541,6 +8802,9 @@ async function getListSchema(
8541
8802
  ctx = {}
8542
8803
  ) {
8543
8804
  const uiSchema = await getUISchema(objectName);
8805
+ if(!uiSchema){
8806
+ return {}
8807
+ }
8544
8808
  const listView = _$1.find(
8545
8809
  uiSchema.list_views,
8546
8810
  (listView, name) => {
@@ -9094,7 +9358,10 @@ async function getListviewInitSchema(objectApiName, listViewName, ctx) {
9094
9358
  const defaults = ctx.defaults || {};
9095
9359
  if(!defaults.headerSchema){
9096
9360
  //传入isListviewInit是区别于对象列表类型的微页面,即getListPageInitSchema函数中该属性为false
9097
- const headerSchema = await getObjectListHeader$1(uiSchema);
9361
+ const headerSchema = await getObjectListHeader$1(uiSchema, listViewName, {
9362
+ onlySecordLine: true,
9363
+ isListviewInit: true
9364
+ });
9098
9365
  defaults.headerSchema = headerSchema;
9099
9366
  }
9100
9367
  ctx.defaults = defaults;
@@ -11770,6 +12037,7 @@ exports.getListviewInitSchema = getListviewInitSchema;
11770
12037
  exports.getLookupSapceUserTreeSchema = getLookupSapceUserTreeSchema;
11771
12038
  exports.getNotifications = getNotifications;
11772
12039
  exports.getObjectDetailButtons = getObjectDetailButtons;
12040
+ exports.getObjectDetailButtonsSchemas = getObjectDetailButtonsSchemas;
11773
12041
  exports.getObjectDetailMoreButtons = getObjectDetailMoreButtons;
11774
12042
  exports.getObjectFieldsFilterBarSchema = getObjectFieldsFilterBarSchema;
11775
12043
  exports.getObjectFieldsFilterButtonSchema = getObjectFieldsFilterButtonSchema;
@@ -11778,6 +12046,7 @@ exports.getObjectListHeader = getObjectListHeader$1;
11778
12046
  exports.getObjectListHeaderFieldsFilterBar = getObjectListHeaderFieldsFilterBar;
11779
12047
  exports.getObjectListHeaderFirstLine = getObjectListHeaderFirstLine;
11780
12048
  exports.getObjectListHeaderSecordLine = getObjectListHeaderSecordLine;
12049
+ exports.getObjectListViewButtonsSchemas = getObjectListViewButtonsSchemas;
11781
12050
  exports.getObjectRecordDetailHeader = getObjectRecordDetailHeader;
11782
12051
  exports.getObjectRecordDetailRelatedListHeader = getObjectRecordDetailRelatedListHeader;
11783
12052
  exports.getObjectRelated = getObjectRelated;