@steedos-widgets/amis-lib 1.2.17 → 1.2.19

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
@@ -1586,7 +1586,7 @@ var frontend_listview_control_rename_label = "重命名";
1586
1586
  var frontend_listview_control_rename_title = "重命名 列表视图";
1587
1587
  var frontend_listview_control_share = "共享设置";
1588
1588
  var frontend_listview_control_sort = "默认排序规则";
1589
- var frontend_export_excel = "导出excel";
1589
+ var frontend_export_excel = "导出";
1590
1590
  var frontend_ercord_operation = "操作";
1591
1591
  var frontend_import_data = "导入数据";
1592
1592
  var frontend_import_data_object_name = "导入对象";
@@ -1737,7 +1737,7 @@ i18next
1737
1737
  * @Description:
1738
1738
  */
1739
1739
 
1740
- const getSchema$4 = async (uiSchema, ctx) => {
1740
+ const getSchema$5 = async (uiSchema, ctx) => {
1741
1741
  const schemaApiAdaptor = `
1742
1742
  let formSchema = {
1743
1743
  "type": "steedos-object-form",
@@ -1911,7 +1911,7 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
1911
1911
  * @Description:
1912
1912
  */
1913
1913
 
1914
- const getSchema$3 = async (uiSchema, ctx) => {
1914
+ const getSchema$4 = async (uiSchema, ctx) => {
1915
1915
  const title = i18next.t('frontend_form_edit') + " " + uiSchema.label;
1916
1916
 
1917
1917
  const defaultFormSchema = {
@@ -1979,7 +1979,7 @@ const getSchema$3 = async (uiSchema, ctx) => {
1979
1979
  * @LastEditors: Please set LastEditors
1980
1980
  * @LastEditTime: 2023-04-12 10:35:36
1981
1981
  */
1982
- const getSchema$2 = (uiSchema)=>{
1982
+ const getSchema$3 = (uiSchema)=>{
1983
1983
  return {
1984
1984
  "type": "service",
1985
1985
  "className": "p-0",
@@ -2048,7 +2048,7 @@ const getSchema$2 = (uiSchema)=>{
2048
2048
  }
2049
2049
  };
2050
2050
 
2051
- const getSchema$1 = (uiSchema) => {
2051
+ const getSchema$2 = (uiSchema) => {
2052
2052
  return {
2053
2053
  type: "service",
2054
2054
  body: [
@@ -2349,7 +2349,7 @@ const getSchema$1 = (uiSchema) => {
2349
2349
  * @Description:
2350
2350
  */
2351
2351
 
2352
- const getSchema = (uiSchema)=>{
2352
+ const getSchema$1 = (uiSchema)=>{
2353
2353
  return {
2354
2354
  "type": "service",
2355
2355
  "className": "p-0",
@@ -2381,6 +2381,94 @@ const getSchema = (uiSchema)=>{
2381
2381
  }
2382
2382
  };
2383
2383
 
2384
+ const getSchema = async (uiSchema, ctx) => {
2385
+ const requestAdaptor = `
2386
+ // 获取列表视图的属性
2387
+ let uiSchema = api.body.uiSchema;
2388
+ let list_views = uiSchema.list_views;
2389
+ let list_views_name = api.body.listName;
2390
+ let col = list_views[list_views_name].columns;
2391
+ let sort_test = list_views[list_views_name].sort;
2392
+
2393
+ // 获取下载字段
2394
+ let select = [];
2395
+ _.each(col, (col) => {
2396
+ if (col.field == undefined)
2397
+ select.push(col);
2398
+ else select.push(col.field);
2399
+ });
2400
+
2401
+ // 获取排序字段
2402
+
2403
+ let sort = [];
2404
+ _.forEach(sort_test, (sortField) => {
2405
+ if (sortField.field_name == undefined)
2406
+ sort.push(sortField);
2407
+ else sort.push([sortField.field_name, sortField.order]);
2408
+ })
2409
+
2410
+ let orders = [];
2411
+ _.map(sort, (value) => {
2412
+ let order_tmp = [];
2413
+ if (value[1] == "desc")
2414
+ order_tmp = value[0] + ' desc';
2415
+ else
2416
+ order_tmp = value[0];
2417
+ orders.push(order_tmp);
2418
+ });
2419
+ let order = orders.join(',');
2420
+
2421
+ let filename = uiSchema.label + "-" + list_views[list_views_name].label;
2422
+
2423
+ url_tmp = api.url.split('?')[0];
2424
+ api.url = url_tmp + "?$select=" + encodeURIComponent(select.toString()) + "&filename=" + encodeURIComponent(filename);
2425
+
2426
+ // 判断sort 和 filters
2427
+ if (sort.length > 0) {
2428
+ api.url += "&$orderby=" + encodeURIComponent(order);
2429
+ }
2430
+ let filters = list_views[list_views_name].filters;
2431
+ if (filters && filters.length > 0) {
2432
+ api.url = api.url + "&filters=" + encodeURIComponent(JSON.stringify(filters));
2433
+ }
2434
+ return api;
2435
+ `;
2436
+ return {
2437
+ "type": "service",
2438
+ "body": [{
2439
+ "type": "button",
2440
+ "label": i18next.t('frontend_export_excel'),
2441
+ "id": "u:standard_export_excel",
2442
+ "level": "default",
2443
+ "onEvent": {
2444
+ "click": {
2445
+ "weight": 0,
2446
+ "actions": [
2447
+ {
2448
+ "args": {
2449
+ "api": {
2450
+ "url": "${context.rootUrl}/api/record/export/${objectName}",
2451
+ "method": "get",
2452
+ "messages": {},
2453
+ "requestAdaptor": requestAdaptor,
2454
+ "data": {
2455
+ "uiSchema": "${uiSchema}",
2456
+ "listName": "${listName}"
2457
+ },
2458
+ "headers": {
2459
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
2460
+ }
2461
+ }
2462
+ },
2463
+ "actionType": "download"
2464
+ }
2465
+ ]
2466
+ }
2467
+ }
2468
+ }]
2469
+ }
2470
+ };
2471
+
2384
2472
  /*
2385
2473
  * @Author: baozhoutao@steedos.com
2386
2474
  * @Date: 2022-11-01 15:53:07
@@ -2393,19 +2481,19 @@ const StandardButtons = {
2393
2481
  getStandardNew: async (uiSchema, ctx)=>{
2394
2482
  return {
2395
2483
  type: 'amis_button',
2396
- amis_schema: await getSchema$4(uiSchema)
2484
+ amis_schema: await getSchema$5(uiSchema)
2397
2485
  }
2398
2486
  },
2399
2487
  getStandardEdit: async (uiSchema, ctx)=>{
2400
2488
  return {
2401
2489
  type: 'amis_button',
2402
- amis_schema: await getSchema$3(uiSchema, ctx)
2490
+ amis_schema: await getSchema$4(uiSchema, ctx)
2403
2491
  }
2404
2492
  },
2405
2493
  getStandardDelete: async (uiSchema, ctx)=>{
2406
2494
  return {
2407
2495
  type: 'amis_button',
2408
- amis_schema: await getSchema$2(uiSchema)
2496
+ amis_schema: await getSchema$3(uiSchema)
2409
2497
  }
2410
2498
  },
2411
2499
  getStandardDeleteMany: async (uiSchema, ctx)=>{
@@ -2441,10 +2529,16 @@ const StandardButtons = {
2441
2529
  getStandardImportData: async (uiSchema, ctx)=>{
2442
2530
  return {
2443
2531
  type: 'amis_button',
2444
- amis_schema: await getSchema$1()
2532
+ amis_schema: await getSchema$2()
2445
2533
  }
2446
2534
  },
2447
2535
  getStandardOpenView: async (uiSchema, ctx)=>{
2536
+ return {
2537
+ type: 'amis_button',
2538
+ amis_schema: await getSchema$1()
2539
+ }
2540
+ },
2541
+ getStandardExportExcel: async (uiSchema, ctx)=>{
2448
2542
  return {
2449
2543
  type: 'amis_button',
2450
2544
  amis_schema: await getSchema()
@@ -2709,6 +2803,16 @@ const getButton = async (objectName, buttonName, ctx)=>{
2709
2803
  }
2710
2804
  }
2711
2805
 
2806
+ if(button.name === 'standard_export_excel'){
2807
+ return {
2808
+ label: button.label,
2809
+ name: button.name,
2810
+ on: button.on,
2811
+ sort: button.sort,
2812
+ ...await StandardButtons.getStandardExportExcel(uiSchema, ctx)
2813
+ }
2814
+ }
2815
+
2712
2816
  if(button.name === 'standard_open_view'){
2713
2817
  return {
2714
2818
  label: button.label,
@@ -4004,97 +4108,6 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
4004
4108
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
4005
4109
  }
4006
4110
 
4007
- const getExportExcelToolbarButtonSchema = ()=>{
4008
- return {
4009
- "type": "button",
4010
- "icon": "fa fa-download",
4011
- "align": "right",
4012
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4013
- "tooltipPlacement": "bottom",
4014
- "visibleOn": "${!isLookup && global.user.is_space_admin}",
4015
- "tooltip": i18next.t('frontend_export_excel'),
4016
- "onEvent": {
4017
- "click": {
4018
- "weight": 0,
4019
- "actions": [
4020
- {
4021
- "args": {
4022
- "api": {
4023
- "url": "${context.rootUrl}/api/record/export/${objectName}",
4024
- "method": "get",
4025
- "messages": {},
4026
- "requestAdaptor": `${requestAdaptor$1()}`,
4027
- "data": {
4028
- "uiSchema": "${uiSchema}",
4029
- "listName": "${listName}"
4030
- },
4031
- "headers": {
4032
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4033
- }
4034
- }
4035
- },
4036
- "actionType": "download"
4037
- }
4038
- ]
4039
- }
4040
- }
4041
- }
4042
- };
4043
-
4044
- function requestAdaptor$1(){
4045
- return `
4046
- // 获取列表视图的属性
4047
- let uiSchema = api.body.uiSchema;
4048
- let list_views = uiSchema.list_views;
4049
- let list_views_name = api.body.listName;
4050
- let col = list_views[list_views_name].columns;
4051
- let sort_test = list_views[list_views_name].sort;
4052
-
4053
- // 获取下载字段
4054
- let select = [];
4055
- _.each(col, (col) => {
4056
- if (col.field == undefined)
4057
- select.push(col);
4058
- else select.push(col.field);
4059
- });
4060
-
4061
- // 获取排序字段
4062
-
4063
- let sort = [];
4064
- _.forEach(sort_test, (sortField) => {
4065
- if (sortField.field_name == undefined)
4066
- sort.push(sortField);
4067
- else sort.push([sortField.field_name, sortField.order]);
4068
- })
4069
-
4070
- let orders = [];
4071
- _.map(sort, (value) => {
4072
- let order_tmp = [];
4073
- if (value[1] == "desc")
4074
- order_tmp = value[0] + ' desc';
4075
- else
4076
- order_tmp = value[0];
4077
- orders.push(order_tmp);
4078
- });
4079
- let order = orders.join(',');
4080
-
4081
- let filename = uiSchema.label + "-" + list_views[list_views_name].label;
4082
-
4083
- url_tmp = api.url.split('?')[0];
4084
- api.url = url_tmp + "?$select=" + select.toString() + "&filename=" + filename;
4085
-
4086
- // 判断sort 和 filters
4087
- if (sort.length > 0) {
4088
- api.url += "&$orderby=" + order;
4089
- }
4090
- let filters = list_views[list_views_name].filters;
4091
- if (filters && filters.length > 0) {
4092
- api.url = api.url + "&filters=" + JSON.stringify(filters);
4093
- }
4094
- return api;
4095
- `
4096
- }
4097
-
4098
4111
  const getNewListviewButtonSchema = ()=>{
4099
4112
  return {
4100
4113
  "type": "button",
@@ -5184,7 +5197,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5184
5197
  "tooltipPlacement": "bottom",
5185
5198
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5186
5199
  },
5187
- getExportExcelToolbarButtonSchema(),
5200
+ // getExportExcelToolbarButtonSchema(),
5188
5201
  filterVisible ? {
5189
5202
  "label": "",
5190
5203
  "icon": "fa fa-search",
@@ -5808,7 +5821,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5808
5821
  pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, ctx.formFactor, { headerToolbarItems });
5809
5822
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
5810
5823
  if (isAllowCreate) {
5811
- const new_button = await getSchema$4(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
5824
+ const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
5812
5825
  new_button.align = "right";
5813
5826
  pickerSchema.headerToolbar.push(new_button);
5814
5827
  }
@@ -7558,7 +7571,10 @@ async function getMobileTableColumns(fields, options){
7558
7571
  level: "link",
7559
7572
  actionType: "link",
7560
7573
  link: url,
7561
- innerClassName: "steedos-listview-item block text-gray-500",
7574
+ innerClassName: {
7575
+ "steedos-listview-item block text-gray-500":"true",
7576
+ "max-w-[360px]": "${display == 'split'}",
7577
+ },
7562
7578
  body: {
7563
7579
  "type": "wrapper",
7564
7580
  "body": columnLines,