Commit a0b3ab93 by zhangquan

字段限制字数

1 parent 6dfbfaf2
<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
this.$emit('input', value)
}
}
}
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file \ No newline at end of file
...@@ -13,9 +13,11 @@ import glsxPreview from '@/components/preview/index.vue' ...@@ -13,9 +13,11 @@ import glsxPreview from '@/components/preview/index.vue'
import glsxCombiForm from '@/components/glsx-combi-form/index.vue' import glsxCombiForm from '@/components/glsx-combi-form/index.vue'
import bigView from '@/components/big-view/index.vue' import bigView from '@/components/big-view/index.vue'
import activityModel from '@/components/activity-model/index.vue' import activityModel from '@/components/activity-model/index.vue'
import FormatInput from '@/components/FormatInput/index.vue'
Vue.component('glsx-combi-form', glsxCombiForm) Vue.component('glsx-combi-form', glsxCombiForm)
Vue.component('glsx-dialog', glsxDialog) Vue.component('glsx-dialog', glsxDialog)
Vue.component('glsx-preview', glsxPreview) Vue.component('glsx-preview', glsxPreview)
Vue.component('big-view', bigView) Vue.component('big-view', bigView)
Vue.component('activity-model', activityModel) Vue.component('activity-model', activityModel)
Vue.component('format-input', FormatInput)
\ No newline at end of file \ No newline at end of file
...@@ -80,6 +80,8 @@ export default { ...@@ -80,6 +80,8 @@ export default {
{ {
label: '案例名称', label: '案例名称',
name: 'caseName', name: 'caseName',
maxlength: 20,
showLimit: true,
type: 'input', type: 'input',
isDisabled: false isDisabled: false
}, },
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</div> </div>
<div slot="secondCategorySlot" class="category-slot"> <div slot="secondCategorySlot" class="category-slot">
<div class="category-item" v-for="(item,index) in categoryList" :key="index"> <div class="category-item" v-for="(item,index) in categoryList" :key="index">
<el-input placeholder="请输入" maxLength="15" v-model="item.name" class="input"></el-input> <el-input placeholder="请输入" v-model="item.name" class="input" maxlength="20" show-word-limit></el-input>
<i v-if="categoryList.length>1" class="el-icon-delete del-icon" @click="delSecondCategory(index)"></i> <i v-if="categoryList.length>1" class="el-icon-delete del-icon" @click="delSecondCategory(index)"></i>
</div> </div>
<div v-if="!routeInfo.id" class="add-btn" @click="addCategory()"> <div v-if="!routeInfo.id" class="add-btn" @click="addCategory()">
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<i class="el-icon-close del-icon" @click.stop="delNav(item)"></i> <i class="el-icon-close del-icon" @click.stop="delNav(item)"></i>
</div> </div>
</div> </div>
<div v-if="showInput" class="input-area"><el-input maxLength="15" ref="addInput" @blur="inputBlur" v-model="addValue" class="input"></el-input></div> <div v-if="showInput" class="input-area"><el-input maxlength="20" show-word-limit ref="addInput" @blur="inputBlur" v-model="addValue" class="input"></el-input></div>
<div v-else class="nav-item add-icon" style="cursor: pointer;" @click="addNav"><i class="el-icon-plus border"></i></div> <div v-else class="nav-item add-icon" style="cursor: pointer;" @click="addNav"><i class="el-icon-plus border"></i></div>
<div v-if="colList && colList.length" class="nav-item pull-btn" style="cursor: pointer;"> <div v-if="colList && colList.length" class="nav-item pull-btn" style="cursor: pointer;">
<i class="el-icon-arrow-down border"></i> <i class="el-icon-arrow-down border"></i>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<div class="menu-dialog-body"> <div class="menu-dialog-body">
<el-form ref="menuRef" label-width="154px" :rules="navRules" :model="navForm"> <el-form ref="menuRef" label-width="154px" :rules="navRules" :model="navForm">
<el-form-item label="名称:" prop="name" class="m-t-20"> <el-form-item label="名称:" prop="name" class="m-t-20">
<el-input style="width: 284px;" :size="size" type="text" v-model="navForm.name" placeholder="请输入"></el-input> <el-input maxlength="20" show-word-limit style="width: 284px;" :size="size" type="text" v-model="navForm.name" placeholder="请输入"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
<div class="channel-content gl-form-page"> <div class="channel-content gl-form-page">
<el-form ref="ruleForm1" :model="channelForm" label-width="154px" size="small" :rules="rules"> <el-form ref="ruleForm1" :model="channelForm" label-width="154px" size="small" :rules="rules">
<el-form-item label="频道名称:" prop="channelName"> <el-form-item label="频道名称:" prop="channelName">
<el-input v-model="channelForm.channelName"></el-input> <el-input v-model="channelForm.channelName" maxlength="20" show-word-limit></el-input>
</el-form-item> </el-form-item>
<el-form-item label="频道子名称:" prop="channelChildName"> <el-form-item label="频道子名称:" prop="channelChildName">
<el-input v-model="channelForm.channelChildName"></el-input> <el-input v-model="channelForm.channelChildName" maxlength="20" show-word-limit></el-input>
</el-form-item> </el-form-item>
<span v-if="channelForm.channelType == 1"> <span v-if="channelForm.channelType == 1">
<el-form-item label="频道主题:" prop="channelStyle"> <el-form-item label="频道主题:" prop="channelStyle">
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<div class="money-wrap" v-if="formObj.paymentType == 2"> <div class="money-wrap" v-if="formObj.paymentType == 2">
<label class="label" for="">定金金额/元:</label> <label class="label" for="">定金金额/元:</label>
<el-input :disabled="disabled" v-model="formObj.depositPrice"></el-input> <el-input :disabled="disabled" v-model="formObj.depositPrice"></el-input>
<format-input :disabled="disabled" :intDigit="4" :precise="2" v-model="formObj.depositPrice"></format-input>
</div> </div>
</div> </div>
<div slot="saleStoreSlot"> <div slot="saleStoreSlot">
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
<template v-if="merchantRequestList && merchantRequestList.length"> <template v-if="merchantRequestList && merchantRequestList.length">
<GLTable class="selected-table" :hasPage="false" ref="selectedRef" :tableParams="selectedtableParams" :tableData="merchantRequestList"> <GLTable class="selected-table" :hasPage="false" ref="selectedRef" :tableParams="selectedtableParams" :tableData="merchantRequestList">
<div slot="activityPriceSlot" slot-scope="scope"> <div slot="activityPriceSlot" slot-scope="scope">
<el-input :disabled="disabled" placeholder="请输入" v-model="scope.scope.activityPrice" /> <format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入" v-model="scope.scope.activityPrice"></format-input>
</div> </div>
<div slot="retainagePriceSlot" slot-scope="scope"> <div slot="retainagePriceSlot" slot-scope="scope">
{{ retainagePriceFn(scope.scope.activityPrice) }} {{ retainagePriceFn(scope.scope.activityPrice) }}
...@@ -105,6 +106,8 @@ export default { ...@@ -105,6 +106,8 @@ export default {
{ {
label: '商品名称', label: '商品名称',
name: 'goodsName', name: 'goodsName',
maxlength: 20,
showLimit: true,
type: 'input', type: 'input',
isDisabled: false isDisabled: false
}, },
...@@ -283,6 +286,7 @@ export default { ...@@ -283,6 +286,7 @@ export default {
methods:{ methods:{
retainagePriceFn(price){ retainagePriceFn(price){
let depositPrice = this.formObj.paymentType==1 ? 0 : this.formObj.depositPrice let depositPrice = this.formObj.paymentType==1 ? 0 : this.formObj.depositPrice
if(this.formObj.paymentType==1) return '--'
if(!price){ if(!price){
return '待计算' return '待计算'
}else{ }else{
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!