@steedos-widgets/amis-lib 1.2.26 → 1.2.28

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
@@ -674,6 +674,10 @@ async function getFieldsTemplate(fields, expand){
674
674
  if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
675
675
  displayFields.push(`${field.name}`);
676
676
  }
677
+ }else {
678
+ objectFieldName = field.name.split('.')[0];
679
+ fieldsName.push(objectFieldName);
680
+ displayFields.push(objectFieldName);
677
681
  }
678
682
  }
679
683
 
@@ -1754,8 +1758,8 @@ i18next__default["default"]
1754
1758
  /*
1755
1759
  * @Author: baozhoutao@steedos.com
1756
1760
  * @Date: 2022-11-01 15:51:00
1757
- * @LastEditors: liaodaxue
1758
- * @LastEditTime: 2023-06-06 11:12:33
1761
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1762
+ * @LastEditTime: 2023-06-28 23:19:41
1759
1763
  * @Description:
1760
1764
  */
1761
1765
 
@@ -1807,6 +1811,16 @@ const getSchema$5 = async (uiSchema, ctx) => {
1807
1811
  data: formSchema
1808
1812
  };
1809
1813
  `;
1814
+ const onDialogCancelScript = `
1815
+ // 这里加setTimeout是因为amis的Bug,它会先触发cancel事件执行此脚本关闭父窗口然后再关闭子窗口
1816
+ // 正确的顺序应该是先关闭子窗口再关闭父窗口,顺序错了会造成第二次点击新建按钮的时候异常
1817
+ setTimeout(function(){
1818
+ doAction({
1819
+ "actionType": "cancel",
1820
+ "componentId": "object_actions_drawer_${uiSchema.name}"
1821
+ });
1822
+ }, 200);
1823
+ `;
1810
1824
  return {
1811
1825
  "type": "service",
1812
1826
  "body": [
@@ -1867,6 +1881,17 @@ const getSchema$5 = async (uiSchema, ctx) => {
1867
1881
  "closeOnEsc": false,
1868
1882
  "closeOnOutside": false,
1869
1883
  "size": "lg",
1884
+ "onEvent": {
1885
+ "cancel": {
1886
+ "actions": [
1887
+ {
1888
+ "actionType": "custom",
1889
+ "script": onDialogCancelScript,
1890
+ "expression": "${window:innerWidth < 768}",
1891
+ }
1892
+ ]
1893
+ }
1894
+ },
1870
1895
  "actions": [
1871
1896
  {
1872
1897
  type: 'button',
@@ -1929,7 +1954,7 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
1929
1954
  * @Author: baozhoutao@steedos.com
1930
1955
  * @Date: 2022-11-01 15:49:58
1931
1956
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1932
- * @LastEditTime: 2023-03-27 11:36:49
1957
+ * @LastEditTime: 2023-06-28 23:22:31
1933
1958
  * @Description:
1934
1959
  */
1935
1960
 
@@ -1958,6 +1983,17 @@ const getSchema$4 = async (uiSchema, ctx) => {
1958
1983
  ? JSON.parse(page.schema)
1959
1984
  : page.schema;
1960
1985
  }
1986
+
1987
+ const onDialogCancelScript = `
1988
+ // 这里加setTimeout是因为amis的Bug,它会先触发cancel事件执行此脚本关闭父窗口然后再关闭子窗口
1989
+ // 正确的顺序应该是先关闭子窗口再关闭父窗口,顺序错了会造成第二次点击编辑按钮的时候异常
1990
+ setTimeout(function(){
1991
+ doAction({
1992
+ "actionType": "cancel",
1993
+ "componentId": "object_actions_drawer_${uiSchema.name}"
1994
+ });
1995
+ }, 200);
1996
+ `;
1961
1997
 
1962
1998
  return {
1963
1999
  type: "service",
@@ -1981,6 +2017,17 @@ const getSchema$4 = async (uiSchema, ctx) => {
1981
2017
  closeOnOutside: false,
1982
2018
  showCloseButton: true,
1983
2019
  size: "lg",
2020
+ "onEvent": {
2021
+ "cancel": {
2022
+ "actions": [
2023
+ {
2024
+ "actionType": "custom",
2025
+ "script": onDialogCancelScript,
2026
+ "expression": "${window:innerWidth < 768}",
2027
+ }
2028
+ ]
2029
+ }
2030
+ },
1984
2031
  },
1985
2032
  },
1986
2033
  ],
@@ -2277,6 +2324,7 @@ const getSchema$2 = (uiSchema) => {
2277
2324
  label: i18next__default["default"].t('frontend_import_data_file'),
2278
2325
  required: true,
2279
2326
  type: "input-file",
2327
+ accept: ".xlsx,.xls",
2280
2328
  className: "m-1",
2281
2329
  labelClassName: "text-left",
2282
2330
  clearValueOnHidden: true,
@@ -2941,6 +2989,7 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2941
2989
  "drawer": {
2942
2990
  "type": "drawer",
2943
2991
  "title": "操作",
2992
+ "id": "object_actions_drawer_" + objectSchema.name,
2944
2993
  "body": [
2945
2994
  {
2946
2995
  "type": "button-group",
@@ -2963,7 +3012,6 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2963
3012
  "size": "lg"
2964
3013
  }
2965
3014
  ],
2966
- "id": "u:9815f7366b9f",
2967
3015
  "position": "bottom",
2968
3016
  "closeOnOutside": true,
2969
3017
  "resizable": false,
@@ -2974,8 +3022,7 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2974
3022
  }
2975
3023
  ]
2976
3024
  }
2977
- },
2978
- "id": "u:ee7c7929e6ae"
3025
+ }
2979
3026
  }
2980
3027
  }else {
2981
3028
  if(moreButtons.length > 0){
@@ -3007,6 +3054,7 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3007
3054
  "drawer": {
3008
3055
  "type": "drawer",
3009
3056
  "title": "操作",
3057
+ "id": "object_actions_drawer_" + objectSchema.name,
3010
3058
  "body": [
3011
3059
  {
3012
3060
  "type": "button-group",
@@ -3030,7 +3078,6 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3030
3078
  "size": "lg"
3031
3079
  }
3032
3080
  ],
3033
- "id": "u:9815f7366b9f",
3034
3081
  "position": "bottom",
3035
3082
  "closeOnOutside": true,
3036
3083
  "resizable": false,
@@ -3041,8 +3088,7 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3041
3088
  }
3042
3089
  ]
3043
3090
  }
3044
- },
3045
- "id": "u:ee7c7929e6ae"
3091
+ }
3046
3092
  }
3047
3093
  }else {
3048
3094
  return ___default["default"].map(buttons, (button) => {
@@ -3071,6 +3117,7 @@ const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
3071
3117
  "drawer": {
3072
3118
  "type": "drawer",
3073
3119
  "title": "操作",
3120
+ "id": "object_actions_drawer_" + objectSchema.name,
3074
3121
  "body": [
3075
3122
  {
3076
3123
  "type": "button-group",
@@ -5647,6 +5694,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
5647
5694
  const fieldsArr = [];
5648
5695
 
5649
5696
  const listName = "all";
5697
+
5698
+ const isMobile = window.innerWidth < 768;
5650
5699
 
5651
5700
  const listView = ___namespace.find(
5652
5701
  refObjectConfig.list_views,
@@ -5723,6 +5772,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5723
5772
 
5724
5773
  source.data.$term = "$term";
5725
5774
  source.data.$self = "$$";
5775
+
5726
5776
 
5727
5777
  source.requestAdaptor = `
