|
|
@@ -1,6 +1,5 @@
|
|
|
import React from 'react'
|
|
|
-import moment from 'moment'
|
|
|
-import { Layout, Row, Col, Input, Button, Table, Icon, Menu, Dropdown, Card, Breadcrumb, Tag, Checkbox, Select, DatePicker } from 'antd'
|
|
|
+import { Layout, Row, Col, Button, Table, Icon, Menu, Dropdown, Card, Breadcrumb, Tag, Checkbox, Select } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
|
import { arrayToTree, dateFormat } from '../../utils/baseUtils'
|
|
|
import GroupManagementBox from '../common/groupManageMentBox/box'
|
|
|
@@ -9,11 +8,10 @@ import TransferBox from '../common/selectUserBox/selectUserBox'
|
|
|
import CopyBox from './copyBox'
|
|
|
import DeleteBox from '../common/deleteBox/deleteBox'
|
|
|
import DataPreview from '../common/dataPreview/dataPreview'
|
|
|
+import ListFilter from '../common/listFilter/index'
|
|
|
import './list.less'
|
|
|
const { Content } = Layout
|
|
|
-const { Search } = Input
|
|
|
const { Option } = Select
|
|
|
-const { RangePicker } = DatePicker
|
|
|
|
|
|
class DataSource extends React.Component {
|
|
|
constructor(props) {
|
|
|
@@ -67,7 +65,7 @@ class DataSource extends React.Component {
|
|
|
onSearch(list, dataSource) {
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
let filterItem = dataSource.filterItem
|
|
|
- let filterLabel = (dataSource.filterLabel || '').replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
+ let filterLabel = dataSource.filterLabel ? (dataSource.filterLabel + '').replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') : ''; // 添加转义符号
|
|
|
let filterReg = new RegExp('('+ filterLabel +'){1}', 'ig');
|
|
|
|
|
|
return list.map(l => {
|
|
|
@@ -88,7 +86,12 @@ class DataSource extends React.Component {
|
|
|
return null
|
|
|
}
|
|
|
}else {
|
|
|
- return ((o[filterItem.name] + '').search(filterReg) > -1) ? o : null
|
|
|
+ let arr = filterItem.name.split('.');
|
|
|
+ let v = o;
|
|
|
+ for(let i = 0; i < arr.length; i++) {
|
|
|
+ v = v[arr[i]]
|
|
|
+ }
|
|
|
+ return ((v + '').search(filterReg) > -1) ? o : null
|
|
|
}
|
|
|
}).filter(a => a!==null);
|
|
|
}
|
|
|
@@ -202,7 +205,7 @@ class DataSource extends React.Component {
|
|
|
const treeData = arrayToTree(dataSource.groupList, '-1', 'code', 'pcode', 'children');
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
let filterItem = dataSource.filterItem;
|
|
|
- let filterLabel = dataSource.filterLabel.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
+ let filterLabel = dataSource.filterLabel ? (dataSource.filterLabel + '').replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') : ''; // 添加转义符号
|
|
|
|
|
|
const moreOperatingMenu = (
|
|
|
<Menu className='operationmenu' visible={true}>
|
|
|
@@ -282,6 +285,11 @@ class DataSource extends React.Component {
|
|
|
</div>
|
|
|
</div>
|
|
|
}
|
|
|
+ }, {
|
|
|
+ title: '数据链接',
|
|
|
+ dataIndex: 'dbConfig.name',
|
|
|
+ key: 'dbConfig.name',
|
|
|
+ width: 100
|
|
|
}, {
|
|
|
title: '说明',
|
|
|
dataIndex: 'description',
|
|
|
@@ -358,54 +366,8 @@ class DataSource extends React.Component {
|
|
|
{ this.generateGroupTags() }
|
|
|
</Col>
|
|
|
<Col className='search'>
|
|
|
- <Col style={{ padding: '0 1px', margin: '0 -5px' }}>
|
|
|
- <Select
|
|
|
- value={filterItem.name}
|
|
|
- style={{ width: 120 }}
|
|
|
- onChange={value => {
|
|
|
- let item = dataSource.filterItems.find(i => i.name === value);
|
|
|
- dispatch({ type: 'dataSource/setFilterItem', item });
|
|
|
- }}
|
|
|
- >
|
|
|
- { this.generateFilterItems() }
|
|
|
- </Select>
|
|
|
- </Col>
|
|
|
<Col style={{ padding: '0 5px' }}>
|
|
|
- {filterItem.type === 'date' ?
|
|
|
- <RangePicker
|
|
|
- ranges={{
|
|
|
- '今天': [moment().startOf('day'), moment().endOf('day')],
|
|
|
- '昨天': [moment().startOf('day').add(-1,'days'), moment().endOf('day')],
|
|
|
- '近七天': [moment().startOf('day'),moment().endOf('day').add(6,'days')],
|
|
|
- '本月': [moment().startOf('month'), moment().endOf('month')],
|
|
|
- '本年': [moment().startOf('year'), moment().endOf('year')]
|
|
|
- }}
|
|
|
- showTime={{ format: 'HH:mm' }}
|
|
|
- format="YYYY-MM-DD HH:mm:ss"
|
|
|
- onChange={e => {
|
|
|
- //清空时间时
|
|
|
- if(e.length === 0){
|
|
|
- dispatch({ type: 'dataSource/setFilterLabel', label: '' });
|
|
|
- }
|
|
|
- }}
|
|
|
- onOk={e => {
|
|
|
- //解析时间格式
|
|
|
- let start = e[0]
|
|
|
- let end = e[1]
|
|
|
- let time = start._d.getTime() + "#" + end._d.getTime()
|
|
|
- dispatch({ type: 'dataSource/setFilterLabel', label: time });
|
|
|
- }}
|
|
|
- >
|
|
|
- </RangePicker>
|
|
|
- :
|
|
|
- <Search
|
|
|
- value={dataSource.filterLabel}
|
|
|
- placeholder="请输入关键字"
|
|
|
- onChange={e => {
|
|
|
- dispatch({ type: 'dataSource/setFilterLabel', label: e.target.value });
|
|
|
- }}
|
|
|
- />
|
|
|
- }
|
|
|
+ <ListFilter modelName='dataSource' model={dataSource} />
|
|
|
</Col>
|
|
|
<Col>
|
|
|
<Button style={{ marginRight: '8px' }} onClick={() => {
|