mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-21 14:30:00 +08:00
parent
babaadb0cf
commit
07a02714df
@ -89,11 +89,13 @@ const dataSources = computed(() => dataSourceService?.get('dataSources') || []);
|
|||||||
const setDisplayState = () => {
|
const setDisplayState = () => {
|
||||||
displayState.value = [];
|
displayState.value = [];
|
||||||
|
|
||||||
|
// 匹配es6字符串模块
|
||||||
const matches = state.value.matchAll(/\$\{([\s\S]+?)\}/g);
|
const matches = state.value.matchAll(/\$\{([\s\S]+?)\}/g);
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
if (typeof match.index === 'undefined') break;
|
if (typeof match.index === 'undefined') break;
|
||||||
|
|
||||||
|
// 字符串常量
|
||||||
displayState.value.push({
|
displayState.value.push({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
value: state.value.substring(index, match.index),
|
value: state.value.substring(index, match.index),
|
||||||
@ -103,6 +105,7 @@ const setDisplayState = () => {
|
|||||||
let ds: DataSourceSchema | undefined;
|
let ds: DataSourceSchema | undefined;
|
||||||
let fields: DataSchema[] | undefined;
|
let fields: DataSchema[] | undefined;
|
||||||
|
|
||||||
|
// 将模块解析成数据源对应的值
|
||||||
match[1].split('.').forEach((item, index) => {
|
match[1].split('.').forEach((item, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
ds = dataSources.value.find((ds) => ds.id === item);
|
ds = dataSources.value.find((ds) => ds.id === item);
|
||||||
@ -243,17 +246,21 @@ const fieldQuerySearch = (
|
|||||||
let result: DataSchema[] = [];
|
let result: DataSchema[] = [];
|
||||||
|
|
||||||
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.split('.');
|
||||||
|
|
||||||
// 最前的是数据源id
|
// 最前的是数据源id
|
||||||
const ds = dataSources.value.find((ds) => ds.id === keys.shift());
|
const dsId = keys.shift();
|
||||||
|
const ds = dataSources.value.find((ds) => ds.id === dsId);
|
||||||
if (!ds) {
|
if (!ds) {
|
||||||
|
cb([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let fields = ds.fields || [];
|
let fields = ds.fields || [];
|
||||||
|
|
||||||
// 后面这些事字段
|
// 后面这些是字段
|
||||||
let key = keys.shift();
|
let key = keys.shift();
|
||||||
while (key) {
|
while (key) {
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user