20260902223822

This commit is contained in:
oneao committed 2026-09-02 22:38:23 +08:00
1 parent db7813a2d2
commit c8940f6e03
11 files changed
+327 -922

No files matched your search

@@ -185,4 +185,76 @@ describe('fms-table 虚拟滚动验证', () => {
expect(stkTable.props('headerDrag')).toBeTruthy()
wrapper.unmount()
})
it('autoFitWidth 默认关闭表格自动铺满宽度', async () => {
const wrapper = mount(FmsTable, {
props: {
columns: makeColumns(),
dataSource: makeRows(20),
rowKey: 'id',
seq: false,
'onUpdate:columns': () => {},
},
})
await nextTick()
expect(wrapper.find('.fms-table').classes()).not.toContain('fms-table--auto-fit-width')
expect(wrapper.findComponent(StkTable).props('colResizable')).toBe(true)
wrapper.unmount()
})
it('autoFitWidth=true 时关闭列宽拖拽并使用自适应布局', async () => {
const wrapper = mount(FmsTable, {
props: {
columns: makeColumns(),
dataSource: makeRows(20),
rowKey: 'id',
autoFitWidth: true,
'onUpdate:columns': () => {},
},
})
await nextTick()
expect(wrapper.find('.fms-table').classes()).toContain('fms-table--auto-fit-width')
expect(wrapper.findComponent(StkTable).props('colResizable')).toBe(false)
wrapper.unmount()
})
it('序号列和复选框列允许调整宽度且回写后保持', async () => {
const wrapper = mount(FmsTable, {
props: {
columns: [{ title: '名称', dataIndex: 'name', width: 120 }],
dataSource: [{ id: 1, name: '测试' }],
rowKey: 'id',
rowSelection: { selectedRowKeys: [], onChange: () => {} },
'onUpdate:columns': () => {},
},
})
await nextTick()
const table = wrapper.findComponent(StkTable)
const columns = table.props('columns')
const seq = columns.find((column) => column.type === 'seq')
const selection = columns.find((column) => column.__fmsSelection)
expect(seq?.headerAlign).toBe('center')
expect(seq?.resizable).not.toBe(false)
expect(selection?.resizable).not.toBe(false)
await table.vm.$emit(
'update:columns',
columns.map((column) =>
column.type === 'seq'
? { ...column, width: '72px' }
: column.__fmsSelection
? { ...column, width: '56px' }
: column,
),
)
await nextTick()
const updated = wrapper.findComponent(StkTable).props('columns')
expect(updated.find((column) => column.type === 'seq')?.width).toBe(72)
expect(updated.find((column) => column.__fmsSelection)?.width).toBe(56)
wrapper.unmount()
})
})