@steedos-widgets/amis-lib 1.3.0-beta.7 → 1.3.0-beta.9

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
@@ -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,
@@ -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
 
@@ -5464,15 +5447,15 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5464
5447
 
5465
5448
  function getObjectFooterToolbar(mainObject, formFactor, options) {
5466
5449
  if (formFactor === 'SMALL') {
5467
- return [
5468
- "load-more",
5469
- ]
5470
5450
  // return [
5471
- // {
5472
- // "type": "pagination",
5473
- // "maxButtons": 5
5474
- // }
5451
+ // "load-more",
5475
5452
  // ]
5453
+ return [
5454
+ {
5455
+ "type": "pagination",
5456
+ "maxButtons": 5
5457
+ }
5458
+ ]
5476
5459
  }
5477
5460
  else {
5478
5461
  if(options && options.isRelated){
@@ -8065,7 +8048,7 @@ async function getTableColumns(fields, options){
8065
8048
  */
8066
8049
  function getMobileLines(tpls){
8067
8050
  let lines = [];
8068
- let maxLineCount = 2;
8051
+ let maxLineCount = 3;
8069
8052
  let lineChildren = [];
8070
8053
  let isNewLine = false;
8071
8054
  let isLeft = true;
@@ -8083,10 +8066,10 @@ function getMobileLines(tpls){
8083
8066
  }
8084
8067
  if(isLeft){
8085
8068
  // 左侧半行
8086
- lineChildrenClassName = "steedos-listview-item-left two-lines-truncate";
8069
+ lineChildrenClassName = "steedos-listview-item-left truncate";
8087
8070
  if(item.field.is_wide){
8088
- // 左侧全行样式可以单独写
8089
- lineChildrenClassName = "steedos-listview-item-wide two-lines-truncate";
8071
+ // 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
8072
+ lineChildrenClassName = "steedos-listview-item-wide";
8090
8073
  }
8091
8074
  if(lines.length === 0){
8092
8075
  // 第一个字段加粗黑色显示
@@ -8094,7 +8077,7 @@ function getMobileLines(tpls){
8094
8077
  }
8095
8078
  }
8096
8079
  else {
8097
- // 右侧半行
8080
+ // 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
8098
8081
  lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
8099
8082
  }
8100
8083
  lineChildren.push({
@@ -8353,6 +8336,7 @@ async function getTableSchema$1(fields, options){
8353
8336
  columns.push(await getTableOperation(options));
8354
8337
  }
8355
8338
  }
8339
+
8356
8340
  return {
8357
8341
  mode: "table",
8358
8342
  name: "thelist",
@@ -8462,9 +8446,9 @@ async function getTableApi(mainObject, fields, options){
8462
8446
  // 如果是第一次加载组件始终让翻页页码从本地存储中取值
8463
8447
  let formFactor = "${options.formFactor}";
8464
8448
  // 移动端不识别本地存储中的翻页页码,否则点击加载更多按钮后无法刷新回第一页
8465
- api.data.pageNo = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8449
+ // api.data.pageNo = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8466
8450
  // 移动端暂时去除加载更多,放开翻页
8467
- // api.data.pageNo = localListViewProps.page || 1;
8451
+ api.data.pageNo = localListViewProps.page || 1;
8468
8452
  }
8469
8453
  }
8470
8454
  }
@@ -8585,7 +8569,17 @@ async function getTableApi(mainObject, fields, options){
8585
8569
  api.data = {
8586
8570
  query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
8587
8571
  }
8588
- ${options.requestAdaptor || ''}
8572
+ ${options.requestAdaptor || ''};
8573
+
8574
+ //写入本次存储filters、sort
8575
+ const listViewPropsStoreKey = location.pathname + "/crud/query";
8576
+ sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify({
8577
+ filters: filters,
8578
+ sort: sort.trim(),
8579
+ pageSize: pageSize,
8580
+ skip: skip,
8581
+ fields: ${JSON.stringify(___namespace.map(fields, 'name'))}
8582
+ }));
8589
8583
  return api;
8590
8584
  `;
8591
8585
  api.adaptor = `
@@ -8664,8 +8658,8 @@ async function getTableApi(mainObject, fields, options){
8664
8658
  // 如果是第一次加载组件始终让翻页页码从本地存储中取值
8665
8659
  let formFactor = "${options.formFactor}";
8666
8660
  // 移动端不识别本地存储中的翻页页码,否则点击加载更多按钮后无法刷新回第一页
8667
- selfData.page = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8668
- // selfData.page = localListViewProps.page || 1;
8661
+ // selfData.page = formFactor === "SMALL" ? 1 : (localListViewProps.page || 1);
8662
+ selfData.page = localListViewProps.page || 1;
8669
8663
  }
8670
8664
  }
8671
8665
  delete selfData.context;
@@ -9946,6 +9940,10 @@ async function getObjectCRUD(objectSchema, fields, options){
9946
9940
  }
9947
9941
  }
9948
9942
  `;
9943
+ let autoFillHeight = true;
9944
+ if(options.isRelated || Steedos.isMobile()){
9945
+ autoFillHeight = false;
9946
+ }
9949
9947
 
9950
9948
  body = Object.assign({}, table, {
9951
9949
  type: 'crud',
@@ -9956,7 +9954,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9956
9954
  keepItemSelectionOnPageChange: true,
9957
9955
  api: await getTableApi(objectSchema, fields, options),
9958
9956
  hiddenOn: options.tableHiddenOn,
9959
- autoFillHeight: options.isRelated ? false : true,
9957
+ autoFillHeight,
9960
9958
  className: `flex-auto ${crudClassName || ""}`,
9961
9959
  bodyClassName: "bg-white",
9962
9960
  crudClassName: crudClassName,
@@ -10662,8 +10660,8 @@ async function getRelatedListSchema(
10662
10660
  /*
10663
10661
  * @Author: baozhoutao@steedos.com
10664
10662
  * @Date: 2022-07-05 15:55:39
10665
- * @LastEditors: baozhoutao@steedos.com
10666
- * @LastEditTime: 2023-08-17 18:03:51
10663
+ * @LastEditors: liaodaxue
10664
+ * @LastEditTime: 2023-08-25 11:55:15
10667
10665
  * @Description:
10668
10666
  */
10669
10667
 
@@ -10928,7 +10926,7 @@ async function getListSchema(
10928
10926
  * 本次存储代码段
10929
10927
  */
10930
10928
  try {
10931
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewName || "");
10929
+ const listViewPropsStoreKey = location.pathname + "/crud";
10932
10930
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10933
10931
  /**
10934
10932
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
@@ -10950,11 +10948,12 @@ async function getListSchema(
10950
10948
  if(localListViewProps.orderDir){
10951
10949
  listSchema.orderDir = localListViewProps.orderDir;
10952
10950
  }
10953
- // if(localListViewProps.perPage){
10954
- // listSchema.defaultParams = {
10955
- // perPage: localListViewProps.perPage
10956
- // }
10957
- // }
10951
+
10952
+ if(localListViewProps.perPage){
10953
+ listSchema.defaultParams = {
10954
+ perPage: localListViewProps.perPage
10955
+ };
10956
+ }
10958
10957
  defaults.listSchema = _$1.defaultsDeep({}, listSchema, defaults.listSchema || {});
10959
10958
  }
10960
10959
  }