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