|
|
@@ -98,15 +98,38 @@ export default {
|
|
|
obj[name] = value;
|
|
|
let newState = Object.assign({}, state, obj);
|
|
|
return newState;
|
|
|
+ },
|
|
|
+ setChartOption(state, action) {
|
|
|
+ const { option } = action;
|
|
|
+ let obj = {};
|
|
|
+ obj['chartOption'] = option;
|
|
|
+ let newState = Object.assign({}, state, obj);
|
|
|
+ return newState;
|
|
|
}
|
|
|
},
|
|
|
effects: {
|
|
|
*['fetchChartData'](action, { select, call, put }) {
|
|
|
- const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { barConfig, preparing } = chartDesigner;
|
|
|
- const res = yield call(service.fetch, {
|
|
|
- url: URLS.CHART_BAR_OPTION,
|
|
|
- body: {
|
|
|
+ try {
|
|
|
+ const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
+ const { barConfig, preparing } = chartDesigner;
|
|
|
+ const res = yield call(service.fetch, {
|
|
|
+ url: URLS.CHART_BAR_OPTION,
|
|
|
+ body: {
|
|
|
+ "tableName": "TEST_BI_DATA",
|
|
|
+ "groups": preparing.groupBy.map(g => g.key),
|
|
|
+ "xAxis": {
|
|
|
+ "columnRename": barConfig.xAxis.column.value,
|
|
|
+ "columnType": barConfig.xAxis.column.type,
|
|
|
+ "dataType": barConfig.xAxis.granularity.value
|
|
|
+ },
|
|
|
+ "yAxis": {
|
|
|
+ "columnRename": barConfig.yAxis.column.value,
|
|
|
+ "dataType": barConfig.yAxis.gauge.value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log({
|
|
|
"tableName": "TEST_BI_DATA",
|
|
|
"groups": preparing.groupBy.map(g => g.key),
|
|
|
"xAxis": {
|
|
|
@@ -118,51 +141,28 @@ export default {
|
|
|
"columnRename": barConfig.yAxis.column.value,
|
|
|
"dataType": barConfig.yAxis.gauge.value
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- console.log({
|
|
|
- "tableName": "TEST_BI_DATA",
|
|
|
- "groups": preparing.groupBy.map(g => g.key),
|
|
|
- "xAxis": {
|
|
|
- "columnRename": barConfig.xAxis.column.value,
|
|
|
- "columnType": barConfig.xAxis.column.type,
|
|
|
- "dataType": barConfig.xAxis.granularity.value
|
|
|
- },
|
|
|
- "yAxis": {
|
|
|
- "columnRename": barConfig.yAxis.column.value,
|
|
|
- "dataType": barConfig.yAxis.gauge.value
|
|
|
- }
|
|
|
- })
|
|
|
- if(!res.err && res.data.code > 0) {
|
|
|
+ })
|
|
|
+
|
|
|
res.viewType = 'bar';
|
|
|
res.data.data.xTitle = barConfig.xAxis?`${barConfig.xAxis.column.label}${barConfig.xAxis.granularity.value?'('+barConfig.xAxis.granularity.label+')':''}`:null
|
|
|
res.data.data.yTitle = barConfig.yAxis?barConfig.yAxis.column.label:null;
|
|
|
res.data.data.gauge = barConfig.yAxis?barConfig.yAxis.gauge.label:null;
|
|
|
- yield put({ type: 'setModel', name: 'chartOption', value: res });
|
|
|
- }else {
|
|
|
- yield put({ type: 'setModel', name: 'chartOption', value: {} });
|
|
|
- // 弹出错误提示
|
|
|
+ yield put({ type: 'setChartOption', option: res });
|
|
|
+
|
|
|
+ }catch(e) {
|
|
|
+ yield put({ type: 'setChartOption', option: {} });
|
|
|
}
|
|
|
- },
|
|
|
- *test({payload:todo},{put,call}){
|
|
|
-
|
|
|
- yield put({type:'filters/setUsing', action: { key: 0 }})
|
|
|
- },
|
|
|
- *fetch({ payload: { page = 1 } }, { call, put }) {
|
|
|
- const { data, headers } = yield call(usersService.fetch, { page });
|
|
|
- yield put({
|
|
|
- type: 'save',
|
|
|
- payload: {
|
|
|
- data,
|
|
|
- total: parseInt(headers['x-total-count'], 10),
|
|
|
- page: parseInt(page, 10),
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- * redirect (action, { put }) {
|
|
|
- yield put(routerRedux.push(action.path || '/'));
|
|
|
- },
|
|
|
+ // if(!res.err && res.data.code > 0) {
|
|
|
+ // res.viewType = 'bar';
|
|
|
+ // res.data.data.xTitle = barConfig.xAxis?`${barConfig.xAxis.column.label}${barConfig.xAxis.granularity.value?'('+barConfig.xAxis.granularity.label+')':''}`:null
|
|
|
+ // res.data.data.yTitle = barConfig.yAxis?barConfig.yAxis.column.label:null;
|
|
|
+ // res.data.data.gauge = barConfig.yAxis?barConfig.yAxis.gauge.label:null;
|
|
|
+ // yield put({ type: 'setChartOption', option: res });
|
|
|
+ // }else {
|
|
|
+ // yield put({ type: 'setChartOption', option: {} });
|
|
|
+ // // 弹出错误提示
|
|
|
+ // }
|
|
|
+ }
|
|
|
},
|
|
|
subscriptions: {
|
|
|
setup({ dispatch, history }) {
|