import ksButton from '../button';
import { DateSelect, MonthSelect, WeekSelect } from './index';
import { typeToSelectotMap } from './utils';
import "./date-week-month.css";
import './date-week-month-sfc.css';

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c('div', {
    staticClass: "ks-date-week-month-picker"
  }, [_c('div', {
    staticClass: "ks-date-week-month-picker__header"
  }, [_c('div', {
    staticClass: "ks-date-week-month-picker__header-btn"
  }, [_c('ks-button', {
    class: {
      'ks-date-week-month-picker__header-btn__action': _vm.currentType === 'date'
    },
    attrs: {
      "round": ""
    },
    on: {
      "click": function click($event) {
        return _vm.handleChangeType('date');
      }
    }
  }, [_vm._v("\n        日期选择\n      ")])], 1), _vm._v(" "), _c('div', {
    staticClass: "ks-date-week-month-picker__header-btn"
  }, [_c('ks-button', {
    class: {
      'ks-date-week-month-picker__header-btn__action': _vm.currentType === 'week'
    },
    attrs: {
      "round": ""
    },
    on: {
      "click": function click($event) {
        return _vm.handleChangeType('week');
      }
    }
  }, [_vm._v("\n        周选择\n      ")])], 1), _vm._v(" "), _c('div', {
    staticClass: "ks-date-week-month-picker__header-btn"
  }, [_c('ks-button', {
    class: {
      'ks-date-week-month-picker__header-btn__action': _vm.currentType === 'month'
    },
    attrs: {
      "round": ""
    },
    on: {
      "click": function click($event) {
        return _vm.handleChangeType('month');
      }
    }
  }, [_vm._v("\n        月份选择\n      ")])], 1)]), _vm._v(" "), _c('div', {
    staticClass: "ks-date-week-month-picker__body"
  }, [_c(_vm.currentCom, _vm._b({
    ref: "com",
    tag: "component",
    on: {
      "select": _vm.handleSelect
    }
  }, 'component', _vm.$attrs, false))], 1)]);
};

var __vue_staticRenderFns__ = [];
export default {
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__,
  name: 'date-week-month',
  components: {
    ksButton: ksButton,
    DateSelect: DateSelect,
    MonthSelect: MonthSelect,
    WeekSelect: WeekSelect
  },
  data: function data() {
    return {
      currentType: 'date'
    };
  },
  computed: {
    currentCom: function currentCom() {
      return typeToSelectotMap[this.currentType];
    }
  },
  methods: {
    init: function init() {
      this.$refs.com.init();
    },
    handleChangeType: function handleChangeType(e) {
      var _this = this;

      this.currentType = e;
      this.$emit('change-type', e);
      this.$nextTick(function () {
        _this.init();
      });
    },
    handleSelect: function handleSelect(e) {
      this.$emit('select', e, this.currentType);
    }
  }
};