@steedos-widgets/amis-lib 1.1.3 → 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
@@ -806,7 +806,7 @@ function getSaveDataTpl(fields){
806
806
  ${getScriptForSimplifiedValueForFileFields(fields)}
807
807
  let query = \`mutation{record: \${objectName}__insert(doc: {__saveData}){_id}}\`;
808
808
  if(formData.recordId && formData.recordId !='new'){
809
- query = \`mutation{record: \${objectName}__update(id: "\${formData._id}", doc: {__saveData}){_id}}\`;
809
+ query = \`mutation{record: \${objectName}__update(id: "\${formData.recordId}", doc: {__saveData}){_id}}\`;
810
810
  };
811
811
  delete formData._id;
812
812
  let __saveData = JSON.stringify(JSON.stringify(formData));
@@ -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
 
@@ -5413,7 +5420,28 @@ async function getEditFormInitApi(object, recordId, fields){
5413
5420
  if(defaultData && _.isObject(defaultData) && !_.isArray(defaultData)){
5414
5421
  defaultValues = Object.assign({}, defaultValues, defaultData)
5415
5422
  }
5416
- initialValues = defaultValues;
5423
+ if(uiSchema.form){
5424
+ try{
5425
+ var objectFormConfig = JSON.parse(uiSchema.form);
5426
+ initialValues = objectFormConfig.initialValues;
5427
+ if(initialValues){
5428
+ initialValues = new Function("return " + initialValues)();
5429
+ }
5430
+ if(typeof initialValues === "function"){
5431
+ initialValues = initialValues.apply({doc: defaultValues || {} })
5432
+ }
5433
+ }
5434
+ catch(ex){
5435
+ console.warn(ex);
5436
+ }
5437
+ }
5438
+ if(_.isObject(initialValues)){
5439
+ // uiSchema.form.initialValues为函数且执行后为json,则优先取initialValues中的默认值
5440
+ initialValues = Object.assign({}, defaultValues, initialValues);
5441
+ }
5442
+ else{
5443
+ initialValues = defaultValues;
5444
+ }
5417
5445
  }
5418
5446
  // data下的变量需要在保存接口(getSaveApi)中被删除。
5419
5447
  payload.data = {
@@ -5852,7 +5880,7 @@ async function getObjectForm(objectSchema, ctx){
5852
5880
  "data": {
5853
5881
  "objectName": "${_master.objectName}"
5854
5882
  },
5855
- "expression": "${_master.objectName}"
5883
+ "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
5856
5884
  }
5857
5885
  ]
5858
5886
  }
@@ -5869,7 +5897,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
5869
5897
  const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, formInitProps } = ctx;
5870
5898
  const fields = ___default.values(objectSchema.fields);
5871
5899
  const formFields = getFormFields(objectSchema, ctx);
5872
- const serviceId = `detail_${recordId}`;
5900
+ const serviceId = `service_detail_page`;
5873
5901
  return {
5874
5902
  type: 'service',
5875
5903
  name: `page_readonly_${recordId}`,
@@ -6199,7 +6227,7 @@ function getButtonVisibleOn(button){
6199
6227
  // return 'false';
6200
6228
  // }
6201
6229
  if(visible.trim().startsWith('function')){
6202
- return `${visible}(objectName, _id, recordPermissions, data)`
6230
+ return `${visible}(objectName, _id, record.recordPermissions, data)`
6203
6231
  }
6204
6232
  return visible;
6205
6233
  }