Commit 1325f428 authored by 李晓兵's avatar 李晓兵

'12-12uat'

parents 771d4be2 f0968541
Pipeline #4373 canceled with stages
/**
* @Author Sean
* @Date 2019/11/21
*/
<template>
<input
:value="formatValue" :readonly="disable" type="text"
@input="onInput($event.target.value)" @focus="onFocus" @blur="onBlur">
</template>
<script>
export default {
name: 'CurrencyInput',
props: {
value: {
default: 0,
},
disable: {
type: Boolean,
default: false,
},
},
data () {
return {
focused: false,
}
},
filter: {
uncurrency (val) {
if (!val) return null
return (Number((val).replace(/,/gi, ''))) === 0 ? null : Number((val).replace(/,/gi, ''))
},
},
computed: {
formatValue () {
let currency = this.$options.filters['currency']
if (!this.focused) {
return `¥${currency(this.value)}`
} else {
return this.value
}
},
},
methods: {
onInput: function (value) {
if (this.disable) return
let uncurrency = this.$options.filter['uncurrency']
this.currencyValue = uncurrency(value)
this.$emit('input', this.currencyValue)
},
onFocus (event) {
if (this.disable) return
this.focused = true
let value = event.target.value
event.target.value = ''
event.target.value = value
/* if (document.selection) {
var sel = value.createTextRange()
sel.moveStart('character', value.length)
sel.collapse()
sel.select()
} else if (typeof value.selectionStart === 'number' && typeof value.selectionEnd === 'number') {
value.selectionStart = value.selectionEnd = value.length
}*/
setTimeout(function () {
event.target.type = 'number'
event.target.focus()
}, 0)
},
onBlur (event) {
if (this.disable) return
event.target.type = 'text'
this.focused = false
},
},
}
</script>
<style scoped lang="less">
</style>
This diff is collapsed.
......@@ -474,7 +474,7 @@ export default {
window.localStorage.setItem('width', width)
window.localStorage.setItem('height', height)
vm.$router.push('/login')
location.reload()
// location.reload()
}
},
})
......
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