input-table公式编辑器增加索引数据 (#11260)
Some checks are pending
CodeQL / Analyze (javascript) (push) Waiting to run
gh-pages / build (20.x) (push) Waiting to run

Co-authored-by: zhangzhijun03 <zhangzhijun03@baidu.com>
This commit is contained in:
z418577198 2024-11-26 20:00:06 +08:00 committed by GitHub
parent b2a3f9a691
commit 212acc3564
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,6 +17,9 @@ import {
RAW_TYPE_MAP
} from 'amis-editor-core';
import {someTree} from 'amis-core';
import type {SchemaType} from 'amis';
import {isObject} from 'amis';
import set from 'lodash/set';
import {DSBuilderManager} from '../../builder/DSBuilderManager';
import {ValidatorTag} from '../../validator';
import {
@ -29,7 +32,6 @@ import {
resolveArrayDatasource,
resolveInputTableEventDataSchame
} from '../../util';
import type {SchemaType} from 'amis';
export class TableControlPlugin extends BasePlugin {
static id = 'TableControlPlugin';
@ -1456,7 +1458,7 @@ export class TableControlPlugin extends BasePlugin {
trigger?: EditorNodeType,
parent?: EditorNodeType
) {
const itemsSchema: any = {
let itemsSchema: any = {
$id: `${node.id}-${node.type}-tableRows`,
type: 'object',
properties: {}
@ -1515,6 +1517,23 @@ export class TableControlPlugin extends BasePlugin {
}
}
}
let match =
node.schema.source && String(node.schema.source).match(/{([\w-_]+)}/);
let field = node.schema.name || match?.[1];
const origin = this.manager.dataSchema.current;
const schema = this.manager.dataSchema.getSchemaByPath(field);
this.manager.dataSchema.switchTo(origin);
if (isObject(schema?.items)) {
itemsSchema = {
...itemsSchema,
...(schema!.items as any)
};
set(itemsSchema, 'properties.index', {
type: 'number',
title: '索引'
});
}
if (region?.region === 'columns') {
return itemsSchema;