🐛(component): 修复 table 固定列隐藏列的冲突

This commit is contained in:
就眠儀式 2022-08-09 20:59:04 +08:00
parent a62e28bbe9
commit 48cb33036a
3 changed files with 18 additions and 13 deletions

View File

@ -85,13 +85,12 @@
.layui-form-switch em { .layui-form-switch em {
position: relative; position: relative;
top: 0;
width: 25px;
padding: 0 !important;
text-align: center !important; text-align: center !important;
color: #999 !important; color: #999 !important;
font-style: normal !important; font-style: normal !important;
font-size: 12px; font-size: 12px;
width: 25px;
top: 0;
} }
.layui-form-onswitch { .layui-form-onswitch {

View File

@ -176,7 +176,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
if (column.fixed == "left") { if (column.fixed == "left") {
var left = 0; var left = 0;
for (var i = 0; i < columnIndex; i++) { for (var i = 0; i < columnIndex; i++) {
if (props.columns[i].fixed && props.columns[i].fixed == "left") { if (props.columns[i].fixed && props.columns[i].fixed == "left" && props.tableColumnKeys.includes(props.columns[i].key)) {
left = left + props.columns[i]?.width.replace("px", ""); left = left + props.columns[i]?.width.replace("px", "");
} }
} }
@ -184,7 +184,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
} else { } else {
var right = 0; var right = 0;
for (var i = columnIndex + 1; i < props.columns.length; i++) { for (var i = columnIndex + 1; i < props.columns.length; i++) {
if (props.columns[i].fixed && props.columns[i].fixed == "right") { if (props.columns[i].fixed && props.columns[i].fixed == "right" && props.tableColumnKeys.includes(props.columns[i].key)) {
right = right + props.columns[i]?.width.replace("px", ""); right = right + props.columns[i]?.width.replace("px", "");
} }
} }
@ -193,7 +193,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
} else { } else {
var isLast = true; var isLast = true;
for (var i = columnIndex + 1; i < props.columns.length; i++) { for (var i = columnIndex + 1; i < props.columns.length; i++) {
if (props.columns[i].fixed == undefined) { if (props.columns[i].fixed == undefined && props.tableColumnKeys.includes(props.columns[i].key)) {
isLast = false; isLast = false;
} }
} }
@ -207,7 +207,7 @@ const renderFixedClassName = (column: any, columnIndex: number) => {
if (column.fixed == "left") { if (column.fixed == "left") {
var left = true; var left = true;
for (var i = columnIndex + 1; i < props.columns.length; i++) { for (var i = columnIndex + 1; i < props.columns.length; i++) {
if (props.columns[i].fixed && props.columns[i].fixed == "left") { if (props.columns[i].fixed && props.columns[i].fixed == "left" && props.tableColumnKeys.includes(props.columns[i].key)) {
left = false; left = false;
} }
} }
@ -215,7 +215,7 @@ const renderFixedClassName = (column: any, columnIndex: number) => {
} else { } else {
var right = true; var right = true;
for (var i = 0; i < columnIndex; i++) { for (var i = 0; i < columnIndex; i++) {
if (props.columns[i].fixed && props.columns[i].fixed == "right") { if (props.columns[i].fixed && props.columns[i].fixed == "right" && props.tableColumnKeys.includes(props.columns[i].key)) {
right = false; right = false;
} }
} }

View File

@ -473,12 +473,15 @@ props.dataSource.map((value: any) => {
} }
}); });
/**
* @remark 排除 hide
*/
const renderFixedStyle = (column: any, columnIndex: number) => { const renderFixedStyle = (column: any, columnIndex: number) => {
if (column.fixed) { if (column.fixed) {
if (column.fixed == "left") { if (column.fixed == "left") {
var left = 0; var left = 0;
for (var i = 0; i < columnIndex; i++) { for (var i = 0; i < columnIndex; i++) {
if (props.columns[i].fixed && props.columns[i].fixed == "left") { if (props.columns[i].fixed && props.columns[i].fixed == "left" && tableColumnKeys.value.includes(props.columns[i].key)) {
left = left + props.columns[i]?.width.replace("px", ""); left = left + props.columns[i]?.width.replace("px", "");
} }
} }
@ -486,7 +489,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
} else { } else {
var right = 0; var right = 0;
for (var i = columnIndex + 1; i < props.columns.length; i++) { for (var i = columnIndex + 1; i < props.columns.length; i++) {
if (props.columns[i].fixed && props.columns[i].fixed == "right") { if (props.columns[i].fixed && props.columns[i].fixed == "right" && tableColumnKeys.value.includes(props.columns[i].key)) {
right = right + props.columns[i]?.width.replace("px", ""); right = right + props.columns[i]?.width.replace("px", "");
} }
} }
@ -495,7 +498,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
} else { } else {
var isLast = true; var isLast = true;
for (var i = columnIndex + 1; i < props.columns.length; i++) { for (var i = columnIndex + 1; i < props.columns.length; i++) {
if (props.columns[i].fixed == undefined) { if (props.columns[i].fixed == undefined && tableColumnKeys.value.includes(props.columns[i].key)) {
isLast = false; isLast = false;
} }
} }
@ -504,12 +507,15 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
return {} as StyleValue; return {} as StyleValue;
}; };
/**
* @remark 排除 hide
*/
const renderFixedClassName = (column: any, columnIndex: number) => { const renderFixedClassName = (column: any, columnIndex: number) => {
if (column.fixed) { if (column.fixed) {
if (column.fixed == "left") { if (column.fixed == "left") {
var left = true; var left = true;
for (var i = columnIndex + 1; i < props.columns.length; i++) { for (var i = columnIndex + 1; i < props.columns.length; i++) {
if (props.columns[i].fixed && props.columns[i].fixed == "left") { if (props.columns[i].fixed && props.columns[i].fixed == "left" && tableColumnKeys.value.includes(props.columns[i].key)) {
left = false; left = false;
} }
} }
@ -517,7 +523,7 @@ const renderFixedClassName = (column: any, columnIndex: number) => {
} else { } else {
var right = true; var right = true;
for (var i = 0; i < columnIndex; i++) { for (var i = 0; i < columnIndex; i++) {
if (props.columns[i].fixed && props.columns[i].fixed == "right") { if (props.columns[i].fixed && props.columns[i].fixed == "right" && tableColumnKeys.value.includes(props.columns[i].key)) {
right = false; right = false;
} }
} }