|
|
@@ -80,10 +80,21 @@ export default {
|
|
|
},
|
|
|
reducers: {
|
|
|
/**
|
|
|
- * 初始化model字段值
|
|
|
- * 设置撤销重做的起点,不进入撤销重做的历史
|
|
|
+ * 更新model字段值
|
|
|
+ * 1. 进入撤销重做历史
|
|
|
*/
|
|
|
- defaultSetFields(state, action) {
|
|
|
+ setField(state, action) {
|
|
|
+ const { name, value } = action;
|
|
|
+ let obj = {};
|
|
|
+ obj[name] = value;
|
|
|
+ let newState = Object.assign({}, state, obj);
|
|
|
+ return newState;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 批量更新model字段值
|
|
|
+ * 1. 进入撤销重做历史
|
|
|
+ */
|
|
|
+ setFields(state, action) {
|
|
|
const { fields } = action;
|
|
|
let obj = {};
|
|
|
fields.map(f => (obj[f.name] = f.value));
|
|
|
@@ -91,11 +102,10 @@ export default {
|
|
|
return newState;
|
|
|
},
|
|
|
/**
|
|
|
- * 更新model字段值方法1
|
|
|
- * 1. 为保持撤销重做的功能有效性,能够撤销重做的action动作才使用该方法
|
|
|
- * 2. 对数据刷新没有影响的model字段改变一般用该action
|
|
|
+ * 更新model字段值
|
|
|
+ * 1. 不进入撤销重做历史
|
|
|
*/
|
|
|
- setField(state, action) {
|
|
|
+ silentSetField(state, action) {
|
|
|
const { name, value } = action;
|
|
|
let obj = {};
|
|
|
obj[name] = value;
|
|
|
@@ -103,42 +113,18 @@ export default {
|
|
|
return newState;
|
|
|
},
|
|
|
/**
|
|
|
- * 批量更新model字段值方法1
|
|
|
+ * 批量更新model字段值
|
|
|
+ * 1. 不进入撤销重做历史
|
|
|
*/
|
|
|
- setFields(state, action) {
|
|
|
+ silentSetFields(state, action) {
|
|
|
const { fields } = action;
|
|
|
let obj = {};
|
|
|
fields.map(f => (obj[f.name] = f.value));
|
|
|
let newState = Object.assign({}, state, obj);
|
|
|
return newState;
|
|
|
},
|
|
|
- setDataSource(state, action) {
|
|
|
- const { value } = action;
|
|
|
- let obj = {};
|
|
|
- obj['baseConfig'] = value;
|
|
|
- return Object.assign({}, state, obj);
|
|
|
- },
|
|
|
- setColumns(state, action) {
|
|
|
- const { value } = action;
|
|
|
- let obj = {};
|
|
|
- obj['columns'] = value;
|
|
|
- return Object.assign({}, state, obj);
|
|
|
- },
|
|
|
- setAutoRefresh(state, action) {
|
|
|
- const { value } = action;
|
|
|
- let obj = {};
|
|
|
- obj['autoRefresh'] = value;
|
|
|
- return Object.assign({}, state, obj);
|
|
|
- },
|
|
|
- setChartOption(state, action) {
|
|
|
- const { option } = action;
|
|
|
- let obj = {};
|
|
|
- obj['chartOption'] = option;
|
|
|
- return Object.assign({}, state, obj);
|
|
|
- },
|
|
|
reset(state, action) {
|
|
|
let obj = Object.assign({}, state, state.originData);
|
|
|
- console.log(obj);
|
|
|
return obj;
|
|
|
}
|
|
|
},
|
|
|
@@ -149,7 +135,7 @@ export default {
|
|
|
*/
|
|
|
*defaultChangeFields(action, { select, call, put }) {
|
|
|
const { fields } = action;
|
|
|
- yield put({ type: 'defaultSetFields', fields });
|
|
|
+ yield put({ type: 'silentSetFields', fields });
|
|
|
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
const { autoRefresh } = chartDesigner;
|
|
|
@@ -158,7 +144,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
- * 更新model字段值方法2
|
|
|
+ * 更新model字段值
|
|
|
* 可能影响到数据刷新的model字段改变一般用该action
|
|
|
*/
|
|
|
*changeField(action, { select, call, put }) {
|
|
|
@@ -173,7 +159,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
- * 批量更新model字段值方法2
|
|
|
+ * 批量更新model字段值
|
|
|
*/
|
|
|
*changeFields(action, { select, call, put }) {
|
|
|
const { fields } = action;
|
|
|
@@ -187,9 +173,48 @@ export default {
|
|
|
},
|
|
|
*changeDataSource(action, { select, call, put }) {
|
|
|
const { value } = action;
|
|
|
- yield put({ type: 'setDataSource', value });
|
|
|
+ yield put({ type: 'silentSetField', name: 'baseConfig', value });
|
|
|
yield put({ type: 'remoteDataColumn', code: value.dataSource });
|
|
|
},
|
|
|
+ *remoteQucikAdd(action, { select, call, put }) {
|
|
|
+ try{
|
|
|
+ const { dataSource } = action;
|
|
|
+
|
|
|
+ yield put({ type: 'silentSetFields', fields: [
|
|
|
+ { name: 'baseConfig', value: { dataSource: dataSource.code, viewType: '' } }
|
|
|
+ ] });
|
|
|
+ const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
+ const { baseConfig, preparing } = chartDesigner;
|
|
|
+
|
|
|
+ let body = {
|
|
|
+ chartName: dataSource.name + '(未命名)',
|
|
|
+ dataId: baseConfig.dataSource,
|
|
|
+ groupBy: preparing.groupBy && preparing.groupBy.key ? [{
|
|
|
+ columnName: preparing.groupBy.key,
|
|
|
+ columnRamane: preparing.groupBy.label
|
|
|
+ }] : [],
|
|
|
+ createBy: 'zhuth',
|
|
|
+ describes: '',
|
|
|
+ style: '',
|
|
|
+ chartConfig: '{}',
|
|
|
+ chartType: ''
|
|
|
+ };
|
|
|
+ const res = yield call(service.fetch, {
|
|
|
+ url: URLS.CHART_ADD,
|
|
|
+ body: body
|
|
|
+ })
|
|
|
+ if(!res.err && res.data.code > 0) {
|
|
|
+ yield put({ type: 'chart/fetchList', mandatory: true });
|
|
|
+ // TODO
|
|
|
+ // yield put({ type: 'main/redirect', path: '/chart/' + 32 });
|
|
|
+ }else {
|
|
|
+ message.error('新增失败');
|
|
|
+ }
|
|
|
+ }catch(e) {
|
|
|
+ console.error(e);
|
|
|
+ message.error('新增失败');
|
|
|
+ }
|
|
|
+ },
|
|
|
*remoteAdd(action, { select, call, put }) {
|
|
|
try{
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
@@ -198,7 +223,7 @@ export default {
|
|
|
let body = {
|
|
|
chartName: header.label,
|
|
|
dataId: baseConfig.dataSource,
|
|
|
- groupBy: preparing.groupBy ? [{
|
|
|
+ groupBy: preparing.groupBy && preparing.groupBy.key ? [{
|
|
|
columnName: preparing.groupBy.key,
|
|
|
columnRamane: preparing.groupBy.label
|
|
|
}] : [],
|
|
|
@@ -223,7 +248,8 @@ export default {
|
|
|
})
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
message.success('新增成功!');
|
|
|
- yield put({ type: 'chart/fetchList' });
|
|
|
+ // yield put({ type: 'silentSetField', name: 'code', value: code });
|
|
|
+ yield put({ type: 'chart/fetchList', mandatory: true });
|
|
|
}else {
|
|
|
message.error('新增失败');
|
|
|
}
|
|
|
@@ -265,7 +291,7 @@ export default {
|
|
|
})
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
message.success('修改成功!');
|
|
|
- yield put({ type: 'chart/fetchList' });
|
|
|
+ yield put({ type: 'chart/fetchList', mandatory: true });
|
|
|
}
|
|
|
}catch(e) {
|
|
|
console.log(e);
|
|
|
@@ -291,7 +317,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
console.log(columns);
|
|
|
- yield put({ type: 'setColumns', value: columns });
|
|
|
+ yield put({ type: 'silentSetField', name: 'columns', value: columns });
|
|
|
}else {
|
|
|
console.log(res);
|
|
|
}
|
|
|
@@ -321,7 +347,7 @@ export default {
|
|
|
const { barConfig, preparing } = chartDesigner;
|
|
|
const body = {
|
|
|
tableName: "TEST_BI_DATA",
|
|
|
- groups: preparing.groupBy ? [preparing.groupBy.key] : [],
|
|
|
+ groups: preparing.groupBy && preparing.groupBy.key ? [preparing.groupBy.key] : [],
|
|
|
xAxis: {
|
|
|
columnRename: barConfig.xAxis.column.value,
|
|
|
columnType: barConfig.xAxis.column.type,
|
|
|
@@ -343,13 +369,13 @@ export default {
|
|
|
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}${barConfig.yAxis.gauge.value?'('+barConfig.yAxis.gauge.label+')':''}`:null
|
|
|
- yield put({ type: 'setChartOption', option: res });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: res });
|
|
|
}else {
|
|
|
- yield put({ type: 'setChartOption', option: {} });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
}catch(e) {
|
|
|
console.error(e);
|
|
|
- yield put({ type: 'setChartOption', option: {} });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
},
|
|
|
*fetchPieData(action, { select, call, put }) {
|
|
|
@@ -379,13 +405,13 @@ export default {
|
|
|
console.log('res: ', res);
|
|
|
res.viewType = 'pie';
|
|
|
res.data.data.columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
|
|
|
- yield put({ type: 'setChartOption', option: res });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: res });
|
|
|
}else {
|
|
|
- yield put({ type: 'setChartOption', option: {} });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
}catch(e) {
|
|
|
console.error(e);
|
|
|
- yield put({ type: 'setChartOption', option: {} });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
},
|
|
|
*fetchLineData(action, { select, call, put }) {
|
|
|
@@ -403,7 +429,7 @@ export default {
|
|
|
columnRename: lineConfig.yAxis.column.value,
|
|
|
showDataType: lineConfig.yAxis.gauge.value
|
|
|
},
|
|
|
- groups: preparing.groupBy ? [preparing.groupBy.key] : []
|
|
|
+ groups: preparing.groupBy && preparing.groupBy.key ? [preparing.groupBy.key] : [],
|
|
|
};
|
|
|
console.log('lineBody: ', body);
|
|
|
let res = yield call(service.fetch, {
|
|
|
@@ -413,14 +439,13 @@ export default {
|
|
|
console.log('line res', res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
res.viewType = 'line';
|
|
|
- // res.data.data.columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
|
|
|
- yield put({ type: 'setChartOption', option: res });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: res });
|
|
|
}else {
|
|
|
- yield put({ type: 'setChartOption', option: {} });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
}catch(e) {
|
|
|
console.error(e);
|
|
|
- yield put({ type: 'setChartOption', option: {} });
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
}
|
|
|
},
|