|
@@ -28,8 +28,15 @@ import { clearEditBoardState } from '../../pages/BoardEditor/slice/actions/actio
|
|
|
import { toUpdateDashboard } from '../../pages/BoardEditor/slice/thunk';
|
|
|
import { StorageKeys } from '../../../../../globalConstants';
|
|
|
import { selectNeedVerify, selectShareExecuteTokenMap, selectSharePassword } from '../../../SharePage/slice/selectors';
|
|
|
-import { selectShareBoard } from '../../pages/Board/slice/selector';
|
|
|
+import {
|
|
|
+ selectBoardDataChart,
|
|
|
+ selectShareBoard,
|
|
|
+} from '../../pages/Board/slice/selector';
|
|
|
import { useRouteMatch } from 'react-router-dom';
|
|
|
+import { BoardState } from '../../pages/Board/slice/types';
|
|
|
+import { selectScheduleExportBase } from '../../../MainPage/pages/SchedulePage/slice/selectors';
|
|
|
+import { selectSelectedTab } from '../../../MainPage/pages/VizPage/slice/selectors';
|
|
|
+import { copyData, download } from '@antv/s2';
|
|
|
|
|
|
export interface BoardActionContextProps {
|
|
|
// read
|
|
@@ -68,6 +75,11 @@ export const BoardActionProvider: FC<{
|
|
|
const executeTokenMap = useSelector(selectShareExecuteTokenMap);
|
|
|
const routerParams: { params: { token: string } } = useRouteMatch();
|
|
|
const sharePassword = useSelector(selectSharePassword);
|
|
|
+ const dataChart = useSelector((state: { board: BoardState }) =>
|
|
|
+ selectBoardDataChart(state, boardId),
|
|
|
+ );
|
|
|
+ const exportBase = useSelector(selectScheduleExportBase);
|
|
|
+ const currentTab = useSelector(selectSelectedTab);
|
|
|
|
|
|
const actions = useMemo(() => {
|
|
|
const actionObj: BoardActionContextProps = {
|
|
@@ -94,18 +106,28 @@ export const BoardActionProvider: FC<{
|
|
|
return result;
|
|
|
},
|
|
|
onBoardToDownLoad: (downloadType) => {
|
|
|
- dispatch(
|
|
|
- boardDownLoadAction({
|
|
|
- boardId,
|
|
|
- downloadType,
|
|
|
- clientId,
|
|
|
- needVerify,
|
|
|
- shareBoard,
|
|
|
- executeTokenMap,
|
|
|
- routerParams,
|
|
|
- sharePassword
|
|
|
- }),
|
|
|
- );
|
|
|
+ if (downloadType===DownloadFileType.Excel){
|
|
|
+ if (currentTab?.id){
|
|
|
+ const tabExport = exportBase[currentTab?.id];
|
|
|
+ Object.keys(tabExport).reduce((acc, key) => {
|
|
|
+ download(copyData(tabExport[key], ',', false), key)
|
|
|
+ return acc;
|
|
|
+ }, 0)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ dispatch(
|
|
|
+ boardDownLoadAction({
|
|
|
+ boardId,
|
|
|
+ downloadType,
|
|
|
+ clientId,
|
|
|
+ needVerify,
|
|
|
+ shareBoard,
|
|
|
+ executeTokenMap,
|
|
|
+ routerParams,
|
|
|
+ sharePassword
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ }
|
|
|
},
|
|
|
onCloseBoardEditor: (boardId: string) => {
|
|
|
const pathName = history.location.pathname;
|
|
@@ -123,7 +145,7 @@ export const BoardActionProvider: FC<{
|
|
|
},
|
|
|
};
|
|
|
return actionObj;
|
|
|
- }, [boardId, dispatch, history]);
|
|
|
+ }, [boardId, dispatch, history,dataChart,exportBase,currentTab]);
|
|
|
return (
|
|
|
<BoardActionContext.Provider value={actions}>
|
|
|
{children}
|