|
|
@@ -1,6 +1,7 @@
|
|
|
import React from 'react'
|
|
|
-import { Layout, Row, Col, Input, Button, Table, Icon, Menu, Dropdown, Card, Breadcrumb, Popover, Tree, Tag } from 'antd'
|
|
|
+import { Layout, Row, Col, Input, Button, Table, Icon, Menu, Dropdown, Card, Breadcrumb, Popover, Tree, Tag, Select, DatePicker } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
|
+import moment from 'moment'
|
|
|
import { dateFormat } from '../../utils/baseUtils'
|
|
|
import GroupSelector from './groupSelector'
|
|
|
import TransferBox from '../common/selectUserBox/selectUserBox'
|
|
|
@@ -11,6 +12,8 @@ import './list.less'
|
|
|
const { Content } = Layout
|
|
|
const { Search } = Input
|
|
|
const { TreeNode } = Tree
|
|
|
+const { Option } = Select
|
|
|
+const { RangePicker } = DatePicker
|
|
|
|
|
|
class DataSource extends React.Component {
|
|
|
constructor(props) {
|
|
|
@@ -49,9 +52,7 @@ class DataSource extends React.Component {
|
|
|
|
|
|
onGroup() {
|
|
|
const { dataSource } = this.props;
|
|
|
- const groupList = dataSource.groupList;
|
|
|
- const list = dataSource.list;
|
|
|
- const currentGroup = dataSource.currentGroup;
|
|
|
+ const { groupList, currentGroup, list } = dataSource;
|
|
|
|
|
|
let groupFilter = groupList.concat({ code: '-1', label: '未分组' }).filter(g => (
|
|
|
currentGroup[0].code === 'all' ||
|
|
|
@@ -69,18 +70,33 @@ class DataSource extends React.Component {
|
|
|
return list.filter(l => groupFilter.indexOf(l.groupCode+'') !== -1);
|
|
|
}
|
|
|
|
|
|
- onSearch(list, text) {
|
|
|
+ onSearch(list, dataSource) {
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
- let filterLabel = (text || '').replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
+ let filterLabel = (dataSource.filterLabel || '').replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
+ let typeLabel = dataSource.typeLabel
|
|
|
+
|
|
|
return list.map(l => {
|
|
|
let o = Object.assign({}, l);
|
|
|
let reg = new RegExp('('+ filterLabel +'){1}', 'ig');
|
|
|
- if(o.name && o.name.search(reg) !== -1) {
|
|
|
- return o;
|
|
|
- }else if(o.description && o.description.search(reg) !== -1) {
|
|
|
+
|
|
|
+ if(o[typeLabel] && typeLabel!=='createTime' && o[typeLabel].search(reg) !== -1){
|
|
|
return o;
|
|
|
- }else {
|
|
|
- return null
|
|
|
+ }else if(o[typeLabel] && typeLabel==='createTime'){
|
|
|
+ if(filterLabel===""){
|
|
|
+ return o;
|
|
|
+ }else if(filterLabel.indexOf('#')>-1){
|
|
|
+ let start = filterLabel.split('#')[0]
|
|
|
+ let end = filterLabel.split('#')[1]
|
|
|
+ let nowTime = o[typeLabel].getTime();
|
|
|
+ if(nowTime>=start && nowTime<=end){
|
|
|
+ return o;
|
|
|
+ }
|
|
|
+ return null
|
|
|
+ }else{
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return null
|
|
|
}
|
|
|
}).filter(a => a!==null);
|
|
|
}
|
|
|
@@ -247,10 +263,10 @@ class DataSource extends React.Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
-
|
|
|
const { main, dataSource, dispatch } = this.props;
|
|
|
const { selectedRecord, visibleTransferBox, visibleCopyBox, visibleDeleteBox, visibleDataPreviewBox } = this.state;
|
|
|
const { currentUser } = main;
|
|
|
+ const { changeSearchType } = dataSource;
|
|
|
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
let filterLabel = dataSource.filterLabel.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
@@ -432,14 +448,56 @@ class DataSource extends React.Component {
|
|
|
</Breadcrumb>
|
|
|
</Col>
|
|
|
<Col className='search'>
|
|
|
- <Col>
|
|
|
- <Search
|
|
|
- value={dataSource.filterLabel}
|
|
|
- placeholder="请输入关键字"
|
|
|
+ <Col style={{ padding: '0 1px', margin: '0 -5px' }}>
|
|
|
+ <Select
|
|
|
+ value={dataSource.typeLabel}
|
|
|
+ style={{ width: 120 }}
|
|
|
onChange={e => {
|
|
|
- dispatch({ type: 'dataSource/setFilterLabel', label: e.target.value });
|
|
|
+ dispatch({ type: 'dataSource/setTypeLabel', selected: e });
|
|
|
}}
|
|
|
- />
|
|
|
+ >
|
|
|
+ <Option value="name">名称</Option>
|
|
|
+ <Option hidden value="description">说明</Option>
|
|
|
+ <Option value="creatorName">创建人</Option>
|
|
|
+ <Option value="createTime">创建时间</Option>
|
|
|
+ </Select>
|
|
|
+ </Col>
|
|
|
+ <Col style={{ padding: '0 5px' }}>
|
|
|
+ {changeSearchType ?
|
|
|
+ <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 });
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ }
|
|
|
</Col>
|
|
|
<Col>
|
|
|
<Dropdown overlay={(
|
|
|
@@ -467,7 +525,7 @@ class DataSource extends React.Component {
|
|
|
columns={dataSourceColumns}
|
|
|
dataSource={
|
|
|
this.onSort(
|
|
|
- this.onSearch(this.onGroup(), dataSource.filterLabel)
|
|
|
+ this.onSearch(this.onGroup(), dataSource)
|
|
|
)
|
|
|
}
|
|
|
size='small'
|