5728
5778
  const selfData = JSON.parse(JSON.stringify(api.data.$self));
@@ -5758,6 +5808,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5758
5808
  }
5759
5809
  }
5760
5810
 
5811
+
5761
5812
  if(allowSearchFields){
5762
5813
  allowSearchFields.forEach(function(key){
5763
5814
  const keyValue = selfData[key];
@@ -5873,7 +5924,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
5873
5924
  pickerSchema.affixHeader = false;
5874
5925
 
5875
5926
  var headerToolbarItems = [];
5876
- const isMobile = window.innerWidth < 768;
5877
5927
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
5878
5928
  headerToolbarItems = getLookupSapceUserTreeSchema();
5879
5929
  pickerSchema["style"] = {
@@ -5954,7 +6004,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5954
6004
  }
5955
6005
 
5956
6006
  const ctx = ${JSON.stringify(ctx)};
5957
- const componentId = ctx.defaults.formSchema.id ? 'service-'+ctx.defaults.formSchema.id : 'new-'+ctx.defaults.formSchema.objectApiName;
6007
+ const componentId = ctx.defaults.formSchema.id;
5958
6008
  doAction({
5959
6009
  actionType: 'setValue',
5960
6010
  componentId: componentId,
@@ -6208,6 +6258,11 @@ async function lookupToAmis(field, readonly, ctx){
6208
6258
  // ids人员点选模式
6209
6259
  return await lookupToAmisIdsPicker(field, readonly, ctx);
6210
6260
  }
6261
+ if(!field.filters || field.filters.length == 0){
6262
+ field.filters = [["user_accepted", "=", true]];
6263
+ }else {
6264
+ field.filters = [ ["user_accepted", "=", true], "and", field.filters ];
6265
+ }
6211
6266
  // 左侧树右侧人员列表的下拉框模式,不再支持,而是执行下面的lookupToAmisPicker函数弹出选人窗口
6212
6267
  // return await lookupToAmisSelectUser(field, readonly, ctx);
6213
6268
  }
@@ -6348,7 +6403,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
6348
6403
  * @Author: baozhoutao@steedos.com
6349
6404
  * @Date: 2023-01-13 17:27:54
6350
6405
  * @LastEditors: liaodaxue
6351
- * @LastEditTime: 2023-06-16 15:58:21
6406
+ * @LastEditTime: 2023-06-30 10:29:52
6352
6407
  * @Description:
6353
6408
  */
6354
6409
 
@@ -6356,12 +6411,16 @@ async function getIdsPickerSchema(field, readonly, ctx){
6356
6411
  const getMarkdownFieldSchema = (field, readonly, ctx)=>{
6357
6412
  if(readonly){
6358
6413
  return {
6359
- "type": "markdown",
6360
- "name": field.name,
6361
- "options": {
6362
- "linkify": true,
6363
- "html": true,
6364
- "breaks": true
6414
+ "type": "control",
6415
+ "label": field.label,
6416
+ "body": {
6417
+ "type": "markdown",
6418
+ "name": field.name,
6419
+ "options": {
6420
+ "linkify": true,
6421
+ "html": true,
6422
+ "breaks": true
6423
+ }
6365
6424
  }
6366
6425
  }
6367
6426
  }else {
@@ -7442,6 +7501,7 @@ async function getQuickEditSchema(field, options){
7442
7501
  async function getTableColumns(fields, options){
7443
7502
  const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
7444
7503
  const allowEdit = options.permissions?.allowEdit && options.permissions?.modifyAllRecords && !options.isLookup && options.enable_inline_edit != false;
7504
+ const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
7445
7505
  for (const field of fields) {
7446
7506
  //增加quickEdit属性,实现快速编辑
7447
7507
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
@@ -7498,7 +7558,7 @@ async function getTableColumns(fields, options){
7498
7558
  type: "switch",
7499
7559
  name: field.name,
7500
7560
  label: field.label,
7501
- width: field.width,
7561
+ width: field.width || defaultWidth,
7502
7562
  toggled: field.toggled,
7503
7563
  quickEdit: quickEditSchema,
7504
7564
  className:"whitespace-nowrap",
@@ -7513,7 +7573,7 @@ async function getTableColumns(fields, options){
7513
7573
  label: field.label,
7514
7574
  map: map,
7515
7575
  sortable: field.sortable,
7516
- width: field.width,
7576
+ width: field.width || defaultWidth,
7517
7577
  toggled: field.toggled,
7518
7578
  className:"whitespace-nowrap",
7519
7579
  quickEdit: quickEditSchema
@@ -7542,7 +7602,7 @@ async function getTableColumns(fields, options){
7542
7602
  label: field.label,
7543
7603
  sortable: field.sortable,
7544
7604
  // searchable: field.searchable,
7545
- width: field.width,
7605
+ width: field.width || defaultWidth,
7546
7606
  type: type,
7547
7607
  tpl: tpl,
7548
7608
  toggled: field.toggled,
@@ -7949,6 +8009,7 @@ async function getTableApi(mainObject, fields, options){
7949
8009
  let valueField = mainObject.key_field || '_id';
7950
8010
  const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
7951
8011
 
8012
+ api.url += "&objectName=${objectName}";//设计器上对象表格组件需要切换对象重新请求列表数据
7952
8013
  if(options.isRelated){
7953
8014
  api.url += "&recordId=${_master.recordId}";
7954
8015
  }
@@ -8278,12 +8339,18 @@ function getReadonlyFormAdaptor(object, fields, options){
8278
8339
  // }
8279
8340
  // })
8280
8341
 
8342
+ var fieldNames = ___namespace.map(fields, function(n){return n.name});
8281
8343
  return `
8282
8344
  if(payload.data.data.length === 0){
8283
8345
  var isEditor = !!${options && options.isEditor};
8284
8346
  if(isEditor){
8347
+ var fieldNames = ${JSON.stringify(fieldNames)};
8348
+ var emptyDoc = {};//这里如果不把每个字段值设置为空的话,表单上会显示上一次表单上的字段值
8349
+ fieldNames.forEach(function(n){
8350
+ emptyDoc[n] = null;
8351
+ });
8285
8352
  // 设计器中始终显示表单,有记录则显示第一条记录,没记录时显示为空表单
8286
- payload.data.data = [{}];
8353
+ payload.data.data = [emptyDoc];
8287
8354
  }
8288
8355
  else{
8289
8356
  return {
@@ -9087,8 +9154,8 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
9087
9154
  /*
9088
9155
  * @Author: baozhoutao@steedos.com
9089
9156
  * @Date: 2022-05-26 16:02:08
9090
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
9091
- * @LastEditTime: 2023-06-04 15:49:23
9157
+ * @LastEditors: liaodaxue
9158
+ * @LastEditTime: 2023-06-29 17:27:19
9092
9159
  * @Description:
9093
9160
  */
9094
9161
 
@@ -9182,7 +9249,7 @@ const getSections = async (permissionFields, formFields, ctx) => {
9182
9249
  const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
9183
9250
  if (section.body.length > 0) {
9184
9251
  if (section.visibleOn) {
9185
- sectionVisibleOns.push(section.visibleOn);
9252
+ sectionVisibleOns.push("("+section.visibleOn+")");
9186
9253
  }
9187
9254
  else {
9188
9255
  sectionVisibleOns.push("true");
@@ -9520,8 +9587,12 @@ async function getObjectForm(objectSchema, ctx){
9520
9587
  if(___default["default"].has(formSchema, 'className')){
9521
9588
  formSchema.className = 'steedos-amis-form';
9522
9589
  }
9590
+ if(!formSchema.id){
9591
+ formSchema.id = 'form_' + objectSchema.name;
9592
+ }
9523
9593
  const amisSchema = {
9524
9594
  type: 'service',
9595
+ id: `service_${formSchema.id}`,
9525
9596
  className: 'p-0',
9526
9597
  name: `page_edit_${recordId}`,
9527
9598
  api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
@@ -9592,11 +9663,6 @@ async function getObjectForm(objectSchema, ctx){
9592
9663
  }
9593
9664
  })]
9594
9665
  };
9595
- if(formSchema.id){
9596
- amisSchema.id = `service-${formSchema.id}`;
9597
- }else {
9598
- amisSchema.id = `new-${objectSchema.name}`;
9599
- }
9600
9666
  return amisSchema;
9601
9667
  }
9602
9668