<template>
  <PickerDate
    :date="value"
    @change="date1Change"
    :range="formItemObj.isRegion"
  />
</template>

<script>
export default {
  props: {
    initValue: {
      type: [String, Number, Array, Object],
      default: () => {
        return "";
      },
    },
    formItemObj: {
      type: Object,
      default: () => {
        return { isRegion: false };
      },
    },
  },
  computed: {},
  data() {
    return {
      value: this.filterInitValue(this.initValue),
    };
  },
  methods: {
    filterInitValue(str) {
      if (!str) return str;
      if (!this.formItemObj.isRegion) {
        return this.getYearMonthDay(str);
      } else {
      }

      return str;
    },
    date1Change(e) {
      const date = e.replace(/\./g, "");

      this.$emit("change", date);
    },
    getYearMonthDay(str) {
      let year = str.slice(0, 4);
      let month = str.slice(4, 6);
      let day = str.slice(6, 8);
      return `${year}.${month}.${day}`;
    },
  },
};
</script>
