20260902173133
This commit is contained in:
1 parent
6b9cda5424
commit
db7813a2d2
16 files changed
+1350
-675
No files matched your search
@@ -151,32 +151,38 @@ describe('fms-table 虚拟滚动验证', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
// 列宽拖拽回归:库 useColResize 在 mouseUp 时「原地改写」传入的列对象 width 并
|
||||
// emit update:columns(同一批对象的新数组)。未绑定 v-model:columns 的父组件
|
||||
// 不会回灌新数组,displayColumns 必须自行换新数组引用,库才能重算出新列宽。
|
||||
// 复现方式:拿到库实际收到的 displayColumns,原地改第 1 列宽度后以同批对象
|
||||
// emit update:columns,断言表头渲染出新宽度。
|
||||
it('拖拽列宽后(未绑定 v-model:columns),新列宽立即生效不丢失', async () => {
|
||||
const columns = makeColumns()
|
||||
// 列宽/列序拖拽依赖 v-model:columns 回写:未绑定的父组件(如 dashboard 单向 :columns)
|
||||
// 拖了松手就回弹,因此未绑定时直接关闭这两个功能(不渲染把手),绑定时保持开启。
|
||||
it('未绑定 v-model:columns 时关闭列宽拖拽与列头拖拽(无处回写)', async () => {
|
||||
const wrapper = mount(FmsTable, {
|
||||
props: { columns, dataSource: makeRows(20), rowKey: 'id', seq: false },
|
||||
props: { columns: makeColumns(), dataSource: makeRows(20), rowKey: 'id', seq: false },
|
||||
attachTo: document.body,
|
||||
})
|
||||
await nextTick()
|
||||
await new Promise((r) => setTimeout(r, 100))
|
||||
|
||||
const stkTable = wrapper.findComponent(StkTable)
|
||||
const displayColumns = stkTable.props('columns')
|
||||
const target = displayColumns.find((c) => c.dataIndex === 'c1')
|
||||
target.width = '333px' // 模拟 useColResize mouseUp 的原地改写
|
||||
expect(stkTable.props('colResizable')).toBe(false)
|
||||
expect(stkTable.props('headerDrag')).toBe(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
await stkTable.vm.$emit('update:columns', displayColumns.slice())
|
||||
it('绑定 v-model:columns 时列宽拖拽与列头拖拽保持开启', async () => {
|
||||
const wrapper = mount(FmsTable, {
|
||||
props: {
|
||||
columns: makeColumns(),
|
||||
dataSource: makeRows(20),
|
||||
rowKey: 'id',
|
||||
seq: false,
|
||||
// 模拟 v-model:columns:提供 update:columns 监听器
|
||||
'onUpdate:columns': () => {},
|
||||
},
|
||||
attachTo: document.body,
|
||||
})
|
||||
await nextTick()
|
||||
await new Promise((r) => setTimeout(r, 100))
|
||||
|
||||
// 表头 th 宽度经 --cw CSS 变量渲染;virtualX 模式下取自 __W__(dealColumns 重算产物)
|
||||
const th = wrapper.findAll('thead th').find((el) => el.attributes('data-col-key') === 'c1')
|
||||
expect(th.attributes('style')).toContain('333px')
|
||||
const stkTable = wrapper.findComponent(StkTable)
|
||||
expect(stkTable.props('colResizable')).toBe(true)
|
||||
expect(stkTable.props('headerDrag')).toBeTruthy()
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user