date-table-column.vue
986 Bytes
<script setup lang="ts">
import { get } from "lodash";
import TableColumn from "@/components/filter/table-column.vue";
import dayjs from "dayjs";
withDefaults(defineProps<{ title?: string; dataIndex: string; split?: boolean }>(), { split: true });
const getValue = (record: object, path: string) => {
return get(record, path, "");
};
</script>
<template>
<TableColumn v-bind="$attrs" :title="title" :data-index="dataIndex">
<template #default="{ record }">
<template v-if="dataIndex && !getValue(record, dataIndex)">
<span style="color: rgba(0, 0, 0, 0.3)">无</span>
</template>
<template v-else-if="split">
<div>{{ dayjs(getValue(record, dataIndex))?.format("YYYY-MM-DD") || "" }}</div>
<div>{{ dayjs(getValue(record, dataIndex))?.format("HH:mm:ss") || "" }}</div>
</template>
<template v-else>{{ getValue(record, dataIndex) }}</template>
</template>
</TableColumn>
</template>
<style scoped lang="less"></style>