Commit 0f70eae8 by cwq0219

表格优化

1 parent 806dd724
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
:row-key="tableParams.uniqueKey || 'id'" :row-key="tableParams.uniqueKey || 'id'"
border border
:max-height="tableMaxHeight" :max-height="tableMaxHeight"
:height="tableMaxHeight"
v-if="tableParams.dropCol.length" v-if="tableParams.dropCol.length"
> >
<el-table-column <el-table-column
...@@ -256,12 +257,8 @@ export default { ...@@ -256,12 +257,8 @@ export default {
// 表格高度 // 表格高度
getHeight() { getHeight() {
setTimeout(() => { setTimeout(() => {
// var parentHeight = document.querySelector('.table').parentElement.parentElement.clientHeight
var parentHeight = this.$refs.tableCom.parentElement.clientHeight var parentHeight = this.$refs.tableCom.parentElement.clientHeight
var pageHeight = this.hasPage ? this.$refs.page.clientHeight : 0 var pageHeight = this.hasPage ? this.$refs.page.clientHeight : 0
// console.log(parentHeight - pageHeight - 50 + 'px')
// document.querySelector('.table').style.height = parentHeight - pageHeight - 50 + 'px'
// this.loading = false
this.tableMaxHeight = parentHeight - pageHeight - 50 this.tableMaxHeight = parentHeight - pageHeight - 50
}, 400) }, 400)
}, },
...@@ -290,8 +287,6 @@ export default { ...@@ -290,8 +287,6 @@ export default {
}, },
handleSave() { handleSave() {
console.log('保存--')
// console.log(this.tableParams.dropCol)
this.saveTableCol({ this.saveTableCol({
tableName: 'database', tableName: 'database',
path: 'tableCol.' + this.tableParams.tableId, path: 'tableCol.' + this.tableParams.tableId,
...@@ -336,7 +331,6 @@ export default { ...@@ -336,7 +331,6 @@ export default {
tableName: 'database', tableName: 'database',
path: 'tableCol.' + this.tableParams.tableId path: 'tableCol.' + this.tableParams.tableId
}).then(res => { }).then(res => {
// console.log(res)
this.tableParams.tableHead = [] this.tableParams.tableHead = []
if (res && (res.length === this.tableParams.tableColumns.length) && !isReset) { if (res && (res.length === this.tableParams.tableColumns.length) && !isReset) {
res.forEach((item, index) => { res.forEach((item, index) => {
...@@ -357,9 +351,13 @@ export default { ...@@ -357,9 +351,13 @@ export default {
handleOptShow() { handleOptShow() {
this.isShowOption = !this.isShowOption this.isShowOption = !this.isShowOption
}, },
refreshTable(clearMuti = true) { refreshTable(obj) {
var opt = {
clearMuti: true,
...obj
}
// 清空多选 // 清空多选
this.tableParams.dropCol.length && this.tableParams.isMuti && clearMuti && this.clearMutiSelect() this.tableParams.dropCol.length && this.tableParams.isMuti && opt.clearMuti && this.clearMutiSelect()
this.loading = true this.loading = true
this.dealParams().then(res => { this.dealParams().then(res => {
var params = res || this.searchForm var params = res || this.searchForm
...@@ -367,7 +365,6 @@ export default { ...@@ -367,7 +365,6 @@ export default {
...params, ...params,
...this.page ...this.page
} }
// console.log(params)
if (this.sort) { if (this.sort) {
params.sortColum = this.sortColum params.sortColum = this.sortColum
params.sort = this.sort === 'descending' ? 1 : 0 params.sort = this.sort === 'descending' ? 1 : 0
...@@ -393,12 +390,12 @@ export default { ...@@ -393,12 +390,12 @@ export default {
// 页码 // 页码
handleSizeChange(value) { handleSizeChange(value) {
this.page.pageSize = value this.page.pageSize = value
this.getListApi ? this.refreshTable(false) : this.$emit('refreshTable', this.page) this.getListApi ? this.refreshTable({ clearMuti: false }) : this.$emit('refreshTable', this.page)
}, },
handleCurrentChange(value) { handleCurrentChange(value) {
this.page.pageNum = value this.page.pageNum = value
this.getListApi ? this.refreshTable(false) : this.$emit('refreshTable', this.page) this.getListApi ? this.refreshTable({ clearMuti: false }) : this.$emit('refreshTable', this.page)
} }
} }
} }
...@@ -406,24 +403,29 @@ export default { ...@@ -406,24 +403,29 @@ export default {
</script> </script>
<style> <style>
.table { .table {
/* display: flex; */ /* position: relative; */
/* align-items: center; */ display: flex;
align-items: center;
} }
/* .el-table { /* .el-table {
overflow-y: scroll; overflow-y: scroll;
} */ } */
.el-scrollbar__wrap { /* .el-scrollbar__wrap {
overflow-x: hidden; overflow-x: hidden;
} }
.table-scroll { .table-scroll {
height: 100%; height: 100%;
width: 100%; width: 100%;
/* display: flex; */ } */
::-webkit-scrollbar {
width: 8px;
height: 8px;
/* width: 0;
height: 0; */
} }
.sort-btns { ::-webkit-scrollbar-thumb {
position: fixed; background-color: hsla(220, 4%, 58%, 0.3);
top: 300px; border-radius: 3px;
right: 36px;
} }
.refresh-btn { .refresh-btn {
display: block; display: block;
......
...@@ -487,7 +487,7 @@ export default { ...@@ -487,7 +487,7 @@ export default {
tableParams: { tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000), btnId: new Date().getTime() + parseInt(Math.random() * 1000),
tableId: 'assignOrder', tableId: 'assignOrder',
uniqueKey: 'id', uniqueKey: 'merchantOrder',
isMuti: true, isMuti: true,
listName: 'list', listName: 'list',
tableHead: [], tableHead: [],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!