Bladeren bron

调整图标设置界面的撤销重做对象为配置项的更改操作

zhuth 7 jaren geleden
bovenliggende
commit
e72c08d272
3 gewijzigde bestanden met toevoegingen van 51 en 77 verwijderingen
  1. 1 30
      app/components/datasource/accessConfig.jsx
  2. 5 2
      app/index.js
  3. 45 45
      app/models/chartDesigner.js

+ 1 - 30
app/components/datasource/accessConfig.jsx

@@ -40,36 +40,7 @@ const DataSourceAccessConfig = ({ dataSource, dispatch }) => {
     );
 
     return (
-        <Form size='small'>
-            <FormItem label='数据源名称' {...formItemLayout}>
-                <Input
-                    value={dataSource.newOne.name}
-                    onChange={(e) => { dispatch({ type: 'dataSource/setNewModelField', name: 'name', value: e.target.value }) }}>
-                </Input>
-            </FormItem>
-            <FormItem label='自定义标签' {...formItemLayout}>
-                <Select
-                    mode="tags"
-                    placeholder='多个标签使用逗号或空格分隔'
-                    tokenSeparators={[',', ' ']}
-                    value={dataSource.newOne.tags}
-                    dropdownStyle={{display: 'none'}}
-                    onChange={(value) => {
-                        dispatch({ type: 'dataSource/setNewModelField', name: 'tags', value: value });
-                    }}
-                >
-                </Select>
-            </FormItem>
-            <FormItem className='textarea-desc' label='说明' {...formItemLayout}>
-                <Input.TextArea
-                    autosize={{ minRows: 2, maxRows: 2 }}
-                    value={dataSource.newOne.description}
-                    onChange={(e) => {
-                        dispatch({ type: 'dataSource/setNewModelField', name: 'description', value: e.target.value });
-                    }}
-                />
-            </FormItem>
-        </Form>
+        <div>Null</div>
     );
 }
 

+ 5 - 2
app/index.js

@@ -1,5 +1,5 @@
 import dva from 'dva'
-import undoable from 'redux-undo'
+import undoable, { distinctState, includeAction, excludeAction } from 'redux-undo'
 import main from './models/main'
 import chartDesigner from './models/chartDesigner'
 import dataSource from './models/dataSource'
@@ -10,7 +10,10 @@ import './index.less'
 // 1. Initialize
 const app = dva({
     onReducer: reducer => (state, action) => {
-        const newState = undoable(reducer, {})(state, action);
+        const newState = undoable(reducer, {
+            limit: 10,
+            filter: includeAction('chartDesigner/setModel'),
+        })(state, action);
         return { ...newState };
     },
 });

+ 45 - 45
app/models/chartDesigner.js

@@ -98,15 +98,38 @@ export default {
             obj[name] = value;
             let newState = Object.assign({}, state, obj);
             return newState;
+        },
+        setChartOption(state, action) {
+            const { option } = action;
+            let obj = {};
+            obj['chartOption'] = option;
+            let newState = Object.assign({}, state, obj);
+            return newState;
         }
     },
     effects: {
         *['fetchChartData'](action, { select, call, put }) {
-            const chartDesigner = yield select(state => state.present.chartDesigner);
-            const { barConfig, preparing } = chartDesigner;
-            const res = yield call(service.fetch, {
-                url: URLS.CHART_BAR_OPTION,
-                body: {
+            try {
+                const chartDesigner = yield select(state => state.present.chartDesigner);
+                const { barConfig, preparing } = chartDesigner;
+                const res = yield call(service.fetch, {
+                    url: URLS.CHART_BAR_OPTION,
+                    body: {
+                        "tableName": "TEST_BI_DATA",
+                        "groups": preparing.groupBy.map(g => g.key),
+                        "xAxis": {
+                            "columnRename": barConfig.xAxis.column.value,
+                            "columnType": barConfig.xAxis.column.type,
+                            "dataType": barConfig.xAxis.granularity.value
+                        },
+                        "yAxis": {
+                            "columnRename": barConfig.yAxis.column.value,
+                            "dataType": barConfig.yAxis.gauge.value
+                        }
+                    }
+                });
+
+                console.log({
                     "tableName": "TEST_BI_DATA",
                     "groups": preparing.groupBy.map(g => g.key),
                     "xAxis": {
@@ -118,51 +141,28 @@ export default {
                         "columnRename": barConfig.yAxis.column.value,
                         "dataType": barConfig.yAxis.gauge.value
                     }
-                }
-            });
-
-            console.log({
-                "tableName": "TEST_BI_DATA",
-                "groups": preparing.groupBy.map(g => g.key),
-                "xAxis": {
-                    "columnRename": barConfig.xAxis.column.value,
-                    "columnType": barConfig.xAxis.column.type,
-                    "dataType": barConfig.xAxis.granularity.value
-                },
-                "yAxis": {
-                    "columnRename": barConfig.yAxis.column.value,
-                    "dataType": barConfig.yAxis.gauge.value
-                }
-            })
-            if(!res.err && res.data.code > 0) {
+                })
+                
                 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:null;
                 res.data.data.gauge = barConfig.yAxis?barConfig.yAxis.gauge.label:null;
-                yield put({ type: 'setModel', name: 'chartOption', value: res });
-            }else {
-                yield put({ type: 'setModel', name: 'chartOption', value: {} });
-                // 弹出错误提示
+                yield put({ type: 'setChartOption', option: res });
+
+            }catch(e) {
+                yield put({ type: 'setChartOption', option: {} });
             }
-        },
-        *test({payload:todo},{put,call}){
-           
-            yield put({type:'filters/setUsing', action: { key: 0 }})
-        },
-        *fetch({ payload: { page = 1 } }, { call, put }) {
-            const { data, headers } = yield call(usersService.fetch, { page });
-            yield put({
-                type: 'save',
-                payload: {
-                    data,
-                    total: parseInt(headers['x-total-count'], 10),
-                    page: parseInt(page, 10),
-                },
-            });
-        },
-        * redirect (action, { put }) {
-            yield put(routerRedux.push(action.path || '/'));
-        },
+            // if(!res.err && res.data.code > 0) {
+            //     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:null;
+            //     res.data.data.gauge = barConfig.yAxis?barConfig.yAxis.gauge.label:null;
+            //     yield put({ type: 'setChartOption', option: res });
+            // }else {
+            //     yield put({ type: 'setChartOption', option: {} });
+            //     // 弹出错误提示
+            // }
+        }
     },
     subscriptions: {
         setup({ dispatch, history }) {