Browse Source

创建图表时将当前分组设为图表默认分组

zhuth 6 years ago
parent
commit
df518803fe
2 changed files with 9 additions and 5 deletions
  1. 4 4
      src/components/chart/chooseDataSourceBox.jsx
  2. 5 1
      src/models/chartDesigner.js

+ 4 - 4
src/components/chart/chooseDataSourceBox.jsx

@@ -42,9 +42,9 @@ class ChooseDataSourceBox extends React.Component {
 
     okHandler = (model) => {
         const { selectedRecord } = this.state;
-        const { dispatch, hideBox } = this.props;
+        const { dispatch, chart, hideBox } = this.props;
         if(selectedRecord) {
-            dispatch({ type: 'chartDesigner/remoteQucikAdd', dataSource: selectedRecord });
+            dispatch({ type: 'chartDesigner/remoteQucikAdd', dataSource: selectedRecord, group: chart.currentGroup });
             hideBox();
         }else {
             message.warning('未选中数据源');
@@ -237,8 +237,8 @@ class ChooseDataSourceBox extends React.Component {
     }
 }
 
-function mapStateToProps({ present: { dataSource } }) {
-    return { dataSource: dataSource };
+function mapStateToProps({ present: { dataSource, chart } }) {
+    return { dataSource, chart };
 }
 
 export default connect(mapStateToProps)(ChooseDataSourceBox)

+ 5 - 1
src/models/chartDesigner.js

@@ -163,7 +163,7 @@ export default {
         },
         *remoteQucikAdd(action, { select, call, put }) {
             try{
-                const { dataSource } = action;
+                const { dataSource, group } = action;
 
                 yield put({ type: 'silentSetFields', fields: [
                     { name: 'baseConfig', value: { dataSource: dataSource.code, viewType: '' } }
@@ -174,11 +174,15 @@ export default {
                     describes: '',
                     chartConfig: '{}',
                     chartType: '',
+                    chartsGroup: group ? group.code : '-1',
                 };
+                yield put({ type: 'chart/setField', name: 'listLoading', value: true });
                 const res = yield call(service.fetch, {
                     url: URLS.CHART_ADD,
                     body: body
                 })
+                yield put({ type: 'chart/setField', name: 'listLoading', value: false });
+
                 if(res.data > 0) {
                     yield put({ type: 'chart/fetchList', mandatory: true });
                     yield put({ type: 'main/redirect', path: '/chart/' + res.data });