|
@@ -93,21 +93,18 @@ class DashboardList extends React.Component {
|
|
|
onSearch(list, dashboard) {
|
|
onSearch(list, dashboard) {
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
let filterLabel = (dashboard.filterLabel || '').replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
let filterLabel = (dashboard.filterLabel || '').replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
- let typeLabel = dashboard.typeLabel
|
|
|
|
|
-
|
|
|
|
|
|
|
+ let filterItem = dashboard.filterItem;
|
|
|
|
|
+ let filterReg = new RegExp('(' + filterLabel + '){1}', 'ig');
|
|
|
return list.map(l => {
|
|
return list.map(l => {
|
|
|
let o = Object.assign({}, l);
|
|
let o = Object.assign({}, l);
|
|
|
- let reg = new RegExp('('+ filterLabel +'){1}', 'ig');
|
|
|
|
|
|
|
|
|
|
- if(o[typeLabel] && typeLabel!=='createTime' && o[typeLabel].search(reg) !== -1){
|
|
|
|
|
- return o;
|
|
|
|
|
- }else if(o[typeLabel] && typeLabel==='createTime'){
|
|
|
|
|
|
|
+ if(filterItem.type === 'date') {
|
|
|
if(filterLabel===""){
|
|
if(filterLabel===""){
|
|
|
return o;
|
|
return o;
|
|
|
}else if(filterLabel.indexOf('#')>-1){
|
|
}else if(filterLabel.indexOf('#')>-1){
|
|
|
let start = filterLabel.split('#')[0]
|
|
let start = filterLabel.split('#')[0]
|
|
|
let end = filterLabel.split('#')[1]
|
|
let end = filterLabel.split('#')[1]
|
|
|
- let nowTime = new Date(o[typeLabel]).getTime();
|
|
|
|
|
|
|
+ let nowTime = new Date(o[filterItem.name]).getTime();
|
|
|
if(nowTime>=start && nowTime<=end){
|
|
if(nowTime>=start && nowTime<=end){
|
|
|
return o;
|
|
return o;
|
|
|
}
|
|
}
|
|
@@ -115,8 +112,8 @@ class DashboardList extends React.Component {
|
|
|
}else{
|
|
}else{
|
|
|
return null
|
|
return null
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
- return null
|
|
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return ((o[filterItem.name] + '').search(filterReg) > -1) ? o : null
|
|
|
}
|
|
}
|
|
|
}).filter(a => a!==null);
|
|
}).filter(a => a!==null);
|
|
|
}
|
|
}
|
|
@@ -127,11 +124,16 @@ class DashboardList extends React.Component {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ generateFilterItems = () => {
|
|
|
|
|
+ const { filterItems } = this.props.dashboard;
|
|
|
|
|
+ return filterItems.map(t => <Option key={t.name} value={t.name}>{t.label}</Option>);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
const { dispatch, dashboard, main } = this.props;
|
|
const { dispatch, dashboard, main } = this.props;
|
|
|
const { visibleShareBox, shareUrl, visibleDistributeBox, visibleTransferBox, visibleDeleteBox, visibleCopyBox, selectedRecord, defaultSelectedGroups, defaultSelectedUsers } = this.state
|
|
const { visibleShareBox, shareUrl, visibleDistributeBox, visibleTransferBox, visibleDeleteBox, visibleCopyBox, selectedRecord, defaultSelectedGroups, defaultSelectedUsers } = this.state
|
|
|
const { currentUser } = main;
|
|
const { currentUser } = main;
|
|
|
- const { changeSearchType } = dashboard;
|
|
|
|
|
|
|
+ const { filterItem } = dashboard;
|
|
|
|
|
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
let filterLabel = dashboard.filterLabel.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
let filterLabel = dashboard.filterLabel.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
@@ -186,7 +188,7 @@ class DashboardList extends React.Component {
|
|
|
dispatch({ type: 'main/redirect', path: '/dashboard/' + record.code });
|
|
dispatch({ type: 'main/redirect', path: '/dashboard/' + record.code });
|
|
|
dispatch({ type: 'recent/addRecentRecord', tarId: record.code, recordType: 1});
|
|
dispatch({ type: 'recent/addRecentRecord', tarId: record.code, recordType: 1});
|
|
|
}}>
|
|
}}>
|
|
|
- { filterLabel ?
|
|
|
|
|
|
|
+ { filterLabel && filterItem.name === 'name' ?
|
|
|
((text || '').split(new RegExp(`(${filterLabel})`, 'i')).map((fragment, i) => {
|
|
((text || '').split(new RegExp(`(${filterLabel})`, 'i')).map((fragment, i) => {
|
|
|
return (
|
|
return (
|
|
|
fragment.toLowerCase().replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') === filterLabel.toLowerCase() ?
|
|
fragment.toLowerCase().replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') === filterLabel.toLowerCase() ?
|
|
@@ -207,7 +209,7 @@ class DashboardList extends React.Component {
|
|
|
render: (text, record) => {
|
|
render: (text, record) => {
|
|
|
return (
|
|
return (
|
|
|
<span>
|
|
<span>
|
|
|
- { filterLabel ?
|
|
|
|
|
|
|
+ { filterLabel && filterItem.name === 'description' ?
|
|
|
((text || '').split(new RegExp(`(${filterLabel})`, 'i')).map((fragment, i) => {
|
|
((text || '').split(new RegExp(`(${filterLabel})`, 'i')).map((fragment, i) => {
|
|
|
return (
|
|
return (
|
|
|
fragment.toLowerCase().replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') === filterLabel.toLowerCase() ?
|
|
fragment.toLowerCase().replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') === filterLabel.toLowerCase() ?
|
|
@@ -224,7 +226,23 @@ class DashboardList extends React.Component {
|
|
|
title: '创建人',
|
|
title: '创建人',
|
|
|
dataIndex: 'creatorName',
|
|
dataIndex: 'creatorName',
|
|
|
key: 'creatorName',
|
|
key: 'creatorName',
|
|
|
- width: 100
|
|
|
|
|
|
|
+ width: 100,
|
|
|
|
|
+ render: (text, record) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <span>
|
|
|
|
|
+ { filterLabel && filterItem.name === 'creatorName' ?
|
|
|
|
|
+ ((text || '').split(new RegExp(`(${filterLabel})`, 'i')).map((fragment, i) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ fragment.toLowerCase().replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') === filterLabel.toLowerCase() ?
|
|
|
|
|
+ <span key={i} style={{fontWeight: 'bold', color: 'red'}} className="highlight">{fragment}</span> :
|
|
|
|
|
+ fragment
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ )) : text
|
|
|
|
|
+ }
|
|
|
|
|
+ </span>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
}, {
|
|
}, {
|
|
|
title: '创建时间',
|
|
title: '创建时间',
|
|
|
dataIndex: 'createTime',
|
|
dataIndex: 'createTime',
|
|
@@ -252,27 +270,25 @@ class DashboardList extends React.Component {
|
|
|
<Col className='search'>
|
|
<Col className='search'>
|
|
|
<Col style={{ padding: '0 1px', margin: '0 -5px' }}>
|
|
<Col style={{ padding: '0 1px', margin: '0 -5px' }}>
|
|
|
<Select
|
|
<Select
|
|
|
- value={dashboard.typeLabel}
|
|
|
|
|
|
|
+ value={dashboard.filterItem.name}
|
|
|
style={{ width: 120 }}
|
|
style={{ width: 120 }}
|
|
|
- onChange={e => {
|
|
|
|
|
- dispatch({ type: 'dashboard/setTypeLabel', selected: e });
|
|
|
|
|
|
|
+ onChange={value => {
|
|
|
|
|
+ let item = dashboard.filterItems.find(i => i.name === value);
|
|
|
|
|
+ dispatch({ type: 'dashboard/setFilterItem', item });
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
- <Option value="name">名称</Option>
|
|
|
|
|
- <Option hidden value="description">说明</Option>
|
|
|
|
|
- <Option value="creatorName">创建人</Option>
|
|
|
|
|
- <Option value="createTime">创建时间</Option>
|
|
|
|
|
|
|
+ { this.generateFilterItems() }
|
|
|
</Select>
|
|
</Select>
|
|
|
</Col>
|
|
</Col>
|
|
|
<Col style={{ padding: '0 5px' }}>
|
|
<Col style={{ padding: '0 5px' }}>
|
|
|
- {changeSearchType ?
|
|
|
|
|
|
|
+ {dashboard.filterItem.type === 'date' ?
|
|
|
<RangePicker
|
|
<RangePicker
|
|
|
ranges={{
|
|
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')]
|
|
|
|
|
|
|
+ '今天': [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' }}
|
|
showTime={{ format: 'HH:mm' }}
|
|
|
format="YYYY-MM-DD HH:mm:ss"
|
|
format="YYYY-MM-DD HH:mm:ss"
|
|
@@ -293,13 +309,13 @@ class DashboardList extends React.Component {
|
|
|
</RangePicker>
|
|
</RangePicker>
|
|
|
:
|
|
:
|
|
|
<Search
|
|
<Search
|
|
|
- placeholder="请输入关键字"
|
|
|
|
|
value={dashboard.filterLabel}
|
|
value={dashboard.filterLabel}
|
|
|
|
|
+ placeholder="请输入关键字"
|
|
|
onChange={e => {
|
|
onChange={e => {
|
|
|
dispatch({ type: 'dashboard/setFilterLabel', label: e.target.value });
|
|
dispatch({ type: 'dashboard/setFilterLabel', label: e.target.value });
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
</Col>
|
|
</Col>
|
|
|
<Col >
|
|
<Col >
|
|
|
<Button onClick={() => {
|
|
<Button onClick={() => {
|