(component): update

This commit is contained in:
就眠儀式 2022-07-11 10:33:20 +08:00
parent 6a7a429c13
commit 401bc9db63
3 changed files with 96 additions and 16 deletions

View File

@ -128,18 +128,44 @@ 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") {
left = left + props.columns[i]?.width.replace("px", ""); left = left + props.columns[i]?.width.replace("px", "");
} }
}
return `left:${left}px`; return `left:${left}px`;
} 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") {
right = right + props.columns[i]?.width.replace("px", ""); right = right + props.columns[i]?.width.replace("px", "");
} }
}
return `right:${right}px`; return `right:${right}px`;
} }
} }
}; };
const renderFixedClassName = (column: any, columnIndex: number) => {
if (column.fixed) {
if (column.fixed == "left") {
var left = true;
for (var i = columnIndex + 1; i < props.columns.length; i++) {
if(props.columns[i].fixed && props.columns[i].fixed == "left") {
left = false;
}
}
return `layui-table-fixed-left-last`;
} else {
var right = true;
for (var i = 0; i < columnIndex; i++) {
if(props.columns[i].fixed && props.columns[i].fixed == "right") {
right = false;
}
}
return `layui-table-fixed-right-first`;
}
}
}
</script> </script>
<template> <template>
@ -232,6 +258,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
renderCellStyle(data, column, index, columnIndex), renderCellStyle(data, column, index, columnIndex),
]" ]"
:class="[ :class="[
renderFixedClassName(column, columnIndex),
renderCellClassName(data, column, index, columnIndex), renderCellClassName(data, column, index, columnIndex),
column.fixed ? `layui-table-fixed-${column.fixed}` : '', column.fixed ? `layui-table-fixed-${column.fixed}` : '',
]" ]"

View File

@ -106,7 +106,6 @@
.layui-table-box { .layui-table-box {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.layui-table-view .layui-table { .layui-table-view .layui-table {
@ -397,7 +396,7 @@
} }
.layui-table-header .layui-table-cell { .layui-table-header .layui-table-cell {
background-color: #FAFAFA; background-color: #fafafa;
} }
.layui-table-fixed-left { .layui-table-fixed-left {
@ -424,6 +423,33 @@
border: none !important; border: none !important;
} }
.layui-table-fixed-left-last::after {
position: absolute;
top: 0;
right: 0;
bottom: -1px;
width: 30px;
transform: translate(100%);
transition: box-shadow 0.3s;
}
.layui-table-fixed-left-last::after {
box-shadow: inset 10px 0 8px -8px #00000026;
}
.layui-table-fixed-right-first::after {
position: absolute;
top: 0;
bottom: -1px;
left: 0;
width: 30px;
transform: translate(-100%);
transition: box-shadow 0.3s;
}
.layui-table-fixed-right-first::after {
box-shadow: inset -10px 0 8px -8px #00000026;
}
.layui-table-view .layui-table tr th:last-child, .layui-table-view .layui-table tr th:last-child,
.layui-table-view .layui-table tr td:last-child { .layui-table-view .layui-table tr td:last-child {

View File

@ -255,18 +255,44 @@ 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") {
left = left + props.columns[i]?.width.replace("px", ""); left = left + props.columns[i]?.width.replace("px", "");
} }
}
return `left:${left}px`; return `left:${left}px`;
} 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") {
right = right + props.columns[i]?.width.replace("px", ""); right = right + props.columns[i]?.width.replace("px", "");
} }
}
return `right:${right}px`; return `right:${right}px`;
} }
} }
}; };
const renderFixedClassName = (column: any, columnIndex: number) => {
if (column.fixed) {
if (column.fixed == "left") {
var left = true;
for (var i = columnIndex + 1; i < props.columns.length; i++) {
if(props.columns[i].fixed && props.columns[i].fixed == "left") {
left = false;
}
}
return left ? `layui-table-fixed-left-last` : '';
} else {
var right = true;
for (var i = 0; i < columnIndex; i++) {
if(props.columns[i].fixed && props.columns[i].fixed == "right") {
right = false;
}
}
return right ? `layui-table-fixed-right-first` : '';
}
}
}
</script> </script>
<template> <template>
@ -353,6 +379,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
class="layui-table-cell" class="layui-table-cell"
:class="[ :class="[
column.fixed ? `layui-table-fixed-${column.fixed}` : '', column.fixed ? `layui-table-fixed-${column.fixed}` : '',
renderFixedClassName(column, columnIndex)
]" ]"
:style="[ :style="[
{ {