From 2f2f57eed9e0bea8512cfcd521f72ebc8c2e3f91 Mon Sep 17 00:00:00 2001 From: allenve Date: Wed, 27 Jul 2022 17:06:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CRUD=20=E6=96=B0=E5=A2=9E=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I40bd523767025f0e5910ca26c685e80f77dcf2ef --- packages/amis-editor/src/plugin/CRUD.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/amis-editor/src/plugin/CRUD.tsx b/packages/amis-editor/src/plugin/CRUD.tsx index bfcb0722c..c858fba53 100644 --- a/packages/amis-editor/src/plugin/CRUD.tsx +++ b/packages/amis-editor/src/plugin/CRUD.tsx @@ -392,7 +392,10 @@ export class CRUDPlugin extends BasePlugin { valueSchema.bulkActions = []; /** 统一api格式 */ - valueSchema.api = typeof valueSchema.api === 'string' ? valueSchema.api : normalizeApi(valueSchema.api); + valueSchema.api = + typeof valueSchema.api === 'string' + ? valueSchema.api + : normalizeApi(valueSchema.api); hasFeatures && features.forEach((item: string) => { if (itemBtns.includes(item)) { @@ -418,7 +421,7 @@ export class CRUDPlugin extends BasePlugin { ); } else if (item === 'delete') { schema = cloneDeep(this.btnSchemas.delete); - schema.api = valueSchema.api?.method.match(/^(post|delete)$/i) + schema.api = valueSchema.api?.method?.match(/^(post|delete)$/i) ? valueSchema.api : {...valueSchema.api, method: 'post'}; } @@ -446,7 +449,7 @@ export class CRUDPlugin extends BasePlugin { const createSchemaBase = this.btnSchemas.create; createSchemaBase.dialog.body = { type: 'form', - api: valueSchema.api?.method.match(/^(post|put)$/i) + api: valueSchema.api?.method?.match(/^(post|put)$/i) ? valueSchema.api : {...valueSchema.api, method: 'post'}, body: valueSchema.columns.map((column: ColumnItem) => {