Skip to content

Commit

Permalink
dFed: fix the bug that input form does not support scientific counting
Browse files Browse the repository at this point in the history
  • Loading branch information
Diorzz committed Dec 13, 2020
1 parent 78ab633 commit 25055a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/common/components/input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:type="type"
:placeholder="placeholder"
:class="className"
ref="input"
@focus="handleFocus"
@blur="handleBlur"
/>
Expand Down Expand Up @@ -45,7 +46,12 @@ export default class FeInput extends Vue{
@Watch('val')
valChange(nval){
this.$emit('input',nval)
console.log(nval)
if(/e/g.test(nval)){
this.$message.error('Scientific notation is not supported. Please use plain numbers.')
}else{
this.$emit('input',nval)
}
}
@Watch('value')
Expand All @@ -67,10 +73,10 @@ export default class FeInput extends Vue{
const val = this.val === '' ? this.val : Number(this.val);
if(this.isRequire && val === ''){
this.val = this.defaultValue || this.min
}else if(val < 0){
this.val = Math.abs(this.val)
}else if(val < this.min){
this.val = this.defaultValue || this.min
}else if(val < 0){
this.val = Math.abs(this.val)
}else if(val > this.max){
this.val = this.defaultValue || this.max
}
Expand Down
5 changes: 4 additions & 1 deletion src/views/components/function-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
type="number"
class-name="flex-1"
min=""
:max="Number(formData.balance)"
:max="maxDisabled ? null : Number(formData.balance)"
:placeholder="inputPlaceholder"
@inputFocus="inputFocus"
/>
Expand Down Expand Up @@ -54,6 +54,9 @@ export default class FunctionForm extends Vue{
@Prop({default:''})
disabledAddress
@Prop({default:false})
maxDisabled
@Prop({default:'0.0'})
inputPlaceholder
Expand Down

0 comments on commit 25055a3

Please sign in to comment.