|
|
@@ -285,16 +285,31 @@ export default {
|
|
|
};
|
|
|
return { ...state, items };
|
|
|
},
|
|
|
- setItemChartOption(state, action) {
|
|
|
- const { code, chartOption } = action
|
|
|
+ setItemField(state, action) {
|
|
|
+ const { code, name, value } = action;
|
|
|
const { items } = state;
|
|
|
let index = items.findIndex(item => item.code === code);
|
|
|
+ const targetItem = items[index];
|
|
|
+ targetItem[name] = value;
|
|
|
+
|
|
|
items[index] = {
|
|
|
- ...items[index],
|
|
|
- chartOption
|
|
|
+ ...targetItem
|
|
|
};
|
|
|
return { ...state, items };
|
|
|
- }
|
|
|
+ },
|
|
|
+ setItemFields(state, action) {
|
|
|
+ const { code, fields } = action;
|
|
|
+ const { items } = state;
|
|
|
+ let index = items.findIndex(item => item.code === code);
|
|
|
+ const targetItem = items[index];
|
|
|
+ fields.forEach(field => {
|
|
|
+ targetItem[field.name] = field.value;
|
|
|
+ });
|
|
|
+ items[index] = {
|
|
|
+ ...targetItem
|
|
|
+ };
|
|
|
+ return { ...state, items };
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
effects: {
|
|
|
@@ -366,7 +381,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
*fetchChartData(action, { put, call, select }) {
|
|
|
- const { item } = action;
|
|
|
+ const { item, mandatory } = action;
|
|
|
const dashboardDesigner = yield select(state => state.present.dashboardDesigner);
|
|
|
const { filters, relationColumns } = dashboardDesigner;
|
|
|
const { chartCode } = item;
|
|
|
@@ -374,9 +389,9 @@ export default {
|
|
|
dashCreateId: chartCode,
|
|
|
filters: getBodyFilters(getTrueFilters(item, filters, relationColumns))
|
|
|
};
|
|
|
- // if(!mandatory && !!item.chartOption) {
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ if(!mandatory && !!item.chartOption) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
yield put({ type: 'setItemFetching', code: chartCode, fetching: true });
|
|
|
@@ -388,18 +403,29 @@ export default {
|
|
|
console.log('看板请求图表展示数据', body, res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
let resData = res.data.data;
|
|
|
- const { chartType } = resData.chartsColumnConfig;
|
|
|
- let chartOption = parseChartOption(CHART_TYPE[chartType], resData, JSON.parse(resData.chartsColumnConfig.chartConfig));
|
|
|
+ const { chartType : ctype, chartConfig: cfg } = resData.chartsColumnConfig;
|
|
|
+ const chartType = CHART_TYPE[ctype];
|
|
|
+ const chartConfig = JSON.parse(cfg);
|
|
|
+ let chartOption = parseChartOption(chartType, resData, chartConfig);
|
|
|
|
|
|
- yield put({ type: 'setItemChartOption', code: chartCode, chartOption });
|
|
|
+ yield put({ type: 'setItemFields', code: chartCode, fields: [
|
|
|
+ { name: 'chartType', value: chartType },
|
|
|
+ { name: 'chartOption', value: chartOption }
|
|
|
+ ] });
|
|
|
}else {
|
|
|
- yield put({ type: 'setItemChartOption', code: chartCode, chartOption: {} });
|
|
|
+ yield put({ type: 'setItemFields', code: chartCode, fields: [
|
|
|
+ { name: 'chartType', value: '' },
|
|
|
+ { name: 'chartOption', value: {} }
|
|
|
+ ] });
|
|
|
console.error(body, res.err || res.data.msg);
|
|
|
message.error('请求图表展示数据失败: ' + (res.err || res.data.msg));
|
|
|
}
|
|
|
}catch(e) {
|
|
|
console.error(body, e);
|
|
|
- yield put({ type: 'setItemChartOption', code: chartCode, chartOption: {} });
|
|
|
+ yield put({ type: 'setItemFields', code: chartCode, fields: [
|
|
|
+ { name: 'chartType', value: '' },
|
|
|
+ { name: 'chartOption', value: {} }
|
|
|
+ ] });
|
|
|
message.error('请求图表展示数据失败: ' + e);
|
|
|
}finally {
|
|
|
yield put({ type: 'setItemFetching', code: chartCode, fetching: false });
|