Blame view

src/components/date-picker/picker/date-picker.js 915 Bytes
17e1fcf1   梁灏   init DatePicker
1
2
3
4
5
6
7
8
9
10
11
  import Picker from '../picker.vue';
  import DatePanel from '../panel/date.vue';
  import DateRangePanel from '../panel/date-range.vue';
  
  const getPanel = function (type) {
      if (type === 'daterange' || type === 'datetimerange') {
          return DateRangePanel;
      }
      return DatePanel;
  };
  
0f677893   梁灏   update DatePicker
12
13
  import { oneOf } from '../../../utils/assist';
  
17e1fcf1   梁灏   init DatePicker
14
15
16
17
  export default {
      mixins: [Picker],
      props: {
          type: {
0f677893   梁灏   update DatePicker
18
              validator (value) {
e0cd7f90   梁灏   fixed #134
19
                  return oneOf(value, ['year', 'month', 'date', 'daterange', 'datetime', 'datetimerange']);
0f677893   梁灏   update DatePicker
20
              },
17e1fcf1   梁灏   init DatePicker
21
              default: 'date'
50637863   梁灏   update DatePicker
22
          },
c46f385a   梁灏   update DatePicker
23
          value: {}
17e1fcf1   梁灏   init DatePicker
24
      },
50637863   梁灏   update DatePicker
25
26
27
28
29
30
31
32
33
      created () {
          if (!this.value) {
              if (this.type === 'daterange' || this.type === 'datetimerange') {
                  this.value = ['',''];
              } else {
                  this.value = '';
              }
          }
  
17e1fcf1   梁灏   init DatePicker
34
35
          this.panel = getPanel(this.type);
      }
b0893113   jingsam   :art: add eslint
36
  };