fix: CRUD 新增配置问题

Change-Id: I40bd523767025f0e5910ca26c685e80f77dcf2ef
This commit is contained in:
allenve 2022-07-27 17:06:12 +08:00
parent df49046f73
commit 2f2f57eed9

View File

@ -392,7 +392,10 @@ export class CRUDPlugin extends BasePlugin {
valueSchema.bulkActions = []; valueSchema.bulkActions = [];
/** 统一api格式 */ /** 统一api格式 */
valueSchema.api = typeof valueSchema.api === 'string' ? valueSchema.api : normalizeApi(valueSchema.api); valueSchema.api =
typeof valueSchema.api === 'string'
? valueSchema.api
: normalizeApi(valueSchema.api);
hasFeatures && hasFeatures &&
features.forEach((item: string) => { features.forEach((item: string) => {
if (itemBtns.includes(item)) { if (itemBtns.includes(item)) {
@ -418,7 +421,7 @@ export class CRUDPlugin extends BasePlugin {
); );
} else if (item === 'delete') { } else if (item === 'delete') {
schema = cloneDeep(this.btnSchemas.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
: {...valueSchema.api, method: 'post'}; : {...valueSchema.api, method: 'post'};
} }
@ -446,7 +449,7 @@ export class CRUDPlugin extends BasePlugin {
const createSchemaBase = this.btnSchemas.create; const createSchemaBase = this.btnSchemas.create;
createSchemaBase.dialog.body = { createSchemaBase.dialog.body = {
type: 'form', type: 'form',
api: valueSchema.api?.method.match(/^(post|put)$/i) api: valueSchema.api?.method?.match(/^(post|put)$/i)
? valueSchema.api ? valueSchema.api
: {...valueSchema.api, method: 'post'}, : {...valueSchema.api, method: 'post'},
body: valueSchema.columns.map((column: ColumnItem) => { body: valueSchema.columns.map((column: ColumnItem) => {