@steedos-widgets/amis-lib 6.3.0-beta.6 → 6.3.0-beta.8

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.esm.js CHANGED
@@ -570,10 +570,23 @@ function getNameTpl(field, ctx){
570
570
  if(ctx && ctx.isLookup){
571
571
  linkTarget = "target='_blank'";
572
572
  }
573
+ let nameLabel = field.name;
574
+ //若字段类型是lookup,则按照相关表tpl的label规则显示;若是其它类型,则显示_display或字段本身的值
575
+ if (field.type == "lookup") {
576
+ if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
577
+ if(!field.isTableField){
578
+ nameLabel = `\${${field.name}__label}`;
579
+ }
580
+ } else {
581
+ nameLabel = `\${_display.${field.name}.label}`;
582
+ }
583
+ } else {
584
+ nameLabel = `\${_display.${field.name} || ${field.name}}`;
585
+ }
573
586
  if(ctx.isRelated && window.innerWidth >= 768){
574
- return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
587
+ return `<a href="${href}" ${linkTarget} onclick="return false;">\${${nameLabel} | raw}</a>`
575
588
  }else {
576
- return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
589
+ return `<a href="${href}" ${linkTarget}>\${${nameLabel} | raw}</a>`
577
590
  }
578
591
  }
579
592
 
@@ -698,7 +711,7 @@ function getLocationTpl(field){
698
711
  }
699
712
 
700
713
  async function getFieldTpl (field, options){
701
- if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
714
+ if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel && field.multiple !== true){
702
715
  return getNameTpl(field, options)
703
716
  }
704
717
  switch (field.type) {
@@ -2171,7 +2184,7 @@ async function getTableColumns(object, fields, options){
2171
2184
  var file_id = data.versions && data.versions[0] && data.versions[0]._id;
2172
2185
  window.previewFile && window.previewFile({file_name, file_id});
2173
2186
  `;
2174
- columnItem = {
2187
+ columnItem = Object.assign({}, {
2175
2188
  "type": "button",
2176
2189
  "label": `<%=data.versions ? data.name : "${field.label}"%>`,
2177
2190
  className,
@@ -2203,7 +2216,7 @@ async function getTableColumns(object, fields, options){
2203
2216
  ]
2204
2217
  }
2205
2218
  }
2206
- };
2219
+ }, fieldAmis);
2207
2220
  }else if(field.type === 'toggle'){
2208
2221
  columnItem = Object.assign({}, {
2209
2222
  type: "switch",
@@ -3255,6 +3268,19 @@ function getReadonlyFormAdaptor(object, fields, options){
3255
3268
  // })
3256
3269
 
3257
3270
  var fieldNames = _$1.map(fields, function(n){return n.name});
3271
+ var nameField = object.fields[object.NAME_FIELD_KEY];
3272
+ let nameLabel = nameField.name;
3273
+ if (nameField.type == "lookup") {
3274
+ if(!nameField.reference_to && (nameField.optionsFunction || nameField._optionsFunction || nameField.options)){
3275
+ if(!nameField.isTableField){
3276
+ nameLabel = `record.${nameField.name}__label`;
3277
+ }
3278
+ } else {
3279
+ nameLabel = `record._display.${nameField.name}.label`;
3280
+ }
3281
+ } else {
3282
+ nameLabel = `record._display.${nameField.name} || record.${nameField.name}`;
3283
+ }
3258
3284
  return `
3259
3285
  if(payload.data.data.length === 0){
3260
3286
  var isEditor = !!${options && options.isEditor};
@@ -3296,8 +3322,7 @@ function getReadonlyFormAdaptor(object, fields, options){
3296
3322
  payload.data = data;
3297
3323
  payload.data.__objectName = "${object.name}";
3298
3324
  payload.data.record = record;
3299
-
3300
- payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
3325
+ payload.data.NAME_FIELD_VALUE = ${nameLabel} || record.name;
3301
3326
  payload.data._master = {
3302
3327
  record: record,
3303
3328
  objectName: "${object.name}",
@@ -11857,7 +11882,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11857
11882
  var optionsFilters = [["${valueFieldKey}", optionsFiltersOp, []]];
11858
11883
  if (defaultValue && !api.data.$term) {
11859
11884
  const defaultValueOptionsQueryData = ${JSON.stringify(defaultValueOptionsQueryData)};
11860
- const defaultValueOptionsQuery = defaultValueOptionsQueryData?.query?.replace(/^{/,"").replace(/}$/,"");
11885
+ const defaultValueOptionsQuery = defaultValueOptionsQueryData && defaultValueOptionsQueryData.query && defaultValueOptionsQueryData.query.replace(/^{/,"").replace(/}$/,"");
11861
11886
  // 字段值单独请求,没值的时候在请求中返回空
11862
11887
  optionsFilters = [["${valueFieldKey}", optionsFiltersOp, defaultValue]];
11863
11888
  if(filters.length > 0){