Commit 8f57504fdd233617cfaf610b82a87fd9ac12828b
1 parent
a27b1111
commonList新增ctrl+alt+M让表格宽度根据内容撑开;
Showing
3 changed files
with
43 additions
and
6 deletions
src/components/Common/CommonTable/index.js
| @@ -1943,7 +1943,7 @@ class CommonTableRc extends React.Component { | @@ -1943,7 +1943,7 @@ class CommonTableRc extends React.Component { | ||
| 1943 | // } | 1943 | // } |
| 1944 | // } | 1944 | // } |
| 1945 | 1945 | ||
| 1946 | - if (!noVlistTable) { | 1946 | + if (!noVlistTable && !this.props.xlyTableMax) { |
| 1947 | if (this.props.slaveInfo || this.useVListNew) { | 1947 | if (this.props.slaveInfo || this.useVListNew) { |
| 1948 | if (!this.uniqueId || window.vlistNewSearh) { | 1948 | if (!this.uniqueId || window.vlistNewSearh) { |
| 1949 | this.uniqueId = this.props.formId ? `${this.props.formId}_${lodash.uniqueId()}` : lodash.uniqueId(); | 1949 | this.uniqueId = this.props.formId ? `${this.props.formId}_${lodash.uniqueId()}` : lodash.uniqueId(); |
| @@ -7166,7 +7166,7 @@ class CommonTableRc extends React.Component { | @@ -7166,7 +7166,7 @@ class CommonTableRc extends React.Component { | ||
| 7166 | : null} | 7166 | : null} |
| 7167 | </div> | 7167 | </div> |
| 7168 | <div | 7168 | <div |
| 7169 | - className={`xlyCommonTable ${tableClassName} ${this.hasSpanBgColor ? 'tableNoPadding' : ''} ${this.props.enabled ? 'tableEnabled' : ''}`} | 7169 | + className={`xlyCommonTable ${tableClassName} ${this.hasSpanBgColor ? 'tableNoPadding' : ''} ${this.props.enabled ? 'tableEnabled' : ''} ${this.props.xlyTableMax ? 'xlyTableMax' : ''}`} |
| 7170 | style={{ height: isSmall ? 'calc(100% - 44px)' : '' }} ref={(ref) => { | 7170 | style={{ height: isSmall ? 'calc(100% - 44px)' : '' }} ref={(ref) => { |
| 7171 | this.mydiv = ref; | 7171 | this.mydiv = ref; |
| 7172 | if (this.mydiv) { | 7172 | if (this.mydiv) { |
| @@ -7189,12 +7189,12 @@ class CommonTableRc extends React.Component { | @@ -7189,12 +7189,12 @@ class CommonTableRc extends React.Component { | ||
| 7189 | pagination={!hasColorInfo && tableProps.pagination} | 7189 | pagination={!hasColorInfo && tableProps.pagination} |
| 7190 | addRow={addProps} | 7190 | addRow={addProps} |
| 7191 | delProps={delProps} | 7191 | delProps={delProps} |
| 7192 | - tableLayout="fixed" | 7192 | + tableLayout={this.props.xlyTableMax ? "auto" : "fixed"} |
| 7193 | expandable={{ | 7193 | expandable={{ |
| 7194 | expandedRowRender: this.props.setExpandedRowRender === 'Y' ? expandedRow : null, | 7194 | expandedRowRender: this.props.setExpandedRowRender === 'Y' ? expandedRow : null, |
| 7195 | defaultExpandAllRows: this.props.defaultExpandAllRows || null, | 7195 | defaultExpandAllRows: this.props.defaultExpandAllRows || null, |
| 7196 | }} | 7196 | }} |
| 7197 | - scroll={{ x: this.scrollX, y: commonUtils.isNotEmptyNumber(autoHeight) ? autoHeight : 544 }} | 7197 | + scroll={{ x: this.props.xlyTableMax ? 'max-content' : this.scrollX, y: commonUtils.isNotEmptyNumber(autoHeight) ? autoHeight : 544 }} |
| 7198 | summary={this.genFooter} | 7198 | summary={this.genFooter} |
| 7199 | size="small" | 7199 | size="small" |
| 7200 | sticky={this.sticky} | 7200 | sticky={this.sticky} |
| @@ -7207,12 +7207,12 @@ class CommonTableRc extends React.Component { | @@ -7207,12 +7207,12 @@ class CommonTableRc extends React.Component { | ||
| 7207 | pagination={!hasColorInfo && tableProps.pagination} | 7207 | pagination={!hasColorInfo && tableProps.pagination} |
| 7208 | addRow={addProps} | 7208 | addRow={addProps} |
| 7209 | delProps={delProps} | 7209 | delProps={delProps} |
| 7210 | - tableLayout="fixed" | 7210 | + tableLayout={this.props.xlyTableMax ? "auto" : "fixed"} |
| 7211 | expandable={{ | 7211 | expandable={{ |
| 7212 | expandedRowRender: this.props.setExpandedRowRender === 'Y' ? expandedRow : null, | 7212 | expandedRowRender: this.props.setExpandedRowRender === 'Y' ? expandedRow : null, |
| 7213 | defaultExpandAllRows: this.props.defaultExpandAllRows || null, | 7213 | defaultExpandAllRows: this.props.defaultExpandAllRows || null, |
| 7214 | }} | 7214 | }} |
| 7215 | - scroll={{ x: this.scrollX, y: !layoutScrollY ? this.scrollY : layoutScrollY }} | 7215 | + scroll={{ x: this.props.xlyTableMax ? 'max-content' : this.scrollX, y: !layoutScrollY ? this.scrollY : layoutScrollY }} |
| 7216 | summary={this.genFooter} | 7216 | summary={this.genFooter} |
| 7217 | size="small" | 7217 | size="small" |
| 7218 | sticky={this.sticky} | 7218 | sticky={this.sticky} |
| @@ -7528,6 +7528,8 @@ const CommonTable = (props) => { | @@ -7528,6 +7528,8 @@ const CommonTable = (props) => { | ||
| 7528 | setUpdateRowNumTime(pre => pre + 1); | 7528 | setUpdateRowNumTime(pre => pre + 1); |
| 7529 | } | 7529 | } |
| 7530 | const uniqueTableId = `table_${props.formId}_${props.config?.sId}`; | 7530 | const uniqueTableId = `table_${props.formId}_${props.config?.sId}`; |
| 7531 | + | ||
| 7532 | + addState.xlyTableMax = props.app?.currentPane?.route === "/indexPage/commonList" && localStorage.getItem(`${commonConfig.prefix}TableMax`); | ||
| 7531 | 7533 | ||
| 7532 | return ( | 7534 | return ( |
| 7533 | <Tooltip title={props.name} placement='topLeft' visible={props.showTableName}> | 7535 | <Tooltip title={props.name} placement='topLeft' visible={props.showTableName}> |
src/components/IndexCenter/IndexCenter.js
| @@ -441,6 +441,9 @@ class IndexCenter extends Component { | @@ -441,6 +441,9 @@ class IndexCenter extends Component { | ||
| 441 | if (this.tableTree) { | 441 | if (this.tableTree) { |
| 442 | this.tableTree.addEventListener('scroll', this.scrollTreeLoading); | 442 | this.tableTree.addEventListener('scroll', this.scrollTreeLoading); |
| 443 | } | 443 | } |
| 444 | + | ||
| 445 | + // 监听全局ctrl+alt+M事件 | ||
| 446 | + document.addEventListener('keydown', this.handleGlobalCtrlAltM); | ||
| 444 | } | 447 | } |
| 445 | 448 | ||
| 446 | componentWillUnmount() { | 449 | componentWillUnmount() { |
| @@ -451,6 +454,22 @@ class IndexCenter extends Component { | @@ -451,6 +454,22 @@ class IndexCenter extends Component { | ||
| 451 | if (this.tableTree) { | 454 | if (this.tableTree) { |
| 452 | this.tableTree.removeEventListener('scroll', this.scrollTreeLoading); | 455 | this.tableTree.removeEventListener('scroll', this.scrollTreeLoading); |
| 453 | } | 456 | } |
| 457 | + | ||
| 458 | + // 卸载全局ctrl+alt+M事件 | ||
| 459 | + document.removeEventListener('keydown', this.handleGlobalCtrlAltM); | ||
| 460 | + } | ||
| 461 | + | ||
| 462 | + handleGlobalCtrlAltM = (e) => { | ||
| 463 | + if (e.ctrlKey && (e.altKey || e.metaKey) && e.keyCode === 77) { | ||
| 464 | + const itemName = `${commonConfig.prefix}TableMax`; | ||
| 465 | + const xlyTableMax = localStorage.getItem(itemName); | ||
| 466 | + if (!xlyTableMax) { | ||
| 467 | + localStorage.setItem(itemName, 'max'); | ||
| 468 | + } else { | ||
| 469 | + localStorage.removeItem(itemName); | ||
| 470 | + } | ||
| 471 | + this.props.dispatch({ type: "app/refreshPage" }); | ||
| 472 | + } | ||
| 454 | } | 473 | } |
| 455 | 474 | ||
| 456 | scrollLoading = () => { | 475 | scrollLoading = () => { |
src/default.less
| @@ -303,6 +303,10 @@ tbody { | @@ -303,6 +303,10 @@ tbody { | ||
| 303 | td { | 303 | td { |
| 304 | background: #fff7e6 !important; | 304 | background: #fff7e6 !important; |
| 305 | font-weight: bold; | 305 | font-weight: bold; |
| 306 | + div[class*="xlyTableMax"] & { | ||
| 307 | + font-weight: normal; | ||
| 308 | + text-decoration: underline; | ||
| 309 | + } | ||
| 306 | } | 310 | } |
| 307 | 311 | ||
| 308 | .sActiveIdStyle { | 312 | .sActiveIdStyle { |
| @@ -564,14 +568,26 @@ tbody { | @@ -564,14 +568,26 @@ tbody { | ||
| 564 | .selected-record-row { | 568 | .selected-record-row { |
| 565 | background-color: #e6f7ff !important; | 569 | background-color: #e6f7ff !important; |
| 566 | font-weight: bold; | 570 | font-weight: bold; |
| 571 | + div[class*="xlyTableMax"] & { | ||
| 572 | + font-weight: normal; | ||
| 573 | + text-decoration: underline; | ||
| 574 | + } | ||
| 567 | 575 | ||
| 568 | input { | 576 | input { |
| 569 | font-weight: bold; | 577 | font-weight: bold; |
| 578 | + div[class*="xlyTableMax"] & { | ||
| 579 | + font-weight: normal; | ||
| 580 | + text-decoration: underline; | ||
| 581 | + } | ||
| 570 | } | 582 | } |
| 571 | 583 | ||
| 572 | td { | 584 | td { |
| 573 | background: #e6f7ff !important; | 585 | background: #e6f7ff !important; |
| 574 | font-weight: bold; | 586 | font-weight: bold; |
| 587 | + div[class*="xlyTableMax"] & { | ||
| 588 | + font-weight: normal; | ||
| 589 | + text-decoration: underline; | ||
| 590 | + } | ||
| 575 | } | 591 | } |
| 576 | 592 | ||
| 577 | .ant-input-number-disabled { | 593 | .ant-input-number-disabled { |