mirror of https://github.com/ElemeFE/element
				
				
				
			Merge pull request #608 from QingWei-Li/fix/date-picker
DatePicker: fix trigger multiple watch, fixed #597pull/610/head
						commit
						4eb5cf350f
					
				| 
						 | 
				
			
			@ -1 +1 @@
 | 
			
		|||
*.js linguist-language=Vue
 | 
			
		||||
test/**/*.js linguist-language=Vue
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,7 +47,7 @@
 | 
			
		|||
  </table>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script type="text/ecmascript-6">
 | 
			
		||||
<script type="text/babel">
 | 
			
		||||
  import { $t } from '../util';
 | 
			
		||||
 | 
			
		||||
  export default {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,7 +78,6 @@
 | 
			
		|||
          this.hoursPrivate = oldVal;
 | 
			
		||||
        }
 | 
			
		||||
        this.$refs.hour.scrollTop = Math.max(0, (this.hoursPrivate - 2.5) * 32 + 80);
 | 
			
		||||
 | 
			
		||||
        this.$emit('change', { hours: newVal });
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -400,6 +400,9 @@
 | 
			
		|||
      },
 | 
			
		||||
 | 
			
		||||
      handleRangePick(val, close = true) {
 | 
			
		||||
        if (this.maxDate === val.maxDate && this.minDate === val.minDate) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
        this.maxDate = val.maxDate;
 | 
			
		||||
        this.minDate = val.minDate;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -260,8 +260,8 @@
 | 
			
		|||
        } else {
 | 
			
		||||
          this.date.setMonth(month);
 | 
			
		||||
          this.resetDate();
 | 
			
		||||
          this.value = new Date(this.date.getFullYear(), month, 1);
 | 
			
		||||
          this.$emit('pick', this.value);
 | 
			
		||||
          const value = new Date(this.date.getFullYear(), month, 1);
 | 
			
		||||
          this.$emit('pick', value);
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -87,6 +87,9 @@
 | 
			
		|||
    watch: {
 | 
			
		||||
      value(val) {
 | 
			
		||||
        const time = clacTime(val);
 | 
			
		||||
        if (time.minTime === this.minTime && time.maxTime === this.maxTime) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.handleMinChange({
 | 
			
		||||
          hours: time.minTime.getHours(),
 | 
			
		||||
| 
						 | 
				
			
			@ -183,6 +186,7 @@
 | 
			
		|||
        this.minTime = limitRange(this.minTime, minSelectableRange);
 | 
			
		||||
        this.maxTime = limitRange(this.maxTime, maxSelectableRange);
 | 
			
		||||
 | 
			
		||||
        if (first) return;
 | 
			
		||||
        this.$emit('pick', [this.minTime, this.maxTime], visible, first);
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,14 +72,6 @@
 | 
			
		|||
        if (this.value && val && compareTime(this.value, val) === -1) {
 | 
			
		||||
          this.$emit('pick');
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      value(val, old) {
 | 
			
		||||
        if (val && this.items.some(i => i.value === val && !i.disabled)) {
 | 
			
		||||
          this.$emit('pick', val, true);
 | 
			
		||||
        } else {
 | 
			
		||||
          this.$emit('pick', old, true);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -129,6 +129,7 @@
 | 
			
		|||
      },
 | 
			
		||||
 | 
			
		||||
      handleConfirm(visible = false, first) {
 | 
			
		||||
        if (first) return;
 | 
			
		||||
        const date = new Date(limitRange(this.currentDate, this.selectableRange));
 | 
			
		||||
        this.$emit('pick', date, visible, first);
 | 
			
		||||
      },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,7 +46,6 @@ const newPopper = {
 | 
			
		|||
  beforeDestroy: Popper.beforeDestroy
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// const FUNCTION_KEYS = [13, 16, 17, 18, 19, 20, 27, 33, 34, 35, 36, 37, 38, 39, 40];
 | 
			
		||||
const RANGE_SEPARATOR = ' - ';
 | 
			
		||||
const DEFAULT_FORMATS = {
 | 
			
		||||
  date: 'yyyy-MM-dd',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue