@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.esm.js CHANGED
@@ -400,7 +400,7 @@ function getContrastColor(bgColor) {
400
400
  * @Author: baozhoutao@steedos.com
401
401
  * @Date: 2022-05-23 09:53:08
402
402
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
403
- * @LastEditTime: 2023-08-03 18:07:54
403
+ * @LastEditTime: 2023-08-29 15:04:39
404
404
  * @Description:
405
405
  */
406
406
 
@@ -504,7 +504,7 @@ function getRelatedFieldTpl(field, ctx){
504
504
  linkTarget = "target='_blank'";
505
505
  }
506
506
 
507
- const onlyDisplayLabel = ctx.onlyDisplayLabel;
507
+ const onlyDisplayLookLabel = ctx.onlyDisplayLookLabel;
508
508
 
509
509
  let fieldDataStrTpl = `data._display.${field.name}`;
510
510
 
@@ -515,7 +515,7 @@ function getRelatedFieldTpl(field, ctx){
515
515
  if(_.isString(field.reference_to) || !field.reference_to){
516
516
  if(field.multiple){
517
517
  let labelTpl = `<%=item.label%>`;
518
- if(!onlyDisplayLabel){
518
+ if(!onlyDisplayLookLabel){
519
519
  const href = Router.getObjectDetailPath({
520
520
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
521
521
  });
@@ -533,7 +533,7 @@ function getRelatedFieldTpl(field, ctx){
533
533
  objectNameTpl = `\${${field.name}.objectName}`;
534
534
  recordIdTpl = `\${${field.name}.value}`;
535
535
  }
536
- if(!onlyDisplayLabel){
536
+ if(!onlyDisplayLookLabel){
537
537
  const href = Router.getObjectDetailPath({
538
538
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
539
539
  });
@@ -545,7 +545,7 @@ function getRelatedFieldTpl(field, ctx){
545
545
 
546
546
  }else {
547
547
  let labelTpl = `<%=item.label%>`;
548
- if(!onlyDisplayLabel){
548
+ if(!onlyDisplayLookLabel){
549
549
  const href = Router.getObjectDetailPath({
550
550
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
551
551
  });
@@ -598,7 +598,7 @@ function getLocationTpl(field){
598
598
  }
599
599
 
600
600
  async function getFieldTpl (field, options){
601
- if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLabel){
601
+ if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
602
602
  return getNameTpl(field, options)
603
603
  }
604
604
  switch (field.type) {
@@ -787,7 +787,7 @@ function getScriptForRemoveUrlPrefixForImgFields(fields){
787
787
  if(imgFields[item].multiple){
788
788
  if(imgFieldValue instanceof Array){
789
789
  formData[item] = imgFieldValue.map((value)=>{
790
- let itemValue = value?.split('/');
790
+ let itemValue = value && value.split('/');
791
791
  return itemValue[itemValue.length - 1];
792
792
  });
793
793
  }
@@ -1014,6 +1014,7 @@ var frontend_listview_control_rename_title$1 = "Rename List View";
1014
1014
  var frontend_listview_control_share$1 = "Sharing Settings";
1015
1015
  var frontend_listview_control_sort$1 = "Default sorting rule";
1016
1016
  var frontend_export_excel$1 = "Export Excel";
1017
+ var frontend_export_excel_toast$1 = "Exporting, please wait";
1017
1018
  var frontend_operation$1 = "Operation";
1018
1019
  var frontend_import_data$1 = "Import data";
1019
1020
  var frontend_import_data_object_name$1 = "Import object";
@@ -1098,6 +1099,7 @@ var en_us = {
1098
1099
  frontend_listview_control_share: frontend_listview_control_share$1,
1099
1100
  frontend_listview_control_sort: frontend_listview_control_sort$1,
1100
1101
  frontend_export_excel: frontend_export_excel$1,
1102
+ frontend_export_excel_toast: frontend_export_excel_toast$1,
1101
1103
  frontend_operation: frontend_operation$1,
1102
1104
  frontend_import_data: frontend_import_data$1,
1103
1105
  frontend_import_data_object_name: frontend_import_data_object_name$1,
@@ -1184,6 +1186,7 @@ var frontend_listview_control_rename_title = "重命名 列表视图";
1184
1186
  var frontend_listview_control_share = "共享设置";
1185
1187
  var frontend_listview_control_sort = "默认排序规则";
1186
1188
  var frontend_export_excel = "导出";
1189
+ var frontend_export_excel_toast = "正在导出,请稍后...";
1187
1190
  var frontend_operation = "操作";
1188
1191
  var frontend_import_data = "导入数据";
1189
1192
  var frontend_import_data_object_name = "导入对象";
@@ -1269,6 +1272,7 @@ var zh_cn = {
1269
1272
  frontend_listview_control_share: frontend_listview_control_share,
1270
1273
  frontend_listview_control_sort: frontend_listview_control_sort,
1271
1274
  frontend_export_excel: frontend_export_excel,
1275
+ frontend_export_excel_toast: frontend_export_excel_toast,
1272
1276
  frontend_operation: frontend_operation,
1273
1277
  frontend_import_data: frontend_import_data,
1274
1278
  frontend_import_data_object_name: frontend_import_data_object_name,
@@ -2258,7 +2262,7 @@ const getSchema$2 = (uiSchema) => {
2258
2262
  "Bearer ${context.tenantId},${context.authToken}",
2259
2263
  },
2260
2264
  requestAdaptor:
2261
- "\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 ",
2265
+ "\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 ",
2262
2266
  adaptor:
2263
2267
  "\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 ",
2264
2268
  },
@@ -2437,7 +2441,7 @@ const getSchema$2 = (uiSchema) => {
2437
2441
  * @Author: baozhoutao@steedos.com
2438
2442
  * @Date: 2022-11-07 17:00:38
2439
2443
  * @LastEditors: baozhoutao@steedos.com
2440
- * @LastEditTime: 2022-11-07 17:12:20
2444
+ * @LastEditTime: 2023-08-24 16:44:42
2441
2445
  * @Description:
2442
2446
  */
2443
2447
 
@@ -2457,7 +2461,7 @@ const getSchema$1 = (uiSchema)=>{
2457
2461
  "componentId": "",
2458
2462
  "args": {
2459
2463
  "blank": false,
2460
- "url": "/app/${app_id}/${objectName}/view/${_id}"
2464
+ "url": "/app/${app_id}/${objectName}/view/${_id}?side_object=${objectName}&side_listview_id=${listName}"
2461
2465
  },
2462
2466
  "actionType": "link"
2463
2467
  }
@@ -2474,90 +2478,69 @@ const getSchema$1 = (uiSchema)=>{
2474
2478
  };
2475
2479
 
2476
2480
  const getSchema = async (uiSchema, ctx) => {
2477
- const requestAdaptor = `
2478
- // 获取列表视图的属性
2479
- let uiSchema = api.body.uiSchema;
2480
- let list_views = uiSchema.list_views;
2481
- let list_views_name = api.body.listName;
2482
- let col = list_views[list_views_name].columns;
2483
- let sort_test = list_views[list_views_name].sort;
2484
-
2485
- // 获取下载字段
2486
- let select = [];
2487
- _.each(col, (col) => {
2488
- if (col.field == undefined)
2489
- select.push(col);
2490
- else select.push(col.field);
2491
- });
2492
-
2493
- // 获取排序字段
2494
-
2495
- let sort = [];
2496
- _.forEach(sort_test, (sortField) => {
2497
- if (sortField.field_name == undefined)
2498
- sort.push(sortField);
2499
- else sort.push([sortField.field_name, sortField.order]);
2500
- })
2501
-
2502
- let orders = [];
2503
- _.map(sort, (value) => {
2504
- let order_tmp = [];
2505
- if (value[1] == "desc")
2506
- order_tmp = value[0] + ' desc';
2507
- else
2508
- order_tmp = value[0];
2509
- orders.push(order_tmp);
2510
- });
2511
- let order = orders.join(',');
2512
-
2513
- let filename = uiSchema.label + "-" + list_views[list_views_name].label;
2514
-
2515
- url_tmp = api.url.split('?')[0];
2516
- api.url = url_tmp + "?$select=" + encodeURIComponent(select.toString()) + "&filename=" + encodeURIComponent(filename);
2517
-
2518
- // 判断sort 和 filters
2519
- if (sort.length > 0) {
2520
- api.url += "&$orderby=" + encodeURIComponent(order);
2521
- }
2522
- let filters = list_views[list_views_name].filters;
2523
- if (filters && filters.length > 0) {
2524
- api.url = api.url + "&filters=" + encodeURIComponent(JSON.stringify(filters));
2525
- }
2526
- return api;
2527
- `;
2481
+ const requestAdaptor = function () {
2482
+ let uiSchema = api.body.uiSchema;
2483
+ let list_views_name = api.body.listName;
2484
+ let list_views = uiSchema.list_views;
2485
+ const listViewPropsStoreKey = location.pathname + "/crud/query";
2486
+ const query = JSON.parse(sessionStorage.getItem(listViewPropsStoreKey));
2487
+ const { filters, sort, fields: select } = query;
2488
+ let filename = uiSchema.label + "-" + list_views[list_views_name].label;
2489
+
2490
+ var url_tmp = api.url.split('?')[0];
2491
+ api.url = url_tmp + "?$select=" + encodeURIComponent(select.toString()) + "&filename=" + encodeURIComponent(filename);
2492
+ // 判断sort filters
2493
+ if (sort.length > 0) {
2494
+ api.url += "&$orderby=" + encodeURIComponent(sort);
2495
+ }
2496
+ if (filters && filters.length > 0) {
2497
+ api.url = api.url + "&filters=" + encodeURIComponent(JSON.stringify(filters));
2498
+ }
2499
+ return api;
2500
+ };
2528
2501
  return {
2529
2502
  "type": "service",
2530
- "body": [{
2531
- "type": "button",
2532
- "label": i18next.t('frontend_export_excel'),
2533
- "id": "u:standard_export_excel",
2534
- "level": "default",
2535
- "onEvent": {
2536
- "click": {
2537
- "weight": 0,
2538
- "actions": [
2539
- {
2540
- "args": {
2541
- "api": {
2542
- "url": "${context.rootUrl}/api/record/export/${objectName}",
2543
- "method": "get",
2544
- "messages": {},
2545
- "requestAdaptor": requestAdaptor,
2546
- "data": {
2547
- "uiSchema": "${uiSchema}",
2548
- "listName": "${listName}"
2549
- },
2550
- "headers": {
2551
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
2503
+ "body": [
2504
+ {
2505
+ "type": "button",
2506
+ "label": i18next.t('frontend_export_excel'),
2507
+ "id": "u:standard_export_excel",
2508
+ "level": "default",
2509
+ "disabledTip": i18next.t('frontend_export_excel_toast'),
2510
+ "onEvent": {
2511
+ "click": {
2512
+ "weight": 0,
2513
+ "actions": [{
2514
+ "componentId": "u:standard_export_excel",
2515
+ "actionType": "disabled"
2516
+ },
2517
+ {
2518
+ "args": {
2519
+ "api": {
2520
+ "url": "${context.rootUrl}/api/record/export/${objectName}",
2521
+ "method": "get",
2522
+ "messages": {},
2523
+ "requestAdaptor": requestAdaptor.toString().match(/function[^{]+\{([\s\S]*)\}$/)[1],
2524
+ "data": {
2525
+ "uiSchema": "${uiSchema}",
2526
+ "listName": "${listName}"
2527
+ },
2528
+ "headers": {
2529
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
2530
+ }
2552
2531
  }
2553
- }
2532
+ },
2533
+ "actionType": "download"
2554
2534
  },
2555
- "actionType": "download"
2556
- }
2557
- ]
2535
+ {
2536
+ "componentId": "u:standard_export_excel",
2537
+ "actionType": "enabled"
2538
+ }
2539
+ ]
2540
+ }
2558
2541
  }
2559
2542
  }
2560
- }]
2543
+ ]
2561
2544
  }
2562
2545
  };
2563
2546
 
@@ -3069,6 +3052,7 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3069
3052
  return {
3070
3053
  "type": "button",
3071
3054
  "icon": "fa fa-angle-down",
3055
+ "className": "mr-0",
3072
3056
  "onEvent": {
3073
3057
  "click": {
3074
3058
  "actions": [
@@ -3120,7 +3104,7 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3120
3104
  name: button.name,
3121
3105
  objectName: button.objectName,
3122
3106
  visibleOn: getButtonVisibleOn$1(button),
3123
- className: `button_${button.name}`
3107
+ className: `button_${button.name} mr-0`
3124
3108
  }
3125
3109
  });
3126
3110
  }
@@ -3640,7 +3624,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3640
3624
  const selfData = api.body.$self;
3641
3625
  const uiSchema = selfData.uiSchema;
3642
3626
  const fields = uiSchema.fields;
3643
- const options = (payload.data?.options || []).filter(function(item){
3627
+ const options = ((payload.data && payload.data.options) || []).filter(function(item){
3644
3628
  let field = fields[item.value];
3645
3629
  // TODO: 暂时禁用location类型字段的列表搜索
3646
3630
  return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'
@@ -4043,7 +4027,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
4043
4027
  "actions": [
4044
4028
  {
4045
4029
  "actionType": "custom",
4046
- "script": "Steedos.goBack()"
4030
+ "script": "window.goBack()"
4047
4031
  }
4048
4032
  ]
4049
4033
  }
@@ -4919,10 +4903,10 @@ function apiRequestAdaptor$1(){
4919
4903
  const recordId_tmp = api.body.recordId;
4920
4904
 
4921
4905
  if (typeof formData_tmp.columns == 'string') {
4922
- formData_tmp.columns = formData_tmp.columns?.split(',');
4906
+ formData_tmp.columns = formData_tmp.columns && formData_tmp.columns.split(',');
4923
4907
  }
4924
4908
  if (typeof formData_tmp.mobile_columns == 'string') {
4925
- formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');
4909
+ formData_tmp.mobile_columns = formData_tmp.mobile_columns && formData_tmp.mobile_columns.split(',');
4926
4910
  }
4927
4911
 
4928
4912
  // 数据格式转换
@@ -5055,7 +5039,7 @@ function apiRequestAdaptor(){
5055
5039
  const recordId = api.body.recordId;
5056
5040
  //数据格式转换
5057
5041
  if (typeof formData.sort == 'string') {
5058
- formData.sort = formData.sort?.split(',');
5042
+ formData.sort = formData.sort && formData.sort.split(',');
5059
5043
  }
5060
5044
  formData.sort = lodash.map(formData.sort, (item) => {
5061
5045
  const arr = item.split(':');
@@ -5245,7 +5229,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5245
5229
 
5246
5230
  function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords" } = {}){
5247
5231
  const searchableFieldsLabel = [];
5248
- _.each(fields, function (field) {
5232
+ _.each(mainObject.fields, function (field) {
5249
5233
  if (isFieldQuickSearchable(field, mainObject.NAME_FIELD_KEY)) {
5250
5234
  searchableFieldsLabel.push(field.label);
5251
5235
  }
@@ -5437,8 +5421,14 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5437
5421
 
5438
5422
  function getObjectFooterToolbar(mainObject, formFactor, options) {
5439
5423
  if (formFactor === 'SMALL') {
5424
+ // return [
5425
+ // "load-more",
5426
+ // ]
5440
5427
  return [
5441
- "load-more",
5428
+ {
5429
+ "type": "pagination",
5430
+ "maxButtons": 5
5431
+ }
5442
5432
  ]
5443
5433
  }
5444
5434
  else {
@@ -5837,13 +5827,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
5837
5827
  })){
5838
5828
  i++;
5839
5829
  tableFields.push(field);
5840
- if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
5841
- searchableFields.push(field.name);
5842
- }
5843
5830
  }
5844
5831
  }
5845
5832
  });
5846
5833
 
5834
+ _$1.each(refObjectConfig.fields, function (field) {
5835
+ if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
5836
+ searchableFields.push(field.name);
5837
+ }
5838
+ });
5839
+
5847
5840
  const fields = {
5848
5841
  [referenceTo.labelField.name]: referenceTo.labelField,
5849
5842
  [referenceTo.valueField.name]: referenceTo.valueField
@@ -5895,7 +5888,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5895
5888
  if(api.data.$term){
5896
5889
  filters = [["name", "contains", "'+ api.data.$term +'"]];
5897
5890
  }else if(selfData.op === 'loadOptions' && selfData.value){
5898
- if(selfData.value?.indexOf(',') > 0){
5891
+ if(selfData.value && selfData.value.indexOf(',') > 0){
5899
5892
  fieldValue = selfData.value.split(',');
5900
5893
  filters = [["${referenceTo.valueField.name}", "=", fieldValue]];
5901
5894
  }else{
@@ -6028,13 +6021,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
6028
6021
  }
6029
6022
 
6030
6023
  let pickerSchema = null;
6031
- if(ctx.formFactor === 'SMALL'){
6032
- pickerSchema = await getListSchema$1(tableFields, {
6033
- top: top,
6034
- ...ctx,
6035
- actions: false
6036
- });
6037
- }else {
6024
+ {
6038
6025
  pickerSchema = await getTableSchema$1(tableFields, {
6039
6026
  labelFieldName: refObjectConfig.NAME_FIELD_KEY,
6040
6027
  top: top,
@@ -6090,7 +6077,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
6090
6077
  {
6091
6078
  "actionType": "custom",
6092
6079
  "script": `
6093
- const masterRecord = event.data._master?.record;
6080
+ const masterRecord = event.data._master && event.data._master.record;
6094
6081
  const fieldConfig = ${JSON.stringify(field)};
6095
6082
  let reference_to = fieldConfig.reference_to;
6096
6083
  let saveValue;
@@ -6403,6 +6390,7 @@ async function lookupToAmis(field, readonly, ctx){
6403
6390
  }
6404
6391
 
6405
6392
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
6393
+ ctx.onlyDisplayLookLabel = true;
6406
6394
  if(ctx.idsDependOn){
6407
6395
  // ids人员点选模式
6408
6396
  return await lookupToAmisIdsPicker(field, readonly, ctx);
@@ -6473,7 +6461,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
6473
6461
  var pageNo = api.data.pageNo || 1;
6474
6462
  var skip = (pageNo - 1) * pageSize;
6475
6463
  if(selfData.op === 'loadOptions' && selfData.value){
6476
- if(selfData.value?.indexOf(',') > 0){
6464
+ if(selfData.value && selfData.value.indexOf(',') > 0){
6477
6465
  filters = [["${referenceTo.valueField.name}", "=", selfData.value.split(',')]];
6478
6466
  }else{
6479
6467
  filters = [["${referenceTo.valueField.name}", "=", selfData.value]];
@@ -6506,6 +6494,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
6506
6494
  pickerSchema = await getTableSchema$1(tableFields, {
6507
6495
  labelFieldName: refObjectConfig.NAME_FIELD_KEY,
6508
6496
  top: top,
6497
+ isLookup: true,
6509
6498
  ...ctx
6510
6499
  });
6511
6500
 
@@ -6548,8 +6537,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
6548
6537
  /*
6549
6538
  * @Author: baozhoutao@steedos.com
6550
6539
  * @Date: 2023-01-13 17:27:54
6551
- * @LastEditors: liaodaxue
6552
- * @LastEditTime: 2023-07-27 17:33:54
6540
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
6541
+ * @LastEditTime: 2023-08-28 17:45:38
6553
6542
  * @Description:
6554
6543
  */
6555
6544
 
@@ -6611,14 +6600,29 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
6611
6600
 
6612
6601
  const getHtmlFieldSchema = (field, readonly, ctx)=>{
6613
6602
  if(readonly){
6603
+ // return {
6604
+ // "type": "control",
6605
+ // "label": field.label,
6606
+ // "body": {
6607
+ // "type": "html",
6608
+ // "name": field.name
6609
+ // }
6610
+ // }
6614
6611
  return {
6615
- "type": "control",
6616
- "label": field.label,
6617
- "body": {
6618
- "type": "html",
6619
- "name": field.name
6620
- }
6612
+ "type": "input-rich-text",
6613
+ "receiver": "${context.rootUrl}/s3/images",
6614
+ "name": field.name,
6615
+ "options": {
6616
+ "plugins": [
6617
+ "autoresize"
6618
+ ],
6619
+ // "max_height": 2000,
6620
+ "statusbar": false,
6621
+ "readonly": true,
6622
+ "toolbar": false,
6623
+ "menubar": false
6621
6624
  }
6625
+ }
6622
6626
  }else {
6623
6627
  return {
6624
6628
  "type": "input-rich-text",
@@ -6676,6 +6680,9 @@ function getAmisStaticFieldType(type, readonly, options){
6676
6680
  return type;
6677
6681
  }
6678
6682
  if(_$1.includes(['text','image'], type)){
6683
+ if('text' === type && options && options.amis && options.amis.tpl){
6684
+ return 'static';
6685
+ }
6679
6686
  if('image' === type && options && options.multiple){
6680
6687
  return `static-images`;
6681
6688
  }
@@ -6946,7 +6953,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6946
6953
  // }
6947
6954
  switch (field.type) {
6948
6955
  case 'text':
6949
- convertData.type = getAmisStaticFieldType('text', readonly);
6956
+ convertData.type = getAmisStaticFieldType('text', readonly, field);
6950
6957
  break;
6951
6958
  case 'textarea':
6952
6959
  convertData.type = getAmisStaticFieldType('textarea', readonly);
@@ -7712,7 +7719,7 @@ async function getQuickEditSchema(field, options){
7712
7719
  case "number":
7713
7720
  case "currency":
7714
7721
  TempDisplayField = `
7715
- _display["${field.name}"] = event.data.value?.toFixed(${field.scale});
7722
+ _display["${field.name}"] = event.data.value && event.data.value.toFixed(${field.scale});
7716
7723
  `;
7717
7724
  quickEditSchema.body[0].onEvent["change"] = quickEditOnEvent(TempDisplayField);
7718
7725
 
@@ -7900,13 +7907,15 @@ async function getTableColumns(fields, options){
7900
7907
  }
7901
7908
  },
7902
7909
  "actionType": "download",
7903
- "expression": "!!!window?.nw?.require"//浏览器上直接下载
7910
+ // "expression": "!!!window?.nw?.require"//浏览器上直接下载
7911
+ "expression": "!!!(window && window.nw && window.nw.require)"//浏览器上直接下载
7904
7912
  },
7905
7913
  {
7906
7914
  "args": {},
7907
7915
  "actionType": "custom",
7908
7916
  "script": previewFileScript,
7909
- "expression": "!!window?.nw?.require" //PC客户端预览附件
7917
+ // "expression": "!!window?.nw?.require" //PC客户端预览附件
7918
+ "expression": "!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
7910
7919
  }
7911
7920
  ]
7912
7921
  }
@@ -8027,7 +8036,7 @@ async function getTableColumns(fields, options){
8027
8036
  */
8028
8037
  function getMobileLines(tpls){
8029
8038
  let lines = [];
8030
- let maxLineCount = 2;
8039
+ let maxLineCount = 3;
8031
8040
  let lineChildren = [];
8032
8041
  let isNewLine = false;
8033
8042
  let isLeft = true;
@@ -8045,10 +8054,10 @@ function getMobileLines(tpls){
8045
8054
  }
8046
8055
  if(isLeft){
8047
8056
  // 左侧半行
8048
- lineChildrenClassName = "steedos-listview-item-left two-lines-truncate";
8057
+ lineChildrenClassName = "steedos-listview-item-left truncate";
8049
8058
  if(item.field.is_wide){
8050
- // 左侧全行样式可以单独写
8051
- lineChildrenClassName = "steedos-listview-item-wide truncate";
8059
+ // 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
8060
+ lineChildrenClassName = "steedos-listview-item-wide";
8052
8061
  }
8053
8062
  if(lines.length === 0){
8054
8063
  // 第一个字段加粗黑色显示
@@ -8056,7 +8065,7 @@ function getMobileLines(tpls){
8056
8065
  }
8057
8066
  }
8058
8067
  else {
8059
- // 右侧半行
8068
+ // 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
8060
8069
  lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
8061
8070
  }
8062
8071
  lineChildren.push({
@@ -8096,7 +8105,7 @@ async function getMobileTableColumns(fields, options){
8096
8105
  let tpl = "";
8097
8106
  if(field.is_name || field.name === options.labelFieldName){
8098
8107
  nameField = field;
8099
- options.onlyDisplayLabel = true;
8108
+ options.onlyDisplayLookLabel = true;
8100
8109
  tpl = await getFieldTpl(field, options);
8101
8110
  }
8102
8111
  else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
@@ -8105,12 +8114,13 @@ async function getMobileTableColumns(fields, options){
8105
8114
  }
8106
8115
  else {
8107
8116
  if(field.type === 'lookup' || field.type === 'master_detail'){
8108
- options.onlyDisplayLabel = true;
8117
+ options.onlyDisplayLookLabel = true;
8109
8118
  }
8110
8119
  tpl = await getFieldTpl(field, options);
8111
8120
  }
8112
8121
  if(!tpl){
8113
- tpl = `\${${field.name}}`;
8122
+ //qhd需求简易处理,加上raw以支持审批王名称字段通过颜色区分缓急,若之后手机端列表支持配置amis,则可以去掉
8123
+ tpl = `\${${field.name} | raw}`;
8114
8124
  }
8115
8125
  if(!field.hidden && !field.extra){
8116
8126
  tpls.push({ field, tpl });
@@ -8301,19 +8311,26 @@ async function getTableOperation(ctx){
8301
8311
 
8302
8312
  async function getTableSchema$1(fields, options){
8303
8313
  let isLookup = options && options.isLookup;
8314
+ let hiddenColumnOperation = options && options.hiddenColumnOperation;
8304
8315
  if(!options){
8305
8316
  options = {};
8306
8317
  }
8307
8318
  let columns = [];
8308
- if(options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1){
8319
+ let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
8320
+ if(isLookup){
8321
+ // 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
8322
+ useMobileColumns = false;
8323
+ }
8324
+ if(useMobileColumns){
8309
8325
  columns = await getMobileTableColumns(fields, options);
8310
8326
  }
8311
8327
  else {
8312
8328
  columns = await getTableColumns(fields, options);
8313
- if(!isLookup){
8329
+ if(!isLookup && !hiddenColumnOperation){
8314
8330
  columns.push(await getTableOperation(options));
8315
8331
  }
8316
8332
  }
8333
+
8317
8334
  return {
8318
8335
  mode: "table",
8319
8336
  name: "thelist",
@@ -8324,7 +8341,7 @@ async function getTableSchema$1(fields, options){
8324
8341
  columns: columns,
8325
8342
  syncLocation: false,
8326
8343
  keepItemSelectionOnPageChange: true,
8327
- checkOnItemClick: false,
8344
+ checkOnItemClick: isLookup ? true : false,
8328
8345
  labelTpl: `\${${options.labelFieldName}}`,
8329
8346
  autoFillHeight: false, // 自动高度效果不理想,先关闭
8330
8347
  columnsTogglable: false,
@@ -8361,7 +8378,7 @@ async function getTableApi(mainObject, fields, options){
8361
8378
  baseFilters = filter;
8362
8379
  }
8363
8380
 
8364
- _$1.each(fields, function (field) {
8381
+ _$1.each(mainObject.fields, function (field) {
8365
8382
  if (isFieldQuickSearchable(field, mainObject.NAME_FIELD_KEY)) {
8366
8383
  searchableFields.push(field.name);
8367
8384
  }
@@ -8423,7 +8440,9 @@ async function getTableApi(mainObject, fields, options){
8423
8440
  // 如果是第一次加载组件始终让翻页页码从本地存储中取值
8424
8441
  let formFactor = "${options.formFactor}";
8425
8442
  // 移动端不识别本地存储中的翻页页码,否则点击加载更多按钮后无法刷新回第一页
8426
- api.data.pageNo = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8443
+ // api.data.pageNo = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8444
+ // 移动端暂时去除加载更多,放开翻页
8445
+ api.data.pageNo = localListViewProps.page || 1;
8427
8446
  }
8428
8447
  }
8429
8448
  }
@@ -8544,7 +8563,17 @@ async function getTableApi(mainObject, fields, options){
8544
8563
  api.data = {
8545
8564
  query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
8546
8565
  }
8547
- ${options.requestAdaptor || ''}
8566
+ ${options.requestAdaptor || ''};
8567
+
8568
+ //写入本次存储filters、sort
8569
+ const listViewPropsStoreKey = location.pathname + "/crud/query";
8570
+ sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify({
8571
+ filters: filters,
8572
+ sort: sort.trim(),
8573
+ pageSize: pageSize,
8574
+ skip: skip,
8575
+ fields: ${JSON.stringify(_$1.map(fields, 'name'))}
8576
+ }));
8548
8577
  return api;
8549
8578
  `;
8550
8579
  api.adaptor = `
@@ -8623,7 +8652,8 @@ async function getTableApi(mainObject, fields, options){
8623
8652
  // 如果是第一次加载组件始终让翻页页码从本地存储中取值
8624
8653
  let formFactor = "${options.formFactor}";
8625
8654
  // 移动端不识别本地存储中的翻页页码,否则点击加载更多按钮后无法刷新回第一页
8626
- selfData.page = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8655
+ // selfData.page = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8656
+ selfData.page = localListViewProps.page || 1;
8627
8657
  }
8628
8658
  }
8629
8659
  delete selfData.context;
@@ -8641,7 +8671,13 @@ async function getTableApi(mainObject, fields, options){
8641
8671
  const setDataToComponentId = "${setDataToComponentId}";
8642
8672
  if(setDataToComponentId){
8643
8673
  //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
8644
- SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
8674
+ var scope = SteedosUI.getRef(api.body.$self.$scopeId);
8675
+ var scopeParent = scope && scope.parent;
8676
+ var setDataToComponent = scopeParent && scopeParent.getComponentById(setDataToComponentId);
8677
+ if(setDataToComponent){
8678
+ setDataToComponent.setData({$count: payload.data.count});
8679
+ }
8680
+ // SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
8645
8681
  };
8646
8682
  ${options.adaptor || ''}
8647
8683
  return payload;
@@ -8927,7 +8963,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
8927
8963
  var uiSchema = api.body.uiSchema;
8928
8964
  var defaultData = api.body.defaultData;
8929
8965
  var defaultValues = {};
8930
- _.each(uiSchema?.fields, function(field){
8966
+ _.each(uiSchema && uiSchema.fields, function(field){
8931
8967
  var value = SteedosUI.getFieldDefaultValue(field, api.body.global);
8932
8968
  if(value){
8933
8969
  defaultValues[field.name] = value;
@@ -9146,7 +9182,12 @@ async function getCalendarApi(mainObject, fields, options) {
9146
9182
  window.postMessage(Object.assign({type: "listview.loaded"}), "*");
9147
9183
  const setDataToComponentId = "${setDataToComponentId}";
9148
9184
  if(setDataToComponentId){
9149
- SteedosUI.getRef(api.body.$self.scopeId)?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
9185
+ var scope = SteedosUI.getRef(api.body.$self.scopeId);
9186
+ var setDataToComponent = scope && scope.getComponentById(setDataToComponentId);
9187
+ if(setDataToComponent){
9188
+ setDataToComponent.setData({$count: payload.data.count});
9189
+ }
9190
+ // SteedosUI.getRef(api.body.$self.scopeId)?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
9150
9191
  }
9151
9192
  const rows = payload.data.rows || [];
9152
9193
  const selfData = api.data.$self;
@@ -9893,6 +9934,10 @@ async function getObjectCRUD(objectSchema, fields, options){
9893
9934
  }
9894
9935
  }
9895
9936
  `;
9937
+ let autoFillHeight = true;
9938
+ if(options.isRelated || Steedos.isMobile()){
9939
+ autoFillHeight = false;
9940
+ }
9896
9941
 
9897
9942
  body = Object.assign({}, table, {
9898
9943
  type: 'crud',
@@ -9903,7 +9948,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9903
9948
  keepItemSelectionOnPageChange: true,
9904
9949
  api: await getTableApi(objectSchema, fields, options),
9905
9950
  hiddenOn: options.tableHiddenOn,
9906
- autoFillHeight: options.isRelated ? false : true,
9951
+ autoFillHeight,
9907
9952
  className: `flex-auto ${crudClassName || ""}`,
9908
9953
  bodyClassName: "bg-white",
9909
9954
  crudClassName: crudClassName,
@@ -10146,7 +10191,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
10146
10191
  // "blank": false
10147
10192
  // },
10148
10193
  "actionType": "custom",
10149
- "script": "Steedos.goBack()",
10194
+ "script": "window.goBack()",
10150
10195
  "expression": "this.__deletedRecord === true"
10151
10196
  }
10152
10197
  ]
@@ -10263,7 +10308,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
10263
10308
  * @Author: baozhoutao@steedos.com
10264
10309
  * @Date: 2022-07-05 15:55:39
10265
10310
  * @LastEditors: liaodaxue
10266
- * @LastEditTime: 2023-08-21 14:50:21
10311
+ * @LastEditTime: 2023-08-28 14:55:23
10267
10312
  * @Description:
10268
10313
  */
10269
10314
 
@@ -10409,11 +10454,16 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
10409
10454
  // }
10410
10455
  const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
10411
10456
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
10457
+ const isMobile = window.innerWidth < 768;
10458
+ let headerToolbar = [];
10459
+ if(!isMobile){
10460
+ headerToolbar.push("bulkActions");
10461
+ }
10412
10462
  const options = {
10413
10463
  globalFilter,
10414
10464
  defaults: {
10415
10465
  listSchema: {
10416
- headerToolbar:["bulkActions"],
10466
+ headerToolbar,
10417
10467
  columnsTogglable: false,
10418
10468
  onEvent: {
10419
10469
  [`@data.changed.${relatedObjectName}`]: {
@@ -10609,8 +10659,8 @@ async function getRelatedListSchema(
10609
10659
  /*
10610
10660
  * @Author: baozhoutao@steedos.com
10611
10661
  * @Date: 2022-07-05 15:55:39
10612
- * @LastEditors: baozhoutao@steedos.com
10613
- * @LastEditTime: 2023-08-17 18:03:51
10662
+ * @LastEditors: liaodaxue
10663
+ * @LastEditTime: 2023-08-25 11:55:15
10614
10664
  * @Description:
10615
10665
  */
10616
10666
 
@@ -10875,7 +10925,7 @@ async function getListSchema(
10875
10925
  * 本次存储代码段
10876
10926
  */
10877
10927
  try {
10878
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
10928
+ const listViewPropsStoreKey = location.pathname + "/crud";
10879
10929
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10880
10930
  /**
10881
10931
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
@@ -10897,11 +10947,12 @@ async function getListSchema(
10897
10947
  if(localListViewProps.orderDir){
10898
10948
  listSchema.orderDir = localListViewProps.orderDir;
10899
10949
  }
10900
- // if(localListViewProps.perPage){
10901
- // listSchema.defaultParams = {
10902
- // perPage: localListViewProps.perPage
10903
- // }
10904
- // }
10950
+
10951
+ if(localListViewProps.perPage){
10952
+ listSchema.defaultParams = {
10953
+ perPage: localListViewProps.perPage
10954
+ };
10955
+ }
10905
10956
  defaults.listSchema = defaultsDeep$1({}, listSchema, defaults.listSchema || {});
10906
10957
  }
10907
10958
  }
@@ -12254,7 +12305,7 @@ const getNextStepUsersInput = async (instance) => {
12254
12305
  id: "u:ffff15b76c89",
12255
12306
  className: "b-a b-1x p-xs m-b-none m-l-none m-r-none m-t-sm",
12256
12307
  subFormMode: "",
12257
- hiddenOn: "!!!this.new_next_step || this.new_next_step?.step_type === 'end'"
12308
+ hiddenOn: "!!!this.new_next_step || (this.new_next_step && this.new_next_step.step_type === 'end')"
12258
12309
  };
12259
12310
  };
12260
12311
 
@@ -13174,7 +13225,7 @@ const getFieldReadonlyTpl = async (field, label)=>{
13174
13225
  map[item.value] = item.label;
13175
13226
  });
13176
13227
  tpl.type = 'static';
13177
- tpl.tpl = `<% var options = ${JSON.stringify(map)}; return options?.[data.${field.code}] || ''%>`;
13228
+ tpl.tpl = `<% var options = ${JSON.stringify(map)}; return (options && options[data.${field.code}]) || ''%>`;
13178
13229
  }else if(field.type === 'odata'){
13179
13230
  tpl.type = 'static';
13180
13231
  tpl.tpl = `<div>\${${field.code}['@label']}</div>`;
@@ -13204,7 +13255,7 @@ const getFieldReadonlyTpl = async (field, label)=>{
13204
13255
  if(field.is_multiselect){
13205
13256
  tpl.tpl = `\${_.map(${field.code}, 'name')}`;
13206
13257
  }else {
13207
- tpl.tpl = `\${${field.code}?.name}`;
13258
+ tpl.tpl = `\${${field.code} && ${field.code}.name}`;
13208
13259
  }
13209
13260
  }else if(field.type === 'group'){
13210
13261
  tpl.type = 'static';