"use strict";

exports.__esModule = true;
exports.default = void 0;

var _utils = require("./utils");

var _index = require("./index");

var _default = {
  components: {
    DateSelect: _index.DateSelect,
    DateRangeSelect: _index.DateRangeSelect,
    MonthSelect: _index.MonthSelect,
    MonthRangeSelect: _index.MonthRangeSelect,
    WeekSelect: _index.WeekSelect,
    QuarterSelect: _index.QuarterSelect,
    DateWeekMonth: _index.DateWeekMonth
  },
  props: {
    value: {
      type: Boolean,
      default: false
    },
    type: {
      type: String,
      default: 'date'
    },
    showConfirm: {
      type: Boolean,
      default: true
    }
  },
  data: function data() {
    return {
      currentCom: null,
      currentSelectedValue: null,
      startText: '',
      endText: ''
    };
  },
  methods: {
    init: function init() {
      var _this = this;

      this.currentCom = _utils.typeToSelectotMap[this.type];
      this.$nextTick(function () {
        _this.$refs.selector.init();
      });
    },
    handleOpenPopup: function handleOpenPopup() {
      this.init();
    },
    handleClosePopup: function handleClosePopup(e) {
      this.$emit('input', e);
      this.currentCom = null;
      this.currentSelectedValue = null;
      this.startText = '';
      this.endText = '';
    },
    handleSelect: function handleSelect(e, type) {
      if (type === void 0) {
        type = this.type;
      }

      this.$emit('select', e);
      this.currentSelectedValue = e;

      if (this.type === 'dateweekmonth') {
        this.dateweekmonthType = type;
      }

      if (type === 'week') {
        this.startText = e.year + "\u5E74 " + (e.num < 10 ? '0' + e.num : e.num) + "\u5468(" + e.week.startDayStr + "~" + e.week.endDayStr + ")";
      } else if (type === 'quarter') {
        this.startText = e.year + "\u5E74 " + e.cn;
      } else if (type === 'month' || type === 'date') {
        this.startText = e.str;
      } else if (type === 'monthrange' || type === 'daterange') {
        this.startText = e.str[0];
        this.endText = e.str[1];
      }
    },
    handleConfirm: function handleConfirm() {
      this.$emit('confirm', this.currentSelectedValue);
      this.handleClosePopup(false);
    }
  }
};
exports.default = _default;