@steedos-widgets/amis-lib 1.2.6-beta.18 → 1.2.6-beta.20

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
@@ -2685,6 +2685,35 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2685
2685
  // }
2686
2686
  // listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
2687
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
+ `;
2688
2717
  const dataProviderInited = `
2689
2718
  const objectName = data.objectName;
2690
2719
  const isLookup = data.isLookup;
@@ -2878,6 +2907,21 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2878
2907
  }
2879
2908
  }
2880
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
+ },
2881
2925
  {
2882
2926
  "type": "button",
2883
2927
  "label": "设置搜索项",
@@ -3698,7 +3742,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3698
3742
  "list_view": "${uiSchema.list_views[listName]}",
3699
3743
  "appId": "${appId}",
3700
3744
  "global": "${global}",
3701
- "objectName": "${objectName}",
3745
+ "targetObjectName": "${objectName}",
3702
3746
  },
3703
3747
  "body": [
3704
3748
  {
@@ -3738,7 +3782,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3738
3782
  {
3739
3783
  "args": {
3740
3784
  // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3741
- "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}",
3742
3786
  "blank": false
3743
3787
  },
3744
3788
  "actionType": "url",
@@ -3779,7 +3823,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3779
3823
  "data": {
3780
3824
  "&": "$$",
3781
3825
  "listName": "${listName}",
3782
- "objectName": "${objectName}",
3826
+ "targetObjectName": "${objectName}",
3783
3827
  "list_view": "${uiSchema.list_views[listName]}",
3784
3828
  "appId": "${appId}",
3785
3829
  "global": "${global}"
@@ -3822,7 +3866,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3822
3866
  "actions": [
3823
3867
  {
3824
3868
  "args": {
3825
- "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}",
3826
3870
  "blank": false
3827
3871
  },
3828
3872
  "actionType": "url",
@@ -3858,7 +3902,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3858
3902
  "type": "dialog",
3859
3903
  "title": "重命名 列表视图",
3860
3904
  "data": {
3861
- "objectName": "${objectName}",
3905
+ "targetObjectName": "${objectName}",
3862
3906
  "recordId": "${uiSchema.list_views[listName]._id}",
3863
3907
  "appId": "${appId}"
3864
3908
  },
@@ -3879,7 +3923,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3879
3923
  "actions": [
3880
3924
  {
3881
3925
  "args": {
3882
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${name}",
3926
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
3883
3927
  "blank": false
3884
3928
  },
3885
3929
  "actionType": "url",
@@ -3953,6 +3997,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3953
3997
  "type": "dialog",
3954
3998
  "title": "过滤设置",
3955
3999
  "data": {
4000
+ "targetObjectName": "${objectName}",
3956
4001
  "objectName": "${objectName}",
3957
4002
  "recordId": "${uiSchema.list_views[listName]._id}",
3958
4003
  "listName": "${listName}",
@@ -3978,7 +4023,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3978
4023
  "actions": [
3979
4024
  {
3980
4025
  "args": {
3981
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4026
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
3982
4027
  "blank": false
3983
4028
  },
3984
4029
  "actionType": "url",
@@ -4016,6 +4061,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4016
4061
  "title": "显示的列",
4017
4062
  "data": {
4018
4063
  "&": "$$",
4064
+ "targetObjectName": "${objectName}",
4019
4065
  "objectName": "${objectName}",
4020
4066
  "recordId": "${uiSchema.list_views[listName]._id}",
4021
4067
  "listName": "${listName}",
@@ -4041,7 +4087,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4041
4087
  "actions": [
4042
4088
  {
4043
4089
  "args": {
4044
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4090
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4045
4091
  "blank": false
4046
4092
  },
4047
4093
  "actionType": "url"
@@ -4077,6 +4123,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4077
4123
  "title": "弹框标题",
4078
4124
  "data": {
4079
4125
  "&": "$$",
4126
+ "targetObjectName": "${objectName}",
4080
4127
  "objectName": "${objectName}",
4081
4128
  "recordId": "${uiSchema.list_views[listName]._id}",
4082
4129
  "listName": "${listName}",
@@ -4102,7 +4149,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4102
4149
  "actions": [
4103
4150
  {
4104
4151
  "args": {
4105
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4152
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4106
4153
  "blank": false
4107
4154
  },
4108
4155
  "actionType": "url"
@@ -5003,11 +5050,12 @@ async function lookupToAmisSelect(field, readonly, ctx){
5003
5050
  autoComplete: apiInfo,
5004
5051
  searchable: true,
5005
5052
  };
5053
+ //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
5006
5054
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
5007
5055
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
5008
5056
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
5009
5057
  <svg class='slds-icon slds-icon_x-small' aria-hidden='true'>
5010
- <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>
5011
5059
  </svg>
5012
5060
  </span>
5013
5061
  </span>
@@ -7052,8 +7100,9 @@ async function getMobileTableColumns(fields, options){
7052
7100
  const url = getNameTplUrl(nameField, options);
7053
7101
 
7054
7102
  const columnLines = getMobileLines(tpls);
7055
-
7056
- columns.push({
7103
+
7104
+
7105
+ let column = {
7057
7106
  name: nameField.name,
7058
7107
  label: nameField.label,
7059
7108
  sortable: nameField.sortable,
@@ -7062,13 +7111,66 @@ async function getMobileTableColumns(fields, options){
7062
7111
  actionType: "link",
7063
7112
  link: url,
7064
7113
  innerClassName: "steedos-listview-item block text-gray-500",
7065
- body:{
7114
+ body: {
7066
7115
  "type": "wrapper",
7067
7116
  "body": columnLines,
7068
7117
  "size": "none",
7069
7118
  "className": "p-1"
7070
7119
  }
7071
- });
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
+
7072
7174
 
7073
7175
  return columns;
7074
7176
  }
@@ -8159,7 +8261,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
8159
8261
  * @Author: baozhoutao@steedos.com
8160
8262
  * @Date: 2022-07-05 15:55:39
8161
8263
  * @LastEditors: Please set LastEditors
8162
- * @LastEditTime: 2023-04-20 11:43:14
8264
+ * @LastEditTime: 2023-05-08 16:34:25
8163
8265
  * @Description:
8164
8266
  */
8165
8267
 
@@ -8413,7 +8515,7 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
8413
8515
  }
8414
8516
  function getRelatedListProps(uiSchema, listViewName, ctx) {
8415
8517
  if (ctx.columns) {
8416
- const sort = getListViewSort(ctx.sort);
8518
+ const sort = getListViewSort({sort: ctx.sort});
8417
8519
  let { filters , filtersFunction} = ctx;
8418
8520
  if(!filtersFunction && filters){
8419
8521
  filtersFunction = str2function(