💄(component): 整理 table.vue 代码

This commit is contained in:
就眠儀式 2022-08-25 00:48:30 +08:00
parent 198d513896
commit d6b406ed02
4 changed files with 55 additions and 54 deletions

View File

@ -4,7 +4,7 @@ export default {
};
</script>
<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import { onMounted, ref } from "vue";
export interface TeleportWrapperProps {
to?: string;
@ -12,22 +12,22 @@ export interface TeleportWrapperProps {
}
const props = withDefaults(defineProps<TeleportWrapperProps>(), {
to: '',
to: "",
disabled: false,
})
});
const target = ref<Element | null>(null)
const target = ref<Element | null>(null);
onMounted(() => {
if (!props.to) return;
const el = document.querySelector(props.to)
const el = document.querySelector(props.to);
if (el) {
target.value = el
target.value = el;
}
})
});
</script>
<template>
<Teleport :to="target" :disabled="!target || disabled">
<slot></slot>
</Teleport>
</template>
</template>

View File

@ -30,7 +30,7 @@ import {
ElementScrollRect,
DropdownContext,
} from "./interface";
import TeleportWrapper from './TeleportWrapper.vue';
import TeleportWrapper from "./TeleportWrapper.vue";
export type DropdownTrigger = "click" | "hover" | "focus" | "contextMenu";
@ -78,7 +78,10 @@ const props = withDefaults(defineProps<LayDropdownProps>(), {
});
const childrenRefs = new Set<Ref<HTMLElement>>();
const dropdownCtx = inject<DropdownContext | undefined>(dropdownInjectionKey, undefined);
const dropdownCtx = inject<DropdownContext | undefined>(
dropdownInjectionKey,
undefined
);
const dropdownRef = shallowRef<HTMLElement | undefined>();
const contentRef = shallowRef<HTMLElement | undefined>();
const contentStyle = ref<CSSProperties>({});

View File

@ -1,7 +1,7 @@
<script lang="ts">
export default {
name: "TablePage"
}
name: "TablePage",
};
</script>
<script lang="ts" setup>
@ -9,54 +9,54 @@ import { LayIcon } from "@layui/icons-vue";
import LayPage from "../page/index.vue";
export interface LayTablePageProps {
showPage?: boolean;
showSkip?: boolean;
showLimit?: boolean;
showCount?: boolean;
showRefresh?: boolean;
modelValue: number;
limits?: number[];
pages?: number;
total: number;
limit?: number;
theme?: string;
showPage?: boolean;
showSkip?: boolean;
showLimit?: boolean;
showCount?: boolean;
showRefresh?: boolean;
modelValue: number;
limits?: number[];
pages?: number;
total: number;
limit?: number;
theme?: string;
}
const props = withDefaults(defineProps<LayTablePageProps>(), {
showPage: true,
showLimit: true,
showSkip: true,
showPage: true,
showLimit: true,
showSkip: true,
});
const emit = defineEmits(["update:modelValue", "update:limit", "change"]);
const change = (pageData: any) => {
emit('change', pageData)
emit('update:modelValue', pageData.current);
emit('update:limit', pageData.limit);
}
emit("change", pageData);
emit("update:modelValue", pageData.current);
emit("update:limit", pageData.limit);
};
</script>
<template>
<lay-page
:total="total"
:show-page="showPage"
:show-skip="showSkip"
:show-limit="showLimit"
:show-count="showCount"
:show-refresh="showRefresh"
:limits="limits"
:theme="theme"
:pages="pages"
v-model:modelValue="modelValue"
v-model:limit="limit"
@change="change">
<template #prev>
<lay-icon type="layui-icon-left" />
</template>
<template #next>
<lay-icon type="layui-icon-right" />
</template>
</lay-page>
</template>
<lay-page
:total="total"
:show-page="showPage"
:show-skip="showSkip"
:show-limit="showLimit"
:show-count="showCount"
:show-refresh="showRefresh"
:limits="limits"
:theme="theme"
:pages="pages"
v-model:modelValue="modelValue"
v-model:limit="limit"
@change="change"
>
<template #prev>
<lay-icon type="layui-icon-left" />
</template>
<template #next>
<lay-icon type="layui-icon-right" />
</template>
</lay-page>
</template>

View File

@ -22,7 +22,6 @@ import { Recordable } from "../../types";
import { LayIcon } from "@layui/icons-vue";
import LayCheckbox from "../checkbox/index.vue";
import LayDropdown from "../dropdown/index.vue";
import LayPage from "../page/index.vue";
import LayEmpty from "../empty/index.vue";
import TableRow from "./TableRow.vue";
import TablePage from "./TablePage.vue";
@ -619,7 +618,6 @@ onBeforeUnmount(() => {
</script>
<template>
{{ page }}
<div :id="tableId">
<table class="layui-hide" lay-filter="test"></table>
<div class="layui-form layui-border-box layui-table-view" :class="classes">