|
|
@@ -1,5 +1,5 @@
|
|
|
import React from 'react'
|
|
|
-import { Layout, Row, Col, Input, Button, Icon, Menu, Dropdown, Card } from 'antd'
|
|
|
+import { Layout, Row, Col, Input, Button, Icon, Card, Tooltip } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
|
import DeleteBox from '../common/deleteBox/deleteBox'
|
|
|
import DataConnectBox from '../dataSourceDetail/dataConnectBox'
|
|
|
@@ -60,50 +60,27 @@ class DataConnect extends React.Component {
|
|
|
|
|
|
generateCard() {
|
|
|
const { dataConnect, dispatch } = this.props;
|
|
|
- const { selected } = dataConnect;
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
let filterLabel = dataConnect.filterLabel.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
|
|
|
- const operationMenu = (
|
|
|
- <Menu className='menu-operation'>
|
|
|
- <Menu.Item onClick={(e) => {
|
|
|
- dispatch({ type: 'dataConnect/setNewModel', model: selected });
|
|
|
- dispatch({ type: 'dataConnect/setNewModelFields', fields: [
|
|
|
- { name: 'visibleBox', value: true },
|
|
|
- { name: 'boxOperation', value: 'modify' }
|
|
|
- ] });
|
|
|
- }}>
|
|
|
- <Icon type="info-circle-o" />属性设置
|
|
|
- </Menu.Item>
|
|
|
- <Menu.Divider />
|
|
|
- <Menu.Item
|
|
|
- onClick={(e) => {
|
|
|
- dispatch({ type: 'dataConnect/setNewModel', model: { ...selected, code: null } });
|
|
|
- dispatch({ type: 'dataConnect/setNewModelFields', fields: [
|
|
|
- { name: 'visibleBox', value: true },
|
|
|
- { name: 'boxOperation', value: 'create' }
|
|
|
- ] });
|
|
|
- }}
|
|
|
- >
|
|
|
- <Icon type="copy" />复制新增
|
|
|
- </Menu.Item>
|
|
|
- <Menu.Item
|
|
|
- onClick={(e) => {
|
|
|
- this.setState({ visibleDeleteBox: true})
|
|
|
- }}
|
|
|
- >
|
|
|
- <Icon type="delete" />删除
|
|
|
- </Menu.Item>
|
|
|
- </Menu>
|
|
|
- )
|
|
|
-
|
|
|
let cards = dataConnect.list.filter(l => {
|
|
|
return ((l.name || '').search(new RegExp('(' + filterLabel + '){1}', 'ig')) !== -1);
|
|
|
}).map( (l, i) => (
|
|
|
<CardGrid className='dataconnect-card' key={i}>
|
|
|
<Card
|
|
|
+ hoverable={true}
|
|
|
title={
|
|
|
- <Row type='flex' justify='start'>
|
|
|
+ <Row type='flex' justify='start'
|
|
|
+ onClick={() => {
|
|
|
+ // 选中项设置
|
|
|
+ dispatch({ type: 'dataConnect/setSelected', selected: l });
|
|
|
+ dispatch({ type: 'dataConnect/setNewModel', model: l });
|
|
|
+ dispatch({ type: 'dataConnect/setNewModelFields', fields: [
|
|
|
+ { name: 'visibleBox', value: true },
|
|
|
+ { name: 'boxOperation', value: 'modify' }
|
|
|
+ ] });
|
|
|
+ }}
|
|
|
+ >
|
|
|
<Col className='label'>
|
|
|
{ filterLabel ?
|
|
|
((l.name || '').split(new RegExp(`(${filterLabel})`, 'i')).map((fragment, i) => {
|
|
|
@@ -118,31 +95,55 @@ class DataConnect extends React.Component {
|
|
|
</Col>
|
|
|
</Row>
|
|
|
}
|
|
|
- onClick={() => {
|
|
|
- // 选中项设置
|
|
|
- dispatch({ type: 'dataConnect/setSelected', selected: l });
|
|
|
- dispatch({ type: 'dataConnect/setNewModel', model: l });
|
|
|
- dispatch({ type: 'dataConnect/setNewModelFields', fields: [
|
|
|
- { name: 'visibleBox', value: true },
|
|
|
- { name: 'boxOperation', value: 'modify' }
|
|
|
- ] });
|
|
|
- }}
|
|
|
+ actions={[
|
|
|
+ <Tooltip placement='bottom' title="属性设置">
|
|
|
+ <Icon type="info-circle-o" onClick={() => {
|
|
|
+ // 选中项设置
|
|
|
+ dispatch({ type: 'dataConnect/setSelected', selected: l });
|
|
|
+ dispatch({ type: 'dataConnect/setNewModel', model: l });
|
|
|
+ dispatch({ type: 'dataConnect/setNewModelFields', fields: [
|
|
|
+ { name: 'visibleBox', value: true },
|
|
|
+ { name: 'boxOperation', value: 'modify' }
|
|
|
+ ] });
|
|
|
+ }}/>
|
|
|
+ </Tooltip>,
|
|
|
+ <Tooltip placement='bottom' title="复制新增">
|
|
|
+ <Icon type="copy" onClick={() => {
|
|
|
+ // 选中项设置
|
|
|
+ dispatch({ type: 'dataConnect/setSelected', selected: l });
|
|
|
+ dispatch({ type: 'dataConnect/setNewModel', model: { ...l, code: null } });
|
|
|
+ dispatch({ type: 'dataConnect/setNewModelFields', fields: [
|
|
|
+ { name: 'visibleBox', value: true },
|
|
|
+ { name: 'boxOperation', value: 'create' }
|
|
|
+ ] });
|
|
|
+ }}/>
|
|
|
+ </Tooltip>,
|
|
|
+ <Tooltip placement='bottom' title="删除">
|
|
|
+ <Icon type="delete" onClick={() => {
|
|
|
+ // 选中项设置
|
|
|
+ dispatch({ type: 'dataConnect/setSelected', selected: l });
|
|
|
+ this.setState({ visibleDeleteBox: true})
|
|
|
+ }}/>
|
|
|
+ </Tooltip>,
|
|
|
+ ]}
|
|
|
>
|
|
|
- <div className='content'>
|
|
|
+ <div className='content'
|
|
|
+ onClick={() => {
|
|
|
+ // 选中项设置
|
|
|
+ dispatch({ type: 'dataConnect/setSelected', selected: l });
|
|
|
+ dispatch({ type: 'dataConnect/setNewModel', model: l });
|
|
|
+ dispatch({ type: 'dataConnect/setNewModelFields', fields: [
|
|
|
+ { name: 'visibleBox', value: true },
|
|
|
+ { name: 'boxOperation', value: 'modify' }
|
|
|
+ ] });
|
|
|
+ }}
|
|
|
+ >
|
|
|
<Row className='address'>
|
|
|
{l.address}
|
|
|
</Row>
|
|
|
<Row className='username'>
|
|
|
{l.userName}
|
|
|
</Row>
|
|
|
- <Row className='bottom' type='flex' justify='space-between'>
|
|
|
- <Col>{l.dbType}</Col>
|
|
|
- <Col>
|
|
|
- <Dropdown overlay={operationMenu} trigger={['click']}>
|
|
|
- <Icon type="ellipsis" />
|
|
|
- </Dropdown>
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
</div>
|
|
|
</Card>
|
|
|
</CardGrid>
|