n20-common-lib 2.21.9 → 2.21.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -417,23 +417,22 @@ export default {
|
|
|
417
417
|
function calc(columns) {
|
|
418
418
|
// 计算所有列的基础宽度总和
|
|
419
419
|
let totalBaseWidth = 0
|
|
420
|
-
|
|
421
420
|
columns.forEach((column) => {
|
|
422
421
|
if (column.static && column.label === $lc('操作') && !column.width && !column.minWidth) {
|
|
423
|
-
column.width =
|
|
422
|
+
column.width = 180
|
|
424
423
|
}
|
|
425
424
|
if (column.type === 'checkbox') {
|
|
426
|
-
column.width =
|
|
425
|
+
column.width = 50
|
|
427
426
|
}
|
|
428
427
|
|
|
429
428
|
// 如果没有设置宽度,根据字符数计算最小宽度
|
|
430
|
-
if (!column.width && !column.minWidth) {
|
|
429
|
+
if (!column.width && !column.minWidth && !column['min-width']) {
|
|
431
430
|
const textLength = (column.label && column.label.length) || 10
|
|
432
431
|
column.minWidth = Math.ceil(textLength * CHAR_WIDTH + PADDING)
|
|
433
432
|
}
|
|
434
433
|
|
|
435
434
|
// 计算基础宽度:有width的用width,没有的用minWidth
|
|
436
|
-
const widthValue = column.width || column.minWidth || 0
|
|
435
|
+
const widthValue = column.width || column.minWidth || column['min-width'] || 0
|
|
437
436
|
// 处理不同格式的宽度:数字、"100"、"100px"
|
|
438
437
|
let baseWidth = 0
|
|
439
438
|
if (typeof widthValue === 'number') {
|
|
@@ -445,25 +444,17 @@ export default {
|
|
|
445
444
|
column['_baseWidth_'] = baseWidth
|
|
446
445
|
totalBaseWidth += baseWidth
|
|
447
446
|
})
|
|
448
|
-
|
|
449
447
|
// 如果所有列的基础宽度总和 >= 容器宽度,不做处理
|
|
450
448
|
if (totalBaseWidth >= windowWidth) {
|
|
451
449
|
return columns
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
columns.forEach((column) => {
|
|
458
|
-
if (!column.type && !column.isResize) {
|
|
459
|
-
// 按比例扩展列宽,向上取整避免小数宽度
|
|
460
|
-
column.width = Math.ceil(column['_baseWidth_'] * scaleRate)
|
|
450
|
+
} else {
|
|
451
|
+
const seqColumns = columns.filter((item) => item.type !== 'seq' && item.type !== 'checkbox')
|
|
452
|
+
if (seqColumns.length > 0) {
|
|
453
|
+
seqColumns[0].width = ''
|
|
461
454
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
return columns
|
|
455
|
+
return columns
|
|
456
|
+
}
|
|
465
457
|
}
|
|
466
|
-
|
|
467
458
|
return calc(columns)
|
|
468
459
|
}
|
|
469
460
|
}
|