Commit 32a623fb authored by YangAo's avatar YangAo 🇨🇳

千分位 组件 初步完成

parent cd5b9eeb
......@@ -195,3 +195,7 @@ export function includePermission(accessName) {
if (!store.getters.permissions) { return false }
return (store.getters.permissions.includes(accessName) || store.getters.permissions.includes('*:*:*'))
}
export function stringIsEmpty(str) {
return str === undefined || str === null || str === '' || str === 'undefined' || str === 'null'
}
......@@ -8,6 +8,8 @@
</template>
<script>
import { stringIsEmpty } from '@/utils/common'
export default {
name: 'YaInputDigit',
// inheritAttrs: false,
......@@ -46,6 +48,22 @@ export default {
valueFloat: 0.00
}
},
watch: {
digit(newDigit) {
// 新数据与旧数据 相同 不进行处理
if (newDigit === this.valueFloat) return
// 数据不同 进行额外处理 并更新输入框值
console.log(`newDigit ->`, newDigit)
const { value, valueFloat } = this.input({ target: { value: newDigit.toString() }})
this.valueFloat = valueFloat
this.value = value
}
},
created() {
const { value, valueFloat } = this.input({ target: { value: this.digit.toString() }})
this.valueFloat = valueFloat
this.value = value
},
methods: {
// 输入时 数字保证操作, 长度操作
digitOption(str) {
......@@ -106,10 +124,15 @@ export default {
// 重置对应值
this.value = target.value
// 数字反值
this.valueFloat = Number.parseFloat(option)
this.valueFloat = stringIsEmpty(this.value) || Number.isNaN(option) ? 0 : Number.parseFloat(option)
this.$emit('input', this.valueFloat)
return {
value: this.value,
valueFloat: this.valueFloat
}
}
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment