From ded0a522a7747fb841719c13c8c35f13cf5cda4c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 15 十一月 2021 17:28:13 +0800 Subject: [PATCH] 2021-11-15 --- src/tabviews/custom/components/share/normalTable/index.jsx | 78 +++++++++++++++++++++++++++------------ 1 files changed, 54 insertions(+), 24 deletions(-) diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx index a1bb8fc..cadff9e 100644 --- a/src/tabviews/custom/components/share/normalTable/index.jsx +++ b/src/tabviews/custom/components/share/normalTable/index.jsx @@ -5,7 +5,6 @@ import { is, fromJS } from 'immutable' import { Table, Typography, Icon, Col, Switch, message } from 'antd' -import { modifyTabview } from '@/store/action' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' import zhCN from '@/locales/zh-CN/main.js' @@ -352,6 +351,39 @@ {content && _href ? <a href={_href} target="_blank" rel="noopener noreferrer">{content}</a> : null } </div> ) + } else if (col.type === 'formula') { + let content = col.formula + Object.keys(record).forEach(key => { + let reg = new RegExp('@' + key + '@', 'ig') + content = content.replace(reg, record[key]) + }) + + if (col.eval !== 'false') { + try { + // eslint-disable-next-line + content = eval(content) + } catch (e) { + content = '' + } + } + + content = content === undefined ? '' : content + + if (content !== '') { + content = `${col.prefix || ''}${content}${col.postfix || ''}` + + if (col.eval === 'false') { + content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') + content = <span dangerouslySetInnerHTML={{__html: content}}></span> + } + } + + if (col.marks) { + style = style || {} + content = this.getMark(record, col.marks, style, content) + } + + resProps.children = content } else if (col.type === 'custom') { style.padding = '0px' if (col.style) { @@ -400,7 +432,8 @@ activeIndex: null, // 鏍囪褰撳墠閫変腑琛� rowspans: null, // 琛屽悎骞跺瓧娈典俊鎭� pickup: false, // 鏀惰捣鏈�夋嫨椤� - orderfields: {} // 鎺掑簭id涓巉ield杞崲 + orderfields: {}, // 鎺掑簭id涓巉ield杞崲 + pageOptions: [] } UNSAFE_componentWillMount () { @@ -487,7 +520,17 @@ document.getElementsByTagName('head')[0].appendChild(ele) } + let size = (setting.pageSize || 10) + '' + let pageOptions = ['10', '25', '50', '100', '500', '1000'] + + if (!pageOptions.includes(size)) { + pageOptions.push(size) + pageOptions = pageOptions.sort((a, b) => a - b) + } + this.setState({ + pageSize: setting.pageSize || 10, + pageOptions, columns: _columns, rowspans, tableId, @@ -564,7 +607,6 @@ // 瀛楁閫忚 triggerLink = (e, item, record) => { - const { tabviews } = this.props e.stopPropagation() let __param = { @@ -583,21 +625,12 @@ let tabmenu = item.linkThdMenu tabmenu.param = __param - tabmenu.selected = true - - let tabs = tabviews.filter((tab, i) => { - tab.selected = false - return tab.MenuID !== tabmenu.MenuID - }) - - if (tabviews.length > tabs.length) { - this.props.modifyTabview(fromJS(tabs).toJS()) + + if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) { + MKEmitter.emit('modifyTabs', tabmenu, 'replace') + } else { + MKEmitter.emit('modifyTabs', tabmenu, 'plus', true) } - - this.setState({}, () => { - tabs.push(tabmenu) - this.props.modifyTabview(tabs) - }) } else if (item.linkurl) { let src = item.linkurl @@ -823,7 +856,7 @@ render() { const { setting, statFValue, lineMarks, data } = this.props - const { selectedRowKeys, activeIndex, pickup, tableId } = this.state + const { selectedRowKeys, activeIndex, pickup, tableId, pageOptions } = this.state // 璁剧疆琛ㄦ牸閫夋嫨灞炴�э細鍗曢�夈�佸閫夈�佷笉鍙�� let rowSelection = null @@ -856,7 +889,7 @@ _pagination = { current: this.state.pageIndex, pageSize: this.state.pageSize, - pageSizeOptions: ['10', '25', '50', '100', '500', '1000'], + pageSizeOptions: pageOptions, showSizeChanger: true, total: this.props.total || 0, showTotal: (total, range) => `${range[0]}-${range[1]} ${this.state.dict['main.pagination.of']} ${total} ${this.state.dict['main.pagination.items']}` @@ -907,15 +940,12 @@ const mapStateToProps = (state) => { return { menuType: state.editLevel, - tabviews: state.tabviews, memberLevel: state.memberLevel } } -const mapDispatchToProps = (dispatch) => { - return { - modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) - } +const mapDispatchToProps = () => { + return {} } export default connect(mapStateToProps, mapDispatchToProps)(NormalTable) \ No newline at end of file -- Gitblit v1.8.0