|
|
@@ -209,7 +209,8 @@ export default {
|
|
|
dataConnectName: d.dataConnectionName,
|
|
|
access: d.authority === '1', // 权限
|
|
|
database: d.dbStatus === '0', // 数据源是否还存在
|
|
|
- type: CHART_TYPE[d.chartType],
|
|
|
+ // TODO 过渡方案
|
|
|
+ type: CHART_TYPE[d.chartType] || d.chartType,
|
|
|
creatorCode: d.createId + '',
|
|
|
creatorName: d.createBy,
|
|
|
createTime: d.createDate,
|
|
|
@@ -258,7 +259,8 @@ export default {
|
|
|
let chartConfig = JSON.parse(resData.chartConfig || '{ "xAxis": { "column": {}, "granularity": {} }, "yAxis": { "column": {}, "gauge": {} } }');
|
|
|
let styleConfig = JSON.parse(resData.style || '{}');
|
|
|
let otherConfig = JSON.parse(resData.otherConfig || '{}');
|
|
|
- let viewType = CHART_TYPE[resData.chartType];
|
|
|
+ // TODO 过渡方案
|
|
|
+ let viewType = CHART_TYPE[resData.chartType] || resData.chartType;
|
|
|
let filters = JSON.parse(resData.filters || '[]');
|
|
|
// let chartOption = JSON.parse(resData.chartOption || '{}');
|
|
|
let chartOption = {};
|
|
|
@@ -291,19 +293,7 @@ export default {
|
|
|
demo: resData.demo,
|
|
|
}
|
|
|
|
|
|
- if(viewType === 'bar') {
|
|
|
- data.barConfig = chartConfig;
|
|
|
- }else if(viewType === 'pie') {
|
|
|
- data.pieConfig = chartConfig;
|
|
|
- }else if(viewType === 'line') {
|
|
|
- data.lineConfig = chartConfig;
|
|
|
- }else if(viewType === 'scatter') {
|
|
|
- data.scatterConfig = chartConfig;
|
|
|
- }else if(viewType === 'aggregateTable') {
|
|
|
- data.aggregateTableConfig = chartConfig;
|
|
|
- }else if(viewType === 'dataView') {
|
|
|
- data.dataViewConfig = chartConfig;
|
|
|
- }
|
|
|
+ data[`${viewType}Config`] = chartConfig;
|
|
|
|
|
|
let fields = [];
|
|
|
for(let key in data) {
|
|
|
@@ -323,63 +313,11 @@ export default {
|
|
|
message.error('解析图表错误: ' + e.message);
|
|
|
}
|
|
|
},
|
|
|
- *remoteAdd(action, { select, call, put }) {
|
|
|
- try{
|
|
|
- const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { header, baseConfig, pieConfig, lineConfig, aggregateTableConfig, dataViewConfig,
|
|
|
- barConfig, scatterConfig, otherConfig, description, group, filters, chartOption } = chartDesigner;
|
|
|
- let body = {
|
|
|
- chartName: header.label,
|
|
|
- dataId: baseConfig.dataSource.code,
|
|
|
- describes: description,
|
|
|
- style: '{}',
|
|
|
- otherConfig: JSON.stringify(otherConfig),
|
|
|
- chartsGroup: group ? group : '-1',
|
|
|
- filters: JSON.stringify(filters),
|
|
|
- chartOption: JSON.stringify(chartOption),
|
|
|
- }; // 基本属性
|
|
|
- if(baseConfig.viewType === 'bar') {
|
|
|
- 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);
|
|
|
- }else if(baseConfig.viewType === 'scatter') {
|
|
|
- body.chartType = 'scatter';
|
|
|
- body.chartConfig = JSON.stringify(scatterConfig);
|
|
|
- }else if(baseConfig.viewType === 'aggregateTable') {
|
|
|
- body.chartType = 'population';
|
|
|
- body.chartConfig = JSON.stringify(aggregateTableConfig);
|
|
|
- }else if(baseConfig.viewType === 'dataView') {
|
|
|
- body.chartType = 'individual';
|
|
|
- body.chartConfig = JSON.stringify(dataViewConfig);
|
|
|
- }else {
|
|
|
- body.chartType = '';
|
|
|
- body.chartConfig = JSON.stringify({});
|
|
|
- }
|
|
|
- const res = yield call(service.fetch, {
|
|
|
- url: URLS.CHART_ADD,
|
|
|
- body: body
|
|
|
- })
|
|
|
- if(res.code > 0) {
|
|
|
- message.success('新增成功');
|
|
|
- yield put({ type: 'fetchList', mandatory: true });
|
|
|
- }else {
|
|
|
- message.error('新增失败: ' + res.msg);
|
|
|
- }
|
|
|
- }catch(e) {
|
|
|
- console.error(e);
|
|
|
- message.error('新增失败: ' + e.message);
|
|
|
- }
|
|
|
- },
|
|
|
*remoteModify(action, { select, call, put }) {
|
|
|
try{
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
- const { filters, code, header, baseConfig, pieConfig, lineConfig, aggregateTableConfig, dataViewConfig,
|
|
|
- barConfig, scatterConfig, otherConfig, description, group, chartOption, fetchConfig, styleConfig, thumbnail } = chartDesigner;
|
|
|
+ const { filters, code, header, baseConfig, otherConfig, description, group, chartOption,
|
|
|
+ fetchConfig, styleConfig, thumbnail } = chartDesigner;
|
|
|
let body = {
|
|
|
chartId: code,
|
|
|
filters: JSON.stringify(filters),
|
|
|
@@ -395,28 +333,12 @@ export default {
|
|
|
}; // 基本属性
|
|
|
let styleObj = {};
|
|
|
if(!!baseConfig.viewType) {
|
|
|
- styleObj[baseConfig.viewType] = styleConfig[baseConfig.viewType]
|
|
|
+ styleObj[baseConfig.viewType] = styleConfig[baseConfig.viewType];
|
|
|
+ body.chartType = baseConfig.viewType;
|
|
|
+ body.chartConfig = JSON.stringify(chartDesigner[`${baseConfig.viewType}Config`]);
|
|
|
}
|
|
|
body.style = JSON.stringify(styleObj);
|
|
|
- if(baseConfig.viewType === 'bar') {
|
|
|
- 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);
|
|
|
- }else if(baseConfig.viewType === 'scatter') {
|
|
|
- body.chartType = 'scatter';
|
|
|
- body.chartConfig = JSON.stringify(scatterConfig);
|
|
|
- }else if(baseConfig.viewType === 'aggregateTable') {
|
|
|
- body.chartType = 'population';
|
|
|
- body.chartConfig = JSON.stringify(aggregateTableConfig);
|
|
|
- }else if(baseConfig.viewType === 'dataView') {
|
|
|
- body.chartType = 'individual';
|
|
|
- body.chartConfig = JSON.stringify(dataViewConfig);
|
|
|
- }
|
|
|
+
|
|
|
const res = yield call(service.fetch, {
|
|
|
url: URLS.CHART_UPDATE,
|
|
|
body: body
|