Browse Source

图表dataview列选择器功能调整/筛选器时间类型清空bug调整

zhuth 7 years ago
parent
commit
bc855c55ef

File diff suppressed because it is too large
+ 0 - 2
public/fonts/iconfont/custom/iconfont.css


BIN
public/fonts/iconfont/custom/iconfont.eot


File diff suppressed because it is too large
+ 0 - 0
public/fonts/iconfont/custom/iconfont.js


File diff suppressed because it is too large
+ 0 - 0
public/fonts/iconfont/custom/iconfont.svg


BIN
public/fonts/iconfont/custom/iconfont.ttf


BIN
public/fonts/iconfont/custom/iconfont.woff


+ 1 - 0
src/components/chartDesigner/sections/dataViewConfigForm.jsx

@@ -80,6 +80,7 @@ class DataViewConfigForm extends React.Component {
 					autoRefresh={autoRefresh} 
 					visibleDisplayColumnBox={this.state.visibleDisplayColumnBox}
 					hideBox={() => this.setState({visibleDisplayColumnBox:false})}
+					targetColumns={chartDesigner.dataViewConfig.viewColumns.map(c => c.key)}
 				/>	
 			</Form>
         );

+ 35 - 54
src/components/chartDesigner/sections/displayColumnBox.jsx

@@ -2,29 +2,26 @@ import React from 'react'
 import { Modal, Transfer, Icon, Button, Row, Col } from 'antd'
 import { connect } from 'dva'
 
