| 
									
										
										
										
											2018-12-18 18:51:25 +08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <li | 
					
						
							|  |  |  |     v-if="noTouch" | 
					
						
							|  |  |  |     :class="[active ? 'active' : '']" | 
					
						
							| 
									
										
										
										
											2020-07-24 14:47:21 +08:00
										 |  |  |     @click="$_onFocus($event, 'click')" | 
					
						
							| 
									
										
										
										
											2019-07-05 15:34:29 +08:00
										 |  |  |   > | 
					
						
							|  |  |  |     <span v-text="value"></span> | 
					
						
							|  |  |  |   </li> | 
					
						
							| 
									
										
										
										
											2018-12-18 18:51:25 +08:00
										 |  |  |   <li | 
					
						
							|  |  |  |     v-else | 
					
						
							|  |  |  |     :class="[active ? 'active' : '']" | 
					
						
							| 
									
										
										
										
											2020-07-24 14:47:21 +08:00
										 |  |  |     @touchstart="$_onFocus($event, 'touch')" | 
					
						
							| 
									
										
										
										
											2018-12-18 18:51:25 +08:00
										 |  |  |     @touchmove="$_onBlur" | 
					
						
							|  |  |  |     @touchend="$_onBlur" | 
					
						
							|  |  |  |     @touchcancel="$_onBlur" | 
					
						
							| 
									
										
										
										
											2020-07-24 14:47:21 +08:00
										 |  |  |     @click="$_onFocus($event, 'click')" | 
					
						
							| 
									
										
										
										
											2019-07-05 15:34:29 +08:00
										 |  |  |   > | 
					
						
							|  |  |  |     <span v-text="value"></span> | 
					
						
							|  |  |  |   </li> | 
					
						
							| 
									
										
										
										
											2018-12-18 18:51:25 +08:00
										 |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script>
export default { | 
					
						
							|  |  |  |   name: 'md-number-key', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   props: { | 
					
						
							|  |  |  |     value: { | 
					
						
							|  |  |  |       type: [String, Number], | 
					
						
							|  |  |  |       default: '', | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     noTouch: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: false, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2018-12-26 11:24:43 +08:00
										 |  |  |     noPrevent: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: false, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2018-12-18 18:51:25 +08:00
										 |  |  |   }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   data() { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       active: false, | 
					
						
							| 
									
										
										
										
											2020-07-24 14:47:21 +08:00
										 |  |  |       activeType: '', | 
					
						
							| 
									
										
										
										
											2018-12-18 18:51:25 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   methods: { | 
					
						
							| 
									
										
										
										
											2020-07-24 14:47:21 +08:00
										 |  |  |     $_onFocus(event, type) { | 
					
						
							| 
									
										
										
										
											2018-12-26 11:24:43 +08:00
										 |  |  |       if (!this.noPrevent) { | 
					
						
							|  |  |  |         event.preventDefault() | 
					
						
							|  |  |  |         event.stopImmediatePropagation() | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-07-24 14:47:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       if (this.activeType && this.activeType !== type) { | 
					
						
							|  |  |  |         return | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       this.activeType = type | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-18 18:51:25 +08:00
										 |  |  |       if (!this.noTouch) { | 
					
						
							|  |  |  |         this.active = true | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-07-24 14:47:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-18 18:51:25 +08:00
										 |  |  |       this.$emit('press', this.value) | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     $_onBlur() { | 
					
						
							|  |  |  |       this.active = false | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
</script> |