diff --git a/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java b/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java index ed54708c2a..d220458569 100644 --- a/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java +++ b/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java @@ -42,7 +42,7 @@ import static org.apache.calcite.sql.SqlKind.*; public class SqlparserUtils { public static final String regex = "\\$\\{(.*?)\\}"; - public static final String regex2 = "\\[(.*?)\\]"; + public static final String regex2 = "\\$f2cde\\[(.*?)\\]"; private static final String SubstitutedParams = "DATAEASE_PATAMS_BI"; private static final String SysParamsSubstitutedParams = "DeSysParams_"; private static final String SubstitutedSql = " 'DE-BI' = 'DE-BI' "; @@ -177,7 +177,7 @@ public class SqlparserUtils { pattern = Pattern.compile(regex2); matcher = pattern.matcher(tmpSql); while (matcher.find()) { - String paramId = matcher.group().substring(1, matcher.group().length() - 1); + String paramId = matcher.group().substring(7, matcher.group().length() - 1); if(!isParams(paramId)){ continue; } @@ -188,15 +188,15 @@ public class SqlparserUtils { pattern = Pattern.compile(regex2); matcher = pattern.matcher(tmpSql); while (matcher.find()) { - String paramId = matcher.group().substring(1, matcher.group().length() - 1); + String paramId = matcher.group().substring(7, matcher.group().length() - 1); if(!isParams(paramId)){ continue; } hasVariables = true; - tmpSql = tmpSql.replace(matcher.group(), SysParamsSubstitutedParams + matcher.group().substring(1, matcher.group().length() - 1)); + tmpSql = tmpSql.replace(matcher.group(), SysParamsSubstitutedParams + matcher.group().substring(7, matcher.group().length() - 1)); Map sysParam = new HashMap<>(); sysParam.put("origin", matcher.group()); - sysParam.put("replace", SysParamsSubstitutedParams + matcher.group().substring(1, matcher.group().length() - 1)); + sysParam.put("replace", SysParamsSubstitutedParams + matcher.group().substring(7, matcher.group().length() - 1)); sysParams.add(sysParam); } } diff --git a/core/core-frontend/src/views/visualized/data/dataset/form/AddSql.vue b/core/core-frontend/src/views/visualized/data/dataset/form/AddSql.vue index edd956a279..4c1e33c2ac 100644 --- a/core/core-frontend/src/views/visualized/data/dataset/form/AddSql.vue +++ b/core/core-frontend/src/views/visualized/data/dataset/form/AddSql.vue @@ -209,18 +209,18 @@ const setNameIdTrans = (from, to, originName, name2Auto?: string[]) => { pre[next[from]] = next[to] return pre }, {}) - const on = originName.match(/\[(.+?)\]/g) + const on = originName.match(/\$f2cde\[(.+?)\]/g) if (on) { on.forEach(itm => { - const ele = itm.slice(1, -1) + const ele = itm.slice(7, -1) if (name2Auto) { name2Auto.push(nameIdMap[ele]) } if (from === 'id' && ids.includes(ele)) { - name2Id = name2Id.replace(`[${ele}]`, `[${nameIdMap[ele]}]`) + name2Id = name2Id.replace(`$f2cde[${ele}]`, `$f2cde[${nameIdMap[ele]}]`) } if (from === 'name' && names.includes(ele)) { - name2Id = name2Id.replace(`[${ele}]`, `[${nameIdMap[ele]}]`) + name2Id = name2Id.replace(`$f2cde[${ele}]`, `$f2cde[${nameIdMap[ele]}]`) } }) } @@ -785,6 +785,7 @@ const mousedownDrag = () => { @change="changeFlagCode = true" :height="`${dragHeight}px`" dom-id="sql-editor" + :regexp="/\$f2cde\[(.*?)\]/g" ref="myCm" :quotaMap="fieldFormList.filter(ele => ['num'].includes(ele.type)).map(ele => ele.name)" :dimensionMap=" @@ -912,7 +913,7 @@ const mousedownDrag = () => {
@@ -925,7 +926,7 @@ const mousedownDrag = () => { class="variable-item flex-align-center" v-for="fieldForm in fieldFormListComputed" :key="fieldForm.id" - @click="insertFieldToCodeMirror(`[${fieldForm.name}]`)" + @click="insertFieldToCodeMirror(`$f2cde[${fieldForm.name}]`)" :class="['num'].includes(fieldForm.type) && 'with-type'" > diff --git a/core/core-frontend/src/views/visualized/data/dataset/form/CodeMirror.vue b/core/core-frontend/src/views/visualized/data/dataset/form/CodeMirror.vue index 7f7d239c55..662a98c815 100644 --- a/core/core-frontend/src/views/visualized/data/dataset/form/CodeMirror.vue +++ b/core/core-frontend/src/views/visualized/data/dataset/form/CodeMirror.vue @@ -16,9 +16,12 @@ const props = defineProps({ domId: propTypes.string.def('editor'), height: propTypes.string.def('250px'), quotaMap: propTypes.arrayOf(String).def(() => []), - dimensionMap: propTypes.arrayOf(String).def(() => []) + dimensionMap: propTypes.arrayOf(String).def(() => []), + regexp: { + type: RegExp, + default: /\[(.*?)\]/g + } }) - const emits = defineEmits(['change']) const codeComInit = (doc: string, sqlMode?: boolean) => { @@ -45,7 +48,7 @@ const codeComInit = (doc: string, sqlMode?: boolean) => { } //!placeholderMatcher const placeholderMatcher = new MatchDecorator({ - regexp: /\[(.*?)\]/g, + regexp: new RegExp(props.regexp), decoration: match => Decoration.replace({ widget: new PlaceholderWidget(match[1])