@steedos-widgets/amis-lib 1.1.6 → 1.2.0-beta.0

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.umd.js CHANGED
@@ -3418,7 +3418,7 @@ setTimeout(()=>{
3418
3418
  `
3419
3419
  }
3420
3420
 
3421
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false} = {}){
3421
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems} = {}){
3422
3422
  const isMobile = window.innerWidth < 768;
3423
3423
  if(isMobile){
3424
3424
  showDisplayAs = false;
@@ -3477,6 +3477,7 @@ setTimeout(()=>{
3477
3477
  }else {
3478
3478
  return [
3479
3479
  // "filter-toggler",
3480
+ ...(headerToolbarItems || []),
3480
3481
  "bulkActions",
3481
3482
  {
3482
3483
  "type": "columns-toggler",
@@ -3831,6 +3832,89 @@ setTimeout(()=>{
3831
3832
  }
3832
3833
  };
3833
3834
 
3835
+ function getLookupSapceUserTreeSchema(){
3836
+ const tree = [{
3837
+ "type": "input-tree",
3838
+ "className": "",
3839
+ "id": "u:7fd77b7915b0",
3840
+ "source": {
3841
+ "method": "post",
3842
+ "url": "${context.rootUrl}/graphql",
3843
+ "headers": {
3844
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
3845
+ },
3846
+ "adaptor": " const records = payload.data.options;\n const treeRecords = [];\n const getChildren = (records, childrenIds) => {\n if (!childrenIds) {\n return;\n }\n const children = _.filter(records, (record) => {\n return _.includes(childrenIds, record.value)\n });\n _.each(children, (item) => {\n if (item.children) {\n item.children = getChildren(records, item.children)\n }\n })\n return children;\n }\n\n const getRoot = (records) => {\n for (var i = 0; i < records.length; i++){\n records[i].noParent = 0;\n if (!!records[i].parent) {\n biaozhi = 1\n for (var j = 0; j < records.length; j++){\n if (records[i].parent == records[j].value)\n biaozhi = 0;\n }\n if (biaozhi == 1) records[i].noParent = 1;\n } else records[i].noParent = 1;\n }\n }\n getRoot(records);\n console.log(records)\n\n _.each(records, (record) => {\n if (record.noParent ==1) {\n treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));\n }\n });\n console.log(treeRecords)\n\n payload.data.options = treeRecords;\n return payload;\n ",
3847
+ "requestAdaptor": "\n ",
3848
+ "data": {
3849
+ "query": "{options:organizations(filters:[\"hidden\", \"!=\", true],sort:\"sort_no desc\"){value:_id label:name,parent,children}}"
3850
+ },
3851
+ "messages": {
3852
+ }
3853
+ },
3854
+ "onEvent": {
3855
+ "change": {
3856
+ "actions": [
3857
+ {
3858
+ "actionType": "custom",
3859
+ "script": `
3860
+ debugger;
3861
+ const scope = event.context.scoped;
3862
+ //TODO: 将form中的value一同加入筛选内
3863
+ // var filterForm = scope.parent.parent.getComponents().find(function(n){
3864
+ // return n.props.type === "form";
3865
+ // });
3866
+ // var filterFormValues = filterForm.getValues();
3867
+ filterFormValues={
3868
+ "__searchable__organizations_parents":event.data.value.value
3869
+ }
3870
+ var listView = scope.parent.getComponents().find(function(n){
3871
+ return n.props.type === "crud";
3872
+ });
3873
+ const removedValues = {};
3874
+ // for(var k in filterFormValues){
3875
+ // if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
3876
+ // removedValues[k] = "";
3877
+ // }
3878
+ // }
3879
+ listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
3880
+ `
3881
+ }
3882
+ ]
3883
+ }
3884
+ },
3885
+ "label": "",
3886
+ "name": "organizations",
3887
+ "multiple": false,
3888
+ "joinValues": false,
3889
+ "clearValueOnHidden": false,
3890
+ "fieldName": "organizations",
3891
+ "hideRoot": true,
3892
+ "initiallyOpen": false,
3893
+ "extractValue": true,
3894
+ "onlyChildren": true,
3895
+ "treeContainerClassName": "no-border",
3896
+ "showIcon": false,
3897
+ "enableNodePath": false,
3898
+ "autoCheckChildren": false,
3899
+ "searchable": true,
3900
+ "searchConfig": {
3901
+ "sticky": true
3902
+ },
3903
+ "unfoldedLevel": 2,
3904
+ "style": {
3905
+ "max-height": "100%",
3906
+ "position": "absolute",
3907
+ "left": "-190px",
3908
+ "width": "190px",
3909
+ "bottom": 0,
3910
+ "top": "0",
3911
+ "overflow": "auto",
3912
+ "min-height":"300px"
3913
+ },
3914
+ "originPosition": "left-top"
3915
+ }];
3916
+ return tree;
3917
+ }
3834
3918
 
3835
3919
  async function lookupToAmisPicker(field, readonly, ctx){
3836
3920
  let referenceTo = await getReferenceTo(field);
@@ -4073,7 +4157,16 @@ setTimeout(()=>{
4073
4157
  ...ctx
4074
4158
  });
4075
4159
 
4076
- pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, ctx.formFactor);
4160
+ var headerToolbarItems = [];
4161
+ const isMobile = window.innerWidth < 768;
4162
+ if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
4163
+ headerToolbarItems = getLookupSapceUserTreeSchema();
4164
+ pickerSchema["style"] = {
4165
+ "margin-left":"200px",
4166
+ "min-height": "300px"
4167
+ };
4168
+ }
4169
+ pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, ctx.formFactor, { headerToolbarItems });
4077
4170
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
4078
4171
  if (isAllowCreate) {
4079
4172
  const new_button = await getSchema$4(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
@@ -4081,15 +4174,18 @@ setTimeout(()=>{
4081
4174
  pickerSchema.headerToolbar.push(new_button);
4082
4175
  }
4083
4176
  pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
4084
- if(ctx.filterVisible !== false){
4085
- let filterLoopCount = ctx.filterLoopCount || 0;
4086
- filterLoopCount++;
4087
- // 可以传入filterVisible为false防止死循环
4088
- pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
4089
- isLookup: true,
4090
- ...ctx,
4091
- filterLoopCount,
4092
- });
4177
+ //TODO: 等待放大镜bug修复,if会去掉,始终显示放大镜
4178
+ if(referenceTo.objectName != "space_users" || field.reference_to_field != "user"){
4179
+ if (ctx.filterVisible !== false) {
4180
+ let filterLoopCount = ctx.filterLoopCount || 0;
4181
+ filterLoopCount++;
4182
+ // 可以传入filterVisible为false防止死循环
4183
+ pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
4184
+ isLookup: true,
4185
+ ...ctx,
4186
+ filterLoopCount,
4187
+ });
4188
+ }
4093
4189
  }
4094
4190
  pickerSchema.data = Object.assign({}, pickerSchema.data, {
4095
4191
  "&": "$$",
@@ -4337,7 +4433,7 @@ setTimeout(()=>{
4337
4433
  if(ctx.idsDependOn || field.amis){
4338
4434
  return await lookupToAmisIdsPicker(field, readonly, ctx);
4339
4435
  }
4340
- return await lookupToAmisSelectUser(field, readonly, ctx);
4436
+ // return await lookupToAmisSelectUser(field, readonly, ctx);
4341
4437
  }
4342
4438
 
4343
4439
  const refObject = await getUISchema(referenceTo.objectName);
@@ -4973,13 +5069,19 @@ setTimeout(()=>{
4973
5069
  };
4974
5070
  break;
4975
5071
  case 'percent':
4976
- //TODO
4977
- convertData = {
4978
- type: getAmisStaticFieldType('number', readonly),
4979
- min: field.min,
4980
- max: field.max,
4981
- precision: field.scale
4982
- };
5072
+ if(readonly){
5073
+ convertData = {
5074
+ type: 'static-tpl',
5075
+ tpl: getUiFieldTpl(field)
5076
+ };
5077
+ }else {
5078
+ convertData = {
5079
+ type: getAmisStaticFieldType('number', readonly),
5080
+ min: field.min,
5081
+ max: field.max,
5082
+ precision: field.scale
5083
+ };
5084
+ }
4983
5085
  break;
4984
5086
  case 'password':
4985
5087
  convertData = {
@@ -5021,12 +5123,18 @@ setTimeout(()=>{
5021
5123
  break;
5022
5124
  case 'formula':
5023
5125
  if(readonly){
5024
- convertData.type = getAmisStaticFieldType(field.data_type, readonly);
5126
+ convertData = {
5127
+ type: 'static-tpl',
5128
+ tpl: getUiFieldTpl(field)
5129
+ };
5025
5130
  }
5026
5131
  break;
5027
5132
  case 'summary':
5028
5133
  if(readonly){
5029
- convertData.type = getAmisStaticFieldType(field.data_type, readonly);
5134
+ convertData = {
5135
+ type: 'static-tpl',
5136
+ tpl: getUiFieldTpl(field)
5137
+ };
5030
5138
  }
5031
5139
  break;
5032
5140
  case 'code':
@@ -5739,7 +5847,11 @@ setTimeout(()=>{
5739
5847
  }
5740
5848
  }
5741
5849
 
5742
- bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs, hiddenCount: options.queryCount === false});
5850
+ bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {
5851
+ showDisplayAs,
5852
+ hiddenCount: options.queryCount === false,
5853
+ headerToolbarItems: options.headerToolbarItems
5854
+ });
5743
5855
 
5744
5856
 
5745
5857
  let body = null;
@@ -7973,7 +8085,8 @@ setTimeout(()=>{
7973
8085
  "sort": sort,
7974
8086
  "ctx": ctx,
7975
8087
  "requestAdaptor": listView.requestAdaptor,
7976
- "adaptor": listView.adaptor
8088
+ "adaptor": listView.adaptor,
8089
+ "headerToolbarItems": ctx.headerToolbarItems
7977
8090
  };
7978
8091
  return {
7979
8092
  uiSchema,
@@ -8034,6 +8147,7 @@ setTimeout(()=>{
8034
8147
  ...ctx,
8035
8148
  filter: ctx.filters,
8036
8149
  sort,
8150
+ headerToolbarItems: ctx.headerToolbarItems,
8037
8151
  buttons: await getListViewItemButtons(uiSchema, ctx)
8038
8152
  });
8039
8153
  return {
@@ -11115,6 +11229,7 @@ setTimeout(()=>{
11115
11229
  exports.getListViewItemButtons = getListViewItemButtons;
11116
11230
  exports.getListViewSort = getListViewSort;
11117
11231
  exports.getListviewInitSchema = getListviewInitSchema;
11232
+ exports.getLookupSapceUserTreeSchema = getLookupSapceUserTreeSchema;
11118
11233
  exports.getNotifications = getNotifications;
11119
11234
  exports.getObjectDetailButtons = getObjectDetailButtons;
11120
11235
  exports.getObjectDetailMoreButtons = getObjectDetailMoreButtons;