mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
parent
ee269917f8
commit
a66da8de9e
@ -54,6 +54,7 @@ import { Coin } from '@element-plus/icons-vue';
|
||||
import { getConfig, TMagicAutocomplete, TMagicTag } from '@tmagic/design';
|
||||
import type { FieldProps, FormItem } from '@tmagic/form';
|
||||
import type { DataSchema, DataSourceSchema } from '@tmagic/schema';
|
||||
import { isNumber } from '@tmagic/utils';
|
||||
|
||||
import Icon from '@editor/components/Icon.vue';
|
||||
import type { Services } from '@editor/type';
|
||||
@ -209,7 +210,7 @@ const fieldQuerySearch = (
|
||||
const dsKey = queryString.substring(leftAngleIndex + 1, dotIndex);
|
||||
|
||||
// 可能是xx.xx.xx,存在链式调用
|
||||
const keys = dsKey.split('.');
|
||||
const keys = dsKey.replaceAll(/\[(\d+)\]/g, '.$1').split('.');
|
||||
|
||||
// 最前的是数据源id
|
||||
const dsId = keys.shift();
|
||||
@ -224,6 +225,11 @@ const fieldQuerySearch = (
|
||||
// 后面这些是字段
|
||||
let key = keys.shift();
|
||||
while (key) {
|
||||
if (isNumber(key)) {
|
||||
key = keys.shift();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const field of fields) {
|
||||
if (field.name === key) {
|
||||
fields = field.fields || [];
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { CascaderOption, FormConfig, FormState } from '@tmagic/form';
|
||||
import { DataSchema, DataSourceFieldType, DataSourceSchema } from '@tmagic/schema';
|
||||
import { isNumber } from '@tmagic/utils';
|
||||
|
||||
import BaseFormConfig from './formConfigs/base';
|
||||
import HttpFormConfig from './formConfigs/http';
|
||||
@ -165,20 +166,26 @@ export const getDisplayField = (dataSources: DataSourceSchema[], key: string) =>
|
||||
let dsText = '';
|
||||
let ds: DataSourceSchema | undefined;
|
||||
let fields: DataSchema[] | undefined;
|
||||
|
||||
// 将模块解析成数据源对应的值
|
||||
match[1].split('.').forEach((item, index) => {
|
||||
if (index === 0) {
|
||||
ds = dataSources.find((ds) => ds.id === item);
|
||||
dsText += ds?.title || item;
|
||||
fields = ds?.fields;
|
||||
return;
|
||||
}
|
||||
match[1]
|
||||
.replaceAll(/\[(\d+)\]/g, '.$1')
|
||||
.split('.')
|
||||
.forEach((item, index) => {
|
||||
if (index === 0) {
|
||||
ds = dataSources.find((ds) => ds.id === item);
|
||||
dsText += ds?.title || item;
|
||||
fields = ds?.fields;
|
||||
return;
|
||||
}
|
||||
|
||||
const field = fields?.find((field) => field.name === item);
|
||||
fields = field?.fields;
|
||||
dsText += `.${field?.title || item}`;
|
||||
});
|
||||
if (isNumber(item)) {
|
||||
dsText += `[${item}]`;
|
||||
} else {
|
||||
const field = fields?.find((field) => field.name === item);
|
||||
fields = field?.fields;
|
||||
dsText += `.${field?.title || item}`;
|
||||
}
|
||||
});
|
||||
|
||||
displayState.push({
|
||||
type: 'var',
|
||||
|
Loading…
x
Reference in New Issue
Block a user