@steedos-widgets/sortable 3.6.15 → 6.3.0-beta.11

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.
@@ -54141,10 +54141,23 @@ function getNameTpl(field, ctx){
54141
54141
  if(ctx && ctx.isLookup){
54142
54142
  linkTarget = "target='_blank'";
54143
54143
  }
54144
+ let nameLabel = field.name;
54145
+ //若字段类型是lookup,则按照相关表tpl的label规则显示;若是其它类型,则显示_display或字段本身的值
54146
+ if (field.type == "lookup") {
54147
+ if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
54148
+ if(!field.isTableField){
54149
+ nameLabel = `\${${field.name}__label}`;
54150
+ }
54151
+ } else {
54152
+ nameLabel = `\${_display.${field.name}.label}`;
54153
+ }
54154
+ } else {
54155
+ nameLabel = `\${_display.${field.name} || ${field.name}}`;
54156
+ }
54144
54157
  if(ctx.isRelated && window.innerWidth >= 768){
54145
- return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
54158
+ return `<a href="${href}" ${linkTarget} onclick="return false;">\${${nameLabel} | raw}</a>`
54146
54159
  }else {
54147
- return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
54160
+ return `<a href="${href}" ${linkTarget}>\${${nameLabel} | raw}</a>`
54148
54161
  }
54149
54162
  }
54150
54163
 
@@ -54269,7 +54282,7 @@ function getLocationTpl(field){
54269
54282
  }
54270
54283
 
54271
54284
  async function getFieldTpl (field, options){
54272
- if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
54285
+ if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel && field.multiple !== true){
54273
54286
  return getNameTpl(field, options)
54274
54287
  }
54275
54288
  switch (field.type) {
@@ -54310,7 +54323,7 @@ async function getFieldsTemplate(fields, display){
54310
54323
  if(display != false){
54311
54324
  display = true;
54312
54325
  }
54313
- let fieldsName = ['_id'];
54326
+ let fieldsName = ['_id', 'space'];
54314
54327
  let displayFields = [];
54315
54328
  let fieldsArr = [];
54316
54329
  if(lodash.exports.isArray(fields)){
@@ -54999,6 +55012,29 @@ instance
54999
55012
  }
55000
55013
  });
55001
55014
 
55015
+ /*
55016
+ * @Author: baozhoutao@steedos.com
55017
+ * @Date: 2022-07-13 15:18:03
55018
+ * @LastEditors: baozhoutao@steedos.com
55019
+ * @LastEditTime: 2023-04-11 10:34:26
55020
+ * @Description:
55021
+ */
55022
+
55023
+ async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
55024
+ const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
55025
+ const page = await fetchAPI(api);
55026
+ if (page && page.schema) {
55027
+ page.schema = JSON.parse(page.schema);
55028
+ if(page.schema.data){
55029
+ delete page.schema.data.recordId;
55030
+ delete page.schema.data.objectName;
55031
+ delete page.schema.data.context;
55032
+ delete page.schema.data.global;
55033
+ }
55034
+ return page;
55035
+ }
55036
+ }
55037
+
55002
55038
  async function getQuickEditSchema(object, columnField, options){
55003
55039
  let field = object.fields[columnField.name];
55004
55040
  //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
@@ -55633,20 +55669,26 @@ async function getTableColumns(object, fields, options){
55633
55669
  }
55634
55670
 
55635
55671
  if(window.innerWidth >= 768 && ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && lodash.exports.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
55636
-
55637
- const drawerRecordDetailSchema = {
55672
+ const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });
55673
+ const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
55674
+ "recordId": `\${${options.idFieldName}}`,
55675
+ "data": {
55676
+ ...recordPage.schema.data,
55677
+ "_inDrawer": true, // 用于判断是否在抽屉中
55678
+ "recordLoaded": false, // 重置数据加载状态
55679
+ }
55680
+ }) : {
55638
55681
  "type": "steedos-record-detail",
55639
55682
  "objectApiName": "${objectName}",
55640
55683
  "recordId": `\${${options.idFieldName}}`,
55641
55684
  "showBackButton": false,
55642
55685
  "showButtons": true,
55643
55686
  "data": {
55644
- "_inDrawer": true, // 用于判断是否在抽屉中
55645
- "recordLoaded": false, // 重置数据加载状态
55687
+ "_inDrawer": true, // 用于判断是否在抽屉中
55688
+ "recordLoaded": false, // 重置数据加载状态
55646
55689
  }
55647
55690
  };
55648
55691
 
