调整table滚动兼顾使用滚动条

This commit is contained in:
2024-08-05 03:20:14 +08:00
parent f9bbba68b4
commit 1d8d0a05e5
2 changed files with 33 additions and 11 deletions

View File

@@ -168,11 +168,23 @@ a, .green {
width: 100% !important; width: 100% !important;
} }
.scrollTable .el-table__body-wrapper {
overflow-x: hidden !important;
}
.scrollTable .tableCell { .scrollTable .tableCell {
color: #fff; color: #fff;
border-color: transparent !important; border-color: transparent !important;
} }
.scrollTable .cell {
text-wrap: unset !important;
word-break: break-all;
font-size: 12px;
padding-left: 6px !important;
padding-right: 6px !important;
}
.scrollTable .el-table__cell { .scrollTable .el-table__cell {
padding: 3px 0 !important; padding: 3px 0 !important;
} }

View File

@@ -173,14 +173,17 @@ Vue.component("scrollTable", {
}, },
autoScroll() { autoScroll() {
if (this.timer) clearInterval(this.timer) if (this.timer) clearInterval(this.timer)
this.$el.querySelector('.simplebar-vertical').style.display = 'none'
// this.$el.querySelectorAll('.simplebar-scrollbar').map(e => e.display = 'none')
this.timer = setInterval(() => { this.timer = setInterval(() => {
const dom = this.$el.querySelector('.simplebar-content-wrapper') const dom = this.$el.querySelector('.simplebar-content-wrapper')
const max = dom.scrollHeight - dom.clientHeight const max = dom.scrollHeight - dom.clientHeight
if (dom.scrollTop + 30 >= max) dom.scrollTop = 0 if (dom.scrollTop + 1 >= max) dom.scrollTop = 0
else dom.scrollTop += 30 else dom.scrollTop += 1
}, 1000) }, 60)
}, },
stopAutoScroll() { stopAutoScroll() {
this.$el.querySelector('.simplebar-vertical').style.display = 'block'
if (this.timer) clearInterval(this.timer) if (this.timer) clearInterval(this.timer)
} }
}, },
@@ -201,15 +204,22 @@ Vue.component("tableColumn", {
}, },
render(h) { render(h) {
const config = this.$props.column const config = this.$props.column
return h('el-table-column', {props: {...config, label: `${config.label}` || "-"}}, let column = h('el-table-column', {
config.children?.map(col => h("tableColumn", {props: {column: col}})) || h('template', { props: {...config, label: `${config.label}` || "-"}, scopedSlots: {
slotScope: { default: ({row}) => {
default: ({row}) => { return config.custom ? h('div', {
config.custom ? h('div', {style: {color: row.preSaleNum > row.stockNum ? 'red' : '#fff'}}, '周边库存情况') : style: {color: row.preSaleNum > row.stockNum ? 'red' : '#fff'}, class: 'pointer'
h('span', row[config.prop] || '') }, '周边库存情况') :
} h('span', row[config.prop] || '')
} }
})) }
})
if (config.children?.length > 0) {
column = h('el-table-column', {props: {...config, label: `${config.label}` || "-"}},
config.children.map(col => h("tableColumn", {props: {column: col}}))
)
}
return column
}, },
}) })