@steedos-widgets/amis-object 3.6.2-beta.13 → 3.6.2-beta.14

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.
@@ -3570,8 +3570,8 @@ const Router$1 = {
3570
3570
  /*
3571
3571
  * @Author: baozhoutao@steedos.com
3572
3572
  * @Date: 2022-07-20 16:29:22
3573
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
3574
- * @LastEditTime: 2023-12-28 14:59:08
3573
+ * @LastEditors: liaodaxue
3574
+ * @LastEditTime: 2024-01-25 14:44:17
3575
3575
  * @Description:
3576
3576
  */
3577
3577
 
@@ -3643,6 +3643,25 @@ function getComparableAmisVersion() {
3643
3643
  }
3644
3644
  }
3645
3645
 
3646
+ /**
3647
+ * 判断浏览器类型
3648
+ * @returns 按需返回浏览器类型;
3649
+ */
3650
+ function getBowserType() {
3651
+ const userAgent = navigator.userAgent;
3652
+ if (userAgent.indexOf("Chrome")!== -1 && userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Edg") === -1) {
3653
+ return "Chrome";
3654
+ } else if (userAgent.indexOf("Firefox") !== -1) {
3655
+ return "Firefox";
3656
+ } else if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1 && userAgent.indexOf("Edge") === -1) {
3657
+ return "Safari";
3658
+ } else if (userAgent.indexOf("Edg") !== -1) {
3659
+ return "Edge";
3660
+ } else {
3661
+ return "Unknown browser"; // 其他浏览器...(可根据自己需要确定是否新增其他浏览器的判断)
3662
+ }
3663
+ }
3664
+
3646
3665
  /*
3647
3666
  * @Author: baozhoutao@steedos.com
3648
3667
  * @Date: 2022-05-23 09:53:08
@@ -5046,7 +5065,8 @@ async function getQuickEditSchema(field, options){
5046
5065
  "failed": "失败了呢。。"
5047
5066
  }
5048
5067
  }
5049
- }
5068
+ },
5069
+ "expression": "${!recordPermissions.modifyAllRecords}"
5050
5070
  },
5051
5071
  {
5052
5072
  "actionType": "setValue",
@@ -5062,7 +5082,7 @@ async function getQuickEditSchema(field, options){
5062
5082
  "componentId": quickEditId,
5063
5083
  "args": {
5064
5084
  "value":{
5065
- "quickedit_record_permissions": "${event.data}"
5085
+ "quickedit_record_permissions": "${recordPermissions.modifyAllRecords ? {'allowEdit': true} : event.data}"
5066
5086
  }
5067
5087
  }
5068
5088
  }
@@ -5126,7 +5146,7 @@ async function getQuickEditSchema(field, options){
5126
5146
  `
5127
5147
  }
5128
5148
  },
5129
- "expression":"${event.data.value}"
5149
+ "expression":"${event.data.value && !recordPermissions.modifyAllRecords}"
5130
5150
  },
5131
5151
  {
5132
5152
  "actionType": "setValue",
@@ -5157,10 +5177,20 @@ async function getQuickEditSchema(field, options){
5157
5177
  "script": `
5158
5178
  const noPermission = event.data.noPermission;
5159
5179
  const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
5160
- const selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
5180
+ let selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
5161
5181
  noPermission.forEach(function (item) {
5162
5182
  crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
5183
+ _.remove(selectedItems, (selected) => selected._id === item);
5163
5184
  })
5185
+ doAction({
5186
+ "componentId": "${quickEditId}",
5187
+ "actionType": "setValue",
5188
+ "args": {
5189
+ "value": {
5190
+ selectedItems
5191
+ }
5192
+ }
5193
+ });
5164
5194
  `
5165
5195
  },
5166
5196
  {
@@ -5251,7 +5281,8 @@ async function getTableColumns$1(fields, options){
5251
5281
  //增加quickEdit属性,实现快速编辑
5252
5282
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
5253
5283
  let className = "";
5254
- if(/Safari/.test(navigator.userAgent)){
5284
+ const bowserType = getBowserType();
5285
+ if(bowserType === "Safari"){
5255
5286
  className += " whitespace-nowrap ";
5256
5287
  }else {
5257
5288
  if(field.wrap != true){
@@ -5260,6 +5291,18 @@ async function getTableColumns$1(fields, options){
5260
5291
  className += " break-words ";
5261
5292
  }
5262
5293
  }
5294
+
5295
+ if (typeof field.amis?.className == "object") {
5296
+ className = {
5297
+ [className]: "true",
5298
+ ...field.amis.className
5299
+ };
5300
+ } else if (typeof field.amis?.className == "string") {
5301
+ className = `${className} ${field.amis.className} `;
5302
+ }
5303
+ let fieldAmis = _$1__namespace.clone(field.amis);
5304
+ delete fieldAmis?.className;
5305
+
5263
5306
  let columnItem;
5264
5307
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
5265
5308
  const previewFileScript = `
@@ -5310,7 +5353,7 @@ async function getTableColumns$1(fields, options){
5310
5353
  toggled: field.toggled,
5311
5354
  static: true,
5312
5355
  className,
5313
- }, field.amis, {name: field.name});
5356
+ }, fieldAmis, {name: field.name});
5314
5357
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
5315
5358
  columnItem = Object.assign({}, {
5316
5359
  type: "switch",
@@ -5321,7 +5364,7 @@ async function getTableColumns$1(fields, options){
5321
5364
  static: true,
5322
5365
  className,
5323
5366
  ...getAmisFileReadonlySchema(field)
5324
- }, field.amis, {name: field.name});
5367
+ }, fieldAmis, {name: field.name});
5325
5368
  }
5326
5369
  else if(field.type === 'select'){
5327
5370
  const map = getSelectMap(field.options);
@@ -5336,7 +5379,7 @@ async function getTableColumns$1(fields, options){
5336
5379
  className,
5337
5380
  inputClassName: "inline",
5338
5381
  static: true,
5339
- }, field.amis, {name: field.name});
5382
+ }, fieldAmis, {name: field.name});
5340
5383
  }
5341
5384
  else {
5342
5385
  const tpl = await getFieldTpl(field, options);
@@ -5363,15 +5406,6 @@ async function getTableColumns$1(fields, options){
5363
5406
  // }
5364
5407
 
5365
5408
  //field上的amis属性里的clssname需要单独判断类型合并
5366
- if (typeof field.amis?.className == "object") {
5367
- className = {
5368
- [className]: "true",
5369
- ...field.amis.className
5370
- };
5371
- } else if (typeof field.amis?.className == "string") {
5372
- className = `${className} ${field.amis.className} `;
5373
- }
5374
- delete field.amis?.className;
5375
5409
 
5376
5410
  if(!field.hidden && !field.extra){
5377
5411
  columnItem = Object.assign({}, {
@@ -5388,7 +5422,7 @@ async function getTableColumns$1(fields, options){
5388
5422
  static: true,
5389
5423
  options: field.type === 'html' ? {html: true} : null
5390
5424
  // toggled: true
5391
- }, field.amis, {name: field.name});
5425
+ }, fieldAmis, {name: field.name});
5392
5426
 
5393
5427
  if(field.type === 'color'){
5394
5428
  columnItem.type = 'color';
@@ -11792,14 +11826,7 @@ async function getObjectCRUD(objectSchema, fields, options){
11792
11826
  headers: {
11793
11827
  Authorization: "Bearer ${context.tenantId},${context.authToken}",
11794
11828
  },
11795
- requestAdaptor: quickSaveApiRequestAdaptor,
11796
- adaptor: `
11797
- if(payload.errors){
11798
- payload.status = 2;
11799
- payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
11800
- }
11801
- return payload;
11802
- `
11829
+ requestAdaptor: quickSaveApiRequestAdaptor
11803
11830
  },
11804
11831
  // 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
11805
11832
  // 使用表达式给tr添加初始选中状态
@@ -11816,6 +11843,21 @@ async function getObjectCRUD(objectSchema, fields, options){
11816
11843
  crudModeClassName = `steedos-crud-mode-${body.mode}`;
11817
11844
  }
11818
11845
 
11846
+ body.quickSaveApi.adaptor = `
11847
+ if(payload.errors){
11848
+ payload.status = 2;
11849
+ payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
11850
+ }
11851
+ debugger;
11852
+ var scope = SteedosUI.getRef(context.scopeId);
11853
+ var scopeParent = scope && scope.parent;
11854
+ var crudScoped = scopeParent.getComponentById('${body.id}');
11855
+ setTimeout(()=>{
11856
+ crudScoped && crudScoped.control.updateAutoFillHeight();
11857
+ }, 500);
11858
+ return payload;
11859
+ `;
11860
+
11819
11861
  if(body.columns && options.formFactor != 'SMALL'){
11820
11862
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
11821
11863
  body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
@@ -16137,7 +16179,7 @@ function uuidv4() {
16137
16179
  * @Author: 殷亮辉 yinlianghui@hotoa.com
16138
16180
  * @Date: 2023-11-15 09:50:22
16139
16181
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
16140
- * @LastEditTime: 2024-01-24 14:56:03
16182
+ * @LastEditTime: 2024-01-25 14:11:50
16141
16183
  */
