Component({
  props: {
    timeShow: false,
    onCancel: () => null,
    onConfirm: () => null,
    onReset: () => null
  },
  data: {
    maxDate: '',
    minDate: ''
  },

  didMount() {
    const nowDate = new Date();
    const startTime = new Date(nowDate.getFullYear() - 1, 1, 1);
    const endTime = new Date(nowDate.getFullYear() + 1, 11, 31);
    this.setData({
      minDate: startTime,
      maxDate: endTime
    });
  },

  methods: {
    onOperateTime(event) {
      const operate = {
        cancel: () => this.props.onCancel(),
        rest: () => this.props.onReset()
      };
      return operate[event.type]();
    },

    onConfirmTime(tempDate) {
      const date = tempDate.map(item => item.replace(' :', ''));
      this.props.onConfirm(date);
      this.props.onCancel();
    }

  }
});