-
 class DisplayColumnBox extends React.Component {
     constructor(props){
         super(props)
         this.state = {
-            targetKeys: []
+            targetColumns: props.targetColumns || []
         }
     }
     swapItems = (arr, index1, index2) => {
-        let arrClone = JSON.parse(JSON.stringify(arr))    //这里要使用一个深拷贝才能真正地改变state
-        let temp = arrClone[index1]
-        arrClone[index1] = arrClone[index2]
-        arrClone[index2] = temp
-        console.log("changedArrClone", arrClone)
+        let arrClone = JSON.parse(JSON.stringify(arr));    //这里要使用一个深拷贝才能真正地改变state
+        let temp = arrClone[index1];
+        arrClone[index1] = arrClone[index2];
+        arrClone[index2] = temp;
         this.setState({
-            targetKeys: arrClone
-        }, () => { console.log(`${this.state.targetKeys}`) }
-        );
+            targetColumns: arrClone
+        });
     }
 
 
     upSwap = (index) => {
-        let arr = this.state.targetKeys
+        let arr = this.state.targetColumns
         if (index === 0) {
             return;
         }
@@ -32,7 +29,7 @@ class DisplayColumnBox extends React.Component {
     }
 
     downSwap = (index) => {
-        let arr = this.state.targetKeys
+        let arr = this.state.targetColumns
         if (index === arr.length - 1) {
             return;
         }
@@ -40,61 +37,45 @@ class DisplayColumnBox extends React.Component {
     };
 
     renderRow = (item) => {
-        let index = this.state.targetKeys.indexOf(item.key);
-        if (index === -1) {
-            return <span>{item.label}</span>
-        }
-        else {
-            // TODO: 这里样式调整比较麻烦
-            return (
-                <span> 
-                    {item.label} 
-                    <span>
-                        <Icon type="arrow-up" onClick={() => {this.upSwap(index)}} /> 
-                        <Icon type="arrow-down" onClick={() => {this.downSwap(index)}} />
-                    </span>
-                </span>
-            );
-        }
+        let index = this.state.targetColumns.indexOf(item.key);
+        return <span data-key={item.name}>
+            {item.label}
+            {index !== -1 && <span>
+                <Icon type="arrow-up" onClick={() => {this.upSwap(index)}} /> 
+                <Icon type="arrow-down" onClick={() => {this.downSwap(index)}} />
+            </span>}
+        </span>
     }
 
-    handleChange = (targetKeys) => {
-        this.setState({ targetKeys });
-    }
-
-
-    renderFooter = () => {
-        return (
-            <Button
-                size="small"
-                style={{ float: 'right', margin: 5 }}
-                onClick={this.getMock}
-            >
-                reload
-            </Button>
-        );
+    handleChange = (targetKeys, direction, moveKeys) => {
+        this.setState({ targetColumns: targetKeys });
     }
 
     onOk= () => {
-        const { dispatch, chartDesigner, autoRefresh, hideBox } = this.props
-        let viewColumns = chartDesigner.columns.filter(column => this.state.targetKeys.indexOf(column.key) !== -1).map((c) => ({key:c.name, label:c.label}))
-        dispatch({
-            type: 'chartDesigner/changeField', 
-            name: 'dataViewConfig', 
-            value: { ...chartDesigner.dataViewConfig, viewColumns: viewColumns }, autoRefresh });
+        const { dispatch, chartDesigner, autoRefresh, hideBox } = this.props;
+        const { targetColumns } = this.state;
+        let viewColumns = chartDesigner.columns.filter(column => targetColumns.indexOf(column.name) !== -1).map((c) => ({key:c.name, label:c.label}));
+        dispatch(
+            {
+                type: 'chartDesigner/changeField', 
+                name: 'dataViewConfig', 
+                value: { ...chartDesigner.dataViewConfig, viewColumns },
+                autoRefresh 
+            }
+        );
         hideBox()
-        }
+    }
     
     onCancel = () => {
         const { chartDesigner, hideBox } = this.props
         this.setState({
-            targetKeys: chartDesigner.dataViewConfig.viewColumns})
+            targetColumns: chartDesigner.dataViewConfig.viewColumns})
         hideBox()
     }
 
     render() {
         const { visibleDisplayColumnBox } = this.props
-        const { targetKeys } = this.state
+        const { targetColumns } = this.state
 
         return (
             <Modal
@@ -105,7 +86,7 @@ class DisplayColumnBox extends React.Component {
                 onOk={this.onOk}
             >
                 <Transfer
-                    dataSource={this.props.chartDesigner.columns}
+                    dataSource={this.props.chartDesigner.columns.map(c => ({ ...c, key: c.name }))}
                     showSearch
                     listStyle={{
                         width: 250,
@@ -113,7 +94,7 @@ class DisplayColumnBox extends React.Component {
                         textAlign:'left'
                     }}
                     operations={['显示', '隐藏']}
-                    targetKeys={targetKeys}
+                    targetKeys={targetColumns}
                     onChange={this.handleChange}
                     render={this.renderRow}
                 />

+ 2 - 2
src/components/chartDesigner/sections/filterBox.jsx

@@ -294,7 +294,7 @@ class FilterBox extends React.Component {
                                 className='filterValueOne'
                             >
                                 {getFieldDecorator(`filterValueOne${key}`, {
-                                    initialValue: type==='time' ? moment(value1) : value1
+                                    initialValue: type==='time' ? ( value1 ? moment(value1) : null) : value1
                                 })(this.getFilterValueField(key, type, operator, 1))}
                             </FormItem>
                         </Col>
@@ -304,7 +304,7 @@ class FilterBox extends React.Component {
                                 className='filterValueTwo'
                             >
                                 {getFieldDecorator(`filterValueTwo${key}`, {
-                                    initialValue: type==='time' ? moment(value2) : value2
+                                    initialValue: type==='time' ? ( value2 ? moment(value2) : null) : value2
                                 })(this.getFilterValueField(key, type, operator, 2))}
                             </FormItem>
                         </Col>

+ 12 - 1
src/components/datasource/baseConfig.jsx

@@ -34,7 +34,10 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
             <FormItem label='数据源名称' {...formItemLayout}>
                 <Input
                     value={dataSource.newOne.name}
-                    onChange={(e) => { dispatch({ type: 'dataSource/setNewModelField', name: 'name', value: e.target.value }) }}>
+                    onChange={(e) => {
+                        dispatch({ type: 'dataSource/setNewModelField', name: 'name', value: e.target.value });
+                        dispatch({ type: 'dataSource/remoteModify' });
+                    }}>
                 </Input>
             </FormItem>
             {
@@ -52,6 +55,7 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
                                 value={dataSource.newOne.dbType}
                                 onChange={(value) => {
                                     dispatch({ type: 'dataSource/setNewModelField', name: 'dbType', value: value} );
+                                    dispatch({ type: 'dataSource/remoteModify' });
                                 }}
                             >
                                 <SelectOption value='oracle'>
@@ -79,6 +83,7 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
                                         value={dataSource.newOne.address}
                                         onChange={(e) => {
                                             dispatch({ type: 'dataSource/setNewModelField', name: 'address', value: e.target.value });
+                                            dispatch({ type: 'dataSource/remoteModify' });
                                         }}
                                     />
                                 </FormItem>
@@ -93,6 +98,7 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
                                         value={dataSource.newOne.port}
                                         onChange={(value) => {
                                             dispatch({ type: 'dataSource/setNewModelField', name: 'port', value: value });
+                                            dispatch({ type: 'dataSource/remoteModify' });
                                         }}
                                     />
                                 </FormItem>
@@ -104,6 +110,7 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
                                 value={dataSource.newOne.dbName}
                                 onChange={(e) => {
                                     dispatch({ type: 'dataSource/setNewModelField', name: 'dbName', value: e.target.value });
+                                    dispatch({ type: 'dataSource/remoteModify' });
                                 }}
                             />
                         </FormItem>
@@ -118,6 +125,7 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
                                         value={dataSource.newOne.userName}
                                         onChange={(e) => {
                                             dispatch({ type: 'dataSource/setNewModelField', name: 'userName', value: e.target.value });
+                                            dispatch({ type: 'dataSource/remoteModify' });
                                         }}
                                     />
                                 </FormItem>
@@ -133,6 +141,7 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
                                         onChange={(e) => {
                                             let value = e.target.value;
                                             dispatch({ type: 'dataSource/setNewModelField', name: 'password', value: value });
+                                            dispatch({ type: 'dataSource/remoteModify' });
                                             e.target.removeAttribute('value')
                                         }}
                                     />
@@ -167,6 +176,7 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
 					onChange={(value, items) => {
                         let v = value[1] !== undefined ? value[1] : value[0];
                         dispatch({ type: 'dataSource/setNewModelField', name: 'group', value: v });
+                        dispatch({ type: 'dataSource/remoteModify' });
 					}}
 					
 				>
@@ -178,6 +188,7 @@ const DataSourceBaseConfig = ({ dataSource, dataConnect, dispatch, mode }) => {
                     value={dataSource.newOne.description}
                     onChange={(e) => {
                         dispatch({ type: 'dataSource/setNewModelField', name: 'description', value: e.target.value });
+                        dispatch({ type: 'dataSource/remoteModify' });
                     }}
                 />
             </FormItem>

+ 1 - 1
src/components/datasource/dataSourceDetail.jsx

@@ -132,7 +132,7 @@ class DataSourceDetail extends React.Component {
                                 <Button disabled={ ( ( type === 'database' && !dataSource.newOne.name) || ( type === 'file' && +1 === 2) ) ||
                                     (!dataSource.newOne.columns || dataSource.newOne.columns.length === 0)
                                 } type="primary" onClick={() => {
-                                    dispatch({ type: 'dataSource/remoteModify', code: this.props.match.params.code });
+                                    dispatch({ type: 'dataSource/remoteModify' });
                                 }}>保存修改</Button>
                             }
                         >

+ 6 - 7
src/models/dataSource.js

@@ -317,13 +317,13 @@ export default {
             }
         },
         *importNewModelColumns(action, { select, call, put }) {
+            const dataSource = yield select(state => state.present.dataSource);
+            const sqlStr = dataSource.newOne.target;
+            let body = {
+                id: dataSource.newOne.connectCode,
+                strSql: sqlStr
+            };
             try{
-                const dataSource = yield select(state => state.present.dataSource);
-                const sqlStr = dataSource.newOne.target;
-                let body = {
-                    id: dataSource.newOne.connectCode,
-                    strSql: sqlStr
-                };
                 const res = yield call(service.fetch, {
                     url: URLS.DATASOURCE_QUERY_SQLCOLUMNS,
                     body: body
@@ -358,7 +358,6 @@ export default {
                     yield put({ type: 'setNewModelField', name: 'columns', value: [] });
                 }
             }catch(e) {
-                console.log(e);
                 yield put({ type: 'setNewModelInvalidSQL', value: true });
                 yield put({ type: 'setNewModelField', name: 'columns', value: [] });
                 message.error('请求列数据错误');

+ 4 - 0
src/models/user.js

@@ -20,7 +20,11 @@ export default {
     },
     effects: {
         *fetchList(action, { put, call, select }) {
+            const user = yield select(state => state.present.user);
             try {
+                if(!action.mandatory && user.list.length > 0) {
+                    return;
+                }
                 const res = yield call(service.fetch, {
                     url: URLS.USER_LIST
                 });

+ 2 - 1
src/models/userGroup.js

@@ -132,7 +132,8 @@ export default {
                     yield put({ type: 'add', group: {
                         code: res.data.data,
                         name: newOne.name,
-                        description: newOne.description
+                        description: newOne.description,
+                        member: []
                     } });
                     yield put({ type: 'setNewModelField', name: 'visibleDetailBox', value: false });
                     yield put({ type: 'resetNewModel' });

Some files were not shown because too many files changed in this diff