Browse Source

报表导出tableview数据加载使用报表获取图表数据的接口(原为使用图表获取数据的接口)以绕过权限

zhuth 6 years ago
parent
commit
17cba75391
2 changed files with 19 additions and 6 deletions
  1. 11 3
      src/models/chartDesigner.js
  2. 8 3
      src/models/dashboardDesigner.js

+ 11 - 3
src/models/chartDesigner.js

@@ -948,7 +948,7 @@ export default {
         },
         *getChartTableData(action, { select, call, put }) {
             try {
-                const { chartCode, chartType, chartOption, filters } = action;
+                const { chartCode, chartType, chartOption, filters, inDashboard, dashboardCode } = action;
                 let columns = [];
                 let dataSource = [];
                 const TimeType = {
@@ -1065,7 +1065,15 @@ export default {
                             dataIndex: c.name,
                             type: 'string'
                         }));
-                        const body = {
+                        const body = inDashboard ? {
+                            chartId: chartCode,
+                            dashboardCreatorId: dashboardCode,
+                            filters: getBodyFilters(filters),
+                            testPage: {
+                                pageNum: 1,
+                                pageSize: 9999999,
+                            }
+                        } : {
                             id: chartCode,
                             columnListName: viewColumns.map(c => c.name),
                             sortColumn: originConfig.sortColumn ? originConfig.sortColumn.key : originConfig.viewColumns[0].name,
@@ -1078,7 +1086,7 @@ export default {
                         };
         
                         let res = yield call(service.fetch, {
-                            url: URLS.CHART_DATAVIEW_OPTION,
+                            url: inDashboard ? URLS.CHART_OPTION : URLS.CHART_DATAVIEW_OPTION,
                             body: body,
                             timeout: 30000
                         });

+ 8 - 3
src/models/dashboardDesigner.js

@@ -817,7 +817,7 @@ export default {
         },
         *exportToExcel(action, { select, take, put }) {
             const dashboardDesigner = yield select(state => state.dashboardDesigner);
-            const { name, filters, items } = dashboardDesigner;
+            const { code, name, filters, items } = dashboardDesigner;
             try {
                 yield put({ type: 'setField', name: 'loading', value: true });
 
@@ -835,8 +835,13 @@ export default {
                         string: 'String'
                     };
                     if(viewType === 'chart') {
-                        let sync = yield put({ type: 'chartDesigner/getChartTableData',
-                            chartCode, chartType, chartOption, filters: getTrueFilters(item, filters) });
+                        let sync = yield put({
+                            type: 'chartDesigner/getChartTableData',
+                            chartCode, chartType, chartOption,
+                            filters: getTrueFilters(item, filters),
+                            inDashboard: true,
+                            dashboardCode: code
+                        });
                         yield take('chartDesigner/getChartTableData/@@end');
                         yield sync.then(tableData => {
                             let { columns: tcolumns, dataSource: tdatasource } = tableData;