From f497f734966504bd8a7e98bf602da582a53d91e5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 12 九月 2021 02:55:59 +0800 Subject: [PATCH] 2021-09-12 --- src/tabviews/custom/components/card/cardItem/index.jsx | 94 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 92 insertions(+), 2 deletions(-) diff --git a/src/tabviews/custom/components/card/cardItem/index.jsx b/src/tabviews/custom/components/card/cardItem/index.jsx index 044bc4e..f4d35ad 100644 --- a/src/tabviews/custom/components/card/cardItem/index.jsx +++ b/src/tabviews/custom/components/card/cardItem/index.jsx @@ -1,8 +1,12 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { connect } from 'react-redux' import { is, fromJS } from 'immutable' +import { notification } from 'antd' import asyncComponent from '@/utils/asyncComponent' +import { modifyTabview } from '@/store/action' +import MKEmitter from '@/utils/events.js' import './index.scss' const CardCellComponent = asyncComponent(() => import('../cardcellList')) @@ -38,11 +42,84 @@ } } + openView = () => { + const { card, data } = this.props + + if (card.setting.click === 'menu') { + let menu = null + + if (card.setting.MenuID) { + menu = { + MenuID: card.setting.MenuID, + MenuName: card.setting.MenuName, + MenuNo: card.setting.MenuNo, + type: card.setting.tabType + } + } else if (card.setting.menu && card.setting.menu.length > 0) { + let menu_id = card.setting.menu.slice(-1)[0] + menu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || '' + + if (!menu) { + notification.warning({ + top: 92, + message: '鑿滃崟宸插垹闄ゆ垨娌℃湁璁块棶鏉冮檺锛�', + duration: 5 + }) + return + } + } + + let newtab = { + ...menu, + selected: true, + param: {} + } + + if (card.setting.joint === 'true') { + newtab.param.$BID = data.$$uuid || '' + } + + if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) { + this.props.modifyTabview([newtab]) + } else { + let tabs = this.props.tabviews.filter((tab, i) => { + tab.selected = false + return tab.MenuID !== newtab.MenuID + }) + + if (this.props.tabviews.length > tabs.length) { + this.props.modifyTabview(fromJS(tabs).toJS()) + } + + this.setState({}, () => { + tabs.push(newtab) + this.props.modifyTabview(tabs) + }) + } + } else if (card.setting.click === 'link') { + let src = card.setting.linkurl + + if (card.setting.joint === 'true') { + let con = '?' + + if (/\?/ig.test(src)) { + con = '&' + } + + src = src + `${con}id=${data.$$uuid || ''}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` + } + + window.open(src) + } else if (card.setting.click === 'button' && card.setting.linkbtn) { + MKEmitter.emit('triggerBtnId', card.setting.linkbtn, [data]) + } + } + render() { const { card, data, cards } = this.props return ( - <div className="card-item-box" style={card.style}> + <div className="card-item-box" style={card.style} onClick={this.openView}> <CardCellComponent data={data} cards={cards} cardCell={card} elements={card.elements}/> {card.setting.type === 'multi' ? <div className={'back-side ' + card.setting.transform} style={card.backStyle}> <CardCellComponent data={data} cards={cards} cardCell={card} elements={card.backElements}/> @@ -52,4 +129,17 @@ } } -export default CardBoxComponent \ No newline at end of file +const mapStateToProps = (state) => { + return { + permMenus: state.permMenus, + tabviews: state.tabviews, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(CardBoxComponent) \ No newline at end of file -- Gitblit v1.8.0