Merge pull request #8269 from dataease/pr@dev-v2@fix_table_index_column_width

fix(视图): 表格开启序号后拖拽无法保存序号的列宽
This commit is contained in:
wisonic-s 2024-03-01 14:55:45 +08:00 committed by GitHub
commit 8ba43c8835
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 8 deletions

View File

@ -70,7 +70,7 @@ declare interface ChartBasicStyle {
/**
* 字段名称
*/
name: string
name?: string
/**
* 字段宽度占比
*/

View File

@ -302,15 +302,20 @@ const resizeAction = resizeColumn => {
if (showPosition.value !== 'canvas') {
return
}
const fieldId = resizeColumn.info.meta.field
const fieldId: string = resizeColumn.info.meta.field
const { basicStyle } = view.value.customAttr
const containerWidth = document.getElementById(containerId).offsetWidth
basicStyle.tableFieldWidth?.forEach(item => {
if (item.fieldId === fieldId) {
item.width = parseFloat(((resizeColumn.info.resizedWidth / containerWidth) * 100).toFixed(2))
}
})
emitter.emit('set-table-column-width', basicStyle.tableFieldWidth)
const column = basicStyle.tableFieldWidth?.find(i => i.fieldId === fieldId)
let tableWidth: ChartBasicStyle['tableFieldWidth']
const width = parseFloat(((resizeColumn.info.resizedWidth / containerWidth) * 100).toFixed(2))
if (column) {
column.width = width
tableWidth = [...basicStyle.tableFieldWidth]
} else {
const tmp = { fieldId, width }
tableWidth = basicStyle.tableFieldWidth?.length ? [...basicStyle.tableFieldWidth, tmp] : [tmp]
}
emitter.emit('set-table-column-width', tableWidth)
}
defineExpose({
calcData,