@steedos-widgets/amis-object 1.1.4-beta.1 → 1.1.4-beta.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.
@@ -1933,8 +1933,8 @@ const getSchema$3 = async (uiSchema, ctx) => {
1933
1933
  /*
1934
1934
  * @Author: 殷亮辉 yinlianghui@hotoa.com
1935
1935
  * @Date: 2023-03-22 09:31:21
1936
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1937
- * @LastEditTime: 2023-03-27 16:03:34
1936
+ * @LastEditors: Please set LastEditors
1937
+ * @LastEditTime: 2023-03-28 14:06:47
1938
1938
  */
1939
1939
  const getSchema$2 = (uiSchema)=>{
1940
1940
  return {
@@ -1995,7 +1995,7 @@ const getSchema$2 = (uiSchema)=>{
1995
1995
  "data": {
1996
1996
  "objectName": "${_master.objectName}"
1997
1997
  },
1998
- "expression": "${_master.objectName}"
1998
+ "expression": `\${_master.objectName != '${uiSchema.name}' && _master.objectName}`
1999
1999
  }
2000
2000
  ]
2001
2001
  }
@@ -2419,7 +2419,7 @@ function getButtonVisibleOn$1(button){
2419
2419
  if(visible.trim().startsWith('function')){
2420
2420
  return `${visible}.apply({
2421
2421
  object: uiSchema
2422
- }, [objectName, _id, recordPermissions, data])`
2422
+ }, [objectName, _id, record.recordPermissions, data])`
2423
2423
  }
2424
2424
  return visible;
2425
2425
  }
@@ -4340,6 +4340,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
4340
4340
  }
4341
4341
  }
4342
4342
 
4343
+ const enable_tree = ${refObjectConfig.enable_tree};
4344
+ if(enable_tree){
4345
+ pageSize = 10000;
4346
+ }
4343
4347
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());
4344
4348
  return api;
4345
4349
  `;
@@ -4413,7 +4417,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
4413
4417
  new_button.align = "right";
4414
4418
  pickerSchema.headerToolbar.push(new_button);
4415
4419
  }
4416
- pickerSchema.footerToolbar = getObjectFooterToolbar();
4420
+ pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
4417
4421
  if(ctx.filterVisible !== false){
4418
4422
  let filterLoopCount = ctx.filterLoopCount || 0;
4419
4423
  filterLoopCount++;
@@ -4507,7 +4511,10 @@ async function lookupToAmisSelect(field, readonly, ctx){
4507
4511
  apiInfo = {
4508
4512
  method: "post",
4509
4513
  url: getApi$2(),
4510
- data: {query: '{objects(filters: ["_id", "=", "-1"]){_id}}', $: "$$"}
4514
+ data: {query: '{objects(filters: ["_id", "=", "-1"]){_id}}', $: "$$"},
4515
+ "headers": {
4516
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4517
+ }
4511
4518
  };
4512
4519
  }
4513
4520
 
@@ -5789,6 +5796,17 @@ async function getEditFormInitApi(object, recordId, fields){
5789
5796
  }
5790
5797
  else{
5791
5798
  var uiSchema = api.body.uiSchema;
5799
+ var defaultData = api.body.defaultData;
5800
+ var defaultValues = {};
5801
+ _.each(uiSchema?.fields, function(field){
5802
+ var value = SteedosUI.getFieldDefaultValue(field, api.body.global);
5803
+ if(value){
5804
+ defaultValues[field.name] = value;
5805
+ }
5806
+ });
5807
+ if(defaultData && _.isObject(defaultData) && !_.isArray(defaultData)){
5808
+ defaultValues = Object.assign({}, defaultValues, defaultData)
5809
+ }
5792
5810
  if(uiSchema.form){
5793
5811
  try{
5794
5812
  var objectFormConfig = JSON.parse(uiSchema.form);
@@ -5797,24 +5815,13 @@ async function getEditFormInitApi(object, recordId, fields){
5797
5815
  initialValues = new Function("return " + initialValues)();
5798
5816
  }
5799
5817
  if(typeof initialValues === "function"){
5800
- initialValues = initialValues();
5818
+ initialValues = initialValues.apply({doc: defaultValues || {} })
5801
5819
  }
5802
5820
  }
5803
5821
  catch(ex){
5804
5822
  console.warn(ex);
5805
5823
  }
5806
5824
  }
5807
- var defaultData = api.body.defaultData;
5808
- var defaultValues = {};
5809
- _.each(uiSchema?.fields, function(field){
5810
- var value = SteedosUI.getFieldDefaultValue(field, api.body.global);
5811
- if(value){
5812
- defaultValues[field.name] = value;
5813
- }
5814
- });
5815
- if(defaultData && _.isObject(defaultData) && !_.isArray(defaultData)){
5816
- defaultValues = Object.assign({}, defaultValues, defaultData)
5817
- }
5818
5825
  if(_.isObject(initialValues)){
5819
5826
  // uiSchema.form.initialValues为函数且执行后为json,则优先取initialValues中的默认值
5820
5827
  initialValues = Object.assign({}, defaultValues, initialValues);
@@ -6260,7 +6267,7 @@ async function getObjectForm(objectSchema, ctx){
6260
6267
  "data": {
6261
6268
  "objectName": "${_master.objectName}"
6262
6269
  },
6263
- "expression": "${_master.objectName}"
6270
+ "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
6264
6271
  }
6265
6272
  ]
6266
6273
  }
@@ -6277,7 +6284,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6277
6284
  const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, formInitProps } = ctx;
