输入框最小最大值

This commit is contained in:
‘huanghaiixia’
2026-03-02 16:37:23 +08:00
parent 52704d9937
commit 0501b3babc
3 changed files with 20 additions and 3 deletions

View File

@ -54,6 +54,12 @@ export default {
type: Number, type: Number,
default: 2 default: 2
}, },
min: {
type: Number,
},
max: {
type: Number,
},
addonBefore: String, addonBefore: String,
addonAfter: String, addonAfter: String,
allowClear: Boolean, allowClear: Boolean,
@ -92,8 +98,15 @@ export default {
emit('focus', e); emit('focus', e);
}; };
const handleBlur = (e) => { const handleBlur = (e) => {
let val = e.target.value
if (props.min+''&& Number(e.target.value) < Number(props.min)) {
val = Number(props.min)
}
if (props.max+''&& Number(e.target.value) > Number(props.max)) {
val = Number(props.max)
}
model.value.focus = false; model.value.focus = false;
model.value.setViewValue(e.target.value); model.value.setViewValue(val);
emit('blur', e); emit('blur', e);
}; };
</script> </script>

View File

@ -100,3 +100,7 @@ span {
display: inline-flex; display: inline-flex;
} }
} }
.ant-input-affix-wrapper-disabled {
border-color: transparent !important;
border: 1px solid #fff !important;
}

View File

@ -76,7 +76,7 @@
</a-col> </a-col>
<a-col :span="8"> <a-col :span="8">
<a-form-item label="相对方数量" name="cpCount"> <a-form-item label="相对方数量" name="cpCount">
<input-number v-model:value="formState.cpCount" style="width: 100%" disabled :precision="0" /> <input-number v-model:value="formState.cpCount" style="width: 100%" :isSave="true"/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="8"> <a-col :span="8">
@ -91,7 +91,7 @@
<a-col :span="8"> <a-col :span="8">
<a-form-item label="合同金额(万元)" name="amount"> <a-form-item label="合同金额(万元)" name="amount">
<input-number v-model:value="formState.amount" style="width: 100%" <input-number v-model:value="formState.amount" style="width: 100%"
@blur="amountBlur(formState.amount)" :min="8" :disabled="isDisable" /> @blur="amountBlur(formState.amount)" :min="0" :disabled="isDisable" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="8"> <a-col :span="8">