🐛(table): 修复 typescript 类型警告

This commit is contained in:
就眠儀式 2022-07-18 14:49:48 +08:00
parent d2f11c1866
commit 5beab5d80c
2 changed files with 17 additions and 12 deletions

View File

@ -6,7 +6,7 @@ export default {
<script lang="ts" setup> <script lang="ts" setup>
import { Recordable } from "../../types"; import { Recordable } from "../../types";
import { computed, ref, useSlots, WritableComputedRef } from "vue"; import { computed, ref, StyleValue, useSlots, WritableComputedRef } from "vue";
import LayCheckbox from "../checkbox/index.vue"; import LayCheckbox from "../checkbox/index.vue";
import LayDropdown from "../dropdown/index.vue"; import LayDropdown from "../dropdown/index.vue";
import LayTooltip from "../tooltip/index.vue"; import LayTooltip from "../tooltip/index.vue";
@ -133,7 +133,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
left = left + props.columns[i]?.width.replace("px", ""); left = left + props.columns[i]?.width.replace("px", "");
} }
} }
return `left:${left}px`; return { left: `${left}px` } as StyleValue;
} 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++) {
@ -141,9 +141,10 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
right = right + props.columns[i]?.width.replace("px", ""); right = right + props.columns[i]?.width.replace("px", "");
} }
} }
return `right:${right}px`; return { right: `${right}px` } as StyleValue;
} }
} }
return { } as StyleValue;
}; };
const renderFixedClassName = (column: any, columnIndex: number) => { const renderFixedClassName = (column: any, columnIndex: number) => {
@ -155,7 +156,7 @@ const renderFixedClassName = (column: any, columnIndex: number) => {
left = false; left = false;
} }
} }
return `layui-table-fixed-left-last`; return left ? `layui-table-fixed-left-last` : "";
} else { } else {
var right = true; var right = true;
for (var i = 0; i < columnIndex; i++) { for (var i = 0; i < columnIndex; i++) {
@ -163,7 +164,7 @@ const renderFixedClassName = (column: any, columnIndex: number) => {
right = false; right = false;
} }
} }
return `layui-table-fixed-right-first`; return right ? `layui-table-fixed-right-first` : "";
} }
} }
}; };
@ -226,7 +227,8 @@ const renderFixedClassName = (column: any, columnIndex: number) => {
<lay-icon <lay-icon
v-if=" v-if="
(slot.expand || data[childrenColumnName]) && columnIndex === expandIndex (slot.expand || data[childrenColumnName]) &&
columnIndex === expandIndex
" "
class="layui-table-cell-expand-icon" class="layui-table-cell-expand-icon"
:type="expandIconType" :type="expandIconType"
@ -279,7 +281,8 @@ const renderFixedClassName = (column: any, columnIndex: number) => {
<lay-icon <lay-icon
v-if=" v-if="
(slot.expand || data[childrenColumnName]) && columnIndex === expandIndex (slot.expand || data[childrenColumnName]) &&
columnIndex === expandIndex
" "
class="layui-table-cell-expand-icon" class="layui-table-cell-expand-icon"
:type="expandIconType" :type="expandIconType"
@ -334,7 +337,8 @@ const renderFixedClassName = (column: any, columnIndex: number) => {
<lay-icon <lay-icon
v-if=" v-if="
(slot.expand || data[childrenColumnName]) && columnIndex === expandIndex (slot.expand || data[childrenColumnName]) &&
columnIndex === expandIndex
" "
class="layui-table-cell-expand-icon" class="layui-table-cell-expand-icon"
:type="expandIconType" :type="expandIconType"

View File

@ -6,7 +6,7 @@ export default {
<script setup lang="ts"> <script setup lang="ts">
import "./index.less"; import "./index.less";
import { ref, watch, useSlots, withDefaults, onMounted, onUpdated } from "vue"; import { ref, watch, useSlots, withDefaults, onMounted, onUpdated, StyleValue } from "vue";
import { v4 as uuidv4 } from "../../utils/guidUtil"; import { v4 as uuidv4 } from "../../utils/guidUtil";
import { Recordable } from "../../types"; import { Recordable } from "../../types";
import { LayIcon } from "@layui/icons-vue"; import { LayIcon } from "@layui/icons-vue";
@ -264,7 +264,7 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
left = left + props.columns[i]?.width.replace("px", ""); left = left + props.columns[i]?.width.replace("px", "");
} }
} }
return `left:${left}px`; return { left: `${left}px` } as StyleValue;
} 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++) {
@ -272,9 +272,10 @@ const renderFixedStyle = (column: any, columnIndex: number) => {
right = right + props.columns[i]?.width.replace("px", ""); right = right + props.columns[i]?.width.replace("px", "");
} }
} }
return `right:${right}px`; return { right: `${right}px` } as StyleValue;
} }
} }
return { } as StyleValue;
}; };
const renderFixedClassName = (column: any, columnIndex: number) => { const renderFixedClassName = (column: any, columnIndex: number) => {