Commit 1fcf7f8d by 杨北旺

修改输入框

1 parent e793f7b6
<template>
<el-input :value="value" v-bind="$attrs" v-on="{...$listeners}" @blur="blurFn"></el-input>
</template>
<script>
export default {
name: 'FormatInput',
props: ['value','precise','intDigit','maxVal','minVal'],
data() {
return {
}
},
watch:{
value:{
handler(nVal, oVal){
this.inputFn(nVal)
},
deep: true
}
},
mounted(){
},
methods:{
inputFn(e){
e = e ? String(e) : ''
this.intDigit = this.intDigit || 6
this.precise = this.precise || 2
let value = e
if(this.maxVal){
if(+this.maxVal<= +e) value = this.maxVal //加等号是因为 '500' == '500.' 导致多了点
}else{
const intDigitReg = this.intDigit == -1 ? `(^\\d+)(\\.\\d+)?` : `(^\\d{${this.intDigit}})\\d+(\\.\\d+)?`
value = e.replace(/^0\d/g, '0').replace(/[^\d.]/g, '').replace(/^\./g, '').replace(new RegExp(intDigitReg,'g'), '$1').replace('.', '$#$')
.replace(/\./g, '').replace('$#$', '.').replace(new RegExp(`^(-)*(\\d+)\\.(\\d{${this.precise}}).*$`), this.intDigit == -1 ? '$1$2' : '$1$2.$3')
}
this.$emit('input', value)
},
blurFn(e){
let value = e.target.value
if(this.minVal && +this.minVal>=value) value = this.minVal+''
if(value && value.charAt(value.length-1)=='.') value = value.substr(0 ,value.length-1)
this.$emit('input', value)
}
}
}
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file
......@@ -141,7 +141,8 @@
</div>
<div class="arrt_pannel">
<template v-if="attr.attributeType == 'input'">
<el-input class="arrt_pannel" :disabled="disabled || attr.disabled || (attr.attributeName == 'compensation_name' && compensationNameDisable)" @input="getCurChangeInput($event, item, attr, index, attrindex, 2)" v-model="productModal[item.idName][attr.attributeName]" size="small" :maxlength="attr.maxLength" clearable :placeholder="'请输入' + attr.attributeDesc"></el-input>
<FormatInput v-if="limitAttrName.includes(attr.attributeName)" class="arrt_pannel" :disabled="disabled || attr.disabled || (attr.attributeName == 'compensation_name' && compensationNameDisable)" @input="getCurChangeInput($event, item, attr, index, attrindex, 2)" v-model="productModal[item.idName][attr.attributeName]" size="small" :maxlength="attr.maxLength" clearable :placeholder="'请输入' + attr.attributeDesc" precise="2" intDigit="10"></FormatInput>
<el-input v-else class="arrt_pannel" :disabled="disabled || attr.disabled || (attr.attributeName == 'compensation_name' && compensationNameDisable)" @input="getCurChangeInput($event, item, attr, index, attrindex, 2)" v-model="productModal[item.idName][attr.attributeName]" size="small" :maxlength="attr.maxLength" clearable :placeholder="'请输入' + attr.attributeDesc"></el-input>
</template>
<template v-if="attr.attributeType == 'select'">
<el-select :allow-create="attr.attributeName == 'gearbox'" :remote="attr.attributeName == 'gearbox'" :filterable="attr.attributeName == 'gearbox'" class="arrt_pannel" :disabled="disabled || attr.disabled" size="small" @change="getCurChangeSelect($event, item, attr)" v-model="productModal[item.idName][attr.attributeName]" clearable :placeholder="'请选择' + attr.attributeDesc">
......@@ -209,6 +210,7 @@ import qrCode from '@/components/qr-code'
import { fetchConfig } from '@/config'
import utils from '../../util/util'
import uploadInfo from './uploadInfo.vue'
import FormatInput from '@/components/FormatInput'
export default {
name: 'editEquity',
data() {
......@@ -730,7 +732,8 @@ export default {
value: '0',
label: '营运'
}
]
],
limitAttrName: ['warranty_km', 'vehicle_displacement', 'mileage', 'warranty_period']
}
},
......@@ -755,7 +758,8 @@ export default {
components: {
glsxCombiForm,
qrCode,
uploadInfo
uploadInfo,
FormatInput
},
async created() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!