|
1 | 1 | <template> |
2 | | - <div class="vue-excel-editor" :style="{display: 'inline-block', 'max-width': width}"> |
| 2 | + <div ref="editor" class="vue-excel-editor" :style="{display: 'inline-block', width}"> |
3 | 3 | <div class="component-content"> |
4 | 4 | <!-- No record --> |
5 | 5 | <div v-if="localizedLabel.noRecordIndicator && pagingTable.length == 0" class="norecord" :style="{bottom: noFooter? '12px' : '37px'}"> |
|
23 | 23 | ondragover="event.preventDefault(); event.dataTransfer.dropEffect = 'none'"> |
24 | 24 | <colgroup> |
25 | 25 | <col v-if="!noNumCol" style="width:40px"> |
26 | | - <col v-for="(item, p) in fields" v-show="!item.invisible" :key="p" :style="{width: item.width}"> |
| 26 | + <col v-for="(item, p) in fields" v-show="!item.invisible" :key="p" :style="{width: item.width, 'min-width': item.minWidth || item.width}"> |
27 | 27 | <col v-if="vScroller.buttonHeight < vScroller.height" style="width:12px"> |
28 | 28 | </colgroup> |
29 | 29 | <thead class="center-text"> |
@@ -569,6 +569,7 @@ export default { |
569 | 569 | window.removeEventListener('wheel', this.mousewheel) |
570 | 570 | }, |
571 | 571 | mounted () { |
| 572 | + this.editor = this.$refs.editor |
572 | 573 | this.tableContent = this.$refs.tableContent |
573 | 574 | this.systable = this.$refs.systable |
574 | 575 | this.colgroupTr = this.systable.children[0] |
@@ -1034,6 +1035,20 @@ export default { |
1034 | 1035 | // this.refresh() |
1035 | 1036 | }, |
1036 | 1037 |
|
| 1038 | + columnFillWidth () { |
| 1039 | + if (this.table.length === 0) return |
| 1040 | + if (!this.editor) return |
| 1041 | + const doFields = this.fields.filter(f => f.autoFillWidth) |
| 1042 | + const count = doFields.length |
| 1043 | + if (!count) return |
| 1044 | +
|
| 1045 | + const fullWidth = this.editor.getBoundingClientRect().width |
| 1046 | + const viewWidth = this.fields.filter(f => !f.invisible).reduce((c, f) => c - -f.width.replace(/px$/, ''), 0) + 40 |
| 1047 | + const fillWidth = viewWidth - fullWidth + 2 |
| 1048 | + if (fillWidth) |
| 1049 | + doFields.forEach(f => f.minWidth = (f.width.replace(/px$/, '') - fillWidth / count) + 'px') |
| 1050 | + }, |
| 1051 | +
|
1037 | 1052 | /* *** Date Picker ********************************************************************************* |
1038 | 1053 | */ |
1039 | 1054 | showDatePickerDiv () { |
@@ -1251,7 +1266,7 @@ export default { |
1251 | 1266 | return false |
1252 | 1267 | }, |
1253 | 1268 | winResize () { |
1254 | | - this.lazy(this.refreshPageSize, 200) |
| 1269 | + this.lazy(this.refreshPageSize, 500) |
1255 | 1270 | }, |
1256 | 1271 | winPaste (e) { |
1257 | 1272 | if (e.target.tagName !== 'TEXTAREA') return |
@@ -1683,6 +1698,7 @@ export default { |
1683 | 1698 | h = Math.min(24 * (this.table.length - this.pageTop) + offset, h) |
1684 | 1699 | this.systable.parentNode.style.height = h + 'px' |
1685 | 1700 | } |
| 1701 | + this.columnFillWidth() |
1686 | 1702 | setTimeout(this.calVScroll) |
1687 | 1703 | }, |
1688 | 1704 | firstPage (e) { |
|
0 commit comments