|
@@ -2,8 +2,9 @@ import React from 'react'
|
|
|
import { Tabs, Input, Button, Table, Icon, Tag, Menu, Dropdown } from 'antd'
|
|
import { Tabs, Input, Button, Table, Icon, Tag, Menu, Dropdown } from 'antd'
|
|
|
const { TabPane } = Tabs
|
|
const { TabPane } = Tabs
|
|
|
const { Search } = Input
|
|
const { Search } = Input
|
|
|
-import DataSourceBox from './dataSourceBox'
|
|
|
|
|
import { connect } from 'dva'
|
|
import { connect } from 'dva'
|
|
|
|
|
+import { Link } from 'react-router-dom'
|
|
|
|
|
+import DataSourceBox from './dataSourceBox'
|
|
|
import dataSource from '../../models/dataSource'
|
|
import dataSource from '../../models/dataSource'
|
|
|
import './dataSource.less'
|
|
import './dataSource.less'
|
|
|
|
|
|
|
@@ -13,7 +14,9 @@ class DataSource extends React.Component {
|
|
|
this.state = {
|
|
this.state = {
|
|
|
operation: 'create', // 打开数据编辑界面的类型
|
|
operation: 'create', // 打开数据编辑界面的类型
|
|
|
visibleBox: false, // 数据编辑界面显示标识
|
|
visibleBox: false, // 数据编辑界面显示标识
|
|
|
- selectedCode: -1 // 当前选中的table行code
|
|
|
|
|
|
|
+ selectedCode: -1, // 当前选中的table行code
|
|
|
|
|
+ filterDropdownVisible: false,
|
|
|
|
|
+ search: {} // 搜索条件
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -30,10 +33,25 @@ class DataSource extends React.Component {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ onInputChange = (name, value) => {
|
|
|
|
|
+ const { search } = this.state;
|
|
|
|
|
+ let newSearch = Object.assign({}, search );
|
|
|
|
|
+ newSearch[name] = value;
|
|
|
|
|
+ this.setState({ search: newSearch });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ onSearch = () => {
|
|
|
|
|
+ const { search } = this.state;
|
|
|
|
|
+ const reg = new RegExp(search.name, 'gi');
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ filterDropdownVisible: false
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
|
|
|
|
|
const { dataSource, dispatch } = this.props;
|
|
const { dataSource, dispatch } = this.props;
|
|
|
- const { visibleBox, operation, selectedCode } = this.state;
|
|
|
|
|
|
|
+ const { search, visibleBox, operation, selectedCode } = this.state;
|
|
|
|
|
|
|
|
console.log(dataSource.list);
|
|
console.log(dataSource.list);
|
|
|
const moreOperatingMenu = (
|
|
const moreOperatingMenu = (
|
|
@@ -46,23 +64,48 @@ class DataSource extends React.Component {
|
|
|
}}>
|
|
}}>
|
|
|
<Icon type="info-circle-o" />属性设置
|
|
<Icon type="info-circle-o" />属性设置
|
|
|
</Menu.Item>
|
|
</Menu.Item>
|
|
|
- <Menu.Item
|
|
|
|
|
- onClick={(e) => {
|
|
|
|
|
- let selectedModel = dataSource.list.find((i) => { return i.code == selectedCode })
|
|
|
|
|
- this.showColumnBox();
|
|
|
|
|
- }}>
|
|
|
|
|
- <Icon type="table" />数据列设置
|
|
|
|
|
|
|
+ <Menu.Item>
|
|
|
|
|
+ {/* <Link to='/dataSource/1111'> */}
|
|
|
|
|
+ <Icon type="home" /><Icon type="table" />数据列设置
|
|
|
|
|
+ {/* </Link> */}
|
|
|
</Menu.Item>
|
|
</Menu.Item>
|
|
|
<Menu.Item><Icon type="search" />预览数据</Menu.Item>
|
|
<Menu.Item><Icon type="search" />预览数据</Menu.Item>
|
|
|
<Menu.Item><Icon type="lock" />权限设置</Menu.Item>
|
|
<Menu.Item><Icon type="lock" />权限设置</Menu.Item>
|
|
|
<Menu.Divider />
|
|
<Menu.Divider />
|
|
|
- <Menu.Item><Icon type="delete" />删除</Menu.Item>
|
|
|
|
|
|
|
+ <Menu.Item
|
|
|
|
|
+ onClick={(e) => {
|
|
|
|
|
+ let selectedModel = dataSource.list.find((i) => { return i.code == selectedCode })
|
|
|
|
|
+ dispatch({ type: 'dataSource/delete', model: selectedModel });
|
|
|
|
|
+ }}
|
|
|
|
|
+ ><Icon type="delete" />删除</Menu.Item>
|
|
|
</Menu>
|
|
</Menu>
|
|
|
);
|
|
);
|
|
|
const columns = [{
|
|
const columns = [{
|
|
|
title: '名称',
|
|
title: '名称',
|
|
|
dataIndex: 'name',
|
|
dataIndex: 'name',
|
|
|
key: 'name',
|
|
key: 'name',
|
|
|
|
|
+ width: 100,
|
|
|
|
|
+ sorter: (a, b) => a.name.localeCompare(b.name, 'zh-Hans-CN', {sensitivity: 'accent'}),
|
|
|
|
|
+ filterDropdown: (
|
|
|
|
|
+ <div className="custom-filter-dropdown">
|
|
|
|
|
+ <Input
|
|
|
|
|
+ ref={ele => this.searchInput = ele}
|
|
|
|
|
+ placeholder="Search name"
|
|
|
|
|
+ value={this.state.search.name}
|
|
|
|
|
+ onChange={(e) => { this.onInputChange('name', e.target.value) }}
|
|
|
|
|
+ onPressEnter={this.onSearch}
|
|
|
|
|
+ />
|
|
|
|
|
+ <Button type="primary" onClick={this.onSearch}>Search</Button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ),
|
|
|
|
|
+ className: `column-${this.state.search.name?'filtered':'nofiltered'}`,
|
|
|
|
|
+ filterIcon: <Icon type="smile-o"/>,
|
|
|
|
|
+ filterDropdownVisible: this.state.filterDropdownVisible,
|
|
|
|
|
+ onFilterDropdownVisibleChange: (visible) => {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ filterDropdownVisible: visible,
|
|
|
|
|
+ }, () => this.searchInput && this.searchInput.focus());
|
|
|
|
|
+ },
|
|
|
render: (text, record) => {
|
|
render: (text, record) => {
|
|
|
return <div className='datasource-name'>
|
|
return <div className='datasource-name'>
|
|
|
<div className={`datasource-type type-${record.type.key}`}></div>
|
|
<div className={`datasource-type type-${record.type.key}`}></div>
|
|
@@ -73,6 +116,7 @@ class DataSource extends React.Component {
|
|
|
title: '标签',
|
|
title: '标签',
|
|
|
dataIndex: 'tags',
|
|
dataIndex: 'tags',
|
|
|
key: 'tag',
|
|
key: 'tag',
|
|
|
|
|
+ width: 150,
|
|
|
render: (text, record) => {
|
|
render: (text, record) => {
|
|
|
text=text.join(',');
|
|
text=text.join(',');
|
|
|
let tags = text ? text.split(',').map((t, i) => {
|
|
let tags = text ? text.split(',').map((t, i) => {
|
|
@@ -85,20 +129,24 @@ class DataSource extends React.Component {
|
|
|
}, {
|
|
}, {
|
|
|
title: '说明',
|
|
title: '说明',
|
|
|
dataIndex: 'description',
|
|
dataIndex: 'description',
|
|
|
- key: 'description'
|
|
|
|
|
|
|
+ key: 'description',
|
|
|
|
|
+ width: 200
|
|
|
}, {
|
|
}, {
|
|
|
title: '创建人',
|
|
title: '创建人',
|
|
|
dataIndex: 'creator',
|
|
dataIndex: 'creator',
|
|
|
- key: 'creator'
|
|
|
|
|
|
|
+ key: 'creator',
|
|
|
|
|
+ width: 100
|
|
|
}, {
|
|
}, {
|
|
|
title: '创建时间',
|
|
title: '创建时间',
|
|
|
dataIndex: 'createTime',
|
|
dataIndex: 'createTime',
|
|
|
key: 'createTime',
|
|
key: 'createTime',
|
|
|
- render: (text, record) => text.format('yyyy-MM-dd hh:mm:ss')
|
|
|
|
|
|
|
+ render: (text, record) => text.format('yyyy-MM-dd hh:mm:ss'),
|
|
|
|
|
+ width: 100
|
|
|
}, {
|
|
}, {
|
|
|
title: '图表',
|
|
title: '图表',
|
|
|
dataIndex: 'chartSum',
|
|
dataIndex: 'chartSum',
|
|
|
- key: 'chartSum'
|
|
|
|
|
|
|
+ key: 'chartSum',
|
|
|
|
|
+ width: 80
|
|
|
}, {
|
|
}, {
|
|
|
title: '操作',
|
|
title: '操作',
|
|
|
key: 'action',
|
|
key: 'action',
|
|
@@ -107,6 +155,7 @@ class DataSource extends React.Component {
|
|
|
<Icon type="setting" />
|
|
<Icon type="setting" />
|
|
|
</Dropdown>
|
|
</Dropdown>
|
|
|
),
|
|
),
|
|
|
|
|
+ width: 80
|
|
|
}];
|
|
}];
|
|
|
const data = [{
|
|
const data = [{
|
|
|
key: '1',
|
|
key: '1',
|
|
@@ -135,6 +184,9 @@ class DataSource extends React.Component {
|
|
|
defaultActiveKey="1"
|
|
defaultActiveKey="1"
|
|
|
tabBarExtraContent={
|
|
tabBarExtraContent={
|
|
|
<div className='datasource-tabs-tools'>
|
|
<div className='datasource-tabs-tools'>
|
|
|
|
|
+ <Button onClick={()=>{
|
|
|
|
|
+ dispatch({type: 'dataSource/testData'});
|
|
|
|
|
+ }}>测试数据</Button>
|
|
|
<Search
|
|
<Search
|
|
|
placeholder="请输入关键字"
|
|
placeholder="请输入关键字"
|
|
|
onSearch={value => console.log(value)}
|
|
onSearch={value => console.log(value)}
|
|
@@ -143,7 +195,9 @@ class DataSource extends React.Component {
|
|
|
dispatch({ type: 'dataSource/resetNewModel' });
|
|
dispatch({ type: 'dataSource/resetNewModel' });
|
|
|
this.showDataSourceBox('create')}
|
|
this.showDataSourceBox('create')}
|
|
|
}>
|
|
}>
|
|
|
- <Icon type="plus" />添加数据源
|
|
|
|
|
|
|
+ {/* <Link to='./'> */}
|
|
|
|
|
+ <Icon type="plus" />添加数据源
|
|
|
|
|
+ {/* </Link> */}
|
|
|
</Button>
|
|
</Button>
|
|
|
<DataSourceBox operation={operation} visibleBox={visibleBox} hideBox={this.hideBox} />
|
|
<DataSourceBox operation={operation} visibleBox={visibleBox} hideBox={this.hideBox} />
|
|
|
</div>
|
|
</div>
|
|
@@ -156,6 +210,8 @@ class DataSource extends React.Component {
|
|
|
dataSource={dataSource.list}
|
|
dataSource={dataSource.list}
|
|
|
loading={false}
|
|
loading={false}
|
|
|
size='small'
|
|
size='small'
|
|
|
|
|
+ scroll={{x: false, y: 471}} // TODO 需要计算
|
|
|
|
|
+ pagination={false}
|
|
|
onRow={(record) => {
|
|
onRow={(record) => {
|
|
|
return {
|
|
return {
|
|
|
onClick: () => {this.setState({ selectedCode: record.code})}
|
|
onClick: () => {this.setState({ selectedCode: record.code})}
|