@steedos-widgets/amis-lib 1.3.0-beta.7 → 1.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
@@ -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,
@@ -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
 
@@ -5437,15 +5420,15 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5437
5420
 
5438
5421
  function getObjectFooterToolbar(mainObject, formFactor, options) {
5439
5422
  if (formFactor === 'SMALL') {
5440
- return [
5441
- "load-more",
5442
- ]
5443
5423
  // return [
5444
- // {
5445
- // "type": "pagination",
5446
- // "maxButtons": 5
5447
- // }
5424
+ // "load-more",
5448
5425
  // ]
5426
+ return [
5427
+ {
5428
+ "type": "pagination",
5429
+ "maxButtons": 5
5430
+ }
5431
+ ]
5449
5432
  }
5450
5433
  else {
5451
5434
  if(options && options.isRelated){
@@ -8038,7 +8021,7 @@ async function getTableColumns(fields, options){
8038
8021
  */
8039
8022
  function getMobileLines(tpls){
8040
8023
  let lines = [];
8041
- let maxLineCount = 2;
8024
+ let maxLineCount = 3;
8042
8025
  let lineChildren = [];
8043
8026
  let isNewLine = false;
8044
8027
  let isLeft = true;
@@ -8056,10 +8039,10 @@ function getMobileLines(tpls){
8056
8039
  }
8057
8040
  if(isLeft){
8058
8041
  // 左侧半行
8059
- lineChildrenClassName = "steedos-listview-item-left two-lines-truncate";
8042
+ lineChildrenClassName = "steedos-listview-item-left truncate";
8060
8043
  if(item.field.is_wide){
8061
- // 左侧全行样式可以单独写
8062
- lineChildrenClassName = "steedos-listview-item-wide two-lines-truncate";
8044
+ // 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
8045
+ lineChildrenClassName = "steedos-listview-item-wide";
8063
8046
  }
8064
8047
  if(lines.length === 0){
8065
8048
  // 第一个字段加粗黑色显示
@@ -8067,7 +8050,7 @@ function getMobileLines(tpls){
8067
8050
  }
8068
8051
  }
8069
8052
  else {
8070
- // 右侧半行
8053
+ // 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
8071
8054
  lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
8072
8055
  }
8073
8056
  lineChildren.push({
@@ -8326,6 +8309,7 @@ async function getTableSchema$1(fields, options){
8326
8309
  columns.push(await getTableOperation(options));
8327
8310
  }
8328
8311
  }
8312
+
8329
8313
  return {
8330
8314
  mode: "table",
8331
8315
  name: "thelist",
@@ -8435,9 +8419,9 @@ async function getTableApi(mainObject, fields, options){
8435
8419
  // 如果是第一次加载组件始终让翻页页码从本地存储中取值
8436
8420
  let formFactor = "${options.formFactor}";
8437
8421
  // 移动端不识别本地存储中的翻页页码,否则点击加载更多按钮后无法刷新回第一页
8438
- api.data.pageNo = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8422
+ // api.data.pageNo = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8439
8423
  // 移动端暂时去除加载更多,放开翻页
8440
- // api.data.pageNo = localListViewProps.page || 1;
8424
+ api.data.pageNo = localListViewProps.page || 1;
8441
8425
  }
8442
8426
  }
8443
8427
  }
@@ -8558,7 +8542,17 @@ async function getTableApi(mainObject, fields, options){
8558
8542
  api.data = {
8559
8543
  query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
8560
8544
  }
8561
- ${options.requestAdaptor || ''}
8545
+ ${options.requestAdaptor || ''};
8546
+
8547
+ //写入本次存储filters、sort
8548
+ const listViewPropsStoreKey = location.pathname + "/crud/query";
8549
+ sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify({
8550
+ filters: filters,
8551
+ sort: sort.trim(),
8552
+ pageSize: pageSize,
8553
+ skip: skip,
8554
+ fields: ${JSON.stringify(_$1.map(fields, 'name'))}
8555
+ }));
8562
8556
  return api;
8563
8557
  `;
8564
8558
  api.adaptor = `
@@ -8637,8 +8631,8 @@ async function getTableApi(mainObject, fields, options){
8637
8631
  // 如果是第一次加载组件始终让翻页页码从本地存储中取值
8638
8632
  let formFactor = "${options.formFactor}";
8639
8633
  // 移动端不识别本地存储中的翻页页码,否则点击加载更多按钮后无法刷新回第一页
8640
- selfData.page = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8641
- // selfData.page = localListViewProps.page || 1;
8634
+ // selfData.page = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8635
+ selfData.page = localListViewProps.page || 1;
8642
8636
  }
8643
8637
  }
8644
8638
  delete selfData.context;
@@ -9919,6 +9913,10 @@ async function getObjectCRUD(objectSchema, fields, options){
9919
9913
  }
9920
9914
  }
9921
9915
  `;
9916
+ let autoFillHeight = true;
9917
+ if(options.isRelated || Steedos.isMobile()){
9918
+ autoFillHeight = false;
9919
+ }
9922
9920
 
9923
9921
  body = Object.assign({}, table, {
9924
9922
  type: 'crud',
@@ -9929,7 +9927,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9929
9927
  keepItemSelectionOnPageChange: true,
9930
9928
  api: await getTableApi(objectSchema, fields, options),
9931
9929
  hiddenOn: options.tableHiddenOn,
9932
- autoFillHeight: options.isRelated ? false : true,
9930
+ autoFillHeight,
9933
9931
  className: `flex-auto ${crudClassName || ""}`,
9934
9932
  bodyClassName: "bg-white",
9935
9933
  crudClassName: crudClassName,
@@ -10635,8 +10633,8 @@ async function getRelatedListSchema(
10635
10633
  /*
10636
10634
  * @Author: baozhoutao@steedos.com
10637
10635
  * @Date: 2022-07-05 15:55:39
10638
- * @LastEditors: baozhoutao@steedos.com
10639
- * @LastEditTime: 2023-08-17 18:03:51
10636
+ * @LastEditors: liaodaxue
10637
+ * @LastEditTime: 2023-08-25 11:55:15
10640
10638
  * @Description:
10641
10639
  */
10642
10640
 
@@ -10901,7 +10899,7 @@ async function getListSchema(
10901
10899
  * 本次存储代码段
10902
10900
  */
10903
10901
  try {
10904
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
10902
+ const listViewPropsStoreKey = location.pathname + "/crud";
10905
10903
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10906
10904
  /**
10907
10905
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
@@ -10923,11 +10921,12 @@ async function getListSchema(
10923
10921
  if(localListViewProps.orderDir){
10924
10922
  listSchema.orderDir = localListViewProps.orderDir;
10925
10923
  }
10926
- // if(localListViewProps.perPage){
10927
- // listSchema.defaultParams = {
10928
- // perPage: localListViewProps.perPage
10929
- // }
10930
- // }
10924
+
10925
+ if(localListViewProps.perPage){
10926
+ listSchema.defaultParams = {
10927
+ perPage: localListViewProps.perPage
10928
+ };
10929
+ }
10931
10930
  defaults.listSchema = defaultsDeep$1({}, listSchema, defaults.listSchema || {});
10932
10931
  }
10933
10932
  }