|
|
@@ -13,6 +13,7 @@ export default {
|
|
|
aggregateTableConfig: {},
|
|
|
dataViewConfig: {},
|
|
|
barConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} } },
|
|
|
+ lineConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} } },
|
|
|
pieConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} } },
|
|
|
style: {},
|
|
|
filters: [],
|
|
|
@@ -50,6 +51,16 @@ export default {
|
|
|
gauge: {}
|
|
|
}
|
|
|
},
|
|
|
+ lineConfig: {
|
|
|
+ xAxis: {
|
|
|
+ column: {},
|
|
|
+ granularity: {}
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ column: {},
|
|
|
+ gauge: {}
|
|
|
+ }
|
|
|
+ },
|
|
|
pieConfig: {
|
|
|
xAxis: {
|
|
|
column: {},
|
|
|
@@ -182,42 +193,30 @@ export default {
|
|
|
*remoteAdd(action, { select, call, put }) {
|
|
|
try{
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { header, baseConfig, preparing, barConfig } = chartDesigner;
|
|
|
- let body = {}; // 基本属性
|
|
|
+ const { header, baseConfig, preparing, barConfig, pieConfig, lineConfig } = chartDesigner;
|
|
|
+
|
|
|
+ let body = {
|
|
|
+ chartName: header.label,
|
|
|
+ dataId: baseConfig.dataSource,
|
|
|
+ groupBy: preparing.groupBy ? [{
|
|
|
+ columnName: preparing.groupBy.key,
|
|
|
+ columnRamane: preparing.groupBy.label
|
|
|
+ }] : [],
|
|
|
+ createBy: 'zhuth',
|
|
|
+ describes: '',
|
|
|
+ style: ''
|
|
|
+ }; // 基本属性
|
|
|
if(baseConfig.viewType === 'bar') {
|
|
|
- body = {
|
|
|
- chartName: header.label,
|
|
|
- chartType: 'Histogram',
|
|
|
- dataId: baseConfig.dataSource,
|
|
|
- groupBy: preparing.groupBy.map(g => {
|
|
|
- return {
|
|
|
- columnName: g.key,
|
|
|
- columnRamane: g.label
|
|
|
- }
|
|
|
- }),
|
|
|
- chartConfig: {
|
|
|
- xAxis: {
|
|
|
- columnName: barConfig.xAxis.column.value,
|
|
|
- columnRename: barConfig.xAxis.column.label,
|
|
|
- columnType: barConfig.xAxis.column.type,
|
|
|
- showDataType: barConfig.xAxis.granularity.value,
|
|
|
- showDataLable: barConfig.xAxis.granularity.label
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- columnName: barConfig.yAxis.column.value,
|
|
|
- columnRename: barConfig.yAxis.column.label,
|
|
|
- columnType: barConfig.yAxis.column.type,
|
|
|
- showDataType: barConfig.yAxis.gauge.value,
|
|
|
- showDataLable: barConfig.yAxis.gauge.label
|
|
|
- }
|
|
|
- },
|
|
|
- isLegend: 1,
|
|
|
- isTooltip: 1,
|
|
|
- isToolbox: 1,
|
|
|
- createBy: "zhuth",
|
|
|
- describes: ""
|
|
|
- }
|
|
|
+ body.chartType = 'Histogram';
|
|
|
+ body.chartConfig = JSON.stringify(barConfig);
|
|
|
+ }else if(baseConfig.viewType === 'pie') {
|
|
|
+ body.chartType = 'Pie';
|
|
|
+ body.chartConfig = JSON.stringify(pieConfig);
|
|
|
+ }else if(baseConfig.viewType === 'line') {
|
|
|
+ body.chartType = 'Line';
|
|
|
+ body.chartConfig = JSON.stringify(lineConfig);
|
|
|
}
|
|
|
+ console.log('remoteAdd-body', body);
|
|
|
const res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_ADD,
|
|
|
body: body
|
|
|
@@ -225,50 +224,39 @@ export default {
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
message.success('新增成功!');
|
|
|
yield put({ type: 'chart/fetchList' });
|
|
|
+ }else {
|
|
|
+ message.error('新增失败');
|
|
|
}
|
|
|
}catch(e) {
|
|
|
- console.log(e);
|
|
|
+ console.error(e);
|
|
|
+ message.error('新增失败');
|
|
|
}
|
|
|
},
|
|
|
*remoteModify(action, { select, call, put }) {
|
|
|
try{
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { code, header, baseConfig, preparing, barConfig } = chartDesigner;
|
|
|
- let body = {}; // 基本属性
|
|
|
+ const { code, header, baseConfig, pieConfig, lineConfig, preparing, barConfig } = chartDesigner;
|
|
|
+ let body = {
|
|
|
+ chartId: code,
|
|
|
+ chartName: header.label,
|
|
|
+ dataId: baseConfig.dataSource,
|
|
|
+ groupBy: preparing.groupBy ? [{
|
|
|
+ columnName: preparing.groupBy.key,
|
|
|
+ columnRamane: preparing.groupBy.label
|
|
|
+ }] : [],
|
|
|
+ createBy: 'zhuth',
|
|
|
+ describes: '',
|
|
|
+ style: ''
|
|
|
+ }; // 基本属性
|
|
|
if(baseConfig.viewType === 'bar') {
|
|
|
- body = {
|
|
|
- chartId: code,
|
|
|
- chartName: header.label,
|
|
|
- chartType: 'Histogram',
|
|
|
- dataId: baseConfig.dataSource,
|
|
|
- groupBy: preparing.groupBy.map(g => {
|
|
|
- return {
|
|
|
- columnName: g.key,
|
|
|
- columnRamane: g.label
|
|
|
- }
|
|
|
- }),
|
|
|
- chartConfig: {
|
|
|
- xAxis: {
|
|
|
- columnName: barConfig.xAxis.column.value,
|
|
|
- columnRename: barConfig.xAxis.column.label,
|
|
|
- columnType: barConfig.xAxis.column.type,
|
|
|
- showDataType: barConfig.xAxis.granularity.value,
|
|
|
- showDataLable: barConfig.xAxis.granularity.label
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- columnName: barConfig.yAxis.column.value,
|
|
|
- columnRename: barConfig.yAxis.column.label,
|
|
|
- columnType: barConfig.yAxis.column.type,
|
|
|
- showDataType: barConfig.yAxis.gauge.value,
|
|
|
- showDataLable: barConfig.yAxis.gauge.label
|
|
|
- }
|
|
|
- },
|
|
|
- isLegend: 1,
|
|
|
- isTooltip: 1,
|
|
|
- isToolbox: 1,
|
|
|
- createBy: "zhuth",
|
|
|
- describes: ""
|
|
|
- }
|
|
|
+ body.chartType = 'Histogram';
|
|
|
+ body.chartConfig = JSON.stringify(barConfig);
|
|
|
+ }else if(baseConfig.viewType === 'pie') {
|
|
|
+ body.chartType = 'Pie';
|
|
|
+ body.chartConfig = JSON.stringify(pieConfig);
|
|
|
+ }else if(baseConfig.viewType === 'line') {
|
|
|
+ body.chartType = 'Line';
|
|
|
+ body.chartConfig = JSON.stringify(lineConfig);
|
|
|
}
|
|
|
console.log(body);
|
|
|
const res = yield call(service.fetch, {
|
|
|
@@ -332,16 +320,16 @@ export default {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
const { barConfig, preparing } = chartDesigner;
|
|
|
const body = {
|
|
|
- "tableName": "TEST_BI_DATA",
|
|
|
- "groups": preparing.groupBy.key ? [preparing.groupBy.key] : [],
|
|
|
- "xAxis": {
|
|
|
- "columnRename": barConfig.xAxis.column.value,
|
|
|
- "columnType": barConfig.xAxis.column.type,
|
|
|
- "showDataType": barConfig.xAxis.granularity.value
|
|
|
+ tableName: "TEST_BI_DATA",
|
|
|
+ groups: preparing.groupBy ? [preparing.groupBy.key] : [],
|
|
|
+ xAxis: {
|
|
|
+ columnRename: barConfig.xAxis.column.value,
|
|
|
+ columnType: barConfig.xAxis.column.type,
|
|
|
+ showDataType: barConfig.xAxis.granularity.value
|
|
|
},
|
|
|
- "yAxis": {
|
|
|
- "columnRename": barConfig.yAxis.column.value,
|
|
|
- "showDataType": barConfig.yAxis.gauge.value
|
|
|
+ yAxis: {
|
|
|
+ columnRename: barConfig.yAxis.column.value,
|
|
|
+ showDataType: barConfig.yAxis.gauge.value
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -393,48 +381,45 @@ export default {
|
|
|
res.data.data.columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
|
|
|
yield put({ type: 'setChartOption', option: res });
|
|
|
}else {
|
|
|
- yield put({ type: 'setChartOption', option: res });
|
|
|
+ yield put({ type: 'setChartOption', option: {} });
|
|
|
}
|
|
|
}catch(e) {
|
|
|
+ console.error(e);
|
|
|
yield put({ type: 'setChartOption', option: {} });
|
|
|
}
|
|
|
},
|
|
|
*fetchLineData(action, { select, call, put }) {
|
|
|
try {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { lineConfig, pieConfig } = chartDesigner;
|
|
|
+ const { lineConfig, preparing } = chartDesigner;
|
|
|
+ console.log(lineConfig);
|
|
|
const body = {
|
|
|
tableName: "TEST_BI_DATA",
|
|
|
- xAxis:{
|
|
|
+ xAxis: {
|
|
|
columnRename: lineConfig.xAxis.column.value,
|
|
|
columnType: lineConfig.xAxis.column.type
|
|
|
},
|
|
|
- legendData: {
|
|
|
- columnRename: pieConfig.xAxis.column.value,
|
|
|
- columnType: pieConfig.xAxis.column.type,
|
|
|
- showDataType: pieConfig.xAxis.granularity.value
|
|
|
+ yAxis: {
|
|
|
+ columnRename: lineConfig.yAxis.column.value,
|
|
|
+ showDataType: lineConfig.yAxis.gauge.value
|
|
|
},
|
|
|
- series: {
|
|
|
- columnRename: pieConfig.yAxis.column.value,
|
|
|
- columnName: pieConfig.yAxis.column.label,
|
|
|
- showDataType: pieConfig.yAxis.gauge.value
|
|
|
- }
|
|
|
+ groups: preparing.groupBy ? [preparing.groupBy.key] : []
|
|
|
};
|
|
|
- console.log(body);
|
|
|
+ console.log('lineBody: ', body);
|
|
|
let res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_LINE_OPTION,
|
|
|
body: body
|
|
|
});
|
|
|
-
|
|
|
+ console.log('line res', res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
- console.log('res: ', res);
|
|
|
res.viewType = 'line';
|
|
|
- res.data.data.columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
|
|
|
+ // res.data.data.columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
|
|
|
yield put({ type: 'setChartOption', option: res });
|
|
|
}else {
|
|
|
- yield put({ type: 'setChartOption', option: res });
|
|
|
+ yield put({ type: 'setChartOption', option: {} });
|
|
|
}
|
|
|
}catch(e) {
|
|
|
+ console.error(e);
|
|
|
yield put({ type: 'setChartOption', option: {} });
|
|
|
}
|
|
|
}
|