@steedos-widgets/amis-lib 3.6.3-beta.1 → 3.6.4-beta.1

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
@@ -510,8 +510,8 @@ function getComparableAmisVersion() {
510
510
  /*
511
511
  * @Author: baozhoutao@steedos.com
512
512
  * @Date: 2022-05-23 09:53:08
513
- * @LastEditors: liaodaxue
514
- * @LastEditTime: 2024-01-17 16:00:27
513
+ * @LastEditors: baozhoutao@steedos.com
514
+ * @LastEditTime: 2024-02-19 11:57:49
515
515
  * @Description:
516
516
  */
517
517
 
@@ -597,7 +597,11 @@ function getNameTpl(field, ctx){
597
597
  if(ctx && ctx.isLookup){
598
598
  linkTarget = "target='_blank'";
599
599
  }
600
- return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
600
+ if(ctx.isRelated){
601
+ return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
602
+ }else {
603
+ return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
604
+ }
601
605
  }
602
606
 
603
607
  function getRelatedFieldTpl(field, ctx){
@@ -626,6 +630,9 @@ function getRelatedFieldTpl(field, ctx){
626
630
  if(_.isString(field.reference_to) || !field.reference_to){
627
631
  if(field.multiple){
628
632
  let labelTpl = `<%=item.label%>`;
633
+ if(ctx.isRelated){
634
+ linkTarget = "target='_blank'";
635
+ }
629
636
  if(!onlyDisplayLookLabel){
630
637
  const href = Router.getObjectDetailPath({
631
638
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
@@ -648,7 +655,12 @@ function getRelatedFieldTpl(field, ctx){
648
655
  const href = Router.getObjectDetailPath({
649
656
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
650
657
  });
651
- labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
658
+ if(ctx.isRelated){
659
+ labelTpl = `<a href="${href}" ${linkTarget} onclick="return false;">${labelTpl}</a>`;
660
+ }else {
661
+ labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
662
+ }
663
+
652
664
  }
653
665
  tpl = labelTpl;
654
666
  }
@@ -763,27 +775,29 @@ async function getFieldsTemplate(fields, display){
763
775
  fieldsArr = ___namespace.values(fields);
764
776
  }
765
777
  for (const field of fieldsArr) {
766
- //graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
767
- if(field.expand){
768
- expandFields.push(field);
769
- }else {
770
- if(field.name.indexOf('.') < 0){
771
- if(display && (field.type == 'lookup' || field.type == 'master_detail')){
772
- fieldsName.push(`${field.name}`);
773
- displayFields.push(`${field.name}`);
778
+ if(field.name){
779
+ //graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
780
+ if(field.expand){
781
+ expandFields.push(field);
782
+ }else {
783
+ if(field.name.indexOf('.') < 0){
784
+ if(display && (field.type == 'lookup' || field.type == 'master_detail')){
785
+ fieldsName.push(`${field.name}`);
786
+ displayFields.push(`${field.name}`);
787
+ }else {
788
+ fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
789
+ }
790
+ if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
791
+ fieldsName.push(`${field.name}`);
792
+ }
793
+ if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
794
+ displayFields.push(`${field.name}`);
795
+ }
774
796
  }else {
775
- fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
776
- }
777
- if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
778
- fieldsName.push(`${field.name}`);
797
+ objectFieldName = field.name.split('.')[0];
798
+ fieldsName.push(objectFieldName);
799
+ displayFields.push(objectFieldName);
779
800
  }
780
- if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
781
- displayFields.push(`${field.name}`);
782
- }
783
- }else {
784
- objectFieldName = field.name.split('.')[0];
785
- fieldsName.push(objectFieldName);
786
- displayFields.push(objectFieldName);
787
801
  }
788
802
  }
789
803
  }
@@ -2297,6 +2311,54 @@ async function getTableColumns(fields, options){
2297
2311
  columnItem.type = 'color';
2298
2312
  columnItem.defaultColor = null;
2299
2313
  }
2314
+
2315
+ if(((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && ___namespace.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2316
+
2317
+ const drawerRecordDetailSchema = {
2318
+ "type": "steedos-record-detail",
2319
+ "objectApiName": "${objectName}",
2320
+ "recordId": `\${${options.idFieldName}}`,
2321
+ "showBackButton": false,
2322
+ "showButtons": true,
2323
+ "data": {
2324
+ "_inDrawer": true, // 用于判断是否在抽屉中
2325
+ "recordLoaded": false, // 重置数据加载状态
2326
+ }
2327
+ };
2328
+
2329
+
2330
+ if(!(field.is_name || field.name === options.labelFieldName)){
2331
+ drawerRecordDetailSchema.objectApiName = field.reference_to;
2332
+ drawerRecordDetailSchema.recordId = `\${_display.${field.name}.value}`;
2333
+ }
2334
+
2335
+ columnItem.onEvent = {
2336
+ "click": {
2337
+ "actions": [
2338
+ {
2339
+ "actionType": "drawer",
2340
+ "drawer": {
2341
+ "type": "drawer",
2342
+ "title": "&nbsp;",
2343
+ "headerClassName": "",
2344
+ "size": "lg",
2345
+ "bodyClassName": "p-0 m-0 border-t",
2346
+ "closeOnEsc": true,
2347
+ "resizable": true,
2348
+ "actions": [],
2349
+ "body": [
2350
+ drawerRecordDetailSchema
2351
+ ],
2352
+ "className": "app-popover",
2353
+ "id": "u:fc5f055afa8c"
2354
+ },
2355
+ "preventDefault": true
2356
+ }
2357
+ ]
2358
+ }
2359
+ };
2360
+ }
2361
+
2300
2362
  }
2301
2363
  }
2302
2364
  if(columnItem){
@@ -4529,8 +4591,8 @@ const parseSingleExpression = function (func, formData, dataPath, global, userSe
4529
4591
  /*
4530
4592
  * @Author: baozhoutao@steedos.com
4531
4593
  * @Date: 2022-11-01 15:51:00
4532
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
4533
- * @LastEditTime: 2023-09-25 14:53:05
4594
+ * @LastEditors: baozhoutao@steedos.com
4595
+ * @LastEditTime: 2024-02-18 18:37:35
4534
4596
  * @Description:
4535
4597
  */
4536
4598
 
@@ -4570,13 +4632,13 @@ const getSchema$5 = async (uiSchema, ctx) => {
4570
4632
  const recordId = _master.recordId;
4571
4633
  let relatedKeySaveValue = recordId;
4572
4634
  const relatedField = fields[relatedKey];
4573
- if(relatedField.reference_to_field && relatedField.reference_to_field !== '_id'){
4635
+ if(relatedField && relatedField.reference_to_field && relatedField.reference_to_field !== '_id'){
4574
4636
  relatedKeySaveValue = _master.record[relatedField.reference_to_field];
4575
4637
  }
4576
4638
  let relatedKeyValue;
4577
- if(!_.isString(relatedField.reference_to)){
4639
+ if(relatedField && !_.isString(relatedField.reference_to)){
4578
4640
  relatedKeyValue = { o: masterObjectName, ids: [relatedKeySaveValue] };
4579
- }else if (relatedField.multiple) {
4641
+ }else if (relatedField && relatedField.multiple) {
4580
4642
  relatedKeyValue = [relatedKeySaveValue];
4581
4643
  } else {
4582
4644
  relatedKeyValue = relatedKeySaveValue;
@@ -4860,8 +4922,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
4860
4922
  /*
4861
4923
  * @Author: 殷亮辉 yinlianghui@hotoa.com
4862
4924
  * @Date: 2023-03-22 09:31:21
4863
- * @LastEditors: Please set LastEditors
4864
- * @LastEditTime: 2023-04-12 10:35:36
4925
+ * @LastEditors: baozhoutao@steedos.com
4926
+ * @LastEditTime: 2024-02-18 16:06:21
4865
4927
  */
4866
4928
  const getSchema$3 = (uiSchema)=>{
4867
4929
  return {
@@ -4907,7 +4969,8 @@ const getSchema$3 = (uiSchema)=>{
4907
4969
  },
4908
4970
  "data": {
4909
4971
  "objectName": `${uiSchema.name}`,
4910
- "__deletedRecord": true
4972
+ "__deletedRecord": true,
4973
+ "_inDrawer": "${_inDrawer}"
4911
4974
  }
4912
4975
  },
4913
4976
  {
@@ -9192,8 +9255,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
9192
9255
  /*
9193
9256
  * @Author: baozhoutao@steedos.com
9194
9257
  * @Date: 2022-07-05 15:55:39
9195
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
9196
- * @LastEditTime: 2024-02-08 16:10:52
9258
+ * @LastEditors: baozhoutao@steedos.com
9259
+ * @LastEditTime: 2024-02-18 14:46:50
9197
9260
  * @Description:
9198
9261
  */
9199
9262
 
@@ -9327,7 +9390,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9327
9390
  // globalFilter = [`${relatedKey}`, "=", relatedValue];
9328
9391
  // }
9329
9392
  const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
9330
- const componentId = `steedos-record-related-list-${relatedObjectName}`;
9393
+ const componentId = `steedos-record-related-list-${relatedObjectName}_${new Date().getTime()}`;
9331
9394
  const isMobile = window.innerWidth < 768;
9332
9395
  let headerToolbar = [];
9333
9396
  if(!isMobile){
@@ -9601,8 +9664,8 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
9601
9664
  /*
9602
9665
  * @Author: baozhoutao@steedos.com
9603
9666
  * @Date: 2022-07-05 15:55:39
9604
- * @LastEditors: liaodaxue
9605
- * @LastEditTime: 2024-02-05 17:56:27
9667
+ * @LastEditors: baozhoutao@steedos.com
9668
+ * @LastEditTime: 2024-02-18 16:05:21
9606
9669
  * @Description:
9607
9670
  */
9608
9671
 
@@ -10171,10 +10234,14 @@ async function getRecordServiceSchema(objectName, appId, props = {}, body) {
10171
10234
  "componentId": serviceId,
10172
10235
  "expression": "this.__deletedRecord != true"
10173
10236
  },
10237
+ {
10238
+ "actionType": "closeDialog",
10239
+ "expression": "this.__deletedRecord === true && this._inDrawer === true"
10240
+ },
10174
10241
  {
10175
10242
  "actionType": "custom",
10176
10243
  "script": "window.goBack()",
10177
- "expression": "this.__deletedRecord === true"
10244
+ "expression": "this.__deletedRecord === true && this._inDrawer != true"
10178
10245
  }
10179
10246
  ]
10180
10247
  },
@@ -12589,8 +12656,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12589
12656
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
12590
12657
  },
12591
12658
  "adaptor": `
12592
- payload.data["${field.name}"] = payload.data && payload.data.autonumber;
12659
+ var tempValue = payload.data && payload.data.autonumber;
12593
12660
  delete payload.data.autonumber;
12661
+ payload.data["${field.name}"] = tempValue;
12594
12662
  return payload;
12595
12663
  `
12596
12664
  },
@@ -13142,6 +13210,11 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
13142
13210
  section.visibleOn = groupVisibleOn;
13143
13211
  }
13144
13212
  }
13213
+
13214
+ let groupCollapsed = group && group.collapsed;
13215
+ if(groupCollapsed === true) {
13216
+ section.collapsed = true;
13217
+ }
13145
13218
  return section
13146
13219
  };
13147
13220