Commit d66d307c authored by 崔佳豪's avatar 崔佳豪

feat: 消息卡片添加其他消息跳转

parent 3da1389d
Pipeline #53718 waiting for manual action with stages
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Button, Form, Input, Modal } from 'antd'; import { Button, Form, Input, Modal, notification } from 'antd';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Notifier, NoticeIcon, FormattedMessage } from '@wisdom-utils/components'; import { Notifier, NoticeIcon, FormattedMessage } from '@wisdom-utils/components';
import { ERR_OK, MESSAGE_TYPE, NEW_MESSAGE } from '@wisdom-utils/components/lib/AppLayout/notifier/constants'; import { ERR_OK, MESSAGE_TYPE, NEW_MESSAGE } from '@wisdom-utils/components/lib/AppLayout/notifier/constants';
...@@ -240,6 +240,39 @@ class NoticeIconView extends Component { ...@@ -240,6 +240,39 @@ class NoticeIconView extends Component {
this.renderSysPlatform(message); this.renderSysPlatform(message);
}; };
handlerUnknowDetail = message => {
// 需要有跳转路径
if (!message.webPath)
return notification.info({ message: '提示', duration: 3, description: '未配置跳转路径' });
const parsePath = url => {
const [path, param = ''] = url.split('|');
let params = param.split('&').reduce((pre, item) => {
if(!item) return pre;
const [key, value] = item.split('=');
pre[key] = value;
return pre;
}, {});
return [path, param, params];
}
const [path,,params] = parsePath(message.webPath);
// 需要有widget参数
if (!params.widget)
return notification.info({ message: '提示', duration: 3, description: '未配置跳转路径' });
// 根据widget匹配菜单
const menu = (this.props.flatMenu || []).find(item => item.params && item.params.widget === params.widget);
// const menu = (this.props.flatMenu || []).find(item => item.path.indexOf(path) > -1);
let targetMenuPath = menu ? menu.path.replace(/^\//, '') : '';
if (targetMenuPath == '') {
notification.info({ message: '提示', duration: 3, description: '你没有跳转菜单权限,请联系管理员添加权限' });
return;
}
params._source = '消息通知';
params._target = message.webPath;
sessionStorage.setItem('routerParams', JSON.stringify(params));
window.history.pushState(params, '', `/civbase/${targetMenuPath}`);
}
render() { render() {
return ( return (
<> <>
...@@ -257,6 +290,7 @@ class NoticeIconView extends Component { ...@@ -257,6 +290,7 @@ class NoticeIconView extends Component {
emptyText={<FormattedMessage id='component.noticeIcon.allClear'/>} emptyText={<FormattedMessage id='component.noticeIcon.allClear'/>}
confirmRead={this.notifier.confirmRead} confirmRead={this.notifier.confirmRead}
handlerSysDetail={this.handlerSysDetail} handlerSysDetail={this.handlerSysDetail}
handlerUnknowDetail={this.handlerUnknowDetail.bind(this)}
loadMore={this.notifier.loadMore} loadMore={this.notifier.loadMore}
hasMore={this.notifier.hasMore} hasMore={this.notifier.hasMore}
/> />
...@@ -471,6 +505,7 @@ class NoticeIconView extends Component { ...@@ -471,6 +505,7 @@ class NoticeIconView extends Component {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
flatMenu: state.getIn(['global', 'flatMenu']),
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
......
...@@ -18,12 +18,12 @@ const findMenuPath = (flatMenu, url) => { ...@@ -18,12 +18,12 @@ const findMenuPath = (flatMenu, url) => {
const [path, param = ''] = url.split('|'); const [path, param = ''] = url.split('|');
let params = param.split('&').reduce((pre, item) => { let params = param.split('&').reduce((pre, item) => {
if(!item) return pre; if(!item) return pre;
const [key, value] = item.split('&'); const [key, value] = item.split('=');
pre[key] = value; pre[key] = value;
return pre; return pre;
}, {}); }, {});
// const menu = flatMenu.find(item => item.params && item.params.widget === params.widget); // 根据widget匹配菜单 const menu = flatMenu.find(item => item.params && item.params.widget === params.widget); // 根据widget匹配菜单
const menu = flatMenu.find(item => item.path.indexOf(path) > -1); // 根据路径匹配菜单 // const menu = flatMenu.find(item => item.path.indexOf(path) > -1); // 根据路径匹配菜单
return menu ? menu.path.replace(/^\//, '') : ''; return menu ? menu.path.replace(/^\//, '') : '';
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment