Skip to content

Commit e8a9fe4

Browse files
authored
Merge pull request #784 from xieliuduo/up-master
fix(board): clickJump&toLinkingWidgets
2 parents 2c32616 + 3b905fc commit e8a9fe4

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

frontend/src/app/pages/DashBoardPage/components/WidgetProvider/WidgetMethodProvider.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ExclamationCircleOutlined } from '@ant-design/icons';
2020
import { Modal } from 'antd';
2121
import usePrefixI18N from 'app/hooks/useI18NPrefix';
2222
import { urlSearchTransfer } from 'app/pages/MainPage/pages/VizPage/utils';
23-
import { ChartMouseEventParams } from 'app/types/Chart';
23+
import { ChartMouseEventParams, ChartsEventData } from 'app/types/Chart';
2424
import { ControllerFacadeTypes } from 'app/types/FilterControlPanel';
2525
import React, { FC, useCallback, useContext } from 'react';
2626
import { useDispatch } from 'react-redux';
@@ -278,7 +278,13 @@ export const WidgetMethodProvider: FC<{ widgetId: string }> = ({
278278
renderMode,
279279
],
280280
);
281-
281+
const getValueByRowData = (
282+
data: ChartsEventData | undefined,
283+
fieldName: string,
284+
) => {
285+
let toCaseField = fieldName.toUpperCase();
286+
return data?.rowData[toCaseField];
287+
};
282288
const toLinkingWidgets = useCallback(
283289
(widget: Widget, params: ChartMouseEventParams) => {
284290
const { componentType, seriesType, seriesName } = params;
@@ -302,8 +308,7 @@ export const WidgetMethodProvider: FC<{ widgetId: string }> = ({
302308

303309
const filter: BoardLinkFilter = {
304310
triggerWidgetId: widget.id,
305-
triggerValue:
306-
(params?.data?.rowData?.[linkageFieldName] as string) || '',
311+
triggerValue: getValueByRowData(params.data, linkageFieldName),
307312
triggerDataChartId: widget.datachartId,
308313
linkerWidgetId: re.targetId,
309314
};
@@ -369,13 +374,13 @@ export const WidgetMethodProvider: FC<{ widgetId: string }> = ({
369374
if (
370375
params.componentType === 'table' &&
371376
jumpFieldName !== params.seriesName
372-
)
377+
) {
373378
return;
374-
379+
}
380+
const rowDataValue = getValueByRowData(params.data, jumpFieldName);
375381
if (typeof jumpConfig?.filter === 'object' && targetType === 'INTERNAL') {
376382
const searchParamsStr = urlSearchTransfer.toUrlString({
377-
[jumpConfig?.filter?.filterId]:
378-
(params?.data?.rowData?.[jumpFieldName] as string) || '',
383+
[jumpConfig?.filter?.filterId]: rowDataValue,
379384
});
380385
if (targetId) {
381386
history.push(
@@ -385,9 +390,9 @@ export const WidgetMethodProvider: FC<{ widgetId: string }> = ({
385390
} else if (targetType === 'URL') {
386391
let jumpUrl;
387392
if (URL.indexOf('?') > -1) {
388-
jumpUrl = `${URL}&${queryName}=${params?.data?.rowData?.[jumpFieldName]}`;
393+
jumpUrl = `${URL}&${queryName}=${rowDataValue}`;
389394
} else {
390-
jumpUrl = `${URL}?${queryName}=${params?.data?.rowData?.[jumpFieldName]}`;
395+
jumpUrl = `${URL}?${queryName}=${rowDataValue}`;
391396
}
392397
window.location.href = jumpUrl;
393398
}

0 commit comments

Comments
 (0)