Blame view

src/components/date-picker/picker/date-picker.js 936 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
      created () {
531cd165   梁灏   support DatePicke...
26
          if (!this.currentValue) {
50637863   梁灏   update DatePicker
27
              if (this.type === 'daterange' || this.type === 'datetimerange') {
531cd165   梁灏   support DatePicke...
28
                  this.currentValue = ['',''];
50637863   梁灏   update DatePicker
29
              } else {
531cd165   梁灏   support DatePicke...
30
                  this.currentValue = '';
50637863   梁灏   update DatePicker
31
32
33
              }
          }
  
17e1fcf1   梁灏   init DatePicker
34
35
          this.panel = getPanel(this.type);
      }
b0893113   jingsam   :art: add eslint
36
  };