69 lines
1.1 KiB
Vue
69 lines
1.1 KiB
Vue
|
|
<!--
|
|
* @作者: 金鑫
|
|
* @时间: 2021-10-29 07:52:12
|
|
* @描述: 个位数输入框
|
|
-->
|
|
<template>
|
|
<div>
|
|
<el-input v-model="value" @change="downEnter" @input="getVal" :oninput="saleNum(value)" maxlength="1"></el-input>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'InputMini',
|
|
props: {
|
|
msg: String,
|
|
isClear: Boolean
|
|
},
|
|
data() {
|
|
return {
|
|
value: '0'
|
|
}
|
|
},
|
|
methods: {
|
|
getVal(val) {
|
|
this.value = val
|
|
},
|
|
downEnter(val) {
|
|
if (val == '') {
|
|
this.value = 0
|
|
}
|
|
this.$emit('insertNumber', this.value)
|
|
},
|
|
saleNum(val) {
|
|
if (val) {
|
|
if (val.length === 1) {
|
|
this.value = val.toString().replace(/\D/g, '0')
|
|
}
|
|
}
|
|
}
|
|
},
|
|
mounted() {
|
|
this.value = this.msg
|
|
},
|
|
watch: {
|
|
isClear: function (val) {
|
|
if (val) {
|
|
this.value = 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
::v-deep(.el-input) {
|
|
line-height: 28px;
|
|
}
|
|
::v-deep(.el-input__inner) {
|
|
padding: 0 5px !important;
|
|
height: 20px;
|
|
font-size: 12px;
|
|
line-height: 20px;
|
|
width: 28px;
|
|
text-align: center;
|
|
}
|
|
</style>
|