@steedos-widgets/amis-lib 1.2.1 → 1.2.2

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.umd.js CHANGED
@@ -1389,8 +1389,8 @@
1389
1389
  /*
1390
1390
  * @Author: baozhoutao@steedos.com
1391
1391
  * @Date: 2022-11-01 15:51:00
1392
- * @LastEditors: Please set LastEditors
1393
- * @LastEditTime: 2023-04-11 13:58:24
1392
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1393
+ * @LastEditTime: 2023-04-16 17:04:16
1394
1394
  * @Description:
1395
1395
  */
1396
1396
 
@@ -1468,6 +1468,7 @@
1468
1468
  "context": "${context}",
1469
1469
  "global": "${global}",
1470
1470
  "listViewId": "${listViewId}",
1471
+ "displayAs": "${displayAs}",
1471
1472
  "uiSchema": "${uiSchema}",
1472
1473
  "isLookup": "${isLookup}",
1473
1474
  "listName": "${listName}"
@@ -3766,7 +3767,7 @@ setTimeout(()=>{
3766
3767
  {
3767
3768
  "type": "button",
3768
3769
  "label": "重命名",
3769
- "visibleOn": "(global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && ['all', 'recent', 'my'].indexOf(listName) == -1",
3770
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3770
3771
  "onEvent": {
3771
3772
  "click": {
3772
3773
  "weight": 0,
@@ -3821,7 +3822,7 @@ setTimeout(()=>{
3821
3822
  {
3822
3823
  "type": "button",
3823
3824
  "label": "共享设置",
3824
- "visibleOn": "global.user.is_space_admin && ['all', 'recent', 'my'].indexOf(listName) == -1",
3825
+ "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
3825
3826
  "onEvent": {
3826
3827
  "click": {
3827
3828
  "weight": 0,
@@ -3861,7 +3862,7 @@ setTimeout(()=>{
3861
3862
  {
3862
3863
  "type": "button",
3863
3864
  "label": "过滤设置",
3864
- "visibleOn": "(global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && ['all', 'recent', 'my'].indexOf(listName) == -1",
3865
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3865
3866
  "onEvent": {
3866
3867
  "click": {
3867
3868
  "weight": 0,
@@ -3923,7 +3924,7 @@ setTimeout(()=>{
3923
3924
  {
3924
3925
  "type": "button",
3925
3926
  "label": "显示的列",
3926
- "visibleOn": "(global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && ['all', 'recent', 'my'].indexOf(listName) == -1",
3927
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3927
3928
  "onEvent": {
3928
3929
  "click": {
3929
3930
  "weight": 0,
@@ -3982,10 +3983,74 @@ setTimeout(()=>{
3982
3983
  }
3983
3984
  }
3984
3985
  },
3986
+ {
3987
+ "type": "button",
3988
+ "label": "默认排序规则",
3989
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3990
+ "onEvent": {
3991
+ "click": {
3992
+ "weight": 0,
3993
+ "actions": [
3994
+ {
3995
+ "dialog": {
3996
+ "type": "dialog",
3997
+ "title": "弹框标题",
3998
+ "data": {
3999
+ "&": "$$",
4000
+ "objectName": "${objectName}",
4001
+ "recordId": "${uiSchema.list_views[listName]._id}",
4002
+ "listName": "${listName}",
4003
+ "appId": "${appId}"
4004
+ },
4005
+ "body": [
4006
+ {
4007
+ "type": "steedos-object-form",
4008
+ "label": "对象表单",
4009
+ "objectApiName": "object_listviews",
4010
+ "recordId": "${recordId}",
4011
+ "className": "",
4012
+ "id": "u:061f158b4c5a",
4013
+ "mode": "edit",
4014
+ "fields": [
4015
+ "sort",
4016
+ "sort.$.field_name",
4017
+ "sort.$.order"
4018
+ ],
4019
+ "onEvent": {
4020
+ "submitSucc": {
4021
+ "weight": 0,
4022
+ "actions": [
4023
+ {
4024
+ "args": {
4025
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4026
+ "blank": false
4027
+ },
4028
+ "actionType": "url"
4029
+ }
4030
+ ]
4031
+ }
4032
+ },
4033
+ "fieldsExtend": "{\n \"sort\": {\n \"amis\": {\n \"type\": \"tabs-transfer\",\n \"sortable\": true,\n \"searchable\": true,\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/sortFields/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n }\n}",
4034
+ "initApiAdaptor": "let sort;\nif (recordId) {\n sort = payload.data.initialValues.sort;\n //数据格式转换\n if (sort instanceof Array) {\n sort = lodash.map(sort, (item) => {\n return item.field_name + ':' + (item.order || 'asc')\n });\n }\n}\npayload.data.initialValues.sort = sort;\ndelete payload.extensions;",
4035
+ "apiRequestAdaptor": "const recordId = api.body.recordId;\n//数据格式转换\nif (typeof formData.sort == 'string') {\n formData.sort = formData.sort?.split(',');\n}\nformData.sort = lodash.map(formData.sort, (item) => {\n const arr = item.split(':');\n return { field_name: arr[0], order: arr[1] };\n});\nif (recordId) {\n query = 'mutation{record: ' + objectName + '__update(id: \"' + recordId + '\", doc: {__saveData}){_id}}';\n}\n__saveData = JSON.stringify(JSON.stringify(formData));\napi.data = { query: query.replace('{__saveData}', __saveData) };\n"
4036
+ }
4037
+ ],
4038
+ "showCloseButton": true,
4039
+ "showErrorMsg": true,
4040
+ "showLoading": true,
4041
+ "id": "u:d3f6947b6acf",
4042
+ "size": "lg"
4043
+ },
4044
+ "actionType": "dialog"
4045
+ }
4046
+ ]
4047
+ }
4048
+ }
4049
+ },
3985
4050
  {
3986
4051
  "type": "button",
3987
4052
  "label": "删除",
3988
- "visibleOn": "(global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && ['all', 'recent', 'my'].indexOf(listName) == -1",
4053
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3989
4054
  "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
3990
4055
  "onEvent": {
3991
4056
  "click": {
@@ -4346,7 +4411,6 @@ setTimeout(()=>{
4346
4411
  {
4347
4412
  "actionType": "custom",
4348
4413
  "script": `
4349
- debugger;
4350
4414
  const scope = event.context.scoped;
4351
4415
  //TODO: 将form中的value一同加入筛选内
4352
4416
  // var filterForm = scope.parent.parent.getComponents().find(function(n){
@@ -5830,7 +5894,7 @@ setTimeout(()=>{
5830
5894
 
5831
5895
  const API_CACHE = 100;
5832
5896
 
5833
- function getReadonlyFormAdaptor(fields){
5897
+ function getReadonlyFormAdaptor(object, fields){
5834
5898
  let scriptStr = '';
5835
5899
  const selectFields = ___namespace.filter(fields, function(field){return field.name.indexOf('.') < 0 && ((field.type == 'select' && field.options) || ((field.type == 'lookup' || field.type == 'master_detail') && !field.reference_to))});
5836
5900
  const gridAndObjectFieldsName = ___namespace.map(___namespace.filter(fields, function(field){return field.name.indexOf('.') < 0 && (field.type === 'object' || field.type === 'grid')}), 'name');
@@ -5889,6 +5953,7 @@ setTimeout(()=>{
5889
5953
  console.error(e)
5890
5954
  }
5891
5955
  payload.data = data;
5956
+ payload.data.__objectName = "${object.name}";
5892
5957
  payload.data.__record = record;
5893
5958
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
5894
5959
  }
@@ -5906,7 +5971,7 @@ setTimeout(()=>{
5906
5971
  url: getApi$2()+"&recordId=${recordId}",
5907
5972
  cache: API_CACHE,
5908
5973
  // requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
5909
- adaptor: getReadonlyFormAdaptor(fields),
5974
+ adaptor: getReadonlyFormAdaptor(object, fields),
5910
5975
  data: await getFindOneQuery$1(object, recordId, fields, options),
5911
5976
  headers: {
5912
5977
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
@@ -6624,6 +6689,7 @@ setTimeout(()=>{
6624
6689
  eventName: "recordLoaded"
6625
6690
  },
6626
6691
  data: {
6692
+ objectName: "${event.data.__objectName}",
6627
6693
  record: "${event.data.__record}"
6628
6694
  }
6629
6695
  },
@@ -7060,7 +7126,7 @@ setTimeout(()=>{
7060
7126
  const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
7061
7127
 
7062
7128
  if(options.isRelated){
7063
- api.url += "&recordId=${recordId}";
7129
+ api.url += "&recordId=${_master.recordId}";
7064
7130
  }
7065
7131
 
7066
7132
  api.data.$term = "$term";
@@ -8304,8 +8370,8 @@ setTimeout(()=>{
8304
8370
  /*
8305
8371
  * @Author: baozhoutao@steedos.com
8306
8372
  * @Date: 2022-07-05 15:55:39
8307
- * @LastEditors: baozhoutao@steedos.com
8308
- * @LastEditTime: 2023-04-12 14:24:09
8373
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
8374
+ * @LastEditTime: 2023-04-14 11:10:07
8309
8375
  * @Description:
8310
8376
  */
8311
8377
 
@@ -8791,6 +8857,41 @@ setTimeout(()=>{
8791
8857
  }
8792
8858
  }
8793
8859
 
8860
+ async function getRecordServiceSchema(objectName, appId, props = {}) {
8861
+ const uiSchema = await getUISchema(objectName);
8862
+ return {
8863
+ uiSchema,
8864
+ amisSchema: {
8865
+ "type": "service",
8866
+ "body": [],
8867
+ data: {
8868
+ "_master.objectName": "${objectName}",
8869
+ "_master.recordId": "${recordId}"
8870
+ },
8871
+ "style": {
8872
+ "padding": "var(--Page-body-padding)",
8873
+ ...props.style
8874
+ },
8875
+ onEvent: {
8876
+ "recordLoaded": {
8877
+ "actions": [
8878
+ {
8879
+ "actionType": "reload",
8880
+ "data": {
8881
+ "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
8882
+ "_master.record": `\${record}`,
8883
+ // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
8884
+ "_master.objectName": "${objectName}",
8885
+ "_master.recordId": "${recordId}"
8886
+ }
8887
+ }
8888
+ ]
8889
+ },
8890
+ ...props.onEvent
8891
+ }
8892
+ }
8893
+ }
8894
+ }
8794
8895
 
8795
8896
  // 获取单个相关表
8796
8897
  async function getObjectRelated(
@@ -11708,6 +11809,7 @@ setTimeout(()=>{
11708
11809
  exports.getRecordDetailSchema = getRecordDetailSchema;
11709
11810
  exports.getRecordPageInitSchema = getRecordPageInitSchema;
11710
11811
  exports.getRecordPermissions = getRecordPermissions;
11812
+ exports.getRecordServiceSchema = getRecordServiceSchema;
11711
11813
  exports.getRelatedFieldValue = getRelatedFieldValue;
11712
11814
  exports.getRelatedListSchema = getRelatedListSchema;
11713
11815
  exports.getRelatedsCount = getRelatedsCount;