@steedos-widgets/amis-lib 1.2.43 → 1.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.
package/dist/index.cjs.js CHANGED
@@ -427,7 +427,7 @@ function getContrastColor(bgColor) {
427
427
  * @Author: baozhoutao@steedos.com
428
428
  * @Date: 2022-05-23 09:53:08
429
429
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
430
- * @LastEditTime: 2023-08-03 18:07:54
430
+ * @LastEditTime: 2023-08-29 15:04:39
431
431
  * @Description:
432
432
  */
433
433
 
@@ -531,7 +531,7 @@ function getRelatedFieldTpl(field, ctx){
531
531
  linkTarget = "target='_blank'";
532
532
  }
533
533
 
534
- const onlyDisplayLabel = ctx.onlyDisplayLabel;
534
+ const onlyDisplayLookLabel = ctx.onlyDisplayLookLabel;
535
535
 
536
536
  let fieldDataStrTpl = `data._display.${field.name}`;
537
537
 
@@ -542,7 +542,7 @@ function getRelatedFieldTpl(field, ctx){
542
542
  if(_.isString(field.reference_to) || !field.reference_to){
543
543
  if(field.multiple){
544
544
  let labelTpl = `<%=item.label%>`;
545
- if(!onlyDisplayLabel){
545
+ if(!onlyDisplayLookLabel){
546
546
  const href = Router.getObjectDetailPath({
547
547
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
548
548
  });
@@ -560,7 +560,7 @@ function getRelatedFieldTpl(field, ctx){
560
560
  objectNameTpl = `\${${field.name}.objectName}`;
561
561
  recordIdTpl = `\${${field.name}.value}`;
562
562
  }
563
- if(!onlyDisplayLabel){
563
+ if(!onlyDisplayLookLabel){
564
564
  const href = Router.getObjectDetailPath({
565
565
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
566
566
  });
@@ -572,7 +572,7 @@ function getRelatedFieldTpl(field, ctx){
572
572
 
573
573
  }else {
574
574
  let labelTpl = `<%=item.label%>`;
575
- if(!onlyDisplayLabel){
575
+ if(!onlyDisplayLookLabel){
576
576
  const href = Router.getObjectDetailPath({
577
577
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
578
578
  });
@@ -625,7 +625,7 @@ function getLocationTpl(field){
625
625
  }
626
626
 
627
627
  async function getFieldTpl (field, options){
628
- if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLabel){
628
+ if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
629
629
  return getNameTpl(field, options)
630
630
  }
631
631
  switch (field.type) {
@@ -814,7 +814,7 @@ function getScriptForRemoveUrlPrefixForImgFields(fields){
814
814
  if(imgFields[item].multiple){
815
815
  if(imgFieldValue instanceof Array){
816
816
  formData[item] = imgFieldValue.map((value)=>{
817
- let itemValue = value?.split('/');
817
+ let itemValue = value && value.split('/');
818
818
  return itemValue[itemValue.length - 1];
819
819
  });
820
820
  }
@@ -1041,6 +1041,7 @@ var frontend_listview_control_rename_title$1 = "Rename List View";
1041
1041
  var frontend_listview_control_share$1 = "Sharing Settings";
1042
1042
  var frontend_listview_control_sort$1 = "Default sorting rule";
1043
1043
  var frontend_export_excel$1 = "Export Excel";
1044
+ var frontend_export_excel_toast$1 = "Exporting, please wait";
1044
1045
  var frontend_operation$1 = "Operation";
1045
1046
  var frontend_import_data$1 = "Import data";
1046
1047
  var frontend_import_data_object_name$1 = "Import object";
@@ -1125,6 +1126,7 @@ var en_us = {
1125
1126
  frontend_listview_control_share: frontend_listview_control_share$1,
1126
1127
  frontend_listview_control_sort: frontend_listview_control_sort$1,
1127
1128
  frontend_export_excel: frontend_export_excel$1,
1129
+ frontend_export_excel_toast: frontend_export_excel_toast$1,
1128
1130
  frontend_operation: frontend_operation$1,
1129
1131
  frontend_import_data: frontend_import_data$1,
1130
1132
  frontend_import_data_object_name: frontend_import_data_object_name$1,
@@ -1211,6 +1213,7 @@ var frontend_listview_control_rename_title = "重命名 列表视图";
1211
1213
  var frontend_listview_control_share = "共享设置";
1212
1214
  var frontend_listview_control_sort = "默认排序规则";
1213
1215
  var frontend_export_excel = "导出";
1216
+ var frontend_export_excel_toast = "正在导出,请稍后...";
1214
1217
  var frontend_operation = "操作";
1215
1218
  var frontend_import_data = "导入数据";
1216
1219
  var frontend_import_data_object_name = "导入对象";
@@ -1296,6 +1299,7 @@ var zh_cn = {
1296
1299
  frontend_listview_control_share: frontend_listview_control_share,
1297
1300
  frontend_listview_control_sort: frontend_listview_control_sort,
1298
1301
  frontend_export_excel: frontend_export_excel,
1302
+ frontend_export_excel_toast: frontend_export_excel_toast,
1299
1303
  frontend_operation: frontend_operation,
1300
1304
  frontend_import_data: frontend_import_data,
1301
1305
  frontend_import_data_object_name: frontend_import_data_object_name,
@@ -2285,7 +2289,7 @@ const getSchema$2 = (uiSchema) => {
2285
2289
  "Bearer ${context.tenantId},${context.authToken}",
2286
2290
  },
2287
2291
  requestAdaptor:
2288
- "\n const selfData = JSON.parse(JSON.stringify(api.data.$self));\n var filters = [];\n var pageSize = api.data.pageSize || 10;\n var pageNo = api.data.pageNo || 1;\n var skip = (pageNo - 1) * pageSize;\n var orderBy = api.data.orderBy || '';\n var orderDir = api.data.orderDir || '';\n var sort = orderBy + ' ' + orderDir;\n var allowSearchFields = [\"description\"];\n if(api.data.$term){\n filters = [[\"name\", \"contains\", \"'+ api.data.$term +'\"]];\n }else if(selfData.op === 'loadOptions' && selfData.value){\n if(selfData.value?.indexOf(',') > 0){\n filters = [[\"_id\", \"=\", selfData.value.split(',')]];\n }else{\n filters = [[\"_id\", \"=\", selfData.value]];\n }\n }\n if(allowSearchFields){\n allowSearchFields.forEach(function(key){\n const keyValue = selfData[key];\n if(keyValue){\n filters.push([key, \"contains\", keyValue]);\n }\n })\n }\n\n const filtersFunction = function(filters, values){return ['object_name', '=', values.object_name]};\n\n if(filtersFunction){\n const _filters = filtersFunction(filters, api.data.$self.__super.__super);\n if(_filters && _filters.length > 0){\n filters.push(_filters);\n }\n }\n\n api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());\n return api;\n ",
2292
+ "\n const selfData = JSON.parse(JSON.stringify(api.data.$self));\n var filters = [];\n var pageSize = api.data.pageSize || 10;\n var pageNo = api.data.pageNo || 1;\n var skip = (pageNo - 1) * pageSize;\n var orderBy = api.data.orderBy || '';\n var orderDir = api.data.orderDir || '';\n var sort = orderBy + ' ' + orderDir;\n var allowSearchFields = [\"description\"];\n if(api.data.$term){\n filters = [[\"name\", \"contains\", \"'+ api.data.$term +'\"]];\n }else if(selfData.op === 'loadOptions' && selfData.value){\n if(selfData.value && selfData.value.indexOf(',') > 0){\n filters = [[\"_id\", \"=\", selfData.value.split(',')]];\n }else{\n filters = [[\"_id\", \"=\", selfData.value]];\n }\n }\n if(allowSearchFields){\n allowSearchFields.forEach(function(key){\n const keyValue = selfData[key];\n if(keyValue){\n filters.push([key, \"contains\", keyValue]);\n }\n })\n }\n\n const filtersFunction = function(filters, values){return ['object_name', '=', values.object_name]};\n\n if(filtersFunction){\n const _filters = filtersFunction(filters, api.data.$self.__super.__super);\n if(_filters && _filters.length > 0){\n filters.push(_filters);\n }\n }\n\n api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());\n return api;\n ",
2289
2293
  adaptor:
2290
2294
  "\n const enable_tree = undefined;\n if(enable_tree){\n const records = payload.data.rows;\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._id)\n });\n _.each(children, (item)=>{\n if(item.children){\n item.children = getChildren(records, item.children)\n }\n })\n return children;\n }\n\n _.each(records, (record)=>{\n if(!record.parent){\n treeRecords.push(Object.assign({}, record, {children: getChildren(records, record.children)}));\n }\n });\n payload.data.rows = treeRecords;\n }\n return payload;\n ",
2291
2295
  },
@@ -2464,7 +2468,7 @@ const getSchema$2 = (uiSchema) => {
2464
2468
  * @Author: baozhoutao@steedos.com
2465
2469
  * @Date: 2022-11-07 17:00:38
2466
2470
  * @LastEditors: baozhoutao@steedos.com
2467
- * @LastEditTime: 2022-11-07 17:12:20
2471
+ * @LastEditTime: 2023-08-24 16:44:42
2468
2472
  * @Description:
2469
2473
  */
2470
2474
 
@@ -2484,7 +2488,7 @@ const getSchema$1 = (uiSchema)=>{
2484
2488
  "componentId": "",
2485
2489
  "args": {
2486
2490
  "blank": false,
2487
- "url": "/app/${app_id}/${objectName}/view/${_id}"
2491
+ "url": "/app/${app_id}/${objectName}/view/${_id}?side_object=${objectName}&side_listview_id=${listName}"
2488
2492
  },
2489
2493
  "actionType": "link"
2490
2494
  }
@@ -2501,90 +2505,69 @@ const getSchema$1 = (uiSchema)=>{
2501
2505
  };
2502
2506
 
2503
2507
  const getSchema = async (uiSchema, ctx) => {
2504
- const requestAdaptor = `
2505
- // 获取列表视图的属性
2506
- let uiSchema = api.body.uiSchema;
2507
- let list_views = uiSchema.list_views;
2508
- let list_views_name = api.body.listName;
2509
- let col = list_views[list_views_name].columns;
2510
- let sort_test = list_views[list_views_name].sort;
2511
-
2512
- // 获取下载字段
2513
- let select = [];
2514
- _.each(col, (col) => {
2515
- if (col.field == undefined)
2516
- select.push(col);
2517
- else select.push(col.field);
2518
- });
2519
-
2520
- // 获取排序字段
2521
-
2522
- let sort = [];
2523
- _.forEach(sort_test, (sortField) => {
2524
- if (sortField.field_name == undefined)
2525
- sort.push(sortField);
2526
- else sort.push([sortField.field_name, sortField.order]);
2527
- })
2528
-
2529
- let orders = [];
2530
- _.map(sort, (value) => {
2531
- let order_tmp = [];
2532
- if (value[1] == "desc")
2533
- order_tmp = value[0] + ' desc';
2534
- else
2535
- order_tmp = value[0];
2536
- orders.push(order_tmp);
2537
- });
2538
- let order = orders.join(',');
2539
-
2540
- let filename = uiSchema.label + "-" + list_views[list_views_name].label;
2541
-
2542
- url_tmp = api.url.split('?')[0];
2543
- api.url = url_tmp + "?$select=" + encodeURIComponent(select.toString()) + "&filename=" + encodeURIComponent(filename);
2544
-
2545
- // 判断sort 和 filters
2546
- if (sort.length > 0) {
2547
- api.url += "&$orderby=" + encodeURIComponent(order);
2548
- }
2549
- let filters = list_views[list_views_name].filters;
2550
- if (filters && filters.length > 0) {
2551
- api.url = api.url + "&filters=" + encodeURIComponent(JSON.stringify(filters));
2552
- }
2553
- return api;
2554
- `;
2508
+ const requestAdaptor = function () {
2509
+ let uiSchema = api.body.uiSchema;
2510
+ let list_views_name = api.body.listName;
2511
+ let list_views = uiSchema.list_views;
2512
+ const listViewPropsStoreKey = location.pathname + "/crud/query";
2513
+ const query = JSON.parse(sessionStorage.getItem(listViewPropsStoreKey));
2514
+ const { filters, sort, fields: select } = query;
2515
+ let filename = uiSchema.label + "-" + list_views[list_views_name].label;
2516
+
2517
+ var url_tmp = api.url.split('?')[0];
2518
+ api.url = url_tmp + "?$select=" + encodeURIComponent(select.toString()) + "&filename=" + encodeURIComponent(filename);
2519
+ // 判断sort filters
2520
+ if (sort.length > 0) {
2521
+ api.url += "&$orderby=" + encodeURIComponent(sort);
2522
+ }
2523
+ if (filters && filters.length > 0) {
2524
+ api.url = api.url + "&filters=" + encodeURIComponent(JSON.stringify(filters));
2525
+ }
2526
+ return api;
2527
+ };
2555
2528
  return {
2556
2529
  "type": "service",
2557
- "body": [{
2558
- "type": "button",
2559
- "label": i18next__default["default"].t('frontend_export_excel'),
2560
- "id": "u:standard_export_excel",
2561
- "level": "default",
2562
- "onEvent": {
2563
- "click": {
2564
- "weight": 0,
2565
- "actions": [
2566
- {
2567
- "args": {
2568
- "api": {
2569
- "url": "${context.rootUrl}/api/record/export/${objectName}",
2570
- "method": "get",
2571
- "messages": {},
2572
- "requestAdaptor": requestAdaptor,
2573
- "data": {
2574
- "uiSchema": "${uiSchema}",
2575
- "listName": "${listName}"
2576
- },
2577
- "headers": {
2578
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
2530
+ "body": [
2531
+ {
2532
+ "type": "button",
2533
+ "label": i18next__default["default"].t('frontend_export_excel'),
2534
+ "id": "u:standard_export_excel",
2535
+ "level": "default",
2536
+ "disabledTip": i18next__default["default"].t('frontend_export_excel_toast'),
2537
+ "onEvent": {
2538
+ "click": {
2539
+ "weight": 0,
2540
+ "actions": [{
2541
+ "componentId": "u:standard_export_excel",
2542
+ "actionType": "disabled"
2543
+ },
2544
+ {
2545
+ "args": {
2546
+ "api": {
2547
+ "url": "${context.rootUrl}/api/record/export/${objectName}",
2548
+ "method": "get",
2549
+ "messages": {},
2550
+ "requestAdaptor": requestAdaptor.toString().match(/function[^{]+\{([\s\S]*)\}$/)[1],
2551
+ "data": {
2552
+ "uiSchema": "${uiSchema}",
2553
+ "listName": "${listName}"
2554
+ },
2555
+ "headers": {
2556
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
2557
+ }
2579
2558
  }
2580
- }
2559
+ },
2560
+ "actionType": "download"
2581
2561
  },
2582
- "actionType": "download"
2583
- }
2584
- ]
2562
+ {
2563
+ "componentId": "u:standard_export_excel",
2564
+ "actionType": "enabled"
2565
+ }
2566
+ ]
2567
+ }
2585
2568
  }
2586
2569
  }
2587
- }]
2570
+ ]
2588
2571
  }
2589
2572
  };
2590
2573
 
@@ -3096,6 +3079,7 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3096
3079
  return {
3097
3080
  "type": "button",
3098
3081
  "icon": "fa fa-angle-down",
3082
+ "className": "mr-0",
3099
3083
  "onEvent": {
3100
3084
  "click": {
3101
3085
  "actions": [
@@ -3147,7 +3131,7 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3147
3131
  name: button.name,
3148
3132
  objectName: button.objectName,
3149
3133
  visibleOn: getButtonVisibleOn$1(button),
3150
- className: `button_${button.name}`
3134
+ className: `button_${button.name} mr-0`
3151
3135
  }
3152
3136
  });
3153
3137
  }
@@ -3667,7 +3651,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3667
3651
  const selfData = api.body.$self;
3668
3652
  const uiSchema = selfData.uiSchema;
3669
3653
  const fields = uiSchema.fields;
3670
- const options = (payload.data?.options || []).filter(function(item){
3654
+ const options = ((payload.data && payload.data.options) || []).filter(function(item){
3671
3655
  let field = fields[item.value];
3672
3656
  // TODO: 暂时禁用location类型字段的列表搜索
3673
3657
  return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'
@@ -4070,7 +4054,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
4070
4054
  "actions": [
4071
4055
  {
4072
4056
  "actionType": "custom",
4073
- "script": "Steedos.goBack()"
4057
+ "script": "window.goBack()"
4074
4058
  }
4075
4059
  ]
4076
4060
  }
@@ -4946,10 +4930,10 @@ function apiRequestAdaptor$1(){
4946
4930
  const recordId_tmp = api.body.recordId;
4947
4931
 
4948
4932
  if (typeof formData_tmp.columns == 'string') {
4949
- formData_tmp.columns = formData_tmp.columns?.split(',');
4933
+ formData_tmp.columns = formData_tmp.columns && formData_tmp.columns.split(',');
4950
4934
  }
4951
4935
  if (typeof formData_tmp.mobile_columns == 'string') {
4952
- formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');
4936
+ formData_tmp.mobile_columns = formData_tmp.mobile_columns && formData_tmp.mobile_columns.split(',');
4953
4937
  }
4954
4938
 
4955
4939
  // 数据格式转换
@@ -5082,7 +5066,7 @@ function apiRequestAdaptor(){
5082
5066
  const recordId = api.body.recordId;
5083
5067
  //数据格式转换
5084
5068
  if (typeof formData.sort == 'string') {
5085
- formData.sort = formData.sort?.split(',');
5069
+ formData.sort = formData.sort && formData.sort.split(',');
5086
5070
  }
5087
5071
  formData.sort = lodash.map(formData.sort, (item) => {
5088
5072
  const arr = item.split(':');
@@ -5272,7 +5256,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5272
5256
 
5273
5257
  function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords" } = {}){
5274
5258
  const searchableFieldsLabel = [];
5275
- _.each(fields, function (field) {
5259
+ _.each(mainObject.fields, function (field) {
5276
5260
  if (isFieldQuickSearchable(field, mainObject.NAME_FIELD_KEY)) {
5277
5261
  searchableFieldsLabel.push(field.label);
5278
5262
  }
@@ -5464,8 +5448,14 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5464
5448
 
5465
5449
  function getObjectFooterToolbar(mainObject, formFactor, options) {
5466
5450
  if (formFactor === 'SMALL') {
5451
+ // return [
5452
+ // "load-more",
5453
+ // ]
5467
5454
  return [
5468
- "load-more",
5455
+ {
5456
+ "type": "pagination",
5457
+ "maxButtons": 5
5458
+ }
5469
5459
  ]
5470
5460
  }
5471
5461
  else {
@@ -5864,13 +5854,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
5864
5854
  })){
5865
5855
  i++;
5866
5856
  tableFields.push(field);
5867
- if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
5868
- searchableFields.push(field.name);
5869
- }
5870
5857
  }
5871
5858
  }
5872
5859
  });
5873
5860
 
5861
+ ___namespace.each(refObjectConfig.fields, function (field) {
5862
+ if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
5863
+ searchableFields.push(field.name);
5864
+ }
5865
+ });
5866
+
5874
5867
  const fields = {
5875
5868
  [referenceTo.labelField.name]: referenceTo.labelField,
5876
5869
  [referenceTo.valueField.name]: referenceTo.valueField
@@ -5922,7 +5915,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5922
5915
  if(api.data.$term){
5923
5916
  filters = [["name", "contains", "'+ api.data.$term +'"]];
5924
5917
  }else if(selfData.op === 'loadOptions' && selfData.value){
5925
- if(selfData.value?.indexOf(',') > 0){
5918
+ if(selfData.value && selfData.value.indexOf(',') > 0){
5926
5919
  fieldValue = selfData.value.split(',');
5927
5920
  filters = [["${referenceTo.valueField.name}", "=", fieldValue]];
5928
5921
  }else{
@@ -6055,13 +6048,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
6055
6048
  }
6056
6049
 
6057
6050
  let pickerSchema = null;
6058
- if(ctx.formFactor === 'SMALL'){
6059
- pickerSchema = await getListSchema$1(tableFields, {
6060
- top: top,
6061
- ...ctx,
6062
- actions: false
6063
- });
6064
- }else {
6051
+ {
6065
6052
  pickerSchema = await getTableSchema$1(tableFields, {
6066
6053
  labelFieldName: refObjectConfig.NAME_FIELD_KEY,
6067
6054
  top: top,
@@ -6117,7 +6104,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
6117
6104
  {
6118
6105
  "actionType": "custom",
6119
6106
  "script": `
6120
- const masterRecord = event.data._master?.record;
6107
+ const masterRecord = event.data._master && event.data._master.record;
6121
6108
  const fieldConfig = ${JSON.stringify(field)};
6122
6109
  let reference_to = fieldConfig.reference_to;
6123
6110
  let saveValue;
@@ -6430,6 +6417,7 @@ async function lookupToAmis(field, readonly, ctx){
6430
6417
  }
6431
6418
 
6432
6419
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
6420
+ ctx.onlyDisplayLookLabel = true;
6433
6421
  if(ctx.idsDependOn){
6434
6422
  // ids人员点选模式
6435
6423
  return await lookupToAmisIdsPicker(field, readonly, ctx);
@@ -6500,7 +6488,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
6500
6488
  var pageNo = api.data.pageNo || 1;
6501
6489
  var skip = (pageNo - 1) * pageSize;
6502
6490
  if(selfData.op === 'loadOptions' && selfData.value){
6503
- if(selfData.value?.indexOf(',') > 0){
6491
+ if(selfData.value && selfData.value.indexOf(',') > 0){
6504
6492
  filters = [["${referenceTo.valueField.name}", "=", selfData.value.split(',')]];
6505
6493
  }else{
6506
6494
  filters = [["${referenceTo.valueField.name}", "=", selfData.value]];
@@ -6533,6 +6521,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
6533
6521
  pickerSchema = await getTableSchema$1(tableFields, {
6534
6522
  labelFieldName: refObjectConfig.NAME_FIELD_KEY,
6535
6523
  top: top,
6524
+ isLookup: true,
6536
6525
  ...ctx
6537
6526
  });
6538
6527
 
@@ -6575,8 +6564,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
6575
6564
  /*
6576
6565
  * @Author: baozhoutao@steedos.com
6577
6566
  * @Date: 2023-01-13 17:27:54
6578
- * @LastEditors: liaodaxue
6579
- * @LastEditTime: 2023-07-27 17:33:54
6567
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
6568
+ * @LastEditTime: 2023-08-28 17:45:38
6580
6569
  * @Description:
6581
6570
  */
6582
6571
 
@@ -6638,14 +6627,29 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
6638
6627
 
6639
6628
  const getHtmlFieldSchema = (field, readonly, ctx)=>{
6640
6629
  if(readonly){
6630
+ // return {
6631
+ // "type": "control",
6632
+ // "label": field.label,
6633
+ // "body": {
6634
+ // "type": "html",
6635
+ // "name": field.name
6636
+ // }
6637
+ // }
6641
6638
  return {
6642
- "type": "control",
6643
- "label": field.label,
6644
- "body": {
6645
- "type": "html",
6646
- "name": field.name
6647
- }
6639
+ "type": "input-rich-text",
6640
+ "receiver": "${context.rootUrl}/s3/images",
6641
+ "name": field.name,
6642
+ "options": {
6643
+ "plugins": [
6644
+ "autoresize"
6645
+ ],
6646
+ // "max_height": 2000,
6647
+ "statusbar": false,
6648
+ "readonly": true,
6649
+ "toolbar": false,
6650
+ "menubar": false
6648
6651
  }
6652
+ }
6649
6653
  }else {
6650
6654
  return {
6651
6655
  "type": "input-rich-text",
@@ -6703,6 +6707,9 @@ function getAmisStaticFieldType(type, readonly, options){
6703
6707
  return type;
6704
6708
  }
6705
6709
  if(___namespace.includes(['text','image'], type)){
6710
+ if('text' === type && options && options.amis && options.amis.tpl){
6711
+ return 'static';
6712
+ }
6706
6713
  if('image' === type && options && options.multiple){
6707
6714
  return `static-images`;
6708
6715
  }
@@ -6973,7 +6980,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6973
6980
  // }
6974
6981
  switch (field.type) {
6975
6982
  case 'text':
6976
- convertData.type = getAmisStaticFieldType('text', readonly);
6983
+ convertData.type = getAmisStaticFieldType('text', readonly, field);
6977
6984
  break;
6978
6985
  case 'textarea':
6979
6986
  convertData.type = getAmisStaticFieldType('textarea', readonly);
@@ -7739,7 +7746,7 @@ async function getQuickEditSchema(field, options){
7739
7746
  case "number":
7740
7747
  case "currency":
7741
7748
  TempDisplayField = `
7742
- _display["${field.name}"] = event.data.value?.toFixed(${field.scale});
7749
+ _display["${field.name}"] = event.data.value && event.data.value.toFixed(${field.scale});
7743
7750
  `;
7744
7751
  quickEditSchema.body[0].onEvent["change"] = quickEditOnEvent(TempDisplayField);
7745
7752
 
@@ -7927,13 +7934,15 @@ async function getTableColumns(fields, options){
7927
7934
  }
7928
7935
  },
7929
7936
  "actionType": "download",
7930
- "expression": "!!!window?.nw?.require"//浏览器上直接下载
7937
+ // "expression": "!!!window?.nw?.require"//浏览器上直接下载
7938
+ "expression": "!!!(window && window.nw && window.nw.require)"//浏览器上直接下载
7931
7939
  },
7932
7940
  {
7933
7941
  "args": {},
7934
7942
  "actionType": "custom",
7935
7943
  "script": previewFileScript,
7936
- "expression": "!!window?.nw?.require" //PC客户端预览附件
7944
+ // "expression": "!!window?.nw?.require" //PC客户端预览附件
7945
+ "expression": "!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
7937
7946
  }
7938
7947
  ]
7939
7948
  }
@@ -8054,7 +8063,7 @@ async function getTableColumns(fields, options){
8054
8063
  */
8055
8064
  function getMobileLines(tpls){
8056
8065
  let lines = [];
8057
- let maxLineCount = 2;
8066
+ let maxLineCount = 3;
8058
8067
  let lineChildren = [];
8059
8068
  let isNewLine = false;
8060
8069
  let isLeft = true;
@@ -8072,10 +8081,10 @@ function getMobileLines(tpls){
8072
8081
  }
8073
8082
  if(isLeft){
8074
8083
  // 左侧半行
8075
- lineChildrenClassName = "steedos-listview-item-left two-lines-truncate";
8084
+ lineChildrenClassName = "steedos-listview-item-left truncate";
8076
8085
  if(item.field.is_wide){
8077
- // 左侧全行样式可以单独写
8078
- lineChildrenClassName = "steedos-listview-item-wide truncate";
8086
+ // 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
8087
+ lineChildrenClassName = "steedos-listview-item-wide";
8079
8088
  }
8080
8089
  if(lines.length === 0){
8081
8090
  // 第一个字段加粗黑色显示
@@ -8083,7 +8092,7 @@ function getMobileLines(tpls){
8083
8092
  }
8084
8093
  }
8085
8094
  else {
8086
- // 右侧半行
8095
+ // 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
8087
8096
  lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
8088
8097
  }
8089
8098
  lineChildren.push({
@@ -8123,7 +8132,7 @@ async function getMobileTableColumns(fields, options){
8123
8132
  let tpl = "";
8124
8133
  if(field.is_name || field.name === options.labelFieldName){
8125
8134
  nameField = field;
8126
- options.onlyDisplayLabel = true;
8135
+ options.onlyDisplayLookLabel = true;
8127
8136
  tpl = await getFieldTpl(field, options);
8128
8137
  }
8129
8138
  else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
@@ -8132,12 +8141,13 @@ async function getMobileTableColumns(fields, options){
8132
8141
  }
8133
8142
  else {
8134
8143
  if(field.type === 'lookup' || field.type === 'master_detail'){
8135
- options.onlyDisplayLabel = true;
8144
+ options.onlyDisplayLookLabel = true;
8136
8145
  }
8137
8146
  tpl = await getFieldTpl(field, options);
8138
8147
  }
8139
8148
  if(!tpl){
8140
- tpl = `\${${field.name}}`;
8149
+ //qhd需求简易处理,加上raw以支持审批王名称字段通过颜色区分缓急,若之后手机端列表支持配置amis,则可以去掉
8150
+ tpl = `\${${field.name} | raw}`;
8141
8151
  }
8142
8152
  if(!field.hidden && !field.extra){
8143
8153
  tpls.push({ field, tpl });
@@ -8328,19 +8338,26 @@ async function getTableOperation(ctx){
8328
8338
 
8329
8339
  async function getTableSchema$1(fields, options){
8330
8340
  let isLookup = options && options.isLookup;
8341
+ let hiddenColumnOperation = options && options.hiddenColumnOperation;
8331
8342
  if(!options){
8332
8343
  options = {};
8333
8344
  }
8334
8345
  let columns = [];
8335
- if(options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1){
8346
+ let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
8347
+ if(isLookup){
8348
+ // 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
8349
+ useMobileColumns = false;
8350
+ }
8351
+ if(useMobileColumns){
8336
8352
  columns = await getMobileTableColumns(fields, options);
8337
8353
  }
8338
8354
  else {
8339
8355
  columns = await getTableColumns(fields, options);
8340
- if(!isLookup){
8356
+ if(!isLookup && !hiddenColumnOperation){
8341
8357
  columns.push(await getTableOperation(options));
8342
8358
  }
8343
8359
  }
8360
+
8344
8361
  return {
8345
8362
  mode: "table",
8346
8363
  name: "thelist",
@@ -8351,7 +8368,7 @@ async function getTableSchema$1(fields, options){
8351
8368
  columns: columns,
8352
8369
  syncLocation: false,
8353
8370
  keepItemSelectionOnPageChange: true,
8354
- checkOnItemClick: false,
8371
+ checkOnItemClick: isLookup ? true : false,
8355
8372
  labelTpl: `\${${options.labelFieldName}}`,
8356
8373
  autoFillHeight: false, // 自动高度效果不理想,先关闭
8357
8374
  columnsTogglable: false,
@@ -8388,7 +8405,7 @@ async function getTableApi(mainObject, fields, options){
8388
8405
  baseFilters = filter;
8389
8406
  }
8390
8407
 
8391
- ___namespace.each(fields, function (field) {
8408
+ ___namespace.each(mainObject.fields, function (field) {
8392
8409
  if (isFieldQuickSearchable(field, mainObject.NAME_FIELD_KEY)) {
8393
8410
  searchableFields.push(field.name);
8394
8411
  }
@@ -8450,7 +8467,9 @@ async function getTableApi(mainObject, fields, options){
8450
8467
  // 如果是第一次加载组件始终让翻页页码从本地存储中取值
8451
8468
  let formFactor = "${options.formFactor}";
8452
8469
  // 移动端不识别本地存储中的翻页页码,否则点击加载更多按钮后无法刷新回第一页
8453
- api.data.pageNo = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8470
+ // api.data.pageNo = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8471
+ // 移动端暂时去除加载更多,放开翻页
8472
+ api.data.pageNo = localListViewProps.page || 1;
8454
8473
  }
8455
8474
  }
8456
8475
  }
@@ -8571,7 +8590,17 @@ async function getTableApi(mainObject, fields, options){
8571
8590
  api.data = {
8572
8591
  query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
8573
8592
  }
8574
- ${options.requestAdaptor || ''}
8593
+ ${options.requestAdaptor || ''};
8594
+
8595
+ //写入本次存储filters、sort
8596
+ const listViewPropsStoreKey = location.pathname + "/crud/query";
8597
+ sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify({
8598
+ filters: filters,
8599
+ sort: sort.trim(),
8600
+ pageSize: pageSize,
8601
+ skip: skip,
8602
+ fields: ${JSON.stringify(___namespace.map(fields, 'name'))}
8603
+ }));
8575
8604
  return api;
8576
8605
  `;
8577
8606
  api.adaptor = `
@@ -8650,7 +8679,8 @@ async function getTableApi(mainObject, fields, options){
8650
8679
  // 如果是第一次加载组件始终让翻页页码从本地存储中取值
8651
8680
  let formFactor = "${options.formFactor}";
8652
8681
  // 移动端不识别本地存储中的翻页页码,否则点击加载更多按钮后无法刷新回第一页
8653
- selfData.page = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8682
+ // selfData.page = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8683
+ selfData.page = localListViewProps.page || 1;
8654
8684
  }
8655
8685
  }
8656
8686
  delete selfData.context;
@@ -8668,7 +8698,13 @@ async function getTableApi(mainObject, fields, options){
8668
8698
  const setDataToComponentId = "${setDataToComponentId}";
8669
8699
  if(setDataToComponentId){
8670
8700
  //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
8671
- SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
8701
+ var scope = SteedosUI.getRef(api.body.$self.$scopeId);
8702
+ var scopeParent = scope && scope.parent;
8703
+ var setDataToComponent = scopeParent && scopeParent.getComponentById(setDataToComponentId);
8704
+ if(setDataToComponent){
8705
+ setDataToComponent.setData({$count: payload.data.count});
8706
+ }
8707
+ // SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
8672
8708
  };
8673
8709
  ${options.adaptor || ''}
8674
8710
  return payload;
@@ -8954,7 +8990,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
8954
8990
  var uiSchema = api.body.uiSchema;
8955
8991
  var defaultData = api.body.defaultData;
8956
8992
  var defaultValues = {};
8957
- _.each(uiSchema?.fields, function(field){
8993
+ _.each(uiSchema && uiSchema.fields, function(field){
8958
8994
  var value = SteedosUI.getFieldDefaultValue(field, api.body.global);
8959
8995
  if(value){
8960
8996
  defaultValues[field.name] = value;
@@ -9173,7 +9209,12 @@ async function getCalendarApi(mainObject, fields, options) {
9173
9209
  window.postMessage(Object.assign({type: "listview.loaded"}), "*");
9174
9210
  const setDataToComponentId = "${setDataToComponentId}";
9175
9211
  if(setDataToComponentId){
9176
- SteedosUI.getRef(api.body.$self.scopeId)?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
9212
+ var scope = SteedosUI.getRef(api.body.$self.scopeId);
9213
+ var setDataToComponent = scope && scope.getComponentById(setDataToComponentId);
9214
+ if(setDataToComponent){
9215
+ setDataToComponent.setData({$count: payload.data.count});
9216
+ }
9217
+ // SteedosUI.getRef(api.body.$self.scopeId)?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
9177
9218
  }
9178
9219
  const rows = payload.data.rows || [];
9179
9220
  const selfData = api.data.$self;
@@ -9920,6 +9961,10 @@ async function getObjectCRUD(objectSchema, fields, options){
9920
9961
  }
9921
9962
  }
9922
9963
  `;
9964
+ let autoFillHeight = true;
9965
+ if(options.isRelated || Steedos.isMobile()){
9966
+ autoFillHeight = false;
9967
+ }
9923
9968
 
9924
9969
  body = Object.assign({}, table, {
9925
9970
  type: 'crud',
@@ -9930,7 +9975,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9930
9975
  keepItemSelectionOnPageChange: true,
9931
9976
  api: await getTableApi(objectSchema, fields, options),
9932
9977
  hiddenOn: options.tableHiddenOn,
9933
- autoFillHeight: options.isRelated ? false : true,
9978
+ autoFillHeight,
9934
9979
  className: `flex-auto ${crudClassName || ""}`,
9935
9980
  bodyClassName: "bg-white",
9936
9981
  crudClassName: crudClassName,
@@ -10173,7 +10218,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
10173
10218
  // "blank": false
10174
10219
  // },
10175
10220
  "actionType": "custom",
10176
- "script": "Steedos.goBack()",
10221
+ "script": "window.goBack()",
10177
10222
  "expression": "this.__deletedRecord === true"
10178
10223
  }
10179
10224
  ]
@@ -10290,7 +10335,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
10290
10335
  * @Author: baozhoutao@steedos.com
10291
10336
  * @Date: 2022-07-05 15:55:39
10292
10337
  * @LastEditors: liaodaxue
10293
- * @LastEditTime: 2023-08-21 14:50:21
10338
+ * @LastEditTime: 2023-08-28 14:55:23
10294
10339
  * @Description:
10295
10340
  */
10296
10341
 
@@ -10436,11 +10481,16 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
10436
10481
  // }
10437
10482
  const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
10438
10483
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
10484
+ const isMobile = window.innerWidth < 768;
10485
+ let headerToolbar = [];
10486
+ if(!isMobile){
10487
+ headerToolbar.push("bulkActions");
10488
+ }
10439
10489
  const options = {
10440
10490
  globalFilter,
10441
10491
  defaults: {
10442
10492
  listSchema: {
10443
- headerToolbar:["bulkActions"],
10493
+ headerToolbar,
10444
10494
  columnsTogglable: false,
10445
10495
  onEvent: {
10446
10496
  [`@data.changed.${relatedObjectName}`]: {
@@ -10636,8 +10686,8 @@ async function getRelatedListSchema(
10636
10686
  /*
10637
10687
  * @Author: baozhoutao@steedos.com
10638
10688
  * @Date: 2022-07-05 15:55:39
10639
- * @LastEditors: baozhoutao@steedos.com
10640
- * @LastEditTime: 2023-08-17 18:03:51
10689
+ * @LastEditors: liaodaxue
10690
+ * @LastEditTime: 2023-08-25 11:55:15
10641
10691
  * @Description:
10642
10692
  */
10643
10693
 
@@ -10902,7 +10952,7 @@ async function getListSchema(
10902
10952
  * 本次存储代码段
10903
10953
  */
10904
10954
  try {
10905
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
10955
+ const listViewPropsStoreKey = location.pathname + "/crud";
10906
10956
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10907
10957
  /**
10908
10958
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
@@ -10924,11 +10974,12 @@ async function getListSchema(
10924
10974
  if(localListViewProps.orderDir){
10925
10975
  listSchema.orderDir = localListViewProps.orderDir;
10926
10976
  }
10927
- // if(localListViewProps.perPage){
10928
- // listSchema.defaultParams = {
10929
- // perPage: localListViewProps.perPage
10930
- // }
10931
- // }
10977
+
10978
+ if(localListViewProps.perPage){
10979
+ listSchema.defaultParams = {
10980
+ perPage: localListViewProps.perPage
10981
+ };
10982
+ }
10932
10983
  defaults.listSchema = _$1.defaultsDeep({}, listSchema, defaults.listSchema || {});
10933
10984
  }
10934
10985
  }
@@ -12281,7 +12332,7 @@ const getNextStepUsersInput = async (instance) => {
12281
12332
  id: "u:ffff15b76c89",
12282
12333
  className: "b-a b-1x p-xs m-b-none m-l-none m-r-none m-t-sm",
12283
12334
  subFormMode: "",
12284
- hiddenOn: "!!!this.new_next_step || this.new_next_step?.step_type === 'end'"
12335
+ hiddenOn: "!!!this.new_next_step || (this.new_next_step && this.new_next_step.step_type === 'end')"
12285
12336
  };
12286
12337
  };
12287
12338
 
@@ -13201,7 +13252,7 @@ const getFieldReadonlyTpl = async (field, label)=>{
13201
13252
  map[item.value] = item.label;
13202
13253
  });
13203
13254
  tpl.type = 'static';
13204
- tpl.tpl = `<% var options = ${JSON.stringify(map)}; return options?.[data.${field.code}] || ''%>`;
13255
+ tpl.tpl = `<% var options = ${JSON.stringify(map)}; return (options && options[data.${field.code}]) || ''%>`;
13205
13256
  }else if(field.type === 'odata'){
13206
13257
  tpl.type = 'static';
13207
13258
  tpl.tpl = `<div>\${${field.code}['@label']}</div>`;
@@ -13231,7 +13282,7 @@ const getFieldReadonlyTpl = async (field, label)=>{
13231
13282
  if(field.is_multiselect){
13232
13283
  tpl.tpl = `\${_.map(${field.code}, 'name')}`;
13233
13284
  }else {
13234
- tpl.tpl = `\${${field.code}?.name}`;
13285
+ tpl.tpl = `\${${field.code} && ${field.code}.name}`;
13235
13286
  }
13236
13287
  }else if(field.type === 'group'){
13237
13288
  tpl.type = 'static';