diff --git a/core/core-backend/src/main/java/io/dataease/engine/utils/SQLUtils.java b/core/core-backend/src/main/java/io/dataease/engine/utils/SQLUtils.java index d385c5e748..819fcd5d5f 100644 --- a/core/core-backend/src/main/java/io/dataease/engine/utils/SQLUtils.java +++ b/core/core-backend/src/main/java/io/dataease/engine/utils/SQLUtils.java @@ -7,7 +7,7 @@ import java.util.Optional; */ public class SQLUtils { public static String transKeyword(String value) { - return Optional.ofNullable(value).orElse("").replaceAll("'", "\\\\'"); + return Optional.ofNullable(value).orElse("").replaceAll("'", "''"); } public static String buildOriginPreviewSql(String sql, int limit, int offset) { diff --git a/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue b/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue index 4a25678b42..7d48537771 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue @@ -1391,6 +1391,7 @@ onMounted(() => { if (isMainCanvas(canvasId.value)) { initSnapshotTimer() initWatermark() + dvMainStore.setEditMode('edit') } // 获取编辑器元素 composeStore.getEditor(canvasId.value) diff --git a/core/core-frontend/src/custom-component/common/CommonStyleSet.vue b/core/core-frontend/src/custom-component/common/CommonStyleSet.vue index b18c074c0d..0958e58229 100644 --- a/core/core-frontend/src/custom-component/common/CommonStyleSet.vue +++ b/core/core-frontend/src/custom-component/common/CommonStyleSet.vue @@ -319,13 +319,13 @@ const scrollSpeedList = [ { name: '1', value: 80 }, { name: '2', value: 60 }, { name: '3', value: 40 }, - { name: '4', value: 20 }, - { name: '5', value: 10 }, - { name: '6', value: 8 }, - { name: '7', value: 6 }, - { name: '8', value: 4 }, - { name: '9', value: 2 }, - { name: '10', value: 1 } + { name: '4', value: 30 }, + { name: '5', value: 20 }, + { name: '6', value: 15 }, + { name: '7', value: 10 }, + { name: '8', value: 8 }, + { name: '9', value: 6 }, + { name: '10', value: 3 } ] const opacitySizeList = [ diff --git a/core/core-frontend/src/custom-component/scroll-text/Component.vue b/core/core-frontend/src/custom-component/scroll-text/Component.vue index 32b2cfb962..b510ce476b 100644 --- a/core/core-frontend/src/custom-component/scroll-text/Component.vue +++ b/core/core-frontend/src/custom-component/scroll-text/Component.vue @@ -78,8 +78,6 @@ const clearStyle = e => { if (text !== '') { document.execCommand('insertText', false, text) } - - emit('input', element.value, e.target.innerHTML) } const handleBlur = e => { @@ -141,11 +139,12 @@ const textStyle = computed(() => { @mousedown="handleMousedown" @blur="handleBlur" @input="handleInput" - v-html="element['propValue']" - > + > + {{ element['propValue'] }} + -
-
+
+
{{ element['propValue'] }}
diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 775f11d110..a85fa55c7b 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -1165,7 +1165,9 @@ export default { top_n_input_2: ', 其余合并至其他', top_n_label: '其他项名称', progress_target: '目标值', - progress_current: '实际值' + progress_current: '实际值', + gauge_axis_label: '显示刻度', + gauge_percentage_tick: '百分比刻度' }, dataset: { scope_edit: '仅编辑时生效', diff --git a/core/core-frontend/src/models/chart/chart-attr.d.ts b/core/core-frontend/src/models/chart/chart-attr.d.ts index 1a86f4292e..4dd8778dac 100644 --- a/core/core-frontend/src/models/chart/chart-attr.d.ts +++ b/core/core-frontend/src/models/chart/chart-attr.d.ts @@ -104,6 +104,14 @@ declare interface ChartBasicStyle { * 仪表盘样式 */ gaugeStyle: string + /** + * 仪表盘刻度显示 + */ + gaugeAxisLine: boolean + /** + * 仪表盘百分比刻度 + */ + gaugePercentLabel: boolean /** * 配色方案 */ diff --git a/core/core-frontend/src/pages/panel/ViewWrapper.vue b/core/core-frontend/src/pages/panel/ViewWrapper.vue index 9465a582e8..b0e8a93db5 100644 --- a/core/core-frontend/src/pages/panel/ViewWrapper.vue +++ b/core/core-frontend/src/pages/panel/ViewWrapper.vue @@ -33,9 +33,9 @@ const winMsgHandle = event => { const msgInfo = event.data // 校验targetSourceId if (msgInfo && msgInfo.type === 'attachParams' && msgInfo.targetSourceId === state.chartId + '') { - const attachParam = msgInfo.params - if (attachParam) { - dvMainStore.addOuterParamsFilter(attachParam, state.canvasDataPreview, 'outer') + const attachParams = msgInfo.params + if (attachParams) { + dvMainStore.addOuterParamsFilter(attachParams, state.canvasDataPreview, 'outer') } } } @@ -58,7 +58,7 @@ onBeforeMount(async () => { window.addEventListener('message', winMsgHandle) // 添加外部参数 - let attachParam + let attachParams await getOuterParamsInfo(embeddedStore.dvId).then(rsp => { dvMainStore.setNowPanelOuterParamsInfo(rsp.data) }) @@ -67,7 +67,7 @@ onBeforeMount(async () => { if (embeddedStore.outerParams) { try { const outerPramsParse = JSON.parse(embeddedStore.outerParams) - attachParam = outerPramsParse.attachParam + attachParams = outerPramsParse.attachParams dvMainStore.setEmbeddedCallBack(outerPramsParse.callBackFlag || 'no') } catch (e) { console.error(e) @@ -90,8 +90,8 @@ onBeforeMount(async () => { state.canvasViewInfoPreview = canvasViewInfoPreview state.dvInfo = dvInfo state.curPreviewGap = curPreviewGap - if (attachParam) { - dvMainStore.addOuterParamsFilter(attachParam, canvasDataResult) + if (attachParams) { + dvMainStore.addOuterParamsFilter(attachParams, canvasDataResult) } viewInfo.value = canvasViewInfoPreview[embeddedStore.chartId] diff --git a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts index 4367d1de5a..e50a781ca6 100644 --- a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts +++ b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts @@ -33,7 +33,7 @@ export const dvMainStore = defineStore('dataVisualization', { datasetAreaCollapse: false }, embeddedCallBack: 'no', // 嵌入模式是否允许反馈参数 - editMode: 'edit', // 编辑器模式 edit preview + editMode: 'preview', // 编辑器模式 edit preview mobileInPc: false, firstLoadMap: [], canvasStyleData: { ...deepCopy(DEFAULT_CANVAS_STYLE_DATA_DARK), backgroundColor: null }, diff --git a/core/core-frontend/src/views/chart/components/editor/editor-senior/components/Threshold.vue b/core/core-frontend/src/views/chart/components/editor/editor-senior/components/Threshold.vue index 17e363c6ba..c7049ae8c9 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-senior/components/Threshold.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-senior/components/Threshold.vue @@ -231,7 +231,12 @@ init()
- + - + { /> + + + {{ t('chart.gauge_axis_label') }} + + + + {{ t('chart.gauge_percentage_tick') }} + { // 禁用线上地图数据 customFetchGeoData: () => null } - options = this.setupOptions(chart, options, drawOption, geoJson) + const context = { drawOption, geoJson } + options = this.setupOptions(chart, options, context) const view = new Choropleth(container, options) const dotLayer = this.getDotLayer(chart, geoJson, drawOption) this.configZoomButton(chart, view) @@ -170,10 +171,10 @@ export class BubbleMap extends L7PlotChartView { private configBasicStyle( chart: Chart, options: ChoroplethOptions, - extra: any[] + context: Record ): ChoroplethOptions { - const { areaId }: L7PlotDrawOptions = extra[0] - const geoJson: FeatureCollection = extra[1] + const { areaId }: L7PlotDrawOptions = context.drawOption + const geoJson: FeatureCollection = context.geoJson const { basicStyle, label } = parseJson(chart.customAttr) const senior = parseJson(chart.senior) const curAreaNameMapping = senior.areaMapping?.[areaId] @@ -208,7 +209,7 @@ export class BubbleMap extends L7PlotChartView { protected setupOptions( chart: Chart, options: ChoroplethOptions, - ...extra: any[] + context: Record ): ChoroplethOptions { return flow( this.configEmptyDataStrategy, @@ -216,6 +217,6 @@ export class BubbleMap extends L7PlotChartView { this.configStyle, this.configTooltip, this.configBasicStyle - )(chart, options, extra) + )(chart, options, context) } } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/map.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/map.ts index 69ecae76d9..586cf742d6 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/map.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/map.ts @@ -96,7 +96,8 @@ export class Map extends L7PlotChartView { // 禁用线上地图数据 customFetchGeoData: () => null } - options = this.setupOptions(chart, options, drawOption, geoJson) + const context = { drawOption, geoJson } + options = this.setupOptions(chart, options, context) const view = new Choropleth(container, options) this.configZoomButton(chart, view) view.once('loaded', () => { @@ -120,10 +121,10 @@ export class Map extends L7PlotChartView { private configBasicStyle( chart: Chart, options: ChoroplethOptions, - extra: any[] + context: Record ): ChoroplethOptions { - const { areaId }: L7PlotDrawOptions = extra[0] - const geoJson: FeatureCollection = extra[1] + const { areaId }: L7PlotDrawOptions = context.drawOption + const geoJson: FeatureCollection = context.geoJson const { basicStyle, label } = parseJson(chart.customAttr) const senior = parseJson(chart.senior) const curAreaNameMapping = senior.areaMapping?.[areaId] @@ -176,7 +177,7 @@ export class Map extends L7PlotChartView { protected setupOptions( chart: Chart, options: ChoroplethOptions, - ...extra: any[] + context: Record ): ChoroplethOptions { return flow( this.configEmptyDataStrategy, @@ -185,6 +186,6 @@ export class Map extends L7PlotChartView { this.configTooltip, this.configBasicStyle, this.configLegend - )(chart, options, extra) + )(chart, options, context) } } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/gauge.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/gauge.ts index d89051a874..e5242809a4 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/gauge.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/gauge.ts @@ -13,6 +13,7 @@ import { import { valueFormatter } from '@/views/chart/components/js/formatter' import { getPadding, setGradientColor } from '@/views/chart/components/js/panel/common/common_antv' import { useI18n } from '@/hooks/web/useI18n' +import { merge } from 'lodash-es' const { t } = useI18n() @@ -28,7 +29,7 @@ export class Gauge extends G2PlotChartView { ] propertyInner: EditorPropertyInner = { 'background-overall-component': ['all'], - 'basic-style-selector': ['colors', 'alpha', 'gaugeStyle', 'gradient'], + 'basic-style-selector': ['colors', 'alpha', 'gradient', 'gaugeAxisLine', 'gaugePercentLabel'], 'label-selector': ['fontSize', 'color', 'labelFormatter'], 'title-selector': [ 'title', @@ -77,10 +78,6 @@ export class Gauge extends G2PlotChartView { label: { style: { fontSize: getScaleValue(12, scale) // 刻度值字体大小 - }, - formatter: function (v) { - const r = parseFloat(v) - return v === '0' || !r ? v : r * 100 + '%' } }, tickLine: { @@ -98,11 +95,15 @@ export class Gauge extends G2PlotChartView { } } } - const options = this.setupOptions(chart, initOptions, scale) + const options = this.setupOptions(chart, initOptions, { scale }) return new G2Gauge(container, options) } - protected configMisc(chart: Chart, options: GaugeOptions): GaugeOptions { + protected configMisc( + chart: Chart, + options: GaugeOptions, + context: Record + ): GaugeOptions { const customAttr = parseJson(chart.customAttr) const data = chart.data.series[0].data[0] let min, max, startAngle, endAngle @@ -123,6 +124,8 @@ export class Gauge extends G2PlotChartView { } startAngle = (misc.gaugeStartAngle * Math.PI) / 180 endAngle = (misc.gaugeEndAngle * Math.PI) / 180 + context.min = min + context.max = max } const percent = (parseFloat(data) - parseFloat(min)) / (parseFloat(max) - parseFloat(min)) const tmp = { @@ -133,8 +136,12 @@ export class Gauge extends G2PlotChartView { return { ...options, ...tmp } } - private configRange(chart: Chart, options: GaugeOptions, extra: any[]): GaugeOptions { - const [scale] = extra + private configRange( + chart: Chart, + options: GaugeOptions, + context: Record + ): GaugeOptions { + const { scale } = context const range = [0] let index = 0 let flag = false @@ -216,36 +223,55 @@ export class Gauge extends G2PlotChartView { return { ...options, ...rangOptions } } - protected configLabel(chart: Chart, options: GaugeOptions): GaugeOptions { + protected configLabel( + chart: Chart, + options: GaugeOptions, + context?: Record + ): GaugeOptions { const customAttr = parseJson(chart.customAttr) const data = chart.data.series[0].data[0] - let labelContent - if (customAttr.label) { - const label = customAttr.label - const labelFormatter = label.labelFormatter ?? DEFAULT_LABEL.labelFormatter - if (label.show) { - labelContent = { - style: () => ({ - fontSize: label.fontSize, - color: label.color - }), - formatter: function () { - let value - if (labelFormatter.type === 'percent') { - value = options.percent - } else { - value = data - } - return valueFormatter(value, labelFormatter) + let labelContent: GaugeOptions['statistic']['content'] = false + const label = customAttr.label + const labelFormatter = label.labelFormatter ?? DEFAULT_LABEL.labelFormatter + if (label.show) { + labelContent = { + style: { + fontSize: `${label.fontSize}`, + color: label.color + }, + formatter: function () { + let value + if (labelFormatter.type === 'percent') { + value = options.percent + } else { + value = data } + return valueFormatter(value, labelFormatter) } - } else { - labelContent = false - } + } as GaugeOptions['statistic']['content'] } const statistic = { content: labelContent } + const { gaugeAxisLine, gaugePercentLabel } = customAttr.basicStyle + const { min, max } = context + const tmp = { + axis: { + label: { + formatter: v => { + if (gaugeAxisLine === false) { + return '' + } + if (gaugePercentLabel === false) { + const val = v === '0' ? min : v === '1' ? max : min + (max - min) * v + return valueFormatter(val, labelFormatter) + } + return v === '0' ? v : v * 100 + '%' + } + } + } + } + options = merge(options, tmp) return { ...options, statistic } } @@ -263,13 +289,17 @@ export class Gauge extends G2PlotChartView { return chart } - protected setupOptions(chart: Chart, options: GaugeOptions, ...extra: any[]): GaugeOptions { + protected setupOptions( + chart: Chart, + options: GaugeOptions, + context: Record + ): GaugeOptions { return flow( this.configTheme, this.configMisc, this.configLabel, this.configRange - )(chart, options, extra) + )(chart, options, context) } constructor() { super('gauge', DEFAULT_DATA) diff --git a/core/core-frontend/src/views/chart/components/js/panel/types/impl/g2plot.ts b/core/core-frontend/src/views/chart/components/js/panel/types/impl/g2plot.ts index 22191b7482..75b5271902 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/types/impl/g2plot.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/types/impl/g2plot.ts @@ -139,7 +139,7 @@ export abstract class G2PlotChartView< * @param chart 数据库图表对象。 * @param options 各个图表的参数,泛化的 Options,可以自行扩展,比如加个扩展 X 轴或者扩展 Y 轴字段。 */ - protected abstract setupOptions(chart: Chart, options: O): O + protected abstract setupOptions(chart: Chart, options: O, context?: Record): O protected constructor(name: string, defaultData: any[]) { super(ChartLibraryType.G2_PLOT, name, defaultData) } diff --git a/core/core-frontend/src/views/chart/components/js/panel/types/impl/l7plot.ts b/core/core-frontend/src/views/chart/components/js/panel/types/impl/l7plot.ts index e308670c91..6e65dea0b7 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/types/impl/l7plot.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/types/impl/l7plot.ts @@ -81,5 +81,5 @@ export abstract class L7PlotChartView< super(ChartLibraryType.L7_PLOT, name) this.defaultData = defaultData } - protected abstract setupOptions(chart: Chart, options: O): O + protected abstract setupOptions(chart: Chart, options: O, context?: Record): O } diff --git a/core/core-frontend/src/views/chart/components/js/util.ts b/core/core-frontend/src/views/chart/components/js/util.ts index 71f11fe10b..4c5fe2928b 100644 --- a/core/core-frontend/src/views/chart/components/js/util.ts +++ b/core/core-frontend/src/views/chart/components/js/util.ts @@ -388,12 +388,12 @@ export function parseJson(str: T | JSONString): T { return JSON.parse(str) as T } -type FlowFunction = (param: P, result: R, extra?: any[]) => R +type FlowFunction = (param: P, result: R, context?: Record) => R export function flow(...flows: FlowFunction[]): FlowFunction { - return (param: P, result: R, extra?: any[]) => { + return (param: P, result: R, context?: Record) => { return flows.reduce((result: R, flow: FlowFunction) => { - return flow(param, result, extra) + return flow(param, result, context) }, result) } } diff --git a/core/core-frontend/src/views/mobile/directory/index.vue b/core/core-frontend/src/views/mobile/directory/index.vue index 816d4134a1..17a2744150 100644 --- a/core/core-frontend/src/views/mobile/directory/index.vue +++ b/core/core-frontend/src/views/mobile/directory/index.vue @@ -1,16 +1,19 @@