@ -1,61 +1,64 @@
< template >
< template >
< div class = "my-table" >
< div class = "list-table" :style ="containerStyle" >
< el -table
< div class = "my-table" >
ref = "table"
< el -table
: size = "state.size.size"
ref = "table"
: data = "page ? data.data : data"
: size = "state.size.size"
: border = "border"
height = "0"
@ selection - change = "selectionChange"
: fit = "true"
@ row - click = "emit('row-click', $event)"
: data = "page ? data.data : data"
@ cell - click = "(row, column, cell, event) => emit('cell-click', row, column, cell, event)"
: border = "border"
: height = "height || (page ? state.size.pTableHeight : state.size.tableHeight)"
@ selection - change = "selectionChange"
highlight - current - row
@ row - click = "emit('row-click', $event)"
: row - key = "rowKey"
@ cell - click = "(row, column, cell, event) => emit('cell-click', row, column, cell, event)"
: tree - porps = "treeProps"
highlight - current - row
: lazy = "lazy"
: row - key = "rowKey"
: load = "load"
: tree - porps = "treeProps"
>
: lazy = "lazy"
< el -table -column
: load = "load"
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 }" >
< el -table -column
< slot :name ="item.code" :row ="row" > < / slot >
v - for = "item in props"
< / template >
: key = "item.code"
: prop = "item.code"
< template v-if ="item.dict" #default="{ row }" >
: label = "item.name || t(item.i18n)"
{ { formatterByDist ( item . dict , lodash . get ( row , item . code ) ) } }
: type = "item.type"
< / template >
: min - width = "item.width"
< / e l - t a b l e - c o l u m n >
: width = "item.type ? item.width : ''"
< / e l - t a b l e >
: fixed = "item.fixed"
< / div >
: align = "item.align ? item.align : 'center'"
< div v-if ="page" class="my-pagination" >
show - overflow - tooltip
< el -pagination
: formatter = "(row: any, column: any, value: any) => formatter(row, column, value, item)"
: small = "state.size.size == 'small'"
>
@ size - change = "handleSizeChange"
< template v-if ="item.slot" #default="{ row }" >
@ current - change = "handleCurrentChange"
< slot :name ="item.code" :row ="row" > < / slot >
: current - page = "example.page"
< / template >
: page - sizes = "[10, 20, 50, 100, 200]"
: page - size = "example.size"
< template v-if ="item.dict" #default="{ row }" >
layout = "total, sizes, prev, pager, next, jumper"
{ { formatterByDist ( item . dict , lodash . get ( row , item . code ) ) } }
: total = "data.total"
< / template >
>
< / e l - t a b l e - c o l u m n >
< / e l - p a g i n a t i o 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 >
< / 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 ;