|
|
@@ -2,20 +2,61 @@ import { message } from 'antd'
|
|
|
import * as service from '../services/index'
|
|
|
import URLS from '../constants/url'
|
|
|
import STATISTICS_OPTION from '../components/chartDesigner/sections/statisticsOption.json'
|
|
|
+import { dateFormat } from '../utils/baseUtils'
|
|
|
+
|
|
|
+function getBodyFilters(filters) {
|
|
|
+ return filters.filter(f => f.using).map(f => {
|
|
|
+ let { name, operator, type, value1, value2 } = f;
|
|
|
+ let bodyFilter = {
|
|
|
+ columnName: name,
|
|
|
+ columnType: type,
|
|
|
+ symbol: operator,
|
|
|
+ value: value1
|
|
|
+ };
|
|
|
+ if(type === 'string' || type === 'index') {
|
|
|
+ if(operator === 'null' || operator === 'notNull') {
|
|
|
+ }else {
|
|
|
+ bodyFilter['value'] = value1;
|
|
|
+ }
|
|
|
+ }else if(type === 'scale') {
|
|
|
+ if(operator === 'null' || operator === 'notNull') {
|
|
|
+ }else if(operator === 'between') {
|
|
|
+ bodyFilter['value'] = value1 + ',' + value2;
|
|
|
+ }else {
|
|
|
+ }
|
|
|
+ }else if(type === 'time') {
|
|
|
+ let v1 = dateFormat(new Date(value1),'yyyy-MM-dd hh:mm:ss');
|
|
|
+ let v2 = dateFormat(new Date(value2),'yyyy-MM-dd hh:mm:ss');
|
|
|
+
|
|
|
+ if(operator === 'null' || operator === 'notNull') {
|
|
|
+ }else if(operator === 'between') {
|
|
|
+ bodyFilter['value'] = v1 + ',' + v2;
|
|
|
+ }else {
|
|
|
+ bodyFilter['value'] = v1;
|
|
|
+ }
|
|
|
+ }else if(type === 'categorical') {
|
|
|
+ if(operator === 'null' || operator === 'notNull') {
|
|
|
+ }else {
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ }
|
|
|
+ return bodyFilter;
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
export default {
|
|
|
namespace: 'chartDesigner',
|
|
|
state: {
|
|
|
originData: {
|
|
|
code: null,
|
|
|
- header: { label: '未命名' },
|
|
|
+ header: { label: '标题' },
|
|
|
baseConfig: { dataSource: '', viewType: '' },
|
|
|
aggregateTableConfig: { targetColumn: {}, statistics: [], groupBy: [] },
|
|
|
dataViewConfig: { viewColumns: [], sortColumn: {}, sortType: 'asc' },
|
|
|
- barConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {} },
|
|
|
- lineConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {} },
|
|
|
+ barConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''} },
|
|
|
+ lineConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''} },
|
|
|
pieConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} } },
|
|
|
- scatterConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {} },
|
|
|
+ scatterConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''} },
|
|
|
style: {},
|
|
|
filters: [],
|
|
|
chartOption: {},
|
|
|
@@ -33,10 +74,10 @@ export default {
|
|
|
},
|
|
|
aggregateTableConfig: { targetColumn: {}, statistics: [], groupBy: [] },
|
|
|
dataViewConfig: { viewColumns: [], sortColumn: {}, sortType: 'asc' },
|
|
|
- barConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {} },
|
|
|
- lineConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {} },
|
|
|
+ barConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''} },
|
|
|
+ lineConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''} },
|
|
|
pieConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} } },
|
|
|
- scatterConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {} },
|
|
|
+ scatterConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''} },
|
|
|
styleConfig: { },
|
|
|
otherConfig:{ },
|
|
|
description: '',
|
|
|
@@ -314,7 +355,7 @@ export default {
|
|
|
*fetchBarData(action, { select, call, put }) {
|
|
|
try {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { code, barConfig } = chartDesigner;
|
|
|
+ const { code, barConfig, filters } = chartDesigner;
|
|
|
const body = {
|
|
|
id: code,
|
|
|
groups: barConfig.groupBy && barConfig.groupBy.key ? [barConfig.groupBy.key] : [],
|
|
|
@@ -326,14 +367,15 @@ export default {
|
|
|
yAxis: {
|
|
|
columnRename: barConfig.yAxis.column.value,
|
|
|
showDataType: barConfig.yAxis.gauge.value
|
|
|
- }
|
|
|
+ },
|
|
|
+ filters: getBodyFilters(filters)
|
|
|
};
|
|
|
- console.log(body);
|
|
|
|
|
|
let res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_BAR_OPTION,
|
|
|
body: body
|
|
|
});
|
|
|
+ console.log('请求柱状图数据', body, res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
let xTitle = barConfig.xAxis?`${barConfig.xAxis.column.label}${barConfig.xAxis.granularity.value?'('+barConfig.xAxis.granularity.label+')':''}`:null
|
|
|
let yTitle = barConfig.yAxis?`${barConfig.yAxis.column.label}${barConfig.yAxis.gauge.value?'('+barConfig.yAxis.gauge.label+')':''}`:null
|
|
|
@@ -359,7 +401,7 @@ export default {
|
|
|
*fetchPieData(action, { select, call, put }) {
|
|
|
try {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { code, pieConfig } = chartDesigner;
|
|
|
+ const { code, pieConfig, filters } = chartDesigner;
|
|
|
const body = {
|
|
|
id: code,
|
|
|
legendData: {
|
|
|
@@ -371,13 +413,14 @@ export default {
|
|
|
columnRename: pieConfig.yAxis.column.value,
|
|
|
columnName: pieConfig.yAxis.column.label,
|
|
|
showDataType: pieConfig.yAxis.gauge.value
|
|
|
- }
|
|
|
+ },
|
|
|
+ filters: getBodyFilters(filters)
|
|
|
};
|
|
|
let res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_PIE_OPTION,
|
|
|
body: body
|
|
|
});
|
|
|
-
|
|
|
+ console.log('请求饼图数据', body, res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
let columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
|
|
|
|
|
|
@@ -401,7 +444,7 @@ export default {
|
|
|
*fetchLineData(action, { select, call, put }) {
|
|
|
try {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { code, lineConfig } = chartDesigner;
|
|
|
+ const { code, lineConfig, filters } = chartDesigner;
|
|
|
const body = {
|
|
|
id: code,
|
|
|
xAxis: {
|
|
|
@@ -413,11 +456,13 @@ export default {
|
|
|
showDataType: lineConfig.yAxis.gauge.value
|
|
|
},
|
|
|
groups: lineConfig.groupBy && lineConfig.groupBy.key ? [lineConfig.groupBy.key] : [],
|
|
|
+ filters: getBodyFilters(filters)
|
|
|
};
|
|
|
let res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_LINE_OPTION,
|
|
|
body: body
|
|
|
});
|
|
|
+ console.log('请求折线图数据', body, res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
let xTitle = lineConfig.xAxis?`${lineConfig.xAxis.column.label}${lineConfig.xAxis.granularity.value?'('+lineConfig.xAxis.granularity.label+')':''}`:null
|
|
|
let yTitle = lineConfig.yAxis?`${lineConfig.yAxis.column.label}${lineConfig.yAxis.gauge.value?'('+lineConfig.yAxis.gauge.label+')':''}`:null
|
|
|
@@ -443,7 +488,7 @@ export default {
|
|
|
*fetchScatterData(action, { select, call, put }) {
|
|
|
try {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { code, scatterConfig } = chartDesigner;
|
|
|
+ const { code, scatterConfig, filters } = chartDesigner;
|
|
|
const body = {
|
|
|
id: code,
|
|
|
xAxis: {
|
|
|
@@ -455,13 +500,13 @@ export default {
|
|
|
showDataType: scatterConfig.yAxis.gauge.value
|
|
|
},
|
|
|
groups: scatterConfig.groupBy && scatterConfig.groupBy.key ? [scatterConfig.groupBy.key] : [],
|
|
|
+ filters: getBodyFilters(filters)
|
|
|
};
|
|
|
- console.log(body);
|
|
|
let res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_SCATTER_OPTION,
|
|
|
body: body
|
|
|
});
|
|
|
- console.log(res);
|
|
|
+ console.log('请求散点图数据', body, res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
res.viewType = 'scatter';
|
|
|
let xTitle = scatterConfig.xAxis?`${scatterConfig.xAxis.column.label}${scatterConfig.xAxis.granularity.value?'('+scatterConfig.xAxis.granularity.label+')':''}`:null
|
|
|
@@ -487,13 +532,14 @@ export default {
|
|
|
*fetchDataViewData(action, { select, call, put }) {
|
|
|
try {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { code, dataViewConfig } = chartDesigner;
|
|
|
+ const { code, dataViewConfig, filters } = chartDesigner;
|
|
|
const body = {
|
|
|
id: code,
|
|
|
columnListName: dataViewConfig.viewColumns.map(c => c.key),
|
|
|
sortColumn: dataViewConfig.sortColumn.key,
|
|
|
sort: dataViewConfig.sortType,
|
|
|
- showLine: dataViewConfig.count
|
|
|
+ showLine: dataViewConfig.count,
|
|
|
+ filters: getBodyFilters(filters)
|
|
|
};
|
|
|
let res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_DATAVIEW_OPTION,
|
|
|
@@ -534,7 +580,7 @@ export default {
|
|
|
*fetchAggregateTableData(action, { select, call, put }) {
|
|
|
try {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { code, aggregateTableConfig } = chartDesigner;
|
|
|
+ const { code, aggregateTableConfig, filters } = chartDesigner;
|
|
|
const { targetColumn, statistics } = aggregateTableConfig;
|
|
|
|
|
|
const body = {
|
|
|
@@ -542,6 +588,7 @@ export default {
|
|
|
columnName: targetColumn.name,
|
|
|
operatorList: statistics,
|
|
|
groupByList: aggregateTableConfig.groupBy && aggregateTableConfig.groupBy.length > 0 ? aggregateTableConfig.groupBy.map(g => g.key) : [],
|
|
|
+ filters: getBodyFilters(filters)
|
|
|
};
|
|
|
let res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_AGGREGATETABLE_OPTION,
|