@steedos-widgets/amis-lib 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.
package/dist/index.esm.js CHANGED
@@ -1546,8 +1546,8 @@ const getSchema$3 = async (uiSchema, ctx) => {
1546
1546
  /*
1547
1547
  * @Author: 殷亮辉 yinlianghui@hotoa.com
1548
1548
  * @Date: 2023-03-22 09:31:21
1549
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1550
- * @LastEditTime: 2023-03-27 16:03:34
1549
+ * @LastEditors: Please set LastEditors
1550
+ * @LastEditTime: 2023-03-28 14:06:47
1551
1551
  */
1552
1552
  const getSchema$2 = (uiSchema)=>{
1553
1553
  return {
@@ -1608,7 +1608,7 @@ const getSchema$2 = (uiSchema)=>{
1608
1608
  "data": {
1609
1609
  "objectName": "${_master.objectName}"
1610
1610
  },
1611
- "expression": "${_master.objectName}"
1611
+ "expression": `\${_master.objectName != '${uiSchema.name}' && _master.objectName}`
1612
1612
  }
1613
1613
  ]
1614
1614
  }
@@ -2032,7 +2032,7 @@ function getButtonVisibleOn$1(button){
2032
2032
  if(visible.trim().startsWith('function')){
2033
2033
  return `${visible}.apply({
2034
2034
  object: uiSchema
2035
- }, [objectName, _id, recordPermissions, data])`
2035
+ }, [objectName, _id, record.recordPermissions, data])`
2036
2036
  }
2037
2037
  return visible;
2038
2038
  }
@@ -3953,6 +3953,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
3953
3953
  }
3954
3954
  }
3955
3955
 
3956
+ const enable_tree = ${refObjectConfig.enable_tree};
3957
+ if(enable_tree){
3958
+ pageSize = 10000;
3959
+ }
3956
3960
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());
3957
3961
  return api;
3958
3962
  `;
@@ -4026,7 +4030,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
4026
4030
  new_button.align = "right";
4027
4031
  pickerSchema.headerToolbar.push(new_button);
4028
4032
  }
4029
- pickerSchema.footerToolbar = getObjectFooterToolbar();
4033
+ pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
4030
4034
  if(ctx.filterVisible !== false){
4031
4035
  let filterLoopCount = ctx.filterLoopCount || 0;
4032
4036
  filterLoopCount++;
@@ -4120,7 +4124,10 @@ async function lookupToAmisSelect(field, readonly, ctx){
4120
4124
  apiInfo = {
4121
4125
  method: "post",
4122
4126
  url: getApi$2(),
4123
- data: {query: '{objects(filters: ["_id", "=", "-1"]){_id}}', $: "$$"}
4127
+ data: {query: '{objects(filters: ["_id", "=", "-1"]){_id}}', $: "$$"},
4128
+ "headers": {
4129
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4130
+ }
4124
4131
  };
4125
4132
  }
4126
4133
 
@@ -5402,6 +5409,17 @@ async function getEditFormInitApi(object, recordId, fields){
5402
5409
  }
5403
5410
  else{
5404
5411
  var uiSchema = api.body.uiSchema;
5412
+ var defaultData = api.body.defaultData;
5413
+ var defaultValues = {};
5414
+ _.each(uiSchema?.fields, function(field){
5415
+ var value = SteedosUI.getFieldDefaultValue(field, api.body.global);
5416
+ if(value){
5417
+ defaultValues[field.name] = value;
5418
+ }
5419
+ });
5420
+ if(defaultData && _.isObject(defaultData) && !_.isArray(defaultData)){
5421
+ defaultValues = Object.assign({}, defaultValues, defaultData)
5422
+ }
5405
5423
  if(uiSchema.form){
5406
5424
  try{
5407
5425
  var objectFormConfig = JSON.parse(uiSchema.form);
@@ -5410,24 +5428,13 @@ async function getEditFormInitApi(object, recordId, fields){
5410
5428
  initialValues = new Function("return " + initialValues)();
5411
5429
  }
5412
5430
  if(typeof initialValues === "function"){
5413
- initialValues = initialValues();
5431
+ initialValues = initialValues.apply({doc: defaultValues || {} })
5414
5432
  }
5415
5433
  }
5416
5434
  catch(ex){
5417
5435
  console.warn(ex);
5418
5436
  }
5419
5437
  }
5420
- var defaultData = api.body.defaultData;
5421
- var defaultValues = {};
5422
- _.each(uiSchema?.fields, function(field){
5423
- var value = SteedosUI.getFieldDefaultValue(field, api.body.global);
5424
- if(value){
5425
- defaultValues[field.name] = value;
5426
- }
5427
- });
5428
- if(defaultData && _.isObject(defaultData) && !_.isArray(defaultData)){
5429
- defaultValues = Object.assign({}, defaultValues, defaultData)
5430
- }
5431
5438
  if(_.isObject(initialValues)){
5432
5439
  // uiSchema.form.initialValues为函数且执行后为json,则优先取initialValues中的默认值
5433
5440
  initialValues = Object.assign({}, defaultValues, initialValues);
@@ -5873,7 +5880,7 @@ async function getObjectForm(objectSchema, ctx){
5873
5880
  "data": {
5874
5881
  "objectName": "${_master.objectName}"
5875
5882
  },
5876
- "expression": "${_master.objectName}"
5883
+ "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
5877
5884
  }
5878
5885
  ]
5879
5886
  }
@@ -5890,7 +5897,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
5890
5897
  const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, formInitProps } = ctx;
5891
5898
  const fields = ___default.values(objectSchema.fields);
5892
5899
  const formFields = getFormFields(objectSchema, ctx);
5893
- const serviceId = `detail_${recordId}`;
5900
+ const serviceId = `service_detail_page`;
5894
5901
  return {
5895
5902
  type: 'service',
5896
5903
  name: `page_readonly_${recordId}`,
@@ -6220,7 +6227,7 @@ function getButtonVisibleOn(button){
6220
6227
  // return 'false';
6221
6228
  // }
6222
6229
  if(visible.trim().startsWith('function')){
6223
- return `${visible}(objectName, _id, recordPermissions, data)`
6230
+ return `${visible}(objectName, _id, record.recordPermissions, data)`
6224
6231
  }
6225
6232
  return visible;
6226
6233
  }