2023-12-18 16:30:33 +00:00
|
|
|
<template>
|
2024-01-31 06:45:51 +00:00
|
|
|
<u-input shape="circle" :placeholder="placeholder" :modelValue="value" :clearable="clearable"
|
2024-05-23 05:38:13 +00:00
|
|
|
:custom-style="inputStyle" :readonly="readonly" :type="type" :inputAlign="inputAlign"
|
2024-01-31 06:45:51 +00:00
|
|
|
:placeholder-style="`color: #999;${placeholderStyle};` " @change="handleChange"
|
2024-05-28 04:32:43 +00:00
|
|
|
:formatter="formatter" :disabled="disabled"
|
2024-01-31 06:45:51 +00:00
|
|
|
>
|
|
|
|
|
<template v-if="suffix" #suffix>
|
|
|
|
|
<text class="font-26 clr-sub pl-10">{{suffix}}</text>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
</u-input>
|
2023-12-18 16:30:33 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
2024-01-31 06:45:51 +00:00
|
|
|
computed: {
|
|
|
|
|
inputStyle(){
|
|
|
|
|
let sty1 = 'border:0;border-radius: 10rpx;background-color: #F6F6F6;padding: 11rpx 20rpx;'
|
|
|
|
|
this.isWhite && (sty1 += 'background-color: #fff;border: 1rpx solid #dadbde;')
|
|
|
|
|
return `${sty1};${this.customStyle};`
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-12-18 16:30:33 +00:00
|
|
|
props: {
|
2024-01-31 06:45:51 +00:00
|
|
|
isWhite: {
|
|
|
|
|
default () {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
suffix: {
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
clearable: {
|
|
|
|
|
default () {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-05-03 17:17:45 +00:00
|
|
|
type: {
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-03-04 11:09:51 +00:00
|
|
|
readonly: {
|
|
|
|
|
default () {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-12-18 16:30:33 +00:00
|
|
|
value: {
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-05-28 04:32:43 +00:00
|
|
|
disabled:{
|
|
|
|
|
default () {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-12-18 16:30:33 +00:00
|
|
|
placeholder:{
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-05-27 03:01:17 +00:00
|
|
|
_digit:{ // 保留小数位
|
|
|
|
|
},
|
2023-12-18 16:30:33 +00:00
|
|
|
customStyle:{
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
placeholderStyle:{
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-05-23 05:38:13 +00:00
|
|
|
inputAlign:{
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-12-18 16:30:33 +00:00
|
|
|
},
|
|
|
|
|
data() {
|
2023-12-30 15:28:01 +00:00
|
|
|
return {
|
|
|
|
|
|
|
|
|
|
}
|
2023-12-18 16:30:33 +00:00
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
},
|
2024-01-30 03:09:14 +00:00
|
|
|
unmounted() {},
|
2023-12-18 16:30:33 +00:00
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
handleChange(val){
|
|
|
|
|
this.$emit('change', val)
|
|
|
|
|
this.$emit('update:value', val)
|
2024-05-27 03:01:17 +00:00
|
|
|
},
|
|
|
|
|
formatter(val) {
|
|
|
|
|
if(this._digit) {
|
|
|
|
|
let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g')
|
|
|
|
|
let newVal = val.match(reg)[0]
|
|
|
|
|
return newVal
|
|
|
|
|
}
|
|
|
|
|
return val
|
2023-12-18 16:30:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
|
|
|
|
</style>
|