fix: 修复使用 sql 变量时,不支持原生函数的问题

This commit is contained in:
taojinlong
2025-05-20 18:02:27 +08:00
committed by taojinlong
parent f924a19b97
commit 378cf3331d
7 changed files with 405 additions and 165 deletions

View File

@@ -0,0 +1,284 @@
package io.dataease.commons.utils;
import com.fasterxml.jackson.core.type.TypeReference;
import io.dataease.api.permissions.user.vo.UserFormVO;
import io.dataease.api.permissions.variable.dto.SysVariableValueDto;
import io.dataease.api.permissions.variable.dto.SysVariableValueItem;
import io.dataease.exception.DEException;
import io.dataease.extensions.datasource.api.PluginManageApi;
import io.dataease.extensions.datasource.dto.DatasourceSchemaDTO;
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
import io.dataease.extensions.datasource.vo.XpackPluginsDatasourceVO;
import io.dataease.extensions.view.dto.SqlVariableDetails;
import io.dataease.i18n.Translator;
import io.dataease.license.utils.LicenseUtil;
import io.dataease.utils.JsonUtil;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.operators.relational.InExpression;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static io.dataease.chart.manage.ChartDataManage.START_END_SEPARATOR;
public class DeSqlparserUtils {
private static final String deVariablePattern = "\\$DE_PARAM\\{(.*?)\\}";
public static final String sqlParamsRegex = "\\$\\[(.*?)\\]";
public static final String sysVariableRegex = "\\$f2cde\\[(.*?)\\]";
private static final String SysParamsSubstitutedParams = "DeSysParams_";
private UserFormVO userEntity;
private static final String SubstitutedSql = " 'DE-BI' = 'DE-BI' ";
private final List<Map<String, String>> sysParams = new ArrayList<>();
TypeReference<List<SqlVariableDetails>> listTypeReference = new TypeReference<List<SqlVariableDetails>>() {
};
private List<SqlVariableDetails> defaultsSqlVariableDetails = new ArrayList<>();
public String handleVariableDefaultValue(String sql, String sqlVariableDetails, boolean isEdit, boolean isFromDataSet, List<SqlVariableDetails> parameters, boolean isCross, Map<Long, DatasourceSchemaDTO> dsMap, PluginManageApi pluginManage, UserFormVO userEntity) {
DatasourceSchemaDTO ds = dsMap.entrySet().iterator().next().getValue();
if (StringUtils.isEmpty(sql)) {
DEException.throwException(Translator.get("i18n_sql_not_empty"));
}
this.userEntity = userEntity;
sql = sql.trim();
if (sql.endsWith(";")) {
sql = sql.substring(0, sql.length() - 1);
}
if (StringUtils.isNotEmpty(sqlVariableDetails)) {
defaultsSqlVariableDetails = JsonUtil.parseList(sqlVariableDetails, listTypeReference);
}
Pattern pattern = Pattern.compile(deVariablePattern);
Matcher matcher = pattern.matcher(sql);
while (matcher.find()) {
String sqlItemWithParam = matcher.group();
String sqlItem = sqlItemWithParam.substring(10, sqlItemWithParam.length() - 1);
boolean replaceParam = false;
Pattern p = Pattern.compile(sqlParamsRegex);
Matcher m = p.matcher(sqlItemWithParam);
if (m.find()) { // 替换sql参数
String sqlVariable = m.group();
SqlVariableDetails defaultsSqlVariableDetail = null;
for (SqlVariableDetails sqlVariableDetail : defaultsSqlVariableDetails) {
if (sqlVariable.substring(2, sqlVariable.length() - 1).equalsIgnoreCase(sqlVariableDetail.getVariableName())) {
defaultsSqlVariableDetail = sqlVariableDetail;
break;
}
}
SqlVariableDetails filterParameter = null;
if (ObjectUtils.isNotEmpty(parameters)) {
for (SqlVariableDetails parameter : parameters) {
if (parameter.getVariableName().equalsIgnoreCase(defaultsSqlVariableDetail.getVariableName())) {
filterParameter = parameter;
}
}
}
if (filterParameter != null) {
sqlItem = sqlItem.replace(sqlVariable, transFilter(filterParameter, dsMap));
replaceParam = true;
} else {
if (defaultsSqlVariableDetail != null && StringUtils.isNotEmpty(defaultsSqlVariableDetail.getDefaultValue())) {
if (!isEdit && isFromDataSet && defaultsSqlVariableDetail.getDefaultValueScope().equals(SqlVariableDetails.DefaultValueScope.ALLSCOPE)) {
sqlItem = sqlItem.replace(sqlVariable, defaultsSqlVariableDetail.getDefaultValue());
replaceParam = true;
}
if (isEdit) {
sqlItem = sqlItem.replace(sqlVariable, defaultsSqlVariableDetail.getDefaultValue());
replaceParam = true;
}
}
}
} else { //替换系统变量
p = Pattern.compile(sysVariableRegex);
m = p.matcher(sqlItemWithParam);
if (m.find()) {
String sysVariableId = m.group().substring(7, m.group().length() - 1);
if (!isParams(sysVariableId)) {
continue;
}
sqlItem = sqlItem.replace(m.group(), SysParamsSubstitutedParams + sysVariableId);
try {
Expression expression = CCJSqlParserUtil.parseCondExpression(sqlItem);
String value = null;
if (expression instanceof InExpression) {
value = handleSubstitutedSqlForIn(sysVariableId);
} else {
value = handleSubstitutedSql(sysVariableId);
}
if (value != null) {
sqlItem = sqlItem.replace(SysParamsSubstitutedParams + sysVariableId, value);
replaceParam = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (!replaceParam) {
sql = sql.replace(sqlItemWithParam, SubstitutedSql);
} else {
sql = sql.replace(sqlItemWithParam, sqlItem);
}
}
try {
if (!isCross) {
Map.Entry<Long, DatasourceSchemaDTO> next = dsMap.entrySet().iterator().next();
DatasourceSchemaDTO value = next.getValue();
String prefix = "";
String suffix = "";
if (Arrays.stream(DatasourceConfiguration.DatasourceType.values()).map(DatasourceConfiguration.DatasourceType::getType).toList().contains(value.getType())) {
DatasourceConfiguration.DatasourceType datasourceType = DatasourceConfiguration.DatasourceType.valueOf(value.getType());
prefix = datasourceType.getPrefix();
suffix = datasourceType.getSuffix();
} else {
if (LicenseUtil.licenseValid()) {
List<XpackPluginsDatasourceVO> xpackPluginsDatasourceVOS = pluginManage.queryPluginDs();
List<XpackPluginsDatasourceVO> list = xpackPluginsDatasourceVOS.stream().filter(ele -> StringUtils.equals(ele.getType(), value.getType())).toList();
if (ObjectUtils.isNotEmpty(list)) {
XpackPluginsDatasourceVO first = list.getFirst();
prefix = first.getPrefix();
suffix = first.getSuffix();
} else {
DEException.throwException("当前数据源插件不存在");
}
}
}
Pattern patternCross = Pattern.compile("(`.*?`)");
Matcher matcherCross = patternCross.matcher(sql);
while (matcherCross.find()) {
String group = matcherCross.group();
String info = group.substring(1, group.length() - 1);
sql = sql.replaceAll(group, prefix + info + suffix);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return sql;
}
private static boolean isParams(String paramId) {
if (Arrays.asList("sysParams.userId", "sysParams.userEmail", "sysParams.userName").contains(paramId)) {
return true;
}
boolean isLong = false;
try {
Long.valueOf(paramId);
isLong = true;
} catch (Exception e) {
isLong = false;
}
if (paramId.length() >= 18 && isLong) {
return true;
}
return false;
}
private String transFilter(SqlVariableDetails sqlVariableDetails, Map<Long, DatasourceSchemaDTO> dsMap) {
if (sqlVariableDetails.getOperator().equals("in")) {
if (StringUtils.equalsIgnoreCase(dsMap.entrySet().iterator().next().getValue().getType(), DatasourceConfiguration.DatasourceType.sqlServer.getType()) && sqlVariableDetails.getDeType() == 0) {
return "N'" + String.join("', N'", sqlVariableDetails.getValue()) + "'";
} else {
if (sqlVariableDetails.getDeType() == 2 || sqlVariableDetails.getDeType() == 3) {
return String.join(",", sqlVariableDetails.getValue());
} else {
return "'" + String.join("','", sqlVariableDetails.getValue()) + "'";
}
}
} else if (sqlVariableDetails.getOperator().equals("between")) {
if (sqlVariableDetails.getDeType() == 1) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(sqlVariableDetails.getType().size() > 1 ? (String) sqlVariableDetails.getType().get(1).replace("DD", "dd").replace("YYYY", "yyyy") : "yyyy");
if (StringUtils.endsWith(sqlVariableDetails.getId(), START_END_SEPARATOR)) {
return simpleDateFormat.format(new Date(Long.parseLong((String) sqlVariableDetails.getValue().get(1))));
} else {
return simpleDateFormat.format(new Date(Long.parseLong((String) sqlVariableDetails.getValue().get(0))));
}
} else {
if (StringUtils.endsWith(sqlVariableDetails.getId(), START_END_SEPARATOR)) {
return sqlVariableDetails.getValue().get(1);
} else {
return sqlVariableDetails.getValue().get(0);
}
}
} else {
return (String) sqlVariableDetails.getValue().get(0);
}
}
private String handleSubstitutedSql(String sysVariableId) {
if (userEntity != null) {
if (sysVariableId.equalsIgnoreCase("sysParams.userId")) {
return userEntity.getAccount();
}
if (sysVariableId.equalsIgnoreCase("sysParams.userEmail")) {
return userEntity.getEmail();
}
if (sysVariableId.equalsIgnoreCase("sysParams.userName")) {
return userEntity.getName();
}
for (SysVariableValueItem variable : userEntity.getVariables()) {
if (!variable.isValid()) {
continue;
}
if (!sysVariableId.equalsIgnoreCase(variable.getVariableId().toString())) {
continue;
}
if (variable.getSysVariableDto().getType().equalsIgnoreCase("text")) {
for (SysVariableValueDto sysVariableValueDto : variable.getValueList()) {
if (variable.getVariableValueIds().contains(sysVariableValueDto.getId().toString())) {
return sysVariableValueDto.getValue();
}
}
} else {
return variable.getVariableValue();
}
}
return null;
} else {
return null;
}
}
private String handleSubstitutedSqlForIn(String sysVariableId) {
if (userEntity != null) {
for (SysVariableValueItem variable : userEntity.getVariables()) {
List<String> values = new ArrayList<>();
if (!variable.isValid()) {
continue;
}
if (!sysVariableId.equalsIgnoreCase(variable.getVariableId().toString())) {
continue;
}
if (variable.getSysVariableDto().getType().equalsIgnoreCase("text")) {
for (SysVariableValueDto sysVariableValueDto : variable.getValueList()) {
if (variable.getVariableValueIds().contains(sysVariableValueDto.getId().toString())) {
values.add(sysVariableValueDto.getValue());
}
}
}
if (CollectionUtils.isNotEmpty(values)) {
return "'" + String.join("','", values) + "'";
}
}
return null;
} else {
return null;
}
}
}

View File

@@ -22,7 +22,6 @@ import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.select.*;
import net.sf.jsqlparser.util.deparser.ExpressionDeParser;
import net.sf.jsqlparser.util.deparser.SelectDeParser;
import org.apache.calcite.sql.*;
import org.apache.calcite.sql.parser.SqlParser;
import org.apache.calcite.sql.util.SqlShuttle;
@@ -30,7 +29,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.junit.jupiter.params.provider.CsvSource;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -50,8 +48,15 @@ public class SqlparserUtils {
boolean hasVariables = false;
private UserFormVO userEntity;
private final List<Map<String, String>> sysParams = new ArrayList<>();
private static final String deVariablePattern = "\\$DE_PARAM\\{(.*?)\\}";
public String handleVariableDefaultValue(String sql, String sqlVariableDetails, boolean isEdit, boolean isFromDataSet, List<SqlVariableDetails> parameters, boolean isCross, Map<Long, DatasourceSchemaDTO> dsMap, PluginManageApi pluginManage, UserFormVO userEntity) {
Pattern r = Pattern.compile(deVariablePattern);
Matcher m = r.matcher(sql);
if (m.find()) {
return new DeSqlparserUtils().handleVariableDefaultValue(sql, sqlVariableDetails, isEdit, isFromDataSet, parameters, isCross, dsMap, pluginManage, userEntity);
}
DatasourceSchemaDTO ds = dsMap.entrySet().iterator().next().getValue();
if (StringUtils.isEmpty(sql)) {
DEException.throwException(Translator.get("i18n_sql_not_empty"));
@@ -160,6 +165,7 @@ public class SqlparserUtils {
}
return false;
}
private String removeVariables(final String sql, String dsType) throws Exception {
String tmpSql = sql.replaceAll("(?m)^\\s*$[\n\r]{0,}", "");
Pattern pattern = Pattern.compile(regex);

View File

@@ -16,7 +16,6 @@ import {
reactive,
ref,
toRefs,
unref,
watch,
computed,
onMounted,
@@ -65,7 +64,8 @@ const { element, view, scale } = toRefs(props)
const { t } = useI18n()
const vQueryRef = ref()
const dvMainStore = dvMainStoreWithOut()
const { curComponent, canvasViewInfo, mobileInPc, firstLoadMap } = storeToRefs(dvMainStore)
const { curComponent, canvasViewInfo, mobileInPc, firstLoadMap, editMode } =
storeToRefs(dvMainStore)
const canEdit = ref(false)
const queryConfig = ref()
const defaultStyle = {
@@ -92,12 +92,14 @@ const defaultStyle = {
queryConditionWidth: 227,
nameboxSpacing: 8,
queryConditionSpacing: 16,
queryConditionHeight: 32,
btnColor: '#3370ff',
labelColorBtn: '#ffffff'
}
const customStyle = reactive({ ...defaultStyle })
const snapshotStore = snapshotStoreWithOut()
const userAgent = navigator.userAgent.toLowerCase()
// 判断是否为飞书内置浏览器
const isFeiShu = /lark/i.test(userAgent)
const btnStyle = computed(() => {
const style = {
@@ -235,7 +237,6 @@ const setCustomStyle = val => {
queryConditionWidth,
nameboxSpacing,
queryConditionSpacing,
queryConditionHeight,
labelColorBtn,
btnColor,
placeholderSize,
@@ -269,7 +270,6 @@ const setCustomStyle = val => {
customStyle.queryConditionWidth = queryConditionWidth ?? 227
customStyle.nameboxSpacing = nameboxSpacing ?? 8
customStyle.queryConditionSpacing = queryConditionSpacing ?? 16
customStyle.queryConditionHeight = queryConditionHeight ?? 32
customStyle.labelColorBtn = labelColorBtn || '#ffffff'
customStyle.labelShow = labelShow ?? true
customStyle.btnColor = btnColor || '#3370ff'
@@ -355,26 +355,22 @@ const getKeyList = next => {
}
const fillRequireVal = arr => {
element.value.propValue?.forEach(next => {
element.value.propValue.forEach(next => {
if (arr.some(itx => next.checkedFields.includes(itx)) && next.required) {
if (next.displayType === '8') {
const { conditionValueF, conditionValueS, conditionType } = next
if (conditionType === 0 && conditionValueF === '') {
next.conditionValueF = next.defaultConditionValueF
} else {
if (conditionValueF === '') {
next.conditionValueF = next.defaultConditionValueF
}
if (conditionValueS === '') {
next.conditionValueS = next.defaultConditionValueS
}
} else if (conditionValueF === '' || conditionValueS === '') {
next.conditionValueF = next.defaultConditionValueF
next.conditionValueS = next.defaultConditionValueS
}
} else if (next.displayType === '22') {
if (next.numValueStart !== 0 && !next.numValueStart) {
if (
(next.numValueStart !== 0 && !next.numValueStart) ||
(next.numValueEnd !== 0 && !next.numValueEnd)
) {
next.numValueStart = next.defaultNumValueStart
}
if (next.numValueEnd !== 0 && !next.numValueEnd) {
next.numValueEnd = next.defaultNumValueEnd
}
} else if (
@@ -479,8 +475,8 @@ const getPlaceholder = computed(() => {
}
})
const isConfirmSearch = (id, disabledFirstItem = false) => {
if (componentWithSure.value && !disabledFirstItem) return
const isConfirmSearch = id => {
if (componentWithSure.value) return
queryDataForId(id)
}
@@ -502,7 +498,7 @@ onBeforeUnmount(() => {
const updateQueryCriteria = () => {
if (dvMainStore.mobileInPc && !isMobile()) return
Array.isArray(element.value.propValue) &&
element.value.propValue?.forEach(ele => {
element.value.propValue.forEach(ele => {
if (ele.auto) {
const componentInfo = {
datasetId: ele.dataset.id,
@@ -594,26 +590,10 @@ const addCriteriaConfigOut = () => {
queryConfig.value.setConditionOut()
}
const reRenderAll = (oldArr, newArr) => {
const newArrIds = newArr.map(ele => ele.id)
const emitterList = (oldArr || []).reduce((pre, next) => {
if (newArrIds.includes(next.id)) return pre
const keyList = getKeyList(next)
pre = [...new Set([...keyList, ...pre])]
return pre
}, [])
if (!emitterList.length) return
emitterList.forEach(ele => {
emitter.emit(`query-data-${ele}`)
})
}
const delQueryConfig = index => {
const com = cloneDeep(unref(list))
list.value.splice(index, 1)
element.value.propValue = [...list.value]
snapshotStore.recordSnapshotCache('delQueryConfig')
reRenderAll(com, cloneDeep(unref(list)))
}
const resetData = () => {
@@ -710,10 +690,6 @@ const boxWidth = computed(() => {
return `${customStyle.placeholderSize}px`
})
const boxHeight = computed(() => {
return `${customStyle.queryConditionHeight || 32}px`
})
const queryData = () => {
let requiredName = ''
let numName = ''
@@ -827,7 +803,7 @@ const marginRight = computed<CSSProperties>(() => {
})
const autoStyle = computed(() => {
if (isISOMobile()) {
if (isISOMobile() || isFeiShu) {
return {
position: 'absolute',
height: 100 / scale.value + '%!important',
@@ -856,7 +832,7 @@ const autoStyle = computed(() => {
<div class="container flex-align-center">
{{ t('v_query.here_or_click') }}
<el-button
:disabled="showPosition === 'preview' || mobileInPc"
:disabled="showPosition === 'preview' || mobileInPc || editMode === 'preview'"
@click="addCriteriaConfigOut"
style="font-family: inherit"
text
@@ -890,7 +866,9 @@ const autoStyle = computed(() => {
</div>
<div
class="label-wrapper-tooltip"
v-if="showPosition !== 'preview' && !dvMainStore.mobileInPc"
v-if="
showPosition !== 'preview' && !dvMainStore.mobileInPc && editMode !== 'preview'
"
>
<el-tooltip
effect="dark"
@@ -954,7 +932,6 @@ const autoStyle = computed(() => {
:query-element="element"
@queryData="queryData"
ref="queryConfig"
@reRenderAll="reRenderAll"
></QueryConditionConfiguration>
</Teleport>
</template>
@@ -972,17 +949,6 @@ const autoStyle = computed(() => {
background-color: v-bind(tagColor);
}
:deep(.ed-input),
:deep(.ed-date-editor) {
--ed-input-height: v-bind(boxHeight);
}
:deep(.ed-select__wrapper),
:deep(.text-search-select .ed-input__wrapper),
:deep(.text-search-select .ed-select__wrapper) {
height: v-bind(boxHeight);
}
.ed-button--primary {
--ed-button-bg-color: v-bind(btnHoverStyle.rawColor);
--ed-button-border-color: v-bind(btnHoverStyle.rawColor);
@@ -1005,8 +971,7 @@ const autoStyle = computed(() => {
--ed-tag-font-size: v-bind(boxWidth);
}
:deep(.ed-select-v2),
:deep(.ed-select__wrapper) {
:deep(.ed-select-v2) {
font-size: v-bind(boxWidth);
}

View File

@@ -1,7 +1,6 @@
export default {
common: {
empty: ' ',
first_item: 'First Item',
cross_source: 'Cross-source',
single_source: 'Single-source',
source_tips:
@@ -975,7 +974,7 @@ export default {
auth_method: 'Authentication Method',
passwd: 'Username and Password',
kerbers_info:
'Please make sure krb5.Conf, Keytab Key, have been added to the path: /opt/dataease3.0/conf',
'Please make sure krb5.Conf, Keytab Key, have been added to the path: /opt/dataease2.0/conf',
client_principal: 'Client Principal',
keytab_Key_path: 'Keytab Key Path',
please_select_left: 'Please select from the left',
@@ -1387,7 +1386,6 @@ export default {
table_title_fontsize: 'Header font size',
table_item_fontsize: 'Table font size',
table_header_bg: 'Header Bg',
table_header_row_bg: 'Header&Row Bg',
table_item_bg: 'Table Bg',
table_header_font_color: 'Header font',
table_item_font_color: 'Table font',
@@ -1491,7 +1489,6 @@ export default {
axis_label_show: 'Label display',
axis_label_color: 'Label color',
axis_label_fontsize: 'Label size',
axis_tick_show: 'Show tick',
text_style: 'Font style',
bolder: 'Bold',
change_ds: 'Change Dataset',
@@ -2094,8 +2091,7 @@ export default {
quota_col_label: 'Quota Column Label',
table_grand_total_label: 'Total Alias',
table_field_total_label: 'Field Alias',
table_row_header_freeze: 'Row Header Freeze',
value_formatter_total_out_percent: 'Show percentage'
table_row_header_freeze: 'Row Header Freeze'
},
dataset: {
field_value: 'Field Value',
@@ -2111,7 +2107,7 @@ export default {
select_year: 'Select year',
sql_variable_limit_1: '1. SQL variables can only be used in WHERE conditions',
sql_variable_limit_2:
"2. select * from table where $DE_PARAM{'{'} name = substring('$[PARAM1]',1,5){'}'} and $DE_PARAM{'{'} name in ($[PARAM2]) {'}'}",
"2. Example: select * from table where $DE_PARAM{ name = '$[PARAM1]' } and $DE_PARAM{ name in ($[PARAM2]) }",
select_month: 'Select month',
select_date: 'Select date',
select_time: 'Select time',
@@ -2908,15 +2904,6 @@ export default {
column_name: 'Field name'
},
visualization: {
select_resource: 'Select {0}',
change_screen_page: 'Change {0}',
new_screen_page: 'New page',
screen_page: 'Page',
color_setting: 'Color{0}',
decoration_name: 'Decoration {0}',
decoration: 'Decoration',
dynamic_background_name: 'Animated {0}',
dynamic_background: 'Animated Image',
support_query: 'Only query components can be added',
publish_update_tips: 'Update available',
filter_freeze_tips:
@@ -2990,7 +2977,6 @@ export default {
'If the query button is displayed, the chart query will be triggered only after clicking the button. If not displayed, the query is triggered immediately after selecting the query conditions.',
custom_query_bg_color: 'Custom Query Background Color',
query_condition_space: 'Query Condition Spacing',
query_condition_height: 'Query condition height',
query_condition_name: 'Query Condition Name',
condition_left: 'Left Side',
condition_top: 'Top Side',
@@ -3136,7 +3122,6 @@ export default {
screen_adaptor_width_first: 'Width First',
screen_adaptor_height_first: 'Height First',
screen_adaptor_full: 'Full Screen',
screen_adaptor_keep_proportion: 'Keep Proportion:',
screen_adaptor_keep: 'No Scaling',
effective_during_preview: 'Effective during preview',
base_config: 'Base Configuration',
@@ -3192,8 +3177,7 @@ export default {
required: 'Required',
default_value: 'Default Value',
default_value_tips1: 'Please use JSON array format Example:',
default_value_tips2:
'Single value ["name1"], multiple values ["name1","name2"]; Bind SQL custom parameters, multiple values not supported;',
default_value_tips2: 'Single value ["name1"], Multiple values ["name1","name2"]',
default_value_tips3: 'Please enter parameters, e.g.: ["name1"]',
time_year_widget: 'Year Filter Widget',
time_month_widget: 'Month Filter Widget',
@@ -3281,6 +3265,7 @@ export default {
space_left: 'Left',
space_width: 'Width',
space_height: 'Height',
to_top: 'Move to Top',
down: 'Download',
mobile_style_setting: 'Style Setting',
mobile_style_setting_tips: 'Customize mobile background',
@@ -3319,7 +3304,7 @@ export default {
apply: 'Apply',
apply_this_template: 'Apply This Template',
market_network_tips:
'To view templates from the template market, your server must be connected to the template market ({0}). Please check your network connection...',
'To view templates from the template market, your server must be connected to the template market (https://templates.dataease.cn). Please check your network connection...',
enter_name_tips: 'Please enter the dashboard name.',
apply_template: 'App Template',
style_template: 'Style Template',
@@ -3860,7 +3845,7 @@ export default {
auth_method: 'Authentication method',
passwd: 'Username and password',
kerbers_info:
'Please make sure krb5.Conf and Keytab Key have been added to the path: /opt/dataease3.0/conf',
'Please make sure krb5.Conf and Keytab Key have been added to the path: /opt/dataease2.0/conf',
client_principal: 'Client Principal',
keytab_Key_path: 'Keytab Key Path',
data_base: 'Database name',
@@ -4128,11 +4113,7 @@ export default {
time_end: 'End',
es_query_param_formatter_error:
'Query parameter format error, please enter the correct JSON format, please check',
show_task_id: 'View Task ID',
offset: 'Offset',
offset_tip: 'Offset: negative for backward, positive for forward',
millisecond: 'Millisecond',
units: 'Unit'
show_task_id: 'View Task ID'
},
watermark: {
support_params: 'Currently supported parameters:',

View File

@@ -1,7 +1,6 @@
export default {
common: {
empty: '',
first_item: '首項',
cross_source: '跨源',
single_source: '單源',
source_tips: '資料集存在跨源情況請檢查其他 SQL 節點的語法是否確認將類型改為單源?',
@@ -941,7 +940,7 @@ export default {
data_source_table: '資料來源表',
auth_method: '認證方式',
passwd: '使用者名稱密碼',
kerbers_info: '請確保krb5.Conf、Keytab Key已新增至路徑/opt/dataease3.0/conf',
kerbers_info: '請確保krb5.Conf、Keytab Key已新增至路徑/opt/dataease2.0/conf',
client_principal: 'Client Principal',
keytab_Key_path: 'Keytab Key Path',
please_select_left: '請從左邊選擇',
@@ -1349,7 +1348,6 @@ export default {
table_title_fontsize: '表頭字體大小',
table_item_fontsize: '表格字體大小',
table_header_bg: '表頭背景',
table_header_row_bg: '表頭/行背景',
table_item_bg: '表格背景',
table_header_font_color: '表頭字型',
table_item_font_color: '表格字型',
@@ -1450,7 +1448,6 @@ export default {
axis_type_dashed: '虛線',
axis_type_dotted: '點',
axis_label_show: '標籤顯示',
axis_tick_show: '刻度顯示',
axis_label_color: '標籤顏色',
axis_label_fontsize: '標籤大小',
text_style: '字體樣式',
@@ -2035,8 +2032,7 @@ export default {
quota_col_label: '指標列名',
table_grand_total_label: '總計別名',
table_field_total_label: '字段別名',
table_row_header_freeze: '行頭凍結',
value_formatter_total_out_percent: '顯示佔比'
table_row_header_freeze: '行頭凍結'
},
dataset: {
field_value: '欄位值',
@@ -2052,7 +2048,7 @@ export default {
select_year: '選擇年',
sql_variable_limit_1: '1、SQL 變數只能在WHERE 條件中使用',
sql_variable_limit_2:
"2範例: select * from table where $DE_PARAM{'{'} name = substring('$[PARAM1]',1,5){'}'} and $DE_PARAM{'{'} name in ($[PARAM2]) {'}'}",
"2範例: select * from table where $DE_PARAM{ name = '$[PARAM1]' } and $DE_PARAM{ name in ($[PARAM2]) }",
select_month: '選擇月',
select_date: '選擇日期',
select_time: '選擇時間',
@@ -2827,15 +2823,6 @@ export default {
column_name: '欄位名稱'
},
visualization: {
select_resource: '請選擇{0}',
change_screen_page: '更換{0}',
new_screen_page: '新建分頁',
screen_page: '分頁',
color_setting: '配色{0}',
decoration_name: '裝飾{0}',
decoration: '裝飾',
dynamic_background_name: '動圖{0}',
dynamic_background: '動圖',
support_query: '僅可新增查詢元件',
publish_update_tips: '有更新',
filter_freeze_tips: '已存在置頂查詢組件,確定切換該組件?',
@@ -2906,7 +2893,6 @@ export default {
'如果展示查詢按鈕,需要點擊該按鈕後才能觸發圖表查詢;如果不展示查詢按鈕,選擇完查詢條件後立即觸發圖表查詢',
custom_query_bg_color: '自定義查詢條件背景',
query_condition_space: '查詢條件間距',
query_condition_height: '查詢條件高度',
query_condition_name: '查詢條件名稱',
condition_left: '左側',
condition_top: '上側',
@@ -3050,7 +3036,6 @@ export default {
screen_adaptor_width_first: '寬度優先',
screen_adaptor_height_first: '高度優先',
screen_adaptor_full: '鋪滿全屏',
screen_adaptor_keep_proportion: '保持比例填充',
screen_adaptor_keep: '不縮放',
effective_during_preview: '預覽時生效',
base_config: '基礎配置',
@@ -3106,7 +3091,7 @@ export default {
required: '必填',
default_value: '預設值',
default_value_tips1: '請使用JSON數組格式 範例:',
default_value_tips2: '單值 ["name1"], 多值 ["name1","name2"]; 綁定SQL自定義參數不支援多值',
default_value_tips2: '單值 ["name1"], 多值 ["name1","name2"]',
default_value_tips3: '請輸入參數,如:["name1"]',
time_year_widget: '年份過濾組件',
time_month_widget: '年月過濾組件',
@@ -3189,6 +3174,7 @@ export default {
space_left: '左',
space_width: '寬',
space_height: '高',
to_top: '置顶',
down: '下載',
mobile_style_setting: '樣式設置',
mobile_style_setting_tips: '自定義移動端背景',
@@ -3224,7 +3210,8 @@ export default {
template_preview: '預覽模板',
apply: '應用',
apply_this_template: '應用此模板',
market_network_tips: '查看模板市場模板需要服務器與模板市場({0})連通,請檢查網絡...',
market_network_tips:
'查看模板市場模板需要服務器與模板市場(https://templates.dataease.cn)連通,請檢查網絡...',
enter_name_tips: '請輸入儀表板名稱',
apply_template: '應用模板',
style_template: '樣式模板',
@@ -3354,6 +3341,7 @@ export default {
template: '模板',
category: '分類',
all_org: '所有組織',
custom: '自定義',
import_template: '匯入模板',
copy_template: '復用模板',
upload_template: '上傳模板',
@@ -3748,7 +3736,7 @@ export default {
data_source_table: '資料來源表',
auth_method: '認證方式',
passwd: '使用者名稱密碼',
kerbers_info: '請確保krb5.Conf、Keytab Key已新增至路徑/opt/dataease3.0/conf',
kerbers_info: '請確保krb5.Conf、Keytab Key已新增至路徑/opt/dataease2.0/conf',
client_principal: 'Client Principal',
keytab_Key_path: 'Keytab Key Path',
data_base: '資料庫名稱',
@@ -4011,11 +3999,7 @@ export default {
dynamic_partition_enable: '動態分區',
time_end: '結束',
es_query_param_formatter_error: '查詢參數格式錯誤請輸入正確的JSON格式請檢查',
show_task_id: '查看任務ID',
offset: '偏移量',
offset_tip: '偏移量,負數為前向偏移,正數為後向偏移',
millisecond: '毫秒',
units: '單位'
show_task_id: '查看任務ID'
},
watermark: {
support_params: '目前支援的參數:',

View File

@@ -1,7 +1,6 @@
export default {
common: {
empty: '',
first_item: '首项',
cross_source: '跨源',
single_source: '单源',
source_tips: '数据集存在跨源情况请检查其他 SQL 节点的语法是否确认将类型改为单源?',
@@ -943,7 +942,7 @@ export default {
data_source_table: '数据源表',
auth_method: '认证方式',
passwd: '用户名密码',
kerbers_info: '请确保 krb5.Conf、Keytab Key已经添加到路径/opt/dataease3.0/conf',
kerbers_info: '请确保 krb5.Conf、Keytab Key已经添加到路径/opt/dataease2.0/conf',
client_principal: 'Client Principal',
keytab_Key_path: 'Keytab Key Path',
please_select_left: '请从左侧选择',
@@ -1354,7 +1353,6 @@ export default {
table_title_fontsize: '表头字体大小',
table_item_fontsize: '表格字体大小',
table_header_bg: '表头背景',
table_header_row_bg: '表头/行背景',
table_item_bg: '表格背景',
table_header_font_color: '表头字体',
table_item_font_color: '表格字体',
@@ -1455,7 +1453,6 @@ export default {
axis_type_dashed: '虚线',
axis_type_dotted: '点',
axis_label_show: '标签显示',
axis_tick_show: '刻度显示',
axis_label_color: '标签颜色',
axis_label_fontsize: '标签大小',
text_style: '字体样式',
@@ -2041,8 +2038,7 @@ export default {
quota_col_label: '指标列名',
table_grand_total_label: '总计别名',
table_field_total_label: '字段别名',
table_row_header_freeze: '行头冻结',
value_formatter_total_out_percent: '显示占比'
table_row_header_freeze: '行头冻结'
},
dataset: {
field_value: '字段值',
@@ -2058,7 +2054,7 @@ export default {
select_year: '选择年',
sql_variable_limit_1: '1、SQL 变量只能在 WHERE 条件中使用',
sql_variable_limit_2:
"2示例: select * from table where $DE_PARAM{'{'} name = substring('$[PARAM1]',1,5){'}'} and $DE_PARAM{'{'} name in ($[PARAM2]) {'}'}",
"2示例: select * from table where $DE_PARAM{ name = '$[PARAM1]' } and $DE_PARAM{ name in ($[PARAM2]) }",
select_month: '选择月',
select_date: '选择日期',
select_time: '选择时间',
@@ -2833,15 +2829,6 @@ export default {
column_name: '字段名称'
},
visualization: {
select_resource: '请选择{0}',
change_screen_page: '更换{0}',
new_screen_page: '新建分页',
screen_page: '分页',
color_setting: '配色{0}',
decoration_name: '装饰{0}',
decoration: '装饰',
dynamic_background_name: '背景{0}',
dynamic_background: '动图',
support_query: '仅支持添加查询组件',
publish_update_tips: '有更新',
filter_freeze_tips: '已存在置顶查询组件,确定切换该组件?',
@@ -2913,7 +2900,6 @@ export default {
'如果展示查询按钮,需要点击该按钮后才能触发图表查询;如果不展示查询按钮,选择完查询条件后立即触发图表查询',
custom_query_bg_color: '自定义查询条件背景',
query_condition_space: '查询条件间距',
query_condition_height: '查询条件高度',
query_condition_name: '查询条件名称',
condition_left: '左侧',
condition_top: '上侧',
@@ -3053,7 +3039,6 @@ export default {
external_parameter_settings: '外部参数设置',
screen_config: '大屏配置',
screen_adaptor: '缩放方式',
screen_adaptor_keep_proportion: '保持比例填充',
screen_adaptor_width_first: '宽度优先',
screen_adaptor_height_first: '高度优先',
screen_adaptor_full: '铺满全屏',
@@ -3112,7 +3097,7 @@ export default {
required: '必填',
default_value: '默认值',
default_value_tips1: '请使用JSON数组格式 示例:',
default_value_tips2: '单值 ["name1"], 多值 ["name1","name2"]; 绑定SQL自定义参数不支持多值',
default_value_tips2: '单值 ["name1"], 多值 ["name1","name2"]',
default_value_tips3: '请输入参数,如:["name1"]',
time_year_widget: '年份过滤组件',
time_month_widget: '年月过滤组件',
@@ -3229,7 +3214,8 @@ export default {
template_preview: '预览模板',
apply: '应用',
apply_this_template: '应用此模板',
market_network_tips: `查看模板市场模板需要服务器与模板市场({0})连通,请检查网络...`,
market_network_tips:
'查看模板市场模板需要服务器与模板市场(https://templates.dataease.cn)连通,请检查网络...',
enter_name_tips: '请输入仪表板名称',
apply_template: '应用模板',
style_template: '样式模板',
@@ -3754,7 +3740,7 @@ export default {
data_source_table: '数据源表',
auth_method: '认证方式',
passwd: '用户名密码',
kerbers_info: '请确保 krb5.Conf、Keytab Key已经添加到路径/opt/dataease3.0/conf',
kerbers_info: '请确保 krb5.Conf、Keytab Key已经添加到路径/opt/dataease2.0/conf',
client_principal: 'Client Principal',
keytab_Key_path: 'Keytab Key Path',
data_base: '数据库名称',
@@ -4015,11 +4001,7 @@ export default {
dynamic_partition_enable: '动态分区',
time_end: '结束',
es_query_param_formatter_error: '查询参数格式错误请输入正确的JSON格式请检查',
show_task_id: '查看任务ID',
offset: '偏移量',
offset_tip: '偏移量,负数为前向偏移,正数为后向偏移',
millisecond: '毫秒',
units: '单位'
show_task_id: '查看任务ID'
},
watermark: {
support_params: '当前支持的参数:',

View File

@@ -506,37 +506,75 @@ const mouseupDrag = () => {
const parseVariable = () => {
state.variablesTmp = []
const reg = new RegExp('\\${(.*?)}', 'gim')
const match = codeCom.value.state.doc.toString().match(reg)
const names = []
if (match !== null) {
for (let index = 0; index < match.length; index++) {
let name = match[index].substring(2, match[index].length - 1)
if (names.indexOf(name) < 0) {
names.push(name)
// eslint-disable-next-line
let obj = undefined
for (let i = 0; i < state.variables?.length; i++) {
if (state.variables[i].variableName === name) {
obj = state.variables[i]
if (!obj.hasOwnProperty('defaultValueScope')) {
obj.defaultValueScope = 'EDIT'
const variableReg = new RegExp('\\$DE_PARAM{(.*?)}', 'gim')
const variableMatch = codeCom.value.state.doc.toString().match(variableReg)
if (variableMatch !== null) {
const names = []
const reg = new RegExp('\\$\\[[^\\]]+\\]', 'gim')
for (let index = 0; index < variableMatch.length; index++) {
let sqlItem = variableMatch[index].substring(10, variableMatch[index].length - 1)
const match = sqlItem.match(reg)
if (match !== null) {
let name = match[0].substring(2, match[0].length - 1)
if (names.indexOf(name) < 0) {
names.push(name)
let obj = undefined
for (let i = 0; i < state.variables?.length; i++) {
if (state.variables[i].variableName === name) {
obj = state.variables[i]
if (!obj.hasOwnProperty('defaultValueScope')) {
obj.defaultValueScope = 'EDIT'
}
}
}
}
if (obj === undefined) {
obj = {
variableName: name,
alias: '',
type: [],
required: false,
defaultValue: '',
details: '',
defaultValueScope: 'EDIT'
if (obj === undefined) {
obj = {
variableName: name,
alias: '',
type: [],
required: false,
defaultValue: '',
details: '',
defaultValueScope: 'EDIT'
}
obj.type.push('TEXT')
}
obj.type.push('TEXT')
state.variablesTmp.push(obj)
}
}
}
} else {
const reg = new RegExp('\\${(.*?)}', 'gim')
const match = codeCom.value.state.doc.toString().match(reg)
const names = []
if (match !== null) {
for (let index = 0; index < match.length; index++) {
let name = match[index].substring(2, match[index].length - 1)
if (names.indexOf(name) < 0) {
names.push(name)
let obj = undefined
for (let i = 0; i < state.variables?.length; i++) {
if (state.variables[i].variableName === name) {
obj = state.variables[i]
if (!obj.hasOwnProperty('defaultValueScope')) {
obj.defaultValueScope = 'EDIT'
}
}
}
if (obj === undefined) {
obj = {
variableName: name,
alias: '',
type: [],
required: false,
defaultValue: '',
details: '',
defaultValueScope: 'EDIT'
}
obj.type.push('TEXT')
}
state.variablesTmp.push(obj)
}
state.variablesTmp.push(obj)
}
}
}