mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 10:38:16 +08:00
input-table公式编辑器增加索引数据 (#11260)
Co-authored-by: zhangzhijun03 <zhangzhijun03@baidu.com>
This commit is contained in:
parent
b2a3f9a691
commit
212acc3564
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user