输入框最小最大值

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,
default: 2
},
min: {
type: Number,
},
max: {
type: Number,
},
addonBefore: String,
addonAfter: String,
allowClear: Boolean,
@ -92,8 +98,15 @@ export default {
emit('focus', 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.setViewValue(e.target.value);
model.value.setViewValue(val);
emit('blur', e);
};
</script>

View File

@ -99,4 +99,8 @@ span {
justify-content: flex-start;
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 :span="8">
<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-col>
<a-col :span="8">
@ -91,7 +91,7 @@
<a-col :span="8">
<a-form-item label="合同金额(万元)" name="amount">
<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-col>
<a-col :span="8">