<template>
  <span :class="'vc-show-date '+size">
    <span v-if="value && value!=null">
      {{ typeof value.format === 'function' ? value.format(dateFormat) : '不是日期类型' }}
    </span>
    <span v-else class="text-secondary"><i>{{ nullText }}</i></span>
  </span>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import dayjs from 'dayjs';

export default defineComponent({
  name: "ShowDateOrNull",
  props: {
    nullText: {
      default: '暂无',
      type: String
    },
    dateFormat: {
      default: 'YYYY-MM-DD HH:mm:ss',
      type: String
    },
    size: {
      default: '',
      type: String
    },
    value: {
      type: Object as import('vue').PropType<dayjs.Dayjs>,
      default: null,
    }
  },
});
</script>