ui库和web端产品库合并版本(还需修复细节)

This commit is contained in:
2022-11-29 18:27:14 +08:00
parent 5e4bd93238
commit 8bf6c57668
151 changed files with 28267 additions and 49 deletions

View File

@@ -0,0 +1,58 @@
<template>
<section class="AiNumber">
<el-input v-model="num" :size="size" @input.native="validate" @focus="$emit('focus')" @blur="format" clearable
@change="$emit('change')" :validate-event="isRule"></el-input>
</section>
</template>
<script>
export default {
name: "AiNumber",
model: {
prop: "value",
event: "change"
},
props: {
value: String,
size: String,
decimal: {type: [String, Number], default: 2},
isRule: {type: Boolean, default: true}
},
computed: {
validRegex() {
let dec = Number(this.decimal || 0),
regex = `^(\\d*\\.?\\d{0,${dec}}).*`
return new RegExp(regex)
}
},
data() {
return {
num: ""
}
},
methods: {
validate() {
let num = JSON.parse(JSON.stringify(this.num))
this.num = num.replace(this.validRegex, '$1')
},
format() {
this.num = Number(this.num||0).toString()
this.$emit("blur")
}
},
watch: {
num(v) {
this.$emit("change", v)
}
},
mounted() {
this.num = this.value
}
}
</script>
<style lang="scss" scoped>
.AiNumber {
}
</style>