@steedos-widgets/amis-object 1.2.34 → 1.2.35-beta.2

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.
@@ -1509,6 +1509,9 @@ fieldset.antd-Collapse > legend{
1509
1509
  .steedos-object-listview .antd-Table-content {
1510
1510
  max-height: calc(100vh - 263px);
1511
1511
  }
1512
+ .steedos-object-table .antd-Table-content {
1513
+ max-height: calc(100vh - 195px);
1514
+ }
1512
1515
  .steedos-global-footer-root .antd-Nav-Menu-horizontal:after {
1513
1516
  /*手机端底部导航左右间隔不平衡*/
1514
1517
  content: unset;
@@ -3568,8 +3568,8 @@ function getContrastColor(bgColor) {
3568
3568
  /*
3569
3569
  * @Author: baozhoutao@steedos.com
3570
3570
  * @Date: 2022-05-23 09:53:08
3571
- * @LastEditors: Please set LastEditors
3572
- * @LastEditTime: 2023-05-22 15:13:18
3571
+ * @LastEditors: liaodaxue
3572
+ * @LastEditTime: 2023-07-28 16:26:31
3573
3573
  * @Description:
3574
3574
  */
3575
3575
 
@@ -3753,6 +3753,9 @@ function getPasswordTpl(field){
3753
3753
  <% } %>`
3754
3754
  }
3755
3755
 
3756
+ function getLocationTpl(field){
3757
+ return `\${${field.name} ? ${field.name}.address : ''}`
3758
+ }
3756
3759
 
3757
3760
  async function getFieldTpl (field, options){
3758
3761
  if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLabel){
@@ -3777,6 +3780,8 @@ async function getFieldTpl (field, options){
3777
3780
  return await getRelatedFieldTpl(field, options);
3778
3781
  case 'master_detail':
3779
3782
  return await getRelatedFieldTpl(field, options);
3783
+ case 'location':
3784
+ return await getLocationTpl(field);
3780
3785
  case 'number':
3781
3786
  case 'currency':
3782
3787
  return await getNumberTpl(field);
@@ -3789,9 +3794,10 @@ async function getFieldTpl (field, options){
3789
3794
  }
3790
3795
  }
3791
3796
 
3792
- async function getFieldsTemplate(fields, expand){
3793
- if(expand != false){
3794
- expand = true;
3797
+ async function getFieldsTemplate(fields, display){
3798
+ let expandFields = [];
3799
+ if(display != false){
3800
+ display = true;
3795
3801
  }
3796
3802
  let fieldsName = ['_id'];
3797
3803
  let displayFields = [];
@@ -3803,33 +3809,43 @@ async function getFieldsTemplate(fields, expand){
3803
3809
  }
3804
3810
  for (const field of fieldsArr) {
3805
3811
  //graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
3806
- if(field.name.indexOf('.') < 0){
3807
- if(expand && (field.type == 'lookup' || field.type == 'master_detail')){
3808
- fieldsName.push(`${field.name}`);
3809
- displayFields.push(`${field.name}`);
3812
+ if(field.expand){
3813
+ expandFields.push(field);
3814
+ }else {
3815
+ if(field.name.indexOf('.') < 0){
3816
+ if(display && (field.type == 'lookup' || field.type == 'master_detail')){
3817
+ fieldsName.push(`${field.name}`);
3818
+ displayFields.push(`${field.name}`);
3819
+ }else {
3820
+ fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
3821
+ }
3822
+ if(___default.includes(['time','date','datetime','boolean','number','currency'], field.type)){
3823
+ fieldsName.push(`${field.name}`);
3824
+ }
3825
+ if(___default.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
3826
+ displayFields.push(`${field.name}`);
3827
+ }
3810
3828
  }else {
3811
- fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
3812
- }
3813
- if(___default.includes(['time','date','datetime','boolean','number','currency'], field.type)){
3814
- fieldsName.push(`${field.name}`);
3815
- }
3816
- if(___default.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
3817
- displayFields.push(`${field.name}`);
3829
+ objectFieldName = field.name.split('.')[0];
3830
+ fieldsName.push(objectFieldName);
3831
+ displayFields.push(objectFieldName);
3818
3832
  }
3819
- }else {
3820
- objectFieldName = field.name.split('.')[0];
3821
- fieldsName.push(objectFieldName);
3822
- displayFields.push(objectFieldName);
3823
3833
  }
3824
3834
  }
3825
3835
 
3826
3836
  displayFields = ___default__namespace.uniq(displayFields);
3827
3837
  fieldsName = ___default__namespace.uniq(fieldsName);
3838
+ let expandFieldsQuery = "";
3839
+ if(expandFields.length > 0){
3840
+ ___default__namespace.each(expandFields, function(field){
3841
+ expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
3842
+ });
3843
+ }
3828
3844
 
3829
3845
  if(displayFields.length > 0){
3830
- return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
3846
+ return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
3831
3847
  }
3832
- return `${fieldsName.join(' ')}`
3848
+ return `${fieldsName.join(' ')},${expandFieldsQuery}`
3833
3849
  }
3834
3850
 
3835
3851
  function getRecordPermissionsTemplate(){
@@ -4119,6 +4135,7 @@ var frontend_form_save_and_new$1 = "Save and New";
4119
4135
  var frontend_form_cancel$1 = "Cancel";
4120
4136
  var frontend_form_new$1 = "New";
4121
4137
  var frontend_form_edit$1 = "Edit";
4138
+ var frontend_form_preview$1 = "Preview";
4122
4139
  var frontend_form_select$1 = "Select";
4123
4140
  var frontend_form_please_select$1 = "Please select";
4124
4141
  var frontend_form_confirm$1 = "Confirm";
@@ -4201,6 +4218,7 @@ var en_us = {
4201
4218
  frontend_form_cancel: frontend_form_cancel$1,
4202
4219
  frontend_form_new: frontend_form_new$1,
4203
4220
  frontend_form_edit: frontend_form_edit$1,
4221
+ frontend_form_preview: frontend_form_preview$1,
4204
4222
  frontend_form_select: frontend_form_select$1,
4205
4223
  frontend_form_please_select: frontend_form_please_select$1,
4206
4224
  frontend_form_confirm: frontend_form_confirm$1,
@@ -4284,6 +4302,7 @@ var frontend_form_save_and_new = "保存并新建";
4284
4302
  var frontend_form_cancel = "取消";
4285
4303
  var frontend_form_new = "新建";
4286
4304
  var frontend_form_edit = "编辑";
4305
+ var frontend_form_preview = "预览";
4287
4306
  var frontend_form_select = "选择";
4288
4307
  var frontend_form_please_select = "请选择";
4289
4308
  var frontend_form_confirm = "确认";
@@ -4367,6 +4386,7 @@ var zh_cn = {
4367
4386
  frontend_form_cancel: frontend_form_cancel,
4368
4387
  frontend_form_new: frontend_form_new,
4369
4388
  frontend_form_edit: frontend_form_edit,
4389
+ frontend_form_preview: frontend_form_preview,
4370
4390
  frontend_form_select: frontend_form_select,
4371
4391
  frontend_form_please_select: frontend_form_please_select,
4372
4392
  frontend_form_confirm: frontend_form_confirm,
@@ -9629,11 +9649,10 @@ async function getIdsPickerSchema(field, readonly, ctx){
9629
9649
  * @Author: baozhoutao@steedos.com
9630
9650
  * @Date: 2023-01-13 17:27:54
9631
9651
  * @LastEditors: liaodaxue
9632
- * @LastEditTime: 2023-07-24 15:23:12
9652
+ * @LastEditTime: 2023-07-27 17:33:54
9633
9653
  * @Description:
9634
9654
  */
9635
9655
 
9636
-
9637
9656
  const getMarkdownFieldSchema = (field, readonly, ctx)=>{
9638
9657
  if(readonly){
9639
9658
  return {
@@ -9660,7 +9679,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
9660
9679
  "className": "steedos-markdown",
9661
9680
  "tabs": [
9662
9681
  {
9663
- "title": "Write",
9682
+ "title": instance.t('frontend_form_edit'),
9664
9683
  "tab": [
9665
9684
  {
9666
9685
  "type": "editor",
@@ -9670,7 +9689,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
9670
9689
  ]
9671
9690
  },
9672
9691
  {
9673
- "title": "Preview",
9692
+ "title": instance.t('frontend_form_preview'),
9674
9693
  "tab": [
9675
9694
  {
9676
9695
  "type": "markdown",
@@ -9727,7 +9746,7 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
9727
9746
  * @Author: baozhoutao@steedos.com
9728
9747
  * @Date: 2022-10-28 14:52:55
9729
9748
  * @LastEditors: liaodaxue
9730
- * @LastEditTime: 2023-07-14 17:18:42
9749
+ * @LastEditTime: 2023-07-28 16:16:29
9731
9750
  * @Description:
9732
9751
  */
9733
9752
 
@@ -9751,6 +9770,8 @@ function getAmisStaticFieldType(type, readonly, options){
9751
9770
  if(!readonly){
9752
9771
  if(___default__namespace.includes(AmisFormInputs, type)){
9753
9772
  return `input-${type}`;
9773
+ }else if(type === 'location'){
9774
+ return "location-picker"
9754
9775
  }
9755
9776
  return type;
9756
9777
  }
@@ -10308,6 +10329,30 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10308
10329
  type: getAmisStaticFieldType('email', readonly)
10309
10330
  };
10310
10331
  break;
10332
+ case 'location':
10333
+ // 申请ak后需要设置白名单; https://lbsyun.baidu.com/apiconsole/key/create#/home
10334
+ // console.log('fie==>', field.name, field);
10335
+ let ak = "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7";
10336
+ let vendor = "baidu"; /* 'baidu' | 'gaode' */
10337
+ if(window.Meteor){
10338
+ const map_ak = Meteor.settings?.public?.amis?.map_ak;
10339
+ if(map_ak){
10340
+ ak = map_ak;
10341
+ }
10342
+ const map_vendor = Meteor.settings?.public?.amis?.map_vendor;
10343
+ if(map_vendor){
10344
+ vendor = map_vendor;
10345
+ }
10346
+ }
10347
+
10348
+ convertData = {
10349
+ type: getAmisStaticFieldType('location', readonly),
10350
+ tpl: readonly ? getLocationTpl(field) : null,
10351
+ ak,
10352
+ vendor,
10353
+ label: field.label
10354
+ };
10355
+ break;
10311
10356
  case 'avatar':
10312
10357
  convertData = getAmisFileSchema(field, readonly);
10313
10358
  break;
@@ -10799,6 +10844,10 @@ async function getTableColumns$1(fields, options){
10799
10844
  for (const field of fields) {
10800
10845
  //增加quickEdit属性,实现快速编辑
10801
10846
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
10847
+ let className = "";
10848
+ if(field.wrap != true){
10849
+ className += " whitespace-nowrap";
10850
+ }
10802
10851
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
10803
10852
  const previewFileScript = `
10804
10853
  var data = event.data;
@@ -10809,7 +10858,7 @@ async function getTableColumns$1(fields, options){
10809
10858
  columns.push({
10810
10859
  "type": "button",
10811
10860
  "label": `<%=data.versions ? data.name : "${field.label}"%>`,
10812
- "className": "whitespace-nowrap",
10861
+ className,
10813
10862
  "level": "link",
10814
10863
  "quickEdit": quickEditSchema,
10815
10864
  "onEvent": {
@@ -10846,7 +10895,7 @@ async function getTableColumns$1(fields, options){
10846
10895
  width: getFieldWidth(field.width),
10847
10896
  toggled: field.toggled,
10848
10897
  static: true,
10849
- className:"whitespace-nowrap",
10898
+ className,
10850
10899
  quickEdit: quickEditSchema
10851
10900
  }, field.amis, {name: field.name}));
10852
10901
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
@@ -10858,16 +10907,12 @@ async function getTableColumns$1(fields, options){
10858
10907
  toggled: field.toggled,
10859
10908
  quickEdit: quickEditSchema,
10860
10909
  static: true,
10861
- className:"whitespace-nowrap",
10910
+ className,
10862
10911
  ...getAmisFileReadonlySchema(field)
10863
10912
  }, field.amis, {name: field.name}));
10864
10913
  }
10865
10914
  else if(field.type === 'select'){
10866
10915
  const map = getSelectMap(field.options);
10867
- let className = "";
10868
- if(field.wrap === false){
10869
- className += " whitespace-nowrap";
10870
- }
10871
10916
  columns.push(Object.assign({}, {
10872
10917
  type: "mapping",
10873
10918
  name: field.name,
@@ -10895,12 +10940,8 @@ async function getTableColumns$1(fields, options){
10895
10940
  type = 'input-url';
10896
10941
  }
10897
10942
  }
10898
- let className = "";
10899
10943
  if(field.type === 'textarea'){
10900
- className = 'min-w-56';
10901
- }
10902
- if(field.wrap === false){
10903
- className += " whitespace-nowrap";
10944
+ className += 'min-w-56';
10904
10945
  }
10905
10946
  if(!field.hidden && !field.extra){
10906
10947
  columns.push(Object.assign({}, {
@@ -10920,6 +10961,7 @@ async function getTableColumns$1(fields, options){
10920
10961
  }, field.amis, {name: field.name}));
10921
10962
  }
10922
10963
  }
10964
+
10923
10965
  }
10924
10966
  // columns.push(getOperation(fields));
10925
10967
  if(!___default__namespace.some(columns, { name: options.labelFieldName })){
@@ -12460,13 +12502,13 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
12460
12502
  "selectMirror": permissions.allowCreate,
12461
12503
  "initialView": initialView,
12462
12504
  "businessHours": businessHours,
12463
- ...config,
12464
- "onEvent": onEvent,
12465
12505
  "views":{
12466
12506
  listWeek: {
12467
12507
  buttonText: instance.t('frontend_calendar_listWeek')
12468
12508
  }
12469
- }
12509
+ },
12510
+ ...config,
12511
+ "onEvent": onEvent
12470
12512
  };
12471
12513
  return amisSchema;
12472
12514
  }
@@ -13499,8 +13541,8 @@ async function getRelatedListSchema(
13499
13541
  /*
13500
13542
  * @Author: baozhoutao@steedos.com
13501
13543
  * @Date: 2022-07-05 15:55:39
13502
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13503
- * @LastEditTime: 2023-06-04 17:36:49
13544
+ * @LastEditors: baozhoutao@steedos.com
13545
+ * @LastEditTime: 2023-07-29 13:58:07
13504
13546
  * @Description:
13505
13547
  */
13506
13548
 
@@ -13834,6 +13876,7 @@ async function getListSchema(
13834
13876
  "filterVisible": ctx.filterVisible,
13835
13877
  "rowClassNameExpr": ctx.rowClassNameExpr
13836
13878
  };
13879
+ // console.log(`getListSchema===>`,amisSchema)
13837
13880
  return {
13838
13881
  uiSchema,
13839
13882
  amisSchema,
@@ -13847,7 +13890,7 @@ async function getTableSchema(
13847
13890
  columns,
13848
13891
  ctx = {}
13849
13892
  ) {
13850
- // console.time('getTableSchema');
13893
+ // console.time('getTableSchema', columns);
13851
13894
  const uiSchema = await getUISchema(objectName);
13852
13895
 
13853
13896
  let sort = ctx.sort;
@@ -13861,19 +13904,52 @@ async function getTableSchema(
13861
13904
  }
13862
13905
 
13863
13906
  let fields = [];
13864
- ___default.each(columns, function (column) {
13865
- if (___default.isString(column) && uiSchema.fields[column]) {
13866
- fields.push(uiSchema.fields[column]);
13867
- } else if (___default.isObject(column) && uiSchema.fields[column.field]) {
13868
- fields.push(
13869
- Object.assign({}, uiSchema.fields[column.field], {
13870
- width: column.width,
13871
- wrap: column.wrap, // wrap = true 是没效果的
13872
- amis: column.amis
13873
- })
13874
- );
13907
+ for(const column of columns){
13908
+ if (___default.isString(column)) {
13909
+ if(column.indexOf('.') > 0){
13910
+ const fieldName = column.split('.')[0];
13911
+ const displayName = column.split('.')[1];
13912
+ const filedInfo = uiSchema.fields[fieldName];
13913
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && ___default.isString(filedInfo.reference_to) ){
13914
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
13915
+ const rfFieldInfo = rfUiSchema.fields[displayName];
13916
+ fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
13917
+ }
13918
+ }else {
13919
+ if(uiSchema.fields[column]){
13920
+ fields.push(uiSchema.fields[column]);
13921
+ }
13922
+ }
13923
+ } else if (___default.isObject(column)) {
13924
+ if(column.field.indexOf('.') > 0){
13925
+ const fieldName = column.field.split('.')[0];
13926
+ const displayName = column.field.split('.')[1];
13927
+ const filedInfo = uiSchema.fields[fieldName];
13928
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && ___default.isString(filedInfo.reference_to) ){
13929
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
13930
+ const rfFieldInfo = rfUiSchema.fields[displayName];
13931
+ fields.push(Object.assign({}, rfFieldInfo,
13932
+ {name: column.field, expand: true, expandInfo: {fieldName, displayName}},
13933
+ {
13934
+ width: column.width,
13935
+ wrap: column.wrap, // wrap = true 是没效果的
13936
+ amis: column.amis
13937
+ }
13938
+ ));
13939
+ }
13940
+ }else {
13941
+ if(uiSchema.fields[column.field]){
13942
+ fields.push(
13943
+ Object.assign({}, uiSchema.fields[column.field], {
13944
+ width: column.width,
13945
+ wrap: column.wrap, // wrap = true 是没效果的
13946
+ amis: column.amis
13947
+ })
13948
+ );
13949
+ }
13950
+ }
13875
13951
  }
13876
- });
13952
+ }
13877
13953
 
13878
13954
  const extraColumns = ctx.extraColumns;
13879
13955