55649
-
55650
55692
  if(!(field.is_name || field.name === options.labelFieldName)){
55651
55693
  drawerRecordDetailSchema.objectApiName = field.reference_to;
55652
55694
  drawerRecordDetailSchema.recordId = `\${_display.${field.name}.value}`;
@@ -55662,7 +55704,7 @@ async function getTableColumns(object, fields, options){
55662
55704
  "title": "&nbsp;",
55663
55705
  "headerClassName": "hidden",
55664
55706
  "size": "lg",
55665
- "bodyClassName": "p-0 m-0",
55707
+ "bodyClassName": "p-0 m-0 bg-gray-100",
55666
55708
  "closeOnEsc": true,
55667
55709
  "closeOnOutside": true,
55668
55710
  "resizable": true,
@@ -56524,7 +56566,8 @@ const getSchema$5 = async (uiSchema, ctx) => {
56524
56566
  type: 'button',
56525
56567
  actionType: 'confirm',
56526
56568
  label: instance.t('frontend_form_save'),
56527
- primary: true
56569
+ primary: true,
56570
+ close: `object_actions_drawer_${uiSchema.name}`
56528
56571
  },
56529
56572
  ]
56530
56573
  }
@@ -58742,7 +58785,7 @@ async function getObjectFilter(objectSchema, fields, options) {
58742
58785
  * @Author: baozhoutao@steedos.com
58743
58786
  * @Date: 2022-07-05 15:55:39
58744
58787
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
58745
- * @LastEditTime: 2024-02-23 16:37:06
58788
+ * @LastEditTime: 2024-04-26 16:46:44
58746
58789
  * @Description:
58747
58790
  */
58748
58791
 
@@ -58975,37 +59018,44 @@ async function getListSchema(
58975
59018
  * 本次存储代码段
58976
59019
  */
58977
59020
  try {
58978
- const listViewPropsStoreKey = location.pathname + "/crud";
58979
- let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
58980
- /**
58981
- * localListViewProps规范来自crud请求api中api.data.$self参数值的。
58982
- * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
58983
- * __searchable__...:顶部放大镜搜索条件
58984
- * filter:右侧过滤器
58985
- * perPage:每页条数
58986
- * page:当前页码
58987
- * orderBy:排序字段
58988
- * orderDir:排序方向
58989
- */
58990
- if (localListViewProps) {
58991
- localListViewProps = JSON.parse(localListViewProps);
58992
- // localListViewProps.perPage = 3;
58993
- let listSchema = {};
58994
- if(localListViewProps.orderBy){
58995
- listSchema.orderBy = localListViewProps.orderBy;
58996
- }
58997
- if(localListViewProps.orderDir){
58998
- listSchema.orderDir = localListViewProps.orderDir;
58999
- }
59021
+ const listViewPropsStoreKey = location.pathname + "/crud";
59022
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
59023
+ /**
59024
+ * localListViewProps规范来自crud请求api中api.data.$self参数值的。
59025
+ * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
59026
+ * __searchable__...:顶部放大镜搜索条件
59027
+ * filter:右侧过滤器
59028
+ * perPage:每页条数
59029
+ * page:当前页码
59030
+ * orderBy:排序字段
59031
+ * orderDir:排序方向
59032
+ */
59033
+ if (localListViewProps) {
59034
+ localListViewProps = JSON.parse(localListViewProps);
59035
+ // localListViewProps.perPage = 3;
59036
+ let listSchema = {};
59037
+ if (localListViewProps.orderBy) {
59038
+ listSchema.orderBy = localListViewProps.orderBy;
59039
+ }
59040
+ if (localListViewProps.orderDir) {
59041
+ listSchema.orderDir = localListViewProps.orderDir;
59042
+ }
59000
59043
 
59001
- if(localListViewProps.perPage){
59002
- listSchema.perPage = localListViewProps.perPage;
59044
+ if (localListViewProps.perPage) {
59045
+ listSchema.perPage = localListViewProps.perPage;
59046
+ }
59047
+ defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
59003
59048
  }
59004
- defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
59005
- }
59006
59049
  }
59007
59050
  catch (ex) {
59008
- console.error("本地存储中crud参数解析异常:", ex);
59051
+ console.error("本地存储中crud参数解析异常:", ex);
59052
+ }
59053
+
59054
+ if (window.innerWidth > 768) {
59055
+ // 列表视图组件PC端高度自动计算实现满屏效果,手机端不需要满屏效果,所以不用autofillheight,且允许重写微页面中重新组件autoFillHeight属性
59056
+ defaults.listSchema = lodash.exports.defaultsDeep({}, defaults.listSchema || {}, {
59057
+ autoFillHeight: true
59058
+ });
59009
59059
  }
59010
59060
 
59011
59061
  ctx.defaults = defaults;
@@ -59566,7 +59616,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
59566
59616
  });
59567
59617
 
59568
59618
  // 把自动填充规则中依赖的字段也加到api请求中
59569
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59619
+ let autoFillMapping = field.auto_fill_mapping;
59570
59620
  if (autoFillMapping && autoFillMapping.length) {
59571
59621
  autoFillMapping.forEach(function (item) {
59572
59622
  if(!lodash.exports.find(tableFields, function(f){
@@ -59716,7 +59766,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
59716
59766
  // 如果当前元素不是数组,则处理该元素
59717
59767
  // 下面正则用于匹配amis公式\${}
59718
59768
  if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
59719
- arr[i] = currentAmis.evaluate(arr[i], api.data.$);
59769
+ try{
59770
+ arr[i] = currentAmis.evaluate(arr[i], api.context);
59771
+ }catch(ex){
59772
+ console.error("运行lookup过滤公式时出现错误:",ex);
59773
+ }
59720
59774
  }
59721
59775
  }
59722
59776
  }
@@ -60038,7 +60092,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
60038
60092
  ];
60039
60093
 
60040
60094
  // 把自动填充规则中依赖的字段也加到api请求中
60041
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
60095
+ let autoFillMapping = field.auto_fill_mapping;
60042
60096
  if (autoFillMapping && autoFillMapping.length) {
60043
60097
  autoFillMapping.forEach(function (item) {
60044
60098
  queryFields.push(refObjectConfig.fields[item.from]);
@@ -60124,6 +60178,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
60124
60178
  var fieldFilters = ${JSON.stringify(field.filters)};
60125
60179
  var currentAmis = amisRequire('amis');
60126
60180
  //递归fieldFilters数组,检查每一个元素,判断若是公式,就仅把它解析
60181
+ debugger;
60127
60182
  function traverseNestedArray(arr) {
60128
60183
  for (let i = 0; i < arr.length; i++) {
60129
60184
  if (Array.isArray(arr[i])) {
@@ -60133,7 +60188,11 @@ async function lookupToAmisSelect(field, readonly, ctx){
60133
60188
  // 如果当前元素不是数组,则处理该元素
60134
60189
  // 下面正则用于匹配amis公式\${}
60135
60190
  if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
60136
- arr[i] = currentAmis.evaluate(arr[i], api.data.$);
60191
+ try{
60192
+ arr[i] = currentAmis.evaluate(arr[i], api.context);
60193
+ }catch(ex){
60194
+ console.error("运行lookup过滤公式时出现错误:",ex);
60195
+ }
60137
60196
  }
60138
60197
  }
60139
60198
  }
@@ -60280,14 +60339,25 @@ async function getApi(object, recordId, fields, options){
60280
60339
  }
60281
60340
 
60282
60341
  async function getAutoFill(field, refObject) {
60283
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
60342
+ let autoFillMapping = field.auto_fill_mapping;
60284
60343
  if (autoFillMapping && autoFillMapping.length) {
60285
60344
  let fillMapping = {};
60345
+ if (field.multiple) {
60346
+ autoFillMapping.forEach(function (item) {
60347
+ //from的字段类型为lookup、master_detail、select时,需要保留数组格式;其他类型需要转变为字符串格式
60348
+ if (lodash.exports.includes(["lookup","master_detail","select"], refObject.fields[item.from].type)) {
60349
+ fillMapping[item.to] = `\${items | pick:${item.from}}`;
60350
+ } else {
60351
+ fillMapping[item.to] = `\${items | pick:${item.from} | join}`;
60352
+ }
60353
+ });
60354
+ }else {
60355
+ autoFillMapping.forEach(function (item) {
60356
+ fillMapping[item.to] = `\${${item.from}}`;
60357
+ });
60358
+ }
60286
60359
  // let fieldsForApi = [];
60287
- autoFillMapping.forEach(function (item) {
60288
- fillMapping[item.to] = `\${${item.from}}`;
60289
- // fieldsForApi.push(item.from);
60290
- });
60360
+ // fieldsForApi.push(item.from);
60291
60361
  // let api = {
60292
60362
  // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
60293
60363
  // "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
@@ -60389,7 +60459,7 @@ async function lookupToAmis(field, readonly, ctx){
60389
60459
  amisSchema = lodash.exports.defaultsDeep({}, pageAmisSchema, amisSchema);
60390
60460
  }
60391
60461
  }
60392
- const autoFill = await getAutoFill(field);
60462
+ const autoFill = await getAutoFill(field, refObject);
60393
60463
  if(autoFill){
60394
60464
  amisSchema.autoFill = autoFill;
60395
60465
  // 这里不配置initAutoFill值,按amis规则initAutoFill默认值为fillIfNotSet处理--需要amis sdk 版本 > 3.6.3-patch.6(不包括)版本