@ -1,14 +1,16 @@
< template >
< template >
< div class = "list-table" :style ="containerStyle" >
< div class = "my-table" >
< div class = "my-table" >
< el -table
< el -table
ref = "table"
ref = "table"
: size = "state.size.size"
: size = "state.size.size"
height = "0"
: fit = "true"
: data = "page ? data.data : data"
: data = "page ? data.data : data"
: border = "border"
: border = "border"
@ selection - change = "selectionChange"
@ selection - change = "selectionChange"
@ row - click = "emit('row-click', $event)"
@ row - click = "emit('row-click', $event)"
@ cell - click = "(row, column, cell, event) => emit('cell-click', row, column, cell, event)"
@ cell - click = "(row, column, cell, event) => emit('cell-click', row, column, cell, event)"
: height = "height || (page ? state.size.pTableHeight : state.size.tableHeight)"
highlight - current - row
highlight - current - row
: row - key = "rowKey"
: row - key = "rowKey"
: tree - porps = "treeProps"
: tree - porps = "treeProps"
@ -51,11 +53,12 @@
>
>
< / e l - p a g i n a t i o n >
< / e l - p a g i n a t i o n >
< / div >
< / div >
< / div >
< / template >
< / template >
< script lang = "ts" setup >
< script lang = "ts" setup >
import { useStore } from "vuex" ;
import { useStore } from "vuex" ;
import { reactive , onMounted , ref , watch , onUpdated } from "vue" ;
import { reactive , onMounted , ref , watch , onUpdated , computed } from "vue" ;
import { useI18n } from "vue3-i18n" ;
import { useI18n } from "vue3-i18n" ;
import { TableColumn } from "noob-mengyxu" ;
import { TableColumn } from "noob-mengyxu" ;
import * as lodash from "lodash-es" ;
import * as lodash from "lodash-es" ;
@ -64,11 +67,23 @@ const { t } = useI18n();
const { state } = useStore ( ) ;
const { state } = useStore ( ) ;
const table = ref ( ) ;
const table = ref ( ) ;
const containerStyle = computed ( ( ) => {
const style : Record < string , string > = { } ;
if ( prop . height !== undefined ) {
style . height = typeof prop . height === "number" ? ` ${ prop . height } px ` : String ( prop . height ) ;
}
if ( prop . maxHeight !== undefined ) {
style . maxHeight = typeof prop . maxHeight === "number" ? ` ${ prop . maxHeight } px ` : String ( prop . maxHeight ) ;
}
return style ;
} ) ;
interface Props {
interface Props {
data ? : any ;
data ? : any ;
props ? : TableColumn [ ] ;
props ? : TableColumn [ ] ;
page ? : boolean ;
page ? : boolean ;
height ? : number ;
height ? : number | string ;
maxHeight ? : number | string ;
example ? : any ;
example ? : any ;
rowKey ? : string ;
rowKey ? : string ;
selectKey ? : string ;
selectKey ? : string ;
@ -82,6 +97,7 @@ const prop = withDefaults(defineProps<Props>(), {
props : ( ) => [ ] ,
props : ( ) => [ ] ,
page : false ,
page : false ,
height : undefined ,
height : undefined ,
maxHeight : undefined ,
example : ( ) => ( { } ) ,
example : ( ) => ( { } ) ,
rowKey : undefined ,
rowKey : undefined ,
selectKey : undefined ,
selectKey : undefined ,
@ -177,6 +193,31 @@ onUpdated(() => {
} ) ;
} ) ;
< / script >
< / script >
< style lang = "scss" scoped >
< style lang = "scss" scoped >
. list - table {
display : flex ;
flex - direction : column ;
flex : 1 ;
overflow : hidden ;
}
. my - table {
flex : 1 ;
width : 100 % ;
display : flex ;
flex - direction : column ;
overflow : hidden ;
}
. my - table . el - table {
height : 100 % ! important ;
display : flex ;
flex - direction : column ;
}
. my - table . el - table _ _inner - wrapper {
height : 100 % ! important ;
}
. my - table * {
. my - table * {
-- el - table - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
-- el - table - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
-- el - table - tr - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
-- el - table - tr - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
@ -192,15 +233,21 @@ onUpdated(() => {
-- el - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
-- el - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
}
}
: : v - deep . el - table _ _row -- level - 1 ,
. list - table : deep ( . el - table _ _row -- level - 1 ) ,
: : v - deep . el - table _ _row -- level - 3 {
. list - table : deep ( . el - table _ _row -- level - 3 ) {
background : v - bind ( "state.style.tableChildBg" ) ! important ;
background : v - bind ( "state.style.tableChildBg" ) ! important ;
}
}
: : v - deep . el - table . el - table _ _cell {
. list - table : deep ( . el - table . el - table _ _cell ) {
padding : v - bind ( "state.size.tablePad" ) ;
padding : v - bind ( "state.size.tablePad" ) ;
}
}
. my - pagination {
display : flex ;
justify - content : center ;
padding - top : 5 px ;
}
. my - pagination * {
. my - pagination * {
-- el - pagination - bg - color : v - bind ( "state.style.bodyBg" ) ! important ;
-- el - pagination - bg - color : v - bind ( "state.style.bodyBg" ) ! important ;
-- el - pagination - disabled - bg - color : v - bind ( "state.style.bodyBg" ) ! important ;
-- el - pagination - disabled - bg - color : v - bind ( "state.style.bodyBg" ) ! important ;