Blame view

src/components/date-picker/base/time-spinner.vue 4.25 KB
9d844d53   梁灏   fixed Layout bug
1
2
3
4
  <template>
      <div :class="classes">
          <div :class="[prefixCls+ '-wrapper']">
              <ul :class="[prefixCls + '-list']">
36628aca   梁灏   update TimePicker
5
                  <li :class="getCellCls(item)" v-for="item in hoursList" v-show="!item.hide">{{ item.text }}</li>
9d844d53   梁灏   fixed Layout bug
6
7
8
              </ul>
          </div>
          <div :class="[prefixCls+ '-wrapper']">
36628aca   梁灏   update TimePicker
9
10
11
              <ul :class="[prefixCls + '-list']">
                  <li :class="getCellCls(item)" v-for="item in minutesList" v-show="!item.hide">{{ item.text }}</li>
              </ul>
9d844d53   梁灏   fixed Layout bug
12
13
          </div>
          <div :class="[prefixCls+ '-wrapper']" v-show="showSeconds">
36628aca   梁灏   update TimePicker
14
15
16
              <ul :class="[prefixCls + '-list']">
                  <li :class="getCellCls(item)" v-for="item in secondsList" v-show="!item.hide">{{ item.text }}</li>
              </ul>
9d844d53   梁灏   fixed Layout bug
17
18
19
20
          </div>
      </div>
  </template>
  <script>
36628aca   梁灏   update TimePicker
21
22
23
      import Options from '../time-mixins';
      import { deepCopy } from '../../../utils/assist';
  
9d844d53   梁灏   fixed Layout bug
24
25
26
      const prefixCls = 'ivu-time-picker-cells';
  
      export default {
36628aca   梁灏   update TimePicker
27
          mixins: [Options],
9d844d53   梁灏   fixed Layout bug
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
          props: {
              hours: {
                  type: Number,
                  default: 0
              },
              minutes: {
                  type: Number,
                  default: 0
              },
              seconds: {
                  type: Number,
                  default: 0
              },
              showSeconds: {
                  type: Boolean,
                  default: true
              }
          },
          data () {
              return {
                  prefixCls: prefixCls
              };
          },
          computed: {
              classes () {
                  return [
                      `${prefixCls}`,
                      {
                          [`${prefixCls}-with-seconds`]: this.showSeconds
                      }
                  ];
              },
              hoursList () {
36628aca   梁灏   update TimePicker
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
                  let hours = [];
                  const hour_tmpl = {
                      text: '',
                      selected: false,
                      disabled: false,
                      hide: false
                  };
  
                  for (let i = 0; i < 24; i++) {
                      const hour = deepCopy(hour_tmpl);
                      hour.text = i;
  
                      if (this.disabledHours && this.disabledHours.indexOf(i) > -1) {
                          hour.disabled = true;
                          if (this.hideDisabledOptions) hour.hide = true;
                      }
                      hours.push(hour);
                  }
  
                  return hours;
9d844d53   梁灏   fixed Layout bug
81
82
              },
              minutesList () {
36628aca   梁灏   update TimePicker
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
                  let minutes = [];
                  const minute_tmpl = {
                      text: '',
                      selected: false,
                      disabled: false,
                      hide: false
                  };
  
                  for (let i = 0; i < 60; i++) {
                      const minute = deepCopy(minute_tmpl);
                      minute.text = i;
  
                      if (this.disabledMinutes && this.disabledMinutes.indexOf(i) > -1) {
                          minute.disabled = true;
                          if (this.hideDisabledOptions) minute.hide = true;
                      }
                      minutes.push(minute);
                  }
  
                  return minutes;
9d844d53   梁灏   fixed Layout bug
103
104
              },
              secondsList () {
36628aca   梁灏   update TimePicker
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
                  let seconds = [];
                  const second_tmpl = {
                      text: '',
                      selected: false,
                      disabled: false,
                      hide: false
                  };
  
                  for (let i = 0; i < 60; i++) {
                      const second = deepCopy(second_tmpl);
                      second.text = i;
  
                      if (this.disabledSeconds && this.disabledSeconds.indexOf(i) > -1) {
                          second.disabled = true;
                          if (this.hideDisabledOptions) second.hide = true;
                      }
                      seconds.push(second);
                  }
  
                  return seconds;
9d844d53   梁灏   fixed Layout bug
125
126
127
              }
          },
          methods: {
36628aca   梁灏   update TimePicker
128
129
130
131
132
133
134
135
136
              getCellCls (cell) {
                  return [
                      `${prefixCls}-cell`,
                      {
                          [`${prefixCls}-cell-selected`]: cell.selected,
                          [`${prefixCls}-cell-disabled`]: cell.disabled
                      }
                  ];
              }
9d844d53   梁灏   fixed Layout bug
137
138
139
          }
      };
  </script>