|
|
@@ -4,8 +4,9 @@ import { connect } from 'dva'
|
|
|
import './dataSource.less'
|
|
|
import { dateFormat } from '../../utils/baseUtils'
|
|
|
import GroupSelector from './groupSelector'
|
|
|
-import TransferBox from '../common/selectUserBox/selectUserBox';
|
|
|
-import DeleteBox from '../common/deleteBox/deleteBox';
|
|
|
+import TransferBox from '../common/selectUserBox/selectUserBox'
|
|
|
+import DeleteBox from '../common/deleteBox/deleteBox'
|
|
|
+import DataPreview from '../common/dataPreview/dataPreview'
|
|
|
const { Content } = Layout
|
|
|
const { Search } = Input
|
|
|
const { TreeNode } = Tree
|
|
|
@@ -19,6 +20,7 @@ class DataSource extends React.Component {
|
|
|
visibleSetGroupMenu: false, //
|
|
|
visibleTransferBox: false,
|
|
|
visibleDeleteBox: false,
|
|
|
+ visibleDataPreviewBox: false, // 显示数据预览
|
|
|
groupEditing: false, // 是否处于编辑状态
|
|
|
}
|
|
|
};
|
|
|
@@ -244,8 +246,9 @@ class DataSource extends React.Component {
|
|
|
|
|
|
render() {
|
|
|
|
|
|
- const { dataSource, dispatch } = this.props;
|
|
|
- const { selectedRecord, visibleTransferBox, visibleDeleteBox } = this.state;
|
|
|
+ const { main, dataSource, dispatch } = this.props;
|
|
|
+ const { selectedRecord, visibleTransferBox, visibleDeleteBox, visibleDataPreviewBox } = this.state;
|
|
|
+ const { currentUser } = main;
|
|
|
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
let filterLabel = dataSource.filterLabel.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
@@ -253,6 +256,7 @@ class DataSource extends React.Component {
|
|
|
const TAG_COLOR = ['blue'];
|
|
|
// const TAG_COLOR1 = ['magenta', 'red', 'volcano', 'orange', 'gold', 'lime', 'green', 'cyan', 'blue', 'geekblue', 'purple'];
|
|
|
|
|
|
+ console.log(selectedRecord, currentUser.code)
|
|
|
const moreOperatingMenu = (
|
|
|
<Menu className='operationmenu' visible={true}>
|
|
|
<Menu.Item
|
|
|
@@ -262,35 +266,38 @@ class DataSource extends React.Component {
|
|
|
>
|
|
|
<Icon type="file-add" />创建图表
|
|
|
</Menu.Item>
|
|
|
- <Menu.Item
|
|
|
- onClick={(e) => {
|
|
|
+ {selectedRecord && currentUser.code === selectedRecord.creatorCode && <Menu.Item onClick={(e) => {
|
|
|
dispatch({ type: 'dataSource/resetNewModel' });
|
|
|
let selectedModel = dataSource.list.find((i) => { return i.code === selectedRecord.code })
|
|
|
dispatch({type: 'main/redirect', path: {pathname: '/datasource/'+ selectedModel.type +'/' + selectedModel.code + '/base'}});
|
|
|
}}>
|
|
|
<Icon type="info-circle-o" />属性设置
|
|
|
- </Menu.Item>
|
|
|
- <Menu.Item><Icon type="search" />预览数据</Menu.Item>
|
|
|
+ </Menu.Item>}
|
|
|
+ <Menu.Item onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleDataPreviewBox: true
|
|
|
+ });
|
|
|
+ }}><Icon type="search" />预览数据</Menu.Item>
|
|
|
<Menu.Divider />
|
|
|
- <Menu.SubMenu className='setgroupmenu' title={<div><Icon style={{ marginRight: '6px' }} type='profile' />移动到</div>}>
|
|
|
+ { selectedRecord && currentUser.code === selectedRecord.creatorCode && <Menu.SubMenu className='setgroupmenu' title={<div><Icon style={{ marginRight: '6px' }} type='profile' />移动到</div>}>
|
|
|
{this.createGroupMenu(selectedRecord)}
|
|
|
- </Menu.SubMenu>
|
|
|
+ </Menu.SubMenu>}
|
|
|
<Menu.Divider />
|
|
|
- <Menu.Item
|
|
|
+ { selectedRecord && currentUser.code === selectedRecord.creatorCode && <Menu.Item
|
|
|
onClick={()=>{
|
|
|
this.setState({ visibleTransferBox: true})
|
|
|
}}
|
|
|
>
|
|
|
<Icon type="swap" />移交
|
|
|
- </Menu.Item>
|
|
|
- <Menu.Item
|
|
|
+ </Menu.Item>}
|
|
|
+ { selectedRecord && currentUser.code === selectedRecord.creatorCode && <Menu.Item
|
|
|
onClick={(e) => {
|
|
|
this.setState({ visibleDeleteBox: true})
|
|
|
}}
|
|
|
>
|
|
|
<Icon type="delete" />删除
|
|
|
|
|
|
- </Menu.Item>
|
|
|
+ </Menu.Item>}
|
|
|
</Menu>
|
|
|
);
|
|
|
const dataSourceColumns = [{
|
|
|
@@ -340,8 +347,8 @@ class DataSource extends React.Component {
|
|
|
}
|
|
|
}, {
|
|
|
title: '创建人',
|
|
|
- dataIndex: 'creator',
|
|
|
- key: 'creator',
|
|
|
+ dataIndex: 'creatorName',
|
|
|
+ key: 'creatorName',
|
|
|
width: 100
|
|
|
}, {
|
|
|
title: '创建时间',
|
|
|
@@ -429,7 +436,7 @@ class DataSource extends React.Component {
|
|
|
dispatch({ type: 'dataSource/setNewModelField', name: 'type', value: type });
|
|
|
dispatch({type: 'main/redirect', path: {pathname: '/datasource/'+ type +'/create/base'}});
|
|
|
}}>
|
|
|
- <Menu.Item key='database'>数据库</Menu.Item>
|
|
|
+ { currentUser.role === 'admin' && <Menu.Item key='database'>数据库</Menu.Item>}
|
|
|
<Menu.Item key='file'>文件</Menu.Item>
|
|
|
</Menu>
|
|
|
)} trigger={['click']}>
|
|
|
@@ -469,6 +476,7 @@ class DataSource extends React.Component {
|
|
|
visibleTransferBox: false
|
|
|
})
|
|
|
}}
|
|
|
+ onlyAdmin={true}
|
|
|
/>
|
|
|
<DeleteBox
|
|
|
visibleDeleteBox={visibleDeleteBox}
|
|
|
@@ -481,7 +489,43 @@ class DataSource extends React.Component {
|
|
|
selectedRecord={selectedRecord}
|
|
|
onOk={() =>{
|
|
|
dispatch({ type: 'dataSource/remoteDelete', code: selectedRecord.code })
|
|
|
- }} />
|
|
|
+ }} />
|
|
|
+ <DataPreview
|
|
|
+ visibleBox={visibleDataPreviewBox}
|
|
|
+ hideBox={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleDataPreviewBox: false
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ columns={[{
|
|
|
+ title: '列1',
|
|
|
+ dataIndex: 'c1'
|
|
|
+ }, {
|
|
|
+ title: '列2',
|
|
|
+ dataIndex: 'c2'
|
|
|
+ }, {
|
|
|
+ title: '列3',
|
|
|
+ dataIndex: 'c3'
|
|
|
+ }, {
|
|
|
+ title: '列4',
|
|
|
+ dataIndex: 'c4'
|
|
|
+ }, {
|
|
|
+ title: '列5',
|
|
|
+ dataIndex: 'c5'
|
|
|
+ }, {
|
|
|
+ title: '列6',
|
|
|
+ dataIndex: 'c6'
|
|
|
+ }]}
|
|
|
+ dataSource={((count) => {
|
|
|
+ let arr = [];
|
|
|
+ for(let i = 0; i < count; i++) {
|
|
|
+ arr.push({
|
|
|
+ key: i, c1: 0, c2: 0, c3: 0, c4: 0, c5: 0, c6: 0
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ })(20)}
|
|
|
+ />
|
|
|
</Card>
|
|
|
</Content>
|
|
|
</Layout>
|
|
|
@@ -491,8 +535,8 @@ class DataSource extends React.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function mapStateToProps({present: {dataSource, dataConnect}}) {
|
|
|
- return { dataSource, dataConnect }
|
|
|
+function mapStateToProps({present: {main, dataSource, dataConnect}}) {
|
|
|
+ return { main, dataSource, dataConnect }
|
|
|
}
|
|
|
|
|
|
export default connect(mapStateToProps)(DataSource)
|