import React from 'react'
import { Layout, Row, Col, Input, Button, Table, Icon, Tag, Menu, Dropdown, Card } from 'antd'
import { connect } from 'dva'
import '../../models/dataSource'
import '../../models/dataConnect'
import './dataSource.less'
import { dateFormat } from '../../utils/baseUtils'
const { Content } = Layout
const { Search } = Input
class DataSource extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: false,
activeTab: 'dataSource',
visibleCreateBox: false,
selectedDataSourceCode: -1, // 当前选中的dataSource的code
filterDropdownVisible: false,
search: {} // 搜索条件
}
};
componentDidMount() {
this.setScrollTableHeight();
}
/**
* 根据视图设置表格高度以呈现滚动条
*/
setScrollTableHeight() {
const mainContent = document.getElementsByClassName('main-content')[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 - toolbar.offsetHeight - tableHeader.offsetHeight - 58}px`;
}
onInputChange = (name, value) => {
const { search } = this.state;
let newSearch = Object.assign({}, search );
newSearch[name] = value;
this.setState({ search: newSearch });
}
onSearch = () => {
this.setState({
filterDropdownVisible: false
});
}
render() {
const { dataSource, dispatch } = this.props;
const { loading, activeTab, selectedDataSourceCode } = this.state;
const moreOperatingMenu = (
);
const dataSourceColumns = [{
title: '名称',
dataIndex: 'name',
key: 'name',
width: 100,
render: (text, record) => {
return
}
}, {
title: '标签',
dataIndex: 'tags',
key: 'tag',
width: 150,
render: (text, record) => {
text=text.join(',');
let tags = text ? text.split(',').map((t, i) => {
return {t}
}) : '';
return (
{tags}
)
}
}, {
title: '说明',
dataIndex: 'description',
key: 'description',
width: 200
}, {
title: '创建人',
dataIndex: 'creator',
key: 'creator',
width: 100
}, {
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
render: (text, record) => dateFormat(text, 'yyyy-MM-dd hh:mm:ss'),
width: 100
}, {
title: '图表',
dataIndex: 'chartSum',
key: 'chartSum',
width: 80
}, {
title: '操作',
key: 'action',
render: (text, record, index) => (
),
width: 80
}];
return (
console.log(value)}
/>
{
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'}});
}}>
数据库
文件
)} trigger={['click']}>
}>
{
return new Date(b.createTime) - new Date(a.createTime);
})}
loading={loading}
size='small'
scroll={{x: false, y: true}}
pagination={false}
onRow={(record) => {
return {
onClick: () => {this.setState({ selectedDataSourceCode: record.code})}
}
}}
/>
)
}
}
function mapStateToProps({present: {dataSource, dataConnect}}) {
return { dataSource, dataConnect }
}
export default connect(mapStateToProps)(DataSource)