@steedos-widgets/amis-lib 1.1.3-beta.9 → 1.1.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.umd.js CHANGED
@@ -832,7 +832,7 @@
832
832
  ${getScriptForSimplifiedValueForFileFields(fields)}
833
833
  let query = \`mutation{record: \${objectName}__insert(doc: {__saveData}){_id}}\`;
834
834
  if(formData.recordId && formData.recordId !='new'){
835
- query = \`mutation{record: \${objectName}__update(id: "\${formData._id}", doc: {__saveData}){_id}}\`;
835
+ query = \`mutation{record: \${objectName}__update(id: "\${formData.recordId}", doc: {__saveData}){_id}}\`;
836
836
  };
837
837
  delete formData._id;
838
838
  let __saveData = JSON.stringify(JSON.stringify(formData));
@@ -5428,6 +5428,21 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
5428
5428
  }
5429
5429
  else{
5430
5430
  var uiSchema = api.body.uiSchema;
5431
+ if(uiSchema.form){
5432
+ try{
5433
+ var objectFormConfig = JSON.parse(uiSchema.form);
5434
+ initialValues = objectFormConfig.initialValues;
5435
+ if(initialValues){
5436
+ initialValues = new Function("return " + initialValues)();
5437
+ }
5438
+ if(typeof initialValues === "function"){
5439
+ initialValues = initialValues();
5440
+ }
5441
+ }
5442
+ catch(ex){
5443
+ console.warn(ex);
5444
+ }
5445
+ }
5431
5446
  var defaultData = api.body.defaultData;
5432
5447
  var defaultValues = {};
5433
5448
  _.each(uiSchema?.fields, function(field){
@@ -5439,7 +5454,13 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
5439
5454
  if(defaultData && _.isObject(defaultData) && !_.isArray(defaultData)){
5440
5455
  defaultValues = Object.assign({}, defaultValues, defaultData)
5441
5456
  }
5442
- initialValues = defaultValues;
5457
+ if(_.isObject(initialValues)){
5458
+ // uiSchema.form.initialValues为函数且执行后为json,则优先取initialValues中的默认值
5459
+ initialValues = Object.assign({}, defaultValues, initialValues);
5460
+ }
5461
+ else{
5462
+ initialValues = defaultValues;
5463
+ }
5443
5464
  }
5444
5465
  // data下的变量需要在保存接口(getSaveApi)中被删除。
5445
5466
  payload.data = {