Blame view

src/components/date-picker/picker/time-picker.js 1.09 KB
9b376832   Sergio Crisostomo   Add feature: allo...
1
  import Vue from 'vue';
9d844d53   梁灏   fixed Layout bug
2
3
  import Picker from '../picker.vue';
  import TimePanel from '../panel/time.vue';
456877a1   梁灏   update TimePicker
4
  import TimeRangePanel from '../panel/time-range.vue';
c1abaed9   梁灏   update TimePicker
5
  import Options from '../time-mixins';
9d844d53   梁灏   fixed Layout bug
6
  
456877a1   梁灏   update TimePicker
7
8
9
10
11
12
13
14
15
  const getPanel = function (type) {
      if (type === 'timerange') {
          return TimeRangePanel;
      }
      return TimePanel;
  };
  
  import { oneOf } from '../../../utils/assist';
  
9d844d53   梁灏   fixed Layout bug
16
  export default {
c1abaed9   梁灏   update TimePicker
17
      mixins: [Picker, Options],
9d844d53   梁灏   fixed Layout bug
18
      props: {
456877a1   梁灏   update TimePicker
19
20
21
22
23
24
          type: {
              validator (value) {
                  return oneOf(value, ['time', 'timerange']);
              },
              default: 'time'
          },
9b376832   Sergio Crisostomo   Add feature: allo...
25
26
27
28
          steps: {
              type: Array,
              default: () => []
          },
c1abaed9   梁灏   update TimePicker
29
          value: {}
9d844d53   梁灏   fixed Layout bug
30
      },
9d844d53   梁灏   fixed Layout bug
31
      created () {
531cd165   梁灏   support DatePicke...
32
          if (!this.currentValue) {
456877a1   梁灏   update TimePicker
33
              if (this.type === 'timerange') {
531cd165   梁灏   support DatePicke...
34
                  this.currentValue = ['',''];
456877a1   梁灏   update TimePicker
35
              } else {
531cd165   梁灏   support DatePicke...
36
                  this.currentValue = '';
456877a1   梁灏   update TimePicker
37
38
              }
          }
9b376832   Sergio Crisostomo   Add feature: allo...
39
40
41
42
43
44
          const Panel = Vue.extend(getPanel(this.type));
          this.Panel = new Panel({
              propsData: {
                  steps: this.steps
              }
          });
9d844d53   梁灏   fixed Layout bug
45
      }
9b376832   Sergio Crisostomo   Add feature: allo...
46
  };