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/table-card/index.jsx | 90 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 88 insertions(+), 2 deletions(-) diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index bf19684..8008410 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -1,5 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { connect } from 'react-redux' import { is, fromJS } from 'immutable' import { Spin, notification, Row, Col, Empty, Pagination } from 'antd' @@ -7,6 +8,7 @@ import Utils from '@/utils/utils.js' import asyncComponent from '@/utils/asyncComponent' import UtilsDM from '@/utils/utils-datamanage.js' +import { modifyTabview } from '@/store/action' import MKEmitter from '@/utils/events.js' import './index.scss' @@ -295,6 +297,77 @@ }) } + openView = (card, data) => { + 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]) + } + } + getLines = (data) => { const { config } = this.state @@ -325,7 +398,7 @@ line.push( <Col key={index} span={24}> - <div className="card-item-box" style={item.style}> + <div className="card-item-box" style={item.style} onClick={() => {this.openView(item, data)}}> <CardCellComponent data={data} cards={config} cardCell={item} elements={item.elements}/> </div> </Col> @@ -368,4 +441,17 @@ } } -export default TableCard \ 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)(TableCard) \ No newline at end of file -- Gitblit v1.8.0