6278
6285
  const fields = ___default__default["default"].values(objectSchema.fields);
6279
6286
  const formFields = getFormFields(objectSchema, ctx);
6280
- const serviceId = `detail_${recordId}`;
6287
+ const serviceId = `service_detail_page`;
6281
6288
  return {
6282
6289
  type: 'service',
6283
6290
  name: `page_readonly_${recordId}`,
@@ -6607,7 +6614,7 @@ function getButtonVisibleOn(button){
6607
6614
  // return 'false';
6608
6615
  // }
6609
6616
  if(visible.trim().startsWith('function')){
6610
- return `${visible}(objectName, _id, recordPermissions, data)`
6617
+ return `${visible}(objectName, _id, record.recordPermissions, data)`
6611
6618
  }
6612
6619
  return visible;
6613
6620
  }
@@ -13264,11 +13271,11 @@ var PageListView = function (props) { return __awaiter(void 0, void 0, void 0, f
13264
13271
  }); };
13265
13272
 
13266
13273
  var PageRecordDetail = function (props) { return __awaiter(void 0, void 0, void 0, function () {
13267
- var defaultFormFactor, appId, objectApiName, recordId, display, sideObject, sideListviewId, $schema, displayAs, formFactor, listPage, recordSchema, recordPage, listSchema, defData;
13274
+ var defaultFormFactor, appId, objectApiName, recordId, display, sideObject, sideListviewId, $schema, data, displayAs, formFactor, listPage, recordSchema, recordPage, listSchema, defData;
13268
13275
  return __generator(this, function (_a) {
13269
13276
  switch (_a.label) {
13270
13277
  case 0:
13271
- defaultFormFactor = props.formFactor, appId = props.appId, objectApiName = props.objectApiName, recordId = props.recordId, display = props.display, sideObject = props.sideObject, sideListviewId = props.sideListviewId, $schema = props.$schema;
13278
+ defaultFormFactor = props.formFactor, appId = props.appId, objectApiName = props.objectApiName, recordId = props.recordId, display = props.display, sideObject = props.sideObject, sideListviewId = props.sideListviewId, $schema = props.$schema, data = props.data;
13272
13279
  if (display)
13273
13280
  Router$1.setTabDisplayAs(objectApiName, display);
13274
13281
  displayAs = (defaultFormFactor === 'SMALL') ? 'grid' : display ? display : sideObject ? 'split' : Router$1.getTabDisplayAs(objectApiName);
@@ -13305,7 +13312,7 @@ var PageRecordDetail = function (props) { return __awaiter(void 0, void 0, void
13305
13312
  "showDisplayAs": true,
13306
13313
  "formFactor": 'SMALL',
13307
13314
  };
13308
- defData = __assign$2(__assign$2({}, $schema.data), { objectName: objectApiName, listViewId: sideListviewId, listName: sideListviewId, recordId: recordId, appId: appId, formFactor: formFactor, displayAs: displayAs });
13315
+ defData = __assign$2(__assign$2({}, $schema.data), { objectName: objectApiName, listViewId: sideListviewId, listName: sideListviewId, recordId: data.recordId || recordId, appId: appId, formFactor: formFactor, displayAs: displayAs });
13309
13316
  return [2 /*return*/, {
13310
13317
  type: 'service',
13311
13318
  data: defData,