From bd1dfc9e6c9b9f8076ca2783ce598e0936b4c664 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 22 十二月 2021 14:36:03 +0800 Subject: [PATCH] 2021-12-22 --- src/tabviews/zshare/cardcomponent/index.jsx | 150 +++++++++++++------------------------------------- 1 files changed, 39 insertions(+), 111 deletions(-) diff --git a/src/tabviews/zshare/cardcomponent/index.jsx b/src/tabviews/zshare/cardcomponent/index.jsx index 229ce3c..0480ba8 100644 --- a/src/tabviews/zshare/cardcomponent/index.jsx +++ b/src/tabviews/zshare/cardcomponent/index.jsx @@ -1,10 +1,12 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Card, Spin, Empty, Tabs } from 'antd' +import { Card, Spin, Empty } from 'antd' import asyncComponent from '@/utils/asyncComponent' import asyncExcelComponent from './asyncButtonComponent' +import MKEmitter from '@/utils/events.js' +import MkIcon from '@/components/mk-icon' import '@/assets/css/table.scss' import './index.scss' @@ -17,8 +19,6 @@ const ChangeUserButton = asyncComponent(() => import('@/tabviews/zshare/actionList/changeuserbutton')) const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton')) -const { TabPane } = Tabs - class CardCell extends Component { static propTpyes = { type: PropTypes.any, // 鍗$墖绫诲瀷锛屾坊鍔犳寜閽负 insert @@ -27,12 +27,11 @@ Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� MenuID: PropTypes.string, // 鑿滃崟ID setting: PropTypes.object, // 椤甸潰璁惧畾 - logcolumns: PropTypes.array, // 瀛楁鍒� + columns: PropTypes.array, // 鏄剧ず鍒� card: PropTypes.object, // 鍗$墖璁剧疆淇℃伅 data: PropTypes.object, // 鍗$墖鏁版嵁 selectKey: PropTypes.string, // 閫夋嫨鍗$墖鐨勫簭鍙� colMap: PropTypes.any, // 鏄剧ず鍒椾俊鎭紝鐢ㄤ簬璁剧疆鏍囪 - refreshdata: PropTypes.func, // 鎸夐挳鎿嶄綔鍚庢暟鎹埛鏂� switchCard: PropTypes.func // 鍗$墖鍒囨崲 } @@ -131,40 +130,38 @@ * @description 鑾峰彇鎸夐挳鍏冪礌 */ getActionList = (actions, show) => { - const { BID, BData, Tab, setting, logcolumns, ContainerId, data, MenuID } = this.props + const { BData, Tab, setting, columns, ContainerId, data, MenuID } = this.props return actions.map(item => { if (['exec', 'prompt', 'pop'].includes(item.OpenType)) { return ( <NormalButton key={item.uuid} - BID={BID} + BID={data.$$BID} Tab={Tab} btn={item} show={show} BData={BData} setting={setting} - columns={logcolumns} + columns={columns} selectedData={[data]} ContainerId={ContainerId} - updateStatus={this.updateStatus} /> ) } else if (item.OpenType === 'popview') { return ( <PopupButton key={item.uuid} - BID={BID} + BID={data.$$BID} Tab={Tab} btn={item} show={show} BData={BData} setting={setting} selectedData={[data]} - updateStatus={this.updateStatus} /> ) - } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { + } else if (item.OpenType === 'tab') { return ( <TabButton key={item.uuid} @@ -173,7 +170,6 @@ MenuID={MenuID} setting={setting} selectedData={[data]} - updateStatus={this.updateStatus} /> ) } else if (item.OpenType === 'innerpage' || item.OpenType === 'outerpage') { @@ -184,27 +180,25 @@ show={show} setting={setting} selectedData={[data]} - updateStatus={this.updateStatus} /> ) } else if (item.OpenType === 'funcbutton') { - if (item.funcType === 'changeuser') { + if (item.funcType === 'changeuser' || item.funcType === 'closetab') { return ( <ChangeUserButton key={item.uuid} - BID={BID} + BID={data.$$BID} btn={item} show={show} setting={setting} selectedData={[data]} - updateStatus={this.updateStatus} /> ) } else if (item.funcType === 'print') { return ( <PrintButton key={item.uuid} - BID={BID} + BID={data.$$BID} Tab={Tab} btn={item} show={show} @@ -212,7 +206,6 @@ setting={setting} selectedData={[data]} ContainerId={ContainerId} - updateStatus={this.updateStatus} /> ) } @@ -220,15 +213,6 @@ return null }) - } - - /** - * @description 鎿嶄綔瀹屾垚鍚庯紝鏁版嵁鍒锋柊 - */ - updateStatus = (type, positon) => { - if (type === 'refresh') { - this.props.refreshdata(positon) - } } /** @@ -262,7 +246,7 @@ if (isNaN(originVal) || isNaN(contrastVal)) { originVal = '' } - } catch { + } catch (e) { originVal = '' } } @@ -290,7 +274,7 @@ if (mark.position === 'front') { position = 'front' } - icon = <Icon className={'font ' + className} type={mark.icon} /> + icon = <MkIcon className={'font ' + className} type={mark.icon} /> className = '' } @@ -349,7 +333,7 @@ if (isNaN(content)) { content = '' } - } catch { + } catch (e) { content = '' } } @@ -458,7 +442,7 @@ } return ( - <div className={'chart-card-box ' + card.outclass} style={card.outstyle || null} > + <div className={'chart-card-box ' + card.outclass}> {type !== 'insert' ? <Card size="small" className={'chart-card ' + (selectKey === data.key ? 'chart-card-selected' : '')} @@ -507,10 +491,9 @@ show={'plus' + plusSize} BData={this.props.BData} setting={this.props.setting} - columns={this.props.logcolumns} + columns={this.props.columns} selectedData={[]} ContainerId={this.props.ContainerId} - updateStatus={this.updateStatus} /> </div> </Card> : null} @@ -526,15 +509,12 @@ Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� MenuID: PropTypes.string, // 鑿滃崟ID config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 - logcolumns: PropTypes.array, // 鏄剧ず鍒� + columns: PropTypes.array, // 鏄剧ず鍒� ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� plot: PropTypes.object, tableId: PropTypes.string, loading: PropTypes.bool, data: PropTypes.array, - refreshdata: PropTypes.func, - getexceloutparam: PropTypes.func, - handleTableId: PropTypes.func } state = { @@ -563,6 +543,13 @@ colMap.set(col.field, col) } }) + + if (plot.widthType === 'absolute') { + plot.cardWidth = 6 + } + if (plot.avatar && plot.avatar.widthType === 'absolute') { + card.avatar.width = 32 + } actions.forEach(item => { if ((item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) || item.funcType === 'changeuser') { @@ -617,13 +604,9 @@ } else if (card.avatar.type === 'picture' && colMap.get(plot.avatar.field)) { card.avatar.field = plot.avatar.field card.avatar.width = plot.avatar.width - card.avatar.widthType = plot.avatar.widthType card.avatar.radius = plot.avatar.radius !== 'false' - let _width = card.avatar.width - if (plot.avatar.widthType === 'ratio') { - _width = _width + '%' - } + let _width = card.avatar.width + '%' card.avatar.class = {width: _width, paddingTop: _width} } @@ -681,18 +664,8 @@ } } - let outclass = '' - - if (plot.widthType === 'ratio' && plot.over !== 'roll') { - outclass += ' ant-col ant-col-' + plot.cardWidth - } - - card.outclass = outclass + card.outclass = ' ant-col ant-col-' + plot.cardWidth card.bordered = plot.border !== 'hidden' - - if (plot.widthType === 'absolute') { - card.outstyle = { width: plot.cardWidth } - } if (plot.bgfield && colMap.get(plot.bgfield)) { let col = fromJS(colMap.get(plot.bgfield)).toJS() @@ -733,17 +706,13 @@ let _flex = false let _cardWidth = 300 - if (plot.widthType === 'absolute') { - _cardWidth = plot.cardWidth - } else { - let _outWidth = document.body.offsetWidth - 260 - if (this.cardRef.offsetWidth) { - _outWidth = this.cardRef.offsetWidth - } - _cardWidth = Math.floor(_outWidth * plot.cardWidth / 24 - 20) + let _outWidth = document.body.offsetWidth - 260 + if (this.cardRef.offsetWidth) { + _outWidth = this.cardRef.offsetWidth } + _cardWidth = Math.floor(_outWidth * plot.cardWidth / 24 - 20) - if (card.avatar.widthType === 'ratio' && card.avatar.display !== 'block') { + if (card.avatar.display !== 'block') { if (card.avatar.width < 90) { _flex = true } @@ -767,11 +736,11 @@ this.setState({selectKey: data.key}) - this.props.handleTableId(this.props.tableId, _id, data) + MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.tableId, _id, data) } render() { - const { plot, data, loading, BID, BData, Tab, MenuID, config, logcolumns, ContainerId } = this.props + const { plot, data, loading, BID, BData, Tab, MenuID, config, columns, ContainerId } = this.props const { card, colMap, selectKey, actionList } = this.state return ( @@ -792,10 +761,9 @@ key={action.uuid} BID={BID} Tab={Tab} - btn={action} show="icon" + btn={action} setting={config.setting} - updateStatus={() => {}} /> ) } else { @@ -804,11 +772,9 @@ key={action.uuid} BID={BID} Tab={Tab} - btn={action} show="icon" + btn={action} setting={config.setting} - getexceloutparam={this.props.getexceloutparam} - updateStatus={() => {}} /> ) } @@ -816,7 +782,7 @@ </div> <div style={{clear: 'both'}}></div> </div> - {plot.over !== 'roll' && data && data.length > 0 && + {data && data.length > 0 && data.map((item, i) => ( <CardCell key={i} @@ -827,16 +793,15 @@ BData={BData} MenuID={MenuID} colMap={colMap} + columns={columns} selectKey={selectKey} - logcolumns={logcolumns} setting={config.setting} ContainerId={ContainerId} switchCard={this.switchCard} - refreshdata={this.props.refreshdata} /> )) } - {!loading && card.insertAction && plot.over !== 'roll' ? + {!loading && card.insertAction ? <CardCell key="insert" type="insert" @@ -849,44 +814,7 @@ setting={config.setting} ContainerId={ContainerId} switchCard={() => {}} - refreshdata={this.props.refreshdata} /> : null - } - {plot.over === 'roll' && data && data.length > 0 ? - <Tabs activeKey=""> - {data.map((item, i) => ( - <TabPane tab={<CardCell - BID={BID} - Tab={Tab} - card={card} - data={item} - BData={BData} - MenuID={MenuID} - colMap={colMap} - selectKey={selectKey} - logcolumns={logcolumns} - setting={config.setting} - ContainerId={ContainerId} - switchCard={this.switchCard} - refreshdata={this.props.refreshdata} - />} key={i}></TabPane> - ))} - {!loading && card.insertAction ? - <TabPane tab={<CardCell - type="insert" - BID={BID} - Tab={Tab} - card={card} - data={{key: 'insert'}} - BData={BData} - MenuID={MenuID} - setting={config.setting} - ContainerId={ContainerId} - switchCard={() => {}} - refreshdata={this.props.refreshdata} - />} key="insert"></TabPane> : null - } - </Tabs> : null } {(loading || !card.insertAction) && (!data || data.length === 0) ? <Empty description={false}/> : null} <div className="clear"></div> -- Gitblit v1.8.0