Commit 4ba717c0 by ym

table

1 parent 049b7935
<template> <template>
<div class="glsx-table" :class="{ hasTableContent: showClass }"> <div class="glsx-table">
<el-table id="initTable" :ref="tableParams.mutiSelectName + 'MutiTable' || 'MutiTable'" :data="getListApi ? data : tableData" :row-key="tableParams.mutiSelectUniqueKey || ''" v-loading="loading" :border="border" :highlight-current-row="true" :stripe="true" @sort-change="sortChange" @selection-change="handleSelect" :size="size" :header-cell-style="headerStyle"> <el-table id="initTable" :ref="tableParams.mutiSelectName + 'MutiTable' || 'MutiTable'" :data="getListApi ? data : tableData" :row-key="tableParams.mutiSelectUniqueKey || ''" v-loading="loading" :border="border" :tableId="tableId" :highlight-current-row="true" :stripe="true" @sort-change="sortChange" @selection-change="handleSelect" :size="size" :header-cell-style="headerStyle">
<el-table-column v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName" type="selection" width="55" :selectable="checkSelectable" :reserve-selection="true"></el-table-column> <el-table-column v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName" type="selection" width="55" :selectable="checkSelectable" :reserve-selection="true"></el-table-column>
<el-table-column v-if="hasNum" align="center" width="60px" label="序号" type="index" :index="index => index + (page[this.pageConf.pageNum] - 1) * page[this.pageConf.pageSize] + 1"></el-table-column> <el-table-column v-if="hasNum" align="center" width="60px" label="序号" type="index" :index="index => index + (page[this.pageConf.pageNum] - 1) * page[this.pageConf.pageSize] + 1"></el-table-column>
<el-table-column v-for="(item, index) in tableColumns" :key="index" :label="item.label" :prop="item.prop" :width="item.width" :min-width="item.minWidth" :align="item.align || 'center'" :sortable="item.sortable"> <el-table-column v-for="(item, index) in tableColumns" :key="index" :label="item.label" :prop="item.prop" :width="item.width" :min-width="item.minWidth" :align="item.align || 'center'" :sortable="item.sortable">
...@@ -75,6 +75,11 @@ export default { ...@@ -75,6 +75,11 @@ export default {
type: Object, type: Object,
default: () => {} default: () => {}
}, },
//表格需要多传入一个id的情况
tableId:{
type:String,
default:''
},
// 搜索条件 // 搜索条件
searchForm: { searchForm: {
type: Object, type: Object,
...@@ -199,13 +204,13 @@ export default { ...@@ -199,13 +204,13 @@ export default {
customHeadShowList(val) { customHeadShowList(val) {
this.isCustomHead && this.findShowHeadCol() this.isCustomHead && this.findShowHeadCol()
}, },
data: { // data: {
immediate: true, // immediate: true,
handler(val) { // handler(val) {
this.showClass = val.length > 0 ? true : false // this.showClass = val.length > 0 ? true : false
}, // },
deep: true // deep: true
} // }
}, },
methods: { methods: {
...@@ -254,6 +259,7 @@ export default { ...@@ -254,6 +259,7 @@ export default {
let clientHeight = document.documentElement.clientHeight let clientHeight = document.documentElement.clientHeight
document.getElementById('initTable').style.height = clientHeight - offsettop - paginationHeight - navHeight + 'px' document.getElementById('initTable').style.height = clientHeight - offsettop - paginationHeight - navHeight + 'px'
document.querySelector('.el-table__empty-block').style.height=(clientHeight - offsettop - paginationHeight - navHeight)+'px';
}, },
refreshTable(isResetPageNum = true, isClearMuti = true) { refreshTable(isResetPageNum = true, isClearMuti = true) {
...@@ -266,6 +272,9 @@ export default { ...@@ -266,6 +272,9 @@ export default {
...this.page, ...this.page,
...this.searchForm ...this.searchForm
} }
if(this.tableId){
params.id=this.tableId
}
this.getListApi(params) this.getListApi(params)
.then(res => { .then(res => {
console.log(res) console.log(res)
...@@ -310,18 +319,6 @@ export default { ...@@ -310,18 +319,6 @@ export default {
this.page[this.pageConf.pageSize] = 10 this.page[this.pageConf.pageSize] = 10
this.page[this.pageConf.pageNum] = 1 this.page[this.pageConf.pageNum] = 1
this.getListApi && this.refreshTable() this.getListApi && this.refreshTable()
// this.$nextTick(() => {
// var _this=this
// setTimeout(() => {
// // 使用getListApi获取和返回数组为空时算高度 !(_this.getListApi && _this.data.length==0)
// if(_this.getListApi ){
// }
// }, 200)
// })
} }
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!