@ -1,61 +1,64 @@
@@ -1,61 +1,64 @@
< template >
< div class = "my-table" >
< el -table
ref = "table"
: size = "state.size.size"
: data = "page ? data.data : data"
: border = "border"
@ selection - change = "selectionChange"
@ row - click = "emit('row-click', $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
: row - key = "rowKey"
: tree - porps = "treeProps"
: lazy = "lazy"
: load = "load"
>
< el -table -column
v - for = "item in props"
: key = "item.code"
: prop = "item.code"
: label = "item.name || t(item.i18n)"
: type = "item.type"
: min - width = "item.width"
: width = "item.type ? item.width : ''"
: fixed = "item.fixed"
: align = "item.align ? item.align : 'center'"
show - overflow - tooltip
: formatter = "(row: any, column: any, value: any) => formatter(row, column, value, item)"
< div class = "list-table" :style ="containerStyle" >
< div class = "my-table" >
< el -table
ref = "table"
: size = "state.size.size"
height = "0"
: fit = "true"
: data = "page ? data.data : data"
: border = "border"
@ selection - change = "selectionChange"
@ row - click = "emit('row-click', $event)"
@ cell - click = "(row, column, cell, event) => emit('cell-click', row, column, cell, event)"
highlight - current - row
: row - key = "rowKey"
: tree - porps = "treeProps"
: lazy = "lazy"
: load = "load"
>
< template v-if ="item.slot" #default="{ row }" >
< slot :name ="item.code" :row ="row" > < / slot >
< / template >
< template v-if ="item.dict" #default="{ row }" >
{ { formatterByDist ( item . dict , lodash . get ( row , item . code ) ) } }
< / template >
< / e l - t a b l e - c o l u m n >
< / e l - t a b l e >
< / div >
< div v-if ="page" class="my-pagination" >
< el -pagination
: small = "state.size.size == 'small'"
@ size - change = "handleSizeChange"
@ current - change = "handleCurrentChange"
: current - page = "example.page"
: page - sizes = "[10, 20, 50, 100, 200]"
: page - size = "example.size"
layout = "total, sizes, prev, pager, next, jumper"
: total = "data.total"
>
< / e l - p a g i n a t i o n >
< el -table -column
v - for = "item in props"
: key = "item.code"
: prop = "item.code"
: label = "item.name || t(item.i18n)"
: type = "item.type"
: min - width = "item.width"
: width = "item.type ? item.width : ''"
: fixed = "item.fixed"
: align = "item.align ? item.align : 'center'"
show - overflow - tooltip
: formatter = "(row: any, column: any, value: any) => formatter(row, column, value, item)"
>
< template v-if ="item.slot" #default="{ row }" >
< slot :name ="item.code" :row ="row" > < / slot >
< / template >
< template v-if ="item.dict" #default="{ row }" >
{ { formatterByDist ( item . dict , lodash . get ( row , item . code ) ) } }
< / template >
< / e l - t a b l e - c o l u m n >
< / e l - t a b l e >
< / div >
< div v-if ="page" class="my-pagination" >
< el -pagination
: small = "state.size.size == 'small'"
@ size - change = "handleSizeChange"
@ current - change = "handleCurrentChange"
: current - page = "example.page"
: page - sizes = "[10, 20, 50, 100, 200]"
: page - size = "example.size"
layout = "total, sizes, prev, pager, next, jumper"
: total = "data.total"
>
< / e l - p a g i n a t i o n >
< / div >
< / div >
< / template >
< script lang = "ts" setup >
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 { TableColumn } from "noob-mengyxu" ;
import * as lodash from "lodash-es" ;
@ -64,11 +67,23 @@ const { t } = useI18n();
@@ -64,11 +67,23 @@ const { t } = useI18n();
const { state } = useStore ( ) ;
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 {
data ? : any ;
props ? : TableColumn [ ] ;
page ? : boolean ;
height ? : number ;
height ? : number | string ;
maxHeight ? : number | string ;
example ? : any ;
rowKey ? : string ;
selectKey ? : string ;
@ -82,6 +97,7 @@ const prop = withDefaults(defineProps<Props>(), {
@@ -82,6 +97,7 @@ const prop = withDefaults(defineProps<Props>(), {
props : ( ) => [ ] ,
page : false ,
height : undefined ,
maxHeight : undefined ,
example : ( ) => ( { } ) ,
rowKey : undefined ,
selectKey : undefined ,
@ -177,6 +193,31 @@ onUpdated(() => {
@@ -177,6 +193,31 @@ onUpdated(() => {
} ) ;
< / script >
< 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 * {
-- el - table - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
-- el - table - tr - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
@ -192,15 +233,21 @@ onUpdated(() => {
@@ -192,15 +233,21 @@ onUpdated(() => {
-- el - bg - color : v - bind ( "state.style.tableBg" ) ! important ;
}
: : v - deep . el - table _ _row -- level - 1 ,
: : v - deep . el - table _ _row -- level - 3 {
. list - table : deep ( . el - table _ _row -- level - 1 ) ,
. list - table : deep ( . el - table _ _row -- level - 3 ) {
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" ) ;
}
. my - pagination {
display : flex ;
justify - content : center ;
padding - top : 5 px ;
}
. my - pagination * {
-- el - pagination - bg - color : v - bind ( "state.style.bodyBg" ) ! important ;
-- el - pagination - disabled - bg - color : v - bind ( "state.style.bodyBg" ) ! important ;