16142
16184
 
16143
16185
  function getTablePrimaryKey(props) {
@@ -16289,16 +16331,20 @@ function getInputTableCell(field, showAsInlineEditMode) {
16289
16331
  }
16290
16332
  }
16291
16333
  else {
16334
+ // 这里加一层service是因为amis 3.6/6.0中有bug,不加的话,这里会显示为父作用域中中的同名变量值,见:https://github.com/baidu/amis/issues/9520
16292
16335
  return {
16293
- "type": "steedos-field",
16294
- "config": Object.assign({}, field, {
16295
- label: false
16296
- }),
16297
- inInputTable: true,
16298
- "static": true,
16299
- "readonly": true,
16336
+ "type": "service",
16300
16337
  label: field.label,
16301
- name: field.name
16338
+ name: field.name,
16339
+ "body":[{
16340
+ "type": "steedos-field",
16341
+ "config": Object.assign({}, field, {
16342
+ label: false
16343
+ }),
16344
+ inInputTable: true,
16345
+ "static": true,
16346
+ "readonly": true
16347
+ }]
16302
16348
  }
16303
16349
  }
16304
16350
  }
@@ -17422,6 +17468,10 @@ const getAmisInputTableSchema = async (props) => {
17422
17468
  "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
17423
17469
  });
17424
17470
  }
17471
+ // if (showAsInlineEditMode) {
17472
+ // // 因为要支持不同的列上配置inlineEditMode属性,所有不可以把整个子表组件都设置为inlineEditMode
17473
+ // inputTableSchema.needConfirm = false;
17474
+ // }
17425
17475
  if (amis) {
17426
17476
  // 支持配置amis属性重写或添加最终生成的input-table中任何属性。
17427
17477
  delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效