From 8f57504fdd233617cfaf610b82a87fd9ac12828b Mon Sep 17 00:00:00 2001 From: zhangzhen <525765282@qq.com> Date: Tue, 18 Nov 2025 13:38:38 +0800 Subject: [PATCH] commonList新增ctrl+alt+M让表格宽度根据内容撑开; --- src/components/Common/CommonTable/index.js | 14 ++++++++------ src/components/IndexCenter/IndexCenter.js | 19 +++++++++++++++++++ src/default.less | 16 ++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js index 64ca5db..04082aa 100644 --- a/src/components/Common/CommonTable/index.js +++ b/src/components/Common/CommonTable/index.js @@ -1943,7 +1943,7 @@ class CommonTableRc extends React.Component { // } // } - if (!noVlistTable) { + if (!noVlistTable && !this.props.xlyTableMax) { if (this.props.slaveInfo || this.useVListNew) { if (!this.uniqueId || window.vlistNewSearh) { this.uniqueId = this.props.formId ? `${this.props.formId}_${lodash.uniqueId()}` : lodash.uniqueId(); @@ -7166,7 +7166,7 @@ class CommonTableRc extends React.Component { : null}
{ this.mydiv = ref; if (this.mydiv) { @@ -7189,12 +7189,12 @@ class CommonTableRc extends React.Component { pagination={!hasColorInfo && tableProps.pagination} addRow={addProps} delProps={delProps} - tableLayout="fixed" + tableLayout={this.props.xlyTableMax ? "auto" : "fixed"} expandable={{ expandedRowRender: this.props.setExpandedRowRender === 'Y' ? expandedRow : null, defaultExpandAllRows: this.props.defaultExpandAllRows || null, }} - scroll={{ x: this.scrollX, y: commonUtils.isNotEmptyNumber(autoHeight) ? autoHeight : 544 }} + scroll={{ x: this.props.xlyTableMax ? 'max-content' : this.scrollX, y: commonUtils.isNotEmptyNumber(autoHeight) ? autoHeight : 544 }} summary={this.genFooter} size="small" sticky={this.sticky} @@ -7207,12 +7207,12 @@ class CommonTableRc extends React.Component { pagination={!hasColorInfo && tableProps.pagination} addRow={addProps} delProps={delProps} - tableLayout="fixed" + tableLayout={this.props.xlyTableMax ? "auto" : "fixed"} expandable={{ expandedRowRender: this.props.setExpandedRowRender === 'Y' ? expandedRow : null, defaultExpandAllRows: this.props.defaultExpandAllRows || null, }} - scroll={{ x: this.scrollX, y: !layoutScrollY ? this.scrollY : layoutScrollY }} + scroll={{ x: this.props.xlyTableMax ? 'max-content' : this.scrollX, y: !layoutScrollY ? this.scrollY : layoutScrollY }} summary={this.genFooter} size="small" sticky={this.sticky} @@ -7528,6 +7528,8 @@ const CommonTable = (props) => { setUpdateRowNumTime(pre => pre + 1); } const uniqueTableId = `table_${props.formId}_${props.config?.sId}`; + + addState.xlyTableMax = props.app?.currentPane?.route === "/indexPage/commonList" && localStorage.getItem(`${commonConfig.prefix}TableMax`); return ( diff --git a/src/components/IndexCenter/IndexCenter.js b/src/components/IndexCenter/IndexCenter.js index e92b7f5..b07c61d 100644 --- a/src/components/IndexCenter/IndexCenter.js +++ b/src/components/IndexCenter/IndexCenter.js @@ -441,6 +441,9 @@ class IndexCenter extends Component { if (this.tableTree) { this.tableTree.addEventListener('scroll', this.scrollTreeLoading); } + + // 监听全局ctrl+alt+M事件 + document.addEventListener('keydown', this.handleGlobalCtrlAltM); } componentWillUnmount() { @@ -451,6 +454,22 @@ class IndexCenter extends Component { if (this.tableTree) { this.tableTree.removeEventListener('scroll', this.scrollTreeLoading); } + + // 卸载全局ctrl+alt+M事件 + document.removeEventListener('keydown', this.handleGlobalCtrlAltM); + } + + handleGlobalCtrlAltM = (e) => { + if (e.ctrlKey && (e.altKey || e.metaKey) && e.keyCode === 77) { + const itemName = `${commonConfig.prefix}TableMax`; + const xlyTableMax = localStorage.getItem(itemName); + if (!xlyTableMax) { + localStorage.setItem(itemName, 'max'); + } else { + localStorage.removeItem(itemName); + } + this.props.dispatch({ type: "app/refreshPage" }); + } } scrollLoading = () => { diff --git a/src/default.less b/src/default.less index cb3e51f..fa2320c 100644 --- a/src/default.less +++ b/src/default.less @@ -303,6 +303,10 @@ tbody { td { background: #fff7e6 !important; font-weight: bold; + div[class*="xlyTableMax"] & { + font-weight: normal; + text-decoration: underline; + } } .sActiveIdStyle { @@ -564,14 +568,26 @@ tbody { .selected-record-row { background-color: #e6f7ff !important; font-weight: bold; + div[class*="xlyTableMax"] & { + font-weight: normal; + text-decoration: underline; + } input { font-weight: bold; + div[class*="xlyTableMax"] & { + font-weight: normal; + text-decoration: underline; + } } td { background: #e6f7ff !important; font-weight: bold; + div[class*="xlyTableMax"] & { + font-weight: normal; + text-decoration: underline; + } } .ant-input-number-disabled { -- libgit2 0.22.2