1
0
mirror of synced 2025-12-11 00:28:09 +08:00

增加参数 row-config.height

This commit is contained in:
xuliangzhan
2021-10-30 18:20:04 +08:00
parent e15447264a
commit b252b4bdf5
24 changed files with 77612 additions and 99 deletions

View File

@@ -442,6 +442,13 @@ export default defineComponent({
},
keywords: ['max-height']
},
{
label: 'app.aside.nav.rowHeight',
locat: {
name: 'TableRowHeight'
},
keywords: ['row-config', 'height']
},
{
label: 'app.aside.nav.resize',
locat: {

View File

@@ -917,15 +917,15 @@ const apis = [
// },
{
name: 'column-config',
desc: '列的默认参数',
desc: '列配置信息',
version: '',
type: 'any',
enum: '',
defVal: '',
defVal: '继承 setup.table.columnConfig',
list: [
{
name: 'width',
desc: '列的默认宽度',
desc: '列的宽度',
version: '',
type: 'number, string',
enum: 'auto, px, %',
@@ -934,7 +934,7 @@ const apis = [
},
{
name: 'minWidth',
desc: '列的默认最小宽度',
desc: '列的最小宽度',
version: '',
type: 'number, string',
enum: 'auto, px, %',
@@ -943,6 +943,25 @@ const apis = [
}
]
},
{
name: 'row-config',
desc: '行配置信息',
version: '4.1.1',
type: 'any',
enum: '',
defVal: '继承 setup.table.rowConfig',
list: [
{
name: 'height',
desc: '只对 show-overflow 有效,行的高度',
version: '',
type: 'number',
enum: '',
defVal: '',
list: []
}
]
},
{
name: 'resizable-config',
descKey: 'app.api.table.desc.resizableConfig',

View File

@@ -132,7 +132,7 @@ export default {
scrollMode: 'Scroll mode',
scrollRows: 'vertical',
scrollFullRows: 'vertical + complicated',
scrollCols: 'horizontal and vertical',
scrollCols: 'horizontal',
scrollFullCols: 'horizontal and vertical + complicated',
moveHighlight: 'Keyboard move highlight row',
scrollTree: 'Virtual tree',

View File

@@ -131,7 +131,7 @@ export default {
scrollMode: '滚动模式',
scrollRows: '纵向',
scrollFullRows: '纵向 + 复杂渲染',
scrollCols: '横向&纵向',
scrollCols: '横向',
scrollFullCols: '横向&纵向 + 复杂渲染',
moveHighlight: '键盘移动高亮行',
scrollTree: '虚拟树',

View File

@@ -131,7 +131,7 @@ export default {
scrollMode: '滚动模式',
scrollRows: '纵向',
scrollFullRows: '纵向 + 复杂渲染',
scrollCols: '横向&纵向',
scrollCols: '横向',
scrollFullCols: '横向&纵向 + 复杂渲染',
moveHighlight: '键盘移动高亮行',
scrollTree: '虚拟树',

View File

@@ -40,6 +40,7 @@ import TableHeaderHighlight from '../views/table/base/HeaderHighlight.vue'
import TableResizable from '../views/table/base/Resizable.vue'
import TableMaxHeight from '../views/table/base/MaxHeight.vue'
import TableHeight from '../views/table/base/Height.vue'
import TableRowHeight from '../views/table/base/RowHeight.vue'
import TableAutoHeight from '../views/table/base/AutoHeight.vue'
import TableFixed from '../views/table/base/Fixed.vue'
import TableFixedFull from '../views/table/base/FixedFull.vue'
@@ -494,6 +495,11 @@ const routes: Array<RouteRecordRaw> = [
name: 'TableHeight',
component: TableHeight
},
{
path: '/table/base/rowHeight',
name: 'TableRowHeight',
component: TableRowHeight
},
{
path: '/table/base/autoHeight',
name: 'TableAutoHeight',

View File

@@ -0,0 +1,128 @@
<template>
<div>
<p class="tip">修改行高可以通过 <table-api-link prop="show-overflow"/> <table-api-link prop="row-config"/>.height 修改行的高度</p>
<vxe-table
border
resizable
show-overflow
height="500"
:row-config="{height: 120}"
:data="demo1.tableData">
<vxe-column type="seq" title="序号" width="100"></vxe-column>
<vxe-column title="图片" width="140" align="center">
<template #default>
<img src="/vxe-table/static/other/img1.gif" style="width: 100px;">
</template>
</vxe-column>
<vxe-column title="基本信息">
<template #default="{ row }">
<div class="label-ellipsis">{{ row.name }}</div>
<div class="label-ellipsis">{{ row.age }}</div>
<div class="label-ellipsis">{{ row.address }}</div>
</template>
</vxe-column>
<vxe-column field="age" title="Age" width="200"></vxe-column>
<vxe-column field="address" title="Address" width="200"></vxe-column>
</vxe-table>
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
<pre>
<pre-code class="xml">{{ demoCodes[0] }}</pre-code>
<pre-code class="javascript">{{ demoCodes[1] }}</pre-code>
<pre-code class="css">{{ demoCodes[1] }}</pre-code>
</pre>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive } from 'vue'
export default defineComponent({
setup () {
const demo1 = reactive({
tableData: [
{ id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'vxe-table 从入门到放弃' },
{ id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
{ id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
{ id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 23, address: 'vxe-table 从入门到放弃' },
{ id: 10005, name: 'Test5', role: 'Develop', sex: 'Women', age: 30, address: 'Shanghai' },
{ id: 10006, name: 'Test6', role: 'Designer', sex: 'Women', age: 21, address: 'vxe-table 从入门到放弃' },
{ id: 10007, name: 'Test7', role: 'Test', sex: 'Man', age: 29, address: 'vxe-table 从入门到放弃' },
{ id: 10008, name: 'Test8', role: 'Develop', sex: 'Man', age: 35, address: 'vxe-table 从入门到放弃' }
]
})
return {
demo1,
demoCodes: [
`
<vxe-table
border
resizable
show-overflow
height="500"
:row-config="{height: 120}"
:data="demo1.tableData">
<vxe-column type="seq" title="序号" width="100"></vxe-column>
<vxe-column title="图片" width="140" align="center">
<template #default>
<img src="/vxe-table/static/other/img1.gif" style="width: 100px;">
</template>
</vxe-column>
<vxe-column title="基本信息">
<template #default="{ row }">
<div class="label-ellipsis">{{ row.name }}</div>
<div class="label-ellipsis">{{ row.age }}</div>
<div class="label-ellipsis">{{ row.address }}</div>
</template>
</vxe-column>
<vxe-column field="age" title="Age" width="200"></vxe-column>
<vxe-column field="address" title="Address" width="200"></vxe-column>
</vxe-table>
`,
`
import { defineComponent, reactive } from 'vue'
export default defineComponent({
setup () {
const demo1 = reactive({
tableData: [
{ id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'vxe-table 从入门到放弃' },
{ id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
{ id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
{ id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 23, address: 'vxe-table 从入门到放弃' },
{ id: 10005, name: 'Test5', role: 'Develop', sex: 'Women', age: 30, address: 'Shanghai' },
{ id: 10006, name: 'Test6', role: 'Designer', sex: 'Women', age: 21, address: 'vxe-table 从入门到放弃' },
{ id: 10007, name: 'Test7', role: 'Test', sex: 'Man', age: 29, address: 'vxe-table 从入门到放弃' },
{ id: 10008, name: 'Test8', role: 'Develop', sex: 'Man', age: 35, address: 'vxe-table 从入门到放弃' }
]
})
return {
demo1
}
}
})
`,
`
.label-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
`
]
}
}
})
</script>
<style lang="scss" scoped>
.label-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>

View File

@@ -1,6 +1,6 @@
<template>
<div>
<p class="tip">虚拟滚动启用后需要等行高可以通过 <table-api-link prop="scroll-x"/>.rHeight 修改所有行的高度</p>
<p class="tip">虚拟滚动启用后需要等行高可以通过 <table-api-link prop="row-config"/>.height 修改行的高度</p>
<vxe-table
border
@@ -8,7 +8,8 @@
show-overflow
ref="xTable"
height="500"
:scroll-y="{gt: 0, rHeight: 120}"
:row-config="{height: 120}"
:scroll-y="{gt: 0}"
:loading="demo1.loading">
<vxe-column type="seq" title="序号" width="100"></vxe-column>
<vxe-column title="图片" width="140" align="center">
@@ -90,10 +91,11 @@ export default defineComponent({
show-overflow
ref="xTable"
height="500"
:scroll-y="{gt: 0, rHeight: 120}"
:loading="loading">
:row-config="{height: 120}"
:scroll-y="{gt: 0}"
:loading="demo1.loading">
<vxe-column type="seq" title="序号" width="100"></vxe-column>
<vxe-column title="图片" width="120" align="center">
<vxe-column title="图片" width="140" align="center">
<template #default>
<img src="/vxe-table/static/other/img1.gif" style="width: 100px;">
</template>
@@ -110,39 +112,51 @@ export default defineComponent({
</vxe-table>
`,
`
export default {
data () {
return {
import { defineComponent, reactive, ref } from 'vue'
import { VxeTableInstance } from 'vxe-table'
export default defineComponent({
setup () {
const demo1 = reactive({
loading: false
}
},
mounted () {
this.loading = true
this.$nextTick(() => {
const $table = this.$refs.xTable
this.mockList(1000).then(data => {
this.loading = false
if ($table) {
$table.loadData(data)
}
})
})
},
methods: {
mockList (size) {
const xTable = ref({} as VxeTableInstance)
const mockList = (size: number) => {
const list: any[] = []
for (let index = 0; index < size; index++) {
list.push({
name: \`名称\${index} 名称名称 名称名称 名称名称名称名称名称名称 名称名称名称名称 名称名称名称名称名称名称\`,
time: '2021-01-01 10:20:30',
num: 20,
address: 'shenzhen shenzhen shenzhen shenzhen shenzhen'
})
}
return list
}
const findList = () => {
demo1.loading = true
return new Promise(resolve => {
const list = []
for (let index = 0; index < size; index++) {
list.push({
name: \`名称\${index} 名称名称 名称名称 名称名称名称名称名称名称 名称名称名称名称 名称名称名称名称名称名称\`,
time: '2021-01-01 10:20:30',
num: 20,
address: 'shenzhen shenzhen shenzhen shenzhen shenzhen'
})
}
resolve(list)
setTimeout(() => {
const data = mockList(600)
const $table = xTable.value
if ($table) {
$table.loadData(data)
}
resolve(null)
demo1.loading = false
}, 300)
})
}
findList()
return {
demo1,
xTable
}
}
})
`,

View File

@@ -8,12 +8,12 @@
<vxe-grid ref="xGrid" v-bind="gridOptions">
<template #toolbar_buttons>
<vxe-button @click="loadColumnAndData(1000, 5000)">1k列5k</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 10000)">1k列1w</vxe-button>
<vxe-button @click="loadColumnAndData(5000, 100000)">5k列10w</vxe-button>
<vxe-button @click="loadColumnAndData(10000, 100000)">1w列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(50000, 200000)">5w列20w条</vxe-button>
<vxe-button @click="loadColumnAndData(100000, 300000)">10w列30w条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 20)">1k列20</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 100)">1k列100</vxe-button>
<vxe-button @click="loadColumnAndData(5000, 500)">5k列500</vxe-button>
<vxe-button @click="loadColumnAndData(10000, 10000)">1w列1w条</vxe-button>
<vxe-button @click="loadColumnAndData(50000, 100000)">5w列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(100000, 30000)">10w列30w条</vxe-button>
</template>
</vxe-grid>
@@ -39,8 +39,8 @@ export default defineComponent({
setup () {
const gridOptions = reactive({
border: true,
showOverflow: true,
showHeaderOverflow: true,
showOverflow: true,
height: 500,
resizable: true,
loading: false,
@@ -181,7 +181,7 @@ export default defineComponent({
}
nextTick(() => {
loadColumnAndData(600, 600)
loadColumnAndData(600, 10)
})
return {
@@ -192,12 +192,12 @@ export default defineComponent({
`
<vxe-grid ref="xGrid" v-bind="gridOptions">
<template #toolbar_buttons>
<vxe-button @click="loadColumnAndData(1000, 5000)">1k列5k条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 10000)">1k列1w条</vxe-button>
<vxe-button @click="loadColumnAndData(5000, 100000)">5k列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(10000, 100000)">1w列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(50000, 200000)">5w列20w条</vxe-button>
<vxe-button @click="loadColumnAndData(100000, 300000)">10w列30w条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 20)">1k列20条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 100)">1k列100条</vxe-button>
<vxe-button @click="loadColumnAndData(5000, 500)">5k列500条</vxe-button>
<vxe-button @click="loadColumnAndData(10000, 10000)">1w列1w条</vxe-button>
<vxe-button @click="loadColumnAndData(50000, 100000)">5w列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(100000, 30000)">10w列30w条</vxe-button>
</template>
</vxe-grid>
`,
@@ -213,8 +213,8 @@ export default defineComponent({
setup () {
const gridOptions = reactive({
border: true,
showOverflow: true,
showHeaderOverflow: true,
showOverflow: true,
height: 500,
resizable: true,
loading: false,
@@ -355,7 +355,7 @@ export default defineComponent({
}
nextTick(() => {
loadColumnAndData(600, 600)
loadColumnAndData(600, 10)
})
return {

View File

@@ -9,11 +9,11 @@
<vxe-grid ref="xGrid" v-bind="gridOptions">
<template #toolbar_buttons>
<vxe-button @click="loadColumnAndData(50, 1000)">50列1k</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 50)">1k列50条</vxe-button>
<vxe-button @click="loadColumnAndData(50, 20)">50列20</vxe-button>
<vxe-button @click="loadColumnAndData(100, 50)">100列50条</vxe-button>
<vxe-button @click="loadColumnAndData(200, 100)">200列100条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 5000)">1k列5k条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 10000)">1k列1w条</vxe-button>
<vxe-button @click="loadColumnAndData(5000, 100000)">5k列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(5000, 10000)">5k列1w条</vxe-button>
<vxe-button @click="loadColumnAndData(10000, 100000)">1w列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(50000, 200000)">5w列20w条</vxe-button>
<vxe-button @click="loadColumnAndData(100000, 50000)">10w列5w条</vxe-button>
@@ -196,7 +196,7 @@ export default defineComponent({
}
nextTick(() => {
loadColumnAndData(600, 600)
loadColumnAndData(20, 10)
})
return {
@@ -208,11 +208,11 @@ export default defineComponent({
`
<vxe-grid ref="xGrid" v-bind="gridOptions">
<template #toolbar_buttons>
<vxe-button @click="loadColumnAndData(50, 1000)">50列1k条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 50)">1k列50条</vxe-button>
<vxe-button @click="loadColumnAndData(50, 20)">50列20条</vxe-button>
<vxe-button @click="loadColumnAndData(100, 50)">100列50条</vxe-button>
<vxe-button @click="loadColumnAndData(200, 100)">200列100条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 5000)">1k列5k条</vxe-button>
<vxe-button @click="loadColumnAndData(1000, 10000)">1k列1w条</vxe-button>
<vxe-button @click="loadColumnAndData(5000, 100000)">5k列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(5000, 10000)">5k列1w条</vxe-button>
<vxe-button @click="loadColumnAndData(10000, 100000)">1w列10w条</vxe-button>
<vxe-button @click="loadColumnAndData(50000, 200000)">5w列20w条</vxe-button>
<vxe-button @click="loadColumnAndData(100000, 50000)">10w列5w条</vxe-button>
@@ -371,7 +371,7 @@ export default defineComponent({
}
nextTick(() => {
loadColumnAndData(600, 600)
loadColumnAndData(20, 10)
})
return {

View File

@@ -181,7 +181,11 @@
},
"vxe-table/column-config": {
"type": "any",
"description": "列的默认参数"
"description": "列配置信息"
},
"vxe-table/row-config": {
"type": "any",
"description": "行配置信息"
},
"vxe-table/resizable-config": {
"type": "object",
@@ -673,7 +677,11 @@
},
"vxe-grid/column-config": {
"type": "any",
"description": "列的默认参数"
"description": "列配置信息"
},
"vxe-grid/row-config": {
"type": "any",
"description": "行配置信息"
},
"vxe-grid/resizable-config": {
"type": "object",

View File

@@ -47,6 +47,7 @@
"row-id",
"keep-source",
"column-config",
"row-config",
"resizable-config",
"seq-config",
"sort-config",
@@ -192,6 +193,7 @@
"row-id",
"keep-source",
"column-config",
"row-config",
"resizable-config",
"seq-config",
"sort-config",

10
lib_temp/demo.html Normal file
View File

@@ -0,0 +1,10 @@
<meta charset="utf-8">
<title>index demo</title>
<script src="./index.umd.js"></script>
<link rel="stylesheet" href="./index.css">
<script>
console.log(index)
</script>

38642
lib_temp/index.common.js Normal file

File diff suppressed because it is too large Load Diff

1
lib_temp/index.css Normal file

File diff suppressed because one or more lines are too long

38652
lib_temp/index.umd.js Normal file

File diff suppressed because it is too large Load Diff

1
lib_temp/index.umd.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -91,11 +91,11 @@ export default defineComponent({
let { fixedType, fixedColumn, tableColumn, footerTableData } = props
const { footerRowClassName, footerCellClassName, footerRowStyle, footerCellStyle, footerAlign: allFooterAlign, footerSpanMethod, align: allAlign, columnKey, showFooterOverflow: allColumnFooterOverflow } = tableProps
const { visibleColumn } = tableInternalData
const { scrollXLoad, overflowX, scrollbarWidth, currentColumn, mergeFooterList } = tableReactData
const { scrollYLoad, overflowX, scrollbarWidth, currentColumn, mergeFooterList } = tableReactData
const tooltipOpts = computeTooltipOpts.value
// 如果是使用优化模式
if (fixedType) {
if (scrollXLoad || allColumnFooterOverflow) {
if (scrollYLoad || allColumnFooterOverflow) {
if (!mergeFooterList.length || !footerSpanMethod) {
tableColumn = fixedColumn
} else {
@@ -165,8 +165,8 @@ export default defineComponent({
const _columnIndex = $xetable.getVTColumnIndex(column)
const itemIndex = _columnIndex
const params: VxeTableDefines.CellRenderFooterParams = { $table: $xetable, _rowIndex, $rowIndex, column, columnIndex, $columnIndex, _columnIndex, itemIndex, items: list, fixed: fixedType, type: renderType, data: footerTableData }
// 虚拟滚动不支持动态高
if (scrollXLoad && !hasEllipsis) {
// 纵向虚拟滚动不支持动态
if (scrollYLoad && !hasEllipsis) {
showEllipsis = hasEllipsis = true
}
if (showTitle || showTooltip || showAllTip) {

View File

@@ -69,7 +69,7 @@ export default defineComponent({
loading: Boolean as PropType<VxeFormPropTypes.Loading>,
data: Object as PropType<VxeFormPropTypes.Data>,
size: { type: String as PropType<VxeFormPropTypes.Size>, default: () => GlobalConfig.form.size || GlobalConfig.size },
span: [String, Number] as PropType<VxeFormPropTypes.Span>,
span: { type: [String, Number] as PropType<VxeFormPropTypes.Span>, default: () => GlobalConfig.form.span },
align: { type: String as PropType<VxeFormPropTypes.Align>, default: () => GlobalConfig.form.align },
titleAlign: { type: String as PropType<VxeFormPropTypes.TitleAlign>, default: () => GlobalConfig.form.titleAlign },
titleWidth: { type: [String, Number] as PropType<VxeFormPropTypes.TitleWidth>, default: () => GlobalConfig.form.titleWidth },

View File

@@ -146,12 +146,12 @@ export default defineComponent({
const renderVN = () => {
let { fixedType, fixedColumn, tableColumn } = props
const { resizable, border, columnKey, headerRowClassName, headerCellClassName, headerRowStyle, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
const { isGroup, currentColumn, scrollXLoad, overflowX, scrollbarWidth } = tableReactData
const { isGroup, currentColumn, scrollYLoad, overflowX, scrollbarWidth } = tableReactData
let headerGroups: VxeTableDefines.ColumnInfo[][] = headerColumn.value
// 如果是使用优化模式
if (!isGroup) {
if (fixedType) {
if (scrollXLoad || allColumnHeaderOverflow) {
if (scrollYLoad || allColumnHeaderOverflow) {
tableColumn = fixedColumn
}
}
@@ -216,8 +216,8 @@ export default defineComponent({
onClick: (evnt: MouseEvent) => $xetable.triggerHeaderCellClickEvent(evnt, params),
onDblclick: (evnt: MouseEvent) => $xetable.triggerHeaderCellDblclickEvent(evnt, params)
}
// 虚拟滚动不支持动态高
if (scrollXLoad && !hasEllipsis) {
// 纵向虚拟滚动不支持动态
if (scrollYLoad && !hasEllipsis) {
showEllipsis = hasEllipsis = true
}
// 按下事件处理

View File

@@ -31,7 +31,7 @@ export default defineComponent({
const { xID, props: tableProps, context: tableContext, reactData: tableReactData, internalData: tableInternalData } = $xetable
const { refTableHeader, refTableBody, refTableFooter, refTableLeftBody, refTableRightBody, refValidTooltip } = $xetable.getRefMaps()
const { computeEditOpts, computeMouseOpts, computeSYOpts, computeEmptyOpts, computeKeyboardOpts, computeTooltipOpts, computeRadioOpts, computeTreeOpts, computeCheckboxOpts, computeValidOpts } = $xetable.getComputeMaps()
const { computeEditOpts, computeMouseOpts, computeSYOpts, computeEmptyOpts, computeKeyboardOpts, computeTooltipOpts, computeRadioOpts, computeTreeOpts, computeCheckboxOpts, computeValidOpts, computeRowOpts } = $xetable.getComputeMaps()
const refElem = ref() as Ref<XEBodyScrollElement>
const refBodyTable = ref() as Ref<HTMLTableElement>
@@ -110,16 +110,18 @@ export default defineComponent({
*/
const renderColumn = ($seq: string, seq: number, rowid: string, fixedType: any, rowLevel: number, row: any, rowIndex: number, $rowIndex: number, _rowIndex: number, column: any, $columnIndex: number, columns: any, items: any[]) => {
const { columnKey, height, showOverflow: allColumnOverflow, cellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig } = tableProps
const { tableData, overflowX, scrollXLoad, scrollYLoad, currentColumn, mergeList, editStore, validStore, isAllOverflow } = tableReactData
const { tableData, overflowX, scrollYLoad, currentColumn, mergeList, editStore, validStore, isAllOverflow } = tableReactData
const { afterFullData } = tableInternalData
const validOpts = computeValidOpts.value
const checkboxOpts = computeCheckboxOpts.value
const editOpts = computeEditOpts.value
const tooltipOpts = computeTooltipOpts.value
const rowOpts = computeRowOpts.value
const sYOpts = computeSYOpts.value
const { type, cellRender, editRender, align, showOverflow, className, treeNode } = column
const { actived } = editStore
const { rHeight } = sYOpts
const { rHeight: scrollYRHeight } = sYOpts
const { height: rowHeight } = rowOpts
const showAllTip = tooltipOpts.showAll
const columnIndex = $xetable.getColumnIndex(column)
const _columnIndex = $xetable.getVTColumnIndex(column)
@@ -138,7 +140,7 @@ export default defineComponent({
const attrs: any = { colid: column.id }
const params: VxeTableDefines.CellRenderBodyParams = { $table: $xetable, $seq, seq, rowid, row, rowIndex, $rowIndex, _rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, level: rowLevel, visibleData: afterFullData, data: tableData, items }
// 虚拟滚动不支持动态高度
if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
if (scrollYLoad && !hasEllipsis) {
showEllipsis = hasEllipsis = true
}
// hover 进入事件
@@ -230,7 +232,7 @@ export default defineComponent({
'c--ellipsis': showEllipsis
}],
style: {
maxHeight: hasEllipsis && rHeight ? `${rHeight}px` : ''
maxHeight: hasEllipsis && (scrollYRHeight || rowHeight) ? `${scrollYRHeight || rowHeight}px` : ''
}
})
)
@@ -245,7 +247,7 @@ export default defineComponent({
'c--ellipsis': showEllipsis
}],
style: {
maxHeight: hasEllipsis && rHeight ? `${rHeight}px` : ''
maxHeight: hasEllipsis && (scrollYRHeight || rowHeight) ? `${scrollYRHeight || rowHeight}px` : ''
},
title: showTitle ? $xetable.getCellLabel(row, column) : null
}, column.renderCell(params))
@@ -283,7 +285,7 @@ export default defineComponent({
key: columnKey ? column.id : $columnIndex,
...attrs,
style: Object.assign({
height: hasEllipsis && rHeight ? `${rHeight}px` : ''
height: hasEllipsis && (scrollYRHeight || rowHeight) ? `${scrollYRHeight || rowHeight}px` : ''
}, cellStyle ? (XEUtils.isFunction(cellStyle) ? cellStyle(params) : cellStyle) : null),
...tdOns
}, tdVNs)
@@ -603,7 +605,7 @@ export default defineComponent({
const renderVN = () => {
let { fixedColumn, fixedType, tableColumn } = props
const { keyboardConfig, showOverflow: allColumnOverflow, spanMethod, mouseConfig } = tableProps
const { tableData, mergeList, scrollXLoad, scrollYLoad, isAllOverflow } = tableReactData
const { tableData, mergeList, scrollYLoad, isAllOverflow } = tableReactData
const { visibleColumn } = tableInternalData
const { slots } = tableContext
const sYOpts = computeSYOpts.value
@@ -614,7 +616,7 @@ export default defineComponent({
// const isMergeRightFixedExceeded = computeIsMergeRightFixedExceeded.value
// 如果是使用优化模式
if (fixedType) {
if (scrollXLoad || scrollYLoad || (allColumnOverflow ? isAllOverflow : allColumnOverflow)) {
if (scrollYLoad || (allColumnOverflow ? isAllOverflow : allColumnOverflow)) {
if (!mergeList.length && !spanMethod && !(keyboardConfig && keyboardOpts.isMerge)) {
tableColumn = fixedColumn
} else {

View File

@@ -99,8 +99,11 @@ export default {
autoResize: { type: Boolean as PropType<VxeTablePropTypes.AutoResize>, default: () => GlobalConfig.table.autoResize },
// 是否自动根据状态属性去更新响应式表格宽高
syncResize: [Boolean, String, Number],
// 设置列的默认参数,仅对部分支持的属性有效
// 列配置信息
columnConfig: Object as PropType<VxeTablePropTypes.ColumnConfig>,
// 行配置信息
rowConfig: Object as PropType<VxeTablePropTypes.RowConfig>,
// 列调整配置项
resizableConfig: Object as PropType<VxeTablePropTypes.ResizableConfig>,
// 序号配置项
seqConfig: Object as PropType<VxeTablePropTypes.SeqConfig>,

View File

@@ -332,7 +332,11 @@ export default defineComponent({
})
const computeColumnOpts = computed(() => {
return Object.assign({}, props.columnConfig) as VxeTablePropTypes.ColumnOpts
return Object.assign({}, GlobalConfig.table.columnConfig, props.columnConfig) as VxeTablePropTypes.ColumnOpts
})
const computeRowOpts = computed(() => {
return Object.assign({}, GlobalConfig.table.rowConfig, props.rowConfig) as VxeTablePropTypes.RowOpts
})
const computeResizableOpts = computed(() => {
@@ -539,6 +543,8 @@ export default defineComponent({
computeValidOpts,
computeSXOpts,
computeSYOpts,
computeColumnOpts,
computeRowOpts,
computeResizableOpts,
computeSeqOpts,
computeRadioOpts,
@@ -1331,7 +1337,7 @@ export default defineComponent({
// 如果是使用优化模式
if (fixedType) {
if (scrollXLoad || scrollYLoad || (allColumnOverflow ? isAllOverflow : allColumnOverflow)) {
if (scrollYLoad || (allColumnOverflow ? isAllOverflow : allColumnOverflow)) {
if (!mergeList.length && !spanMethod && !(keyboardConfig && keyboardOpts.isMerge)) {
tableColumn = fixedColumn
} else {
@@ -1419,15 +1425,9 @@ export default defineComponent({
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
let hasEllipsis = showTitle || showTooltip || showEllipsis
const listElem = elemStore[`${name}-${layout}-list`]
// 滚动的渲染不支持动态行高
if (layout === 'header' || layout === 'footer') {
if (scrollXLoad && !hasEllipsis) {
hasEllipsis = true
}
} else {
if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
hasEllipsis = true
}
// 纵向虚拟滚动不支持动态行高
if (scrollYLoad && !hasEllipsis) {
hasEllipsis = true
}
if (listElem) {
XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem: any) => {
@@ -5433,12 +5433,16 @@ export default defineComponent({
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
const customOpts = computeCustomOpts.value
const mouseOpts = computeMouseOpts.value
const rowOpts = computeRowOpts.value
if (!props.id && props.customConfig && (customOpts.storage === true || (customOpts.storage && customOpts.storage.resizable) || (customOpts.storage && customOpts.storage.visible))) {
errLog('vxe.error.reqProp', ['id'])
}
if (props.treeConfig && checkboxOpts.range) {
errLog('vxe.error.noTree', ['checkbox-config.range'])
}
if (rowOpts.height && !props.showOverflow) {
warnLog('vxe.error.notProp', ['table.show-overflow'])
}
if (!$xetable.handleUpdateCellAreas) {
if (props.clipConfig) {
warnLog('vxe.error.notProp', ['clip-config'])

16
types/table.d.ts vendored
View File

@@ -55,6 +55,8 @@ export interface TablePrivateComputed {
computeValidOpts: ComputedRef<VxeTablePropTypes.ValidOpts>;
computeSXOpts: ComputedRef<VxeTablePropTypes.SXOpts>;
computeSYOpts: ComputedRef<VxeTablePropTypes.SYOpts>;
computeColumnOpts: ComputedRef<VxeTablePropTypes.ColumnOpts>;
computeRowOpts: ComputedRef<VxeTablePropTypes.RowOpts>;
computeResizableOpts: ComputedRef<VxeTablePropTypes.ResizableOpts>;
computeSeqOpts: ComputedRef<VxeTablePropTypes.SeqOpts>;
computeRadioOpts: ComputedRef<VxeTablePropTypes.RadioOpts>;
@@ -1192,7 +1194,7 @@ export namespace VxeTablePropTypes {
export type SyncResize = boolean | string | number;
/**
* 列的默认配置
* 列配置信息
*/
export interface ColumnConfig {
width?: number;
@@ -1200,6 +1202,14 @@ export namespace VxeTablePropTypes {
}
export interface ColumnOpts extends ColumnConfig { }
/**
* 行配置信息
*/
export interface RowConfig {
height?: number;
}
export interface RowOpts extends RowConfig { }
/**
* 自定义列配置项
*/
@@ -1212,6 +1222,9 @@ export namespace VxeTablePropTypes {
}
export interface CustomOpts extends CustomConfig { }
/**
* 列调整配置项
*/
export interface ResizableConfig {
minWidth?: number | string | ((params: {
$table: VxeTableConstructor & VxeTablePrivateMethods;
@@ -1911,6 +1924,7 @@ export type VxeTableProps<D = any> = {
autoResize?: VxeTablePropTypes.AutoResize;
syncResize?: VxeTablePropTypes.SyncResize;
columnConfig?: VxeTablePropTypes.ColumnConfig;
rowConfig?: VxeTablePropTypes.RowConfig;
customConfig?: VxeTablePropTypes.CustomConfig;
resizableConfig?: VxeTablePropTypes.ResizableConfig;
seqConfig?: VxeTablePropTypes.SeqConfig;