فهرست منبع

数据源列表界面调整

zhuth 7 سال پیش
والد
کامیت
27eeb652a2
2فایلهای تغییر یافته به همراه99 افزوده شده و 228 حذف شده
  1. 62 94
      app/components/datasource/dataSource.less
  2. 37 134
      app/components/datasource/datasource.jsx

+ 62 - 94
app/components/datasource/dataSource.less

@@ -1,83 +1,76 @@
-.datasource-tabs {
-    .ant-tabs-bar {
-        margin-bottom: 0;
-        .ant-tabs-extra-content {
-            height: 100%;
-            .datasource-tabs-tools {
-                .ant-input-search {
-                    width: 200px;
-                    margin-right: 5px;
-                }
-            }
+.datasource-view {
+    .datasource-tools {
+        margin-top: 5px;
+        margin-right: 5px;
+        .search {
+            margin-right: 5px;
         }
     }
-    .datasource-tab, .dataconnect-tab {
-        .datasource-table, .dataconnect-table {
-            .ant-table {
-                margin-top: 5px;
-                .ant-table-scroll {
-                    .ant-table-header {
-                        overflow: hidden;
-                        table {
-                            thead {
-                                th {
-                                    .ant-table-column-sorter, .ant-table-filter-icon {
-                                        opacity: 0;
-                                    }
-                                    :hover {
-                                        .ant-table-column-sorter, .ant-table-filter-icon {
-                                            opacity: 1;
-                                        }
-                                    }
+    .datasource-table{
+        .ant-table {
+            margin-top: 5px;
+            .ant-table-scroll {
+                .ant-table-header {
+                    overflow: hidden;
+                    table {
+                        thead {
+                            th {
+                                .ant-table-column-sorter, .ant-table-filter-icon {
+                                    opacity: 0;
                                 }
-                                .column-filtered {
-                                    .ant-table-filter-icon {
+                                :hover {
+                                    .ant-table-column-sorter, .ant-table-filter-icon {
                                         opacity: 1;
-                                        color: red;
                                     }
                                 }
                             }
+                            .column-filtered {
+                                .ant-table-filter-icon {
+                                    opacity: 1;
+                                    color: red;
+                                }
+                            }
                         }
                     }
-                    .ant-table-body {
-                        margin-top: 17px;
-                        overflow-y: auto !important;
-                        table {
-                            padding: 0;
-                            .ant-table-row {
-                                td {
-                                    padding: 8px;
-                                    .datasource-name {
-                                        display: flex;
-                                        .datasource-type {
-                                            width: 20px;
-                                            height: 20px;
-                                            background-size: cover;
-                                            background-repeat: no-repeat;
-                                            background-image: url('https://test-feapp.oss-cn-beijing.aliyuncs.com/feapp/s70f_180613_fix_a_t/images/trdservices/44_2.png');
-                                        }
-                                        .type-oracle {
-                                            background-position: 0 -731px;
-                                        }
-                                    }
-                                    .datasource-tag {
-                                        margin: 2px;
-                                        cursor: default;
-                                    }
-                                    .ant-dropdown-trigger {
-                                        font-size: 18px;
-                                        cursor: pointer;
-                                    }
-                                }
-                                .action-col {
+                }
+                .ant-table-body {
+                    margin-top: 17px;
+                    overflow-y: auto !important;
+                    table {
+                        padding: 0;
+                        .ant-table-row {
+                            td {
+                                padding: 8px;
+                                .datasource-name {
                                     display: flex;
-                                    .operation {
-                                        cursor: pointer;
+                                    .datasource-type {
+                                        width: 20px;
+                                        height: 20px;
+                                        background-size: cover;
+                                        background-repeat: no-repeat;
+                                        background-image: url('https://test-feapp.oss-cn-beijing.aliyuncs.com/feapp/s70f_180613_fix_a_t/images/trdservices/44_2.png');
                                     }
-                                    .operation:hover {
-                                        color: #40a9ff;
+                                    .type-oracle {
+                                        background-position: 0 -731px;
                                     }
                                 }
+                                .datasource-tag {
+                                    margin: 2px;
+                                    cursor: default;
+                                }
+                                .ant-dropdown-trigger {
+                                    font-size: 18px;
+                                    cursor: pointer;
+                                }
+                            }
+                            .action-col {
+                                display: flex;
+                                .operation {
+                                    cursor: pointer;
+                                }
+                                .operation:hover {
+                                    color: #40a9ff;
+                                }
                             }
                         }
                     }
@@ -99,38 +92,17 @@
     }
 }
 
-.dataconnect-box {
-    width: 600px !important;
-    .ant-modal-content {
-        .ant-modal-body {
-            padding: 6px;
-            max-height: 50vh;
-            overflow-y: auto;
-            .textarea-desc {
-                margin-top: 4px;
-            }
-            .input-port {
-                .ant-input-number {
-                    width: 100% !important;
-                    .ant-input-number-handler-wrap {
-                        display: none;
-                    }
-                }
-            }
-        }
-    }
-}
 .ant-table-body::-webkit-scrollbar {/*滚动条整体样式*/
     width: 6px;     /*高宽分别对应横竖滚动条的尺寸*/
     height: 4px;
 }
 .ant-table-body::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
     border-radius: 5px;
-    -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
+    box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
     background: rgba(0,0,0,0.2);
 }
 .ant-table-body::-webkit-scrollbar-track {/*滚动条里面轨道*/
-    -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
+    box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
     border-radius: 0;
     background: rgba(0,0,0,0.1);
 }
@@ -145,8 +117,4 @@
   .custom-filter-dropdown input {
     width: 130px;
     margin-right: 8px;
-  }
-  
-  .highlight {
-    color: #f50;
   }

+ 37 - 134
app/components/datasource/datasource.jsx

@@ -1,13 +1,13 @@
 import React from 'react'
 import { routerRedux } from 'dva/router'
-import { Tabs, Input, Button, Table, Icon, Tag, Menu, Dropdown, Divider } from 'antd'
+import { Layout, Row, Col, Tabs, Input, Button, Table, Icon, Tag, Menu, Dropdown, Divider } from 'antd'
+const { Content } = Layout
 const { TabPane } = Tabs
 const { Search } = Input
 import { connect } from 'dva'
 import { Link } from 'react-router-dom'
-import DataConnectBox from './dataConnectBox'
-import dataSource from '../../models/dataSource'
-import dataConnect from '../../models/dataConnect'
+import '../../models/dataSource'
+import '../../models/dataConnect'
 import './dataSource.less'
 
 class DataSource extends React.Component {
@@ -16,11 +16,8 @@ class DataSource extends React.Component {
         this.state = {
             loading: false,
             activeTab: 'dataSource',
-            operation: 'create', // 打开数据编辑界面的类型
             visibleCreateBox: false,
-            visibleBox: false, // 数据编辑界面显示标识
             selectedDataSourceCode: -1, // 当前选中的dataSource的code
-            selectedDataConnectCode: -1, // 当前选中的dataConnect的code
             filterDropdownVisible: false,
             search: {} // 搜索条件
         }
@@ -35,30 +32,11 @@ class DataSource extends React.Component {
      */
     setScrollTableHeight() {
         const mainContent = document.getElementsByClassName('main-content')[0];
-        const tabBar = mainContent.getElementsByClassName('ant-tabs-bar')[0];
+        //const tabBar = mainContent.getElementsByClassName('datasource-view')[0];
+        const toolbar = mainContent.getElementsByClassName('datasource-tools')[0];
         const tableHeader = mainContent.getElementsByClassName('ant-table-header')[0];
         const tableBody = mainContent.getElementsByClassName('ant-table-body')[0];
-
-        tableBody.style.maxHeight=`${mainContent.offsetHeight - tabBar.offsetHeight - tableHeader.offsetHeight - 38}px`;
-    }
-
-    showCreateBox = () => {
-        this.setState({
-            visibleCreateBox: true
-        });
-    }
-
-    showDataConnectBox = (o) => {
-        this.setState({
-            operation: o,
-            visibleBox: true
-        });
-    }
-
-    hideDataConnectBox = () => {
-        this.setState({
-            visibleBox: false
-        });
+        tableBody.style.maxHeight=`${mainContent.offsetHeight - toolbar.offsetHeight - tableHeader.offsetHeight - 38}px`;
     }
 
     onInputChange = (name, value) => {
@@ -198,105 +176,41 @@ class DataSource extends React.Component {
             width: 80
         }];
 
-        const dataConnectColumns = [{
-            title: '名称',
-            dataIndex: 'name',
-            key: 'name',
-            width: 100,
-            render: (text, record) => {
-                return <div className='datasource-name'>
-                    <div className={`datasource-type type-${record.type}`}></div>
-                    <div>{text}</div>
-                </div>
-            }
-        }, {
-            title: '说明',
-            dataIndex: 'description',
-            key: 'description',
-            width: 100
-        }, {
-            title: '操作',
-            key: 'action',
-            width: 300,
-            render: (text, record) => (
-                <div className='action-col'>
-                    <div className='operation' onClick={() => {
-                        let selectedModel = dataConnect.list.find((i) => { return i.code == record.code });
-                        dispatch({ type: 'dataConnect/setNewModel', model: selectedModel });
-                        this.showDataConnectBox('modify')
-                    }}><Icon type="info-circle-o"/>属性</div>
-                    <div className='operation'><Divider type="vertical" /></div>
-                    <div className='operation' onClick={() => {
-                         dispatch({ type: 'dataSource/resetNewModel' });
-                         dispatch({ type: 'dataSource/setNewModelField', fields: [
-                             { name: 'dbType', value: record.dbType },
-                             { name: 'address', value: record.address },
-                             { name: 'port', value: record.port },
-                             { name: 'dbName', value: record.dbName },
-                             { name: 'userName', value: record.userName },
-                             { name: 'password', value: record.password }
-                         ] });
-
-                         dispatch({type: 'main/redirect', path: {pathname: '/datasource/database/create'}});
-                    }}><Icon type="plus"/>创建数据源</div>
-                    <div className='operation'><Divider type="vertical" /></div>
-                    <div className='operation' onClick={() => {
-                        dispatch({ type: 'dataConnect/remoteDelete', code: record.code });
-                    }}><Icon type="delete"/>删除</div>
-                </div>
-            ),
-            width: 80
-        }];
-
         return (
-            <Tabs
-                className='datasource-tabs'
-                type="card"
-                defaultActiveKey="1"
-                tabBarExtraContent={
-                    <div className='datasource-tabs-tools'>
-                        <Search
-                            placeholder="请输入关键字"
-                            onSearch={value => console.log(value)}
-                        />
-                        <Dropdown overlay={(
-                            <Menu onClick={(item, key, keyPath) => {
-                                const type = item.key;
-                                dispatch({ type: 'dataSource/resetNewModel' });
-                                dispatch({ type: 'dataSource/setNewModelField', name: 'type', value: type });
-                                dispatch({type: 'main/redirect', path: {pathname: '/datasource/'+ type +'/create'}});
-                            }}>
-                                <Menu.Item key='database'>数据库</Menu.Item>
-                                <Menu.Item key='file'>文件</Menu.Item>
-                            </Menu>
-                        )} trigger={['click']}>
-                            <Button style={{ display: activeTab=='dataConnect'?'none':'inline-block' }}>
-                                <Icon type="plus" />添加数据源
-                            </Button>
-                        </Dropdown>
-                        <Button style={{ display: activeTab=='dataConnect'?'inline-block':'none' }} onClick={(e) => {
-                            dispatch({ type: 'dataConnect/resetNewModel' });
-                            this.showDataConnectBox('create')
-                        }}>
-                            <Icon type="plus" />添加数据连接
-                        </Button>
-                        <DataConnectBox operation={operation} visibleBox={visibleBox} hideBox={this.hideDataConnectBox} />
-                    </div>
-                }
-                onChange={(key) => {
-                    this.setState({
-                        activeTab: key == '1' ? 'dataSource' : 'dataConnect'
-                    });
-                }}
-            >
-                <TabPane className='datasource-tab' tab="数据源" key="1" >
+            <Layout className='datasource-view'>
+                <Content>
+                    <Row className='datasource-tools' type='flex' justify='end'>
+                        <Col className='search'>
+                            <Search
+                                placeholder="请输入关键字"
+                                onSearch={value => console.log(value)}
+                            />
+                        </Col>
+                        <Col>
+                            <Dropdown overlay={(
+                                <Menu onClick={(item, key, keyPath) => {
+                                    const type = item.key;
+                                    dispatch({ type: 'dataSource/resetNewModel' });
+                                    dispatch({ type: 'dataSource/setNewModelField', name: 'type', value: type });
+                                    dispatch({type: 'main/redirect', path: {pathname: '/datasource/'+ type +'/create'}});
+                                }}>
+                                    <Menu.Item key='database'>数据库</Menu.Item>
+                                    <Menu.Item key='file'>文件</Menu.Item>
+                                </Menu>
+                            )} trigger={['click']}>
+                                <Button style={{ display: activeTab=='dataConnect'?'none':'inline-block' }}>
+                                    <Icon type="plus" />添加数据源
+                                </Button>
+                            </Dropdown>
+                        </Col>
+                    </Row>
                     <Table
                         className='datasource-table datasource-table'
                         columns={dataSourceColumns}
                         dataSource={dataSource.list}
                         loading={loading}
                         size='small'
-                        scroll={{x: false, y: 471}}
+                        scroll={{x: false, y: true}}
                         pagination={false}
                         onRow={(record) => {
                             return {
@@ -304,19 +218,8 @@ class DataSource extends React.Component {
                             }
                         }}
                     />
-                </TabPane>
-                <TabPane className='dataconnect-tab dataconnect' tab="数据库连接" key="2" >
-                    <Table
-                        className='dataconnect-table'
-                        columns={dataConnectColumns}
-                        dataSource={dataConnect.list}
-                        loading={loading}
-                        size='small'
-                        scroll={{x: false, y: 471}}
-                        pagination={false}
-                    />
-                </TabPane>
-            </Tabs>
+                </Content>
+            </Layout>
         )