loading
This commit is contained in:
@@ -29,6 +29,7 @@ export interface InputProps {
|
||||
maxlength?: number;
|
||||
max?: number;
|
||||
min?: number;
|
||||
qfw?:boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<InputProps>(), {
|
||||
@@ -39,6 +40,7 @@ const props = withDefaults(defineProps<InputProps>(), {
|
||||
password: false,
|
||||
modelValue: "",
|
||||
size: "md",
|
||||
qfw: false
|
||||
});
|
||||
|
||||
interface InputEmits {
|
||||
@@ -71,6 +73,9 @@ watch(
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
() => {
|
||||
if(props.qfw && currentValue.value.indexOf(",") != -1){
|
||||
return
|
||||
}
|
||||
currentValue.value = String(
|
||||
props.modelValue == null ? "" : props.modelValue
|
||||
);
|
||||
@@ -79,9 +84,12 @@ watch(
|
||||
|
||||
const onInput = function (event: Event) {
|
||||
const inputElement = event.target as HTMLInputElement;
|
||||
const value = inputElement.value;
|
||||
let value = inputElement.value;
|
||||
emit("input", value);
|
||||
if (composing.value) return;
|
||||
if(props.qfw){
|
||||
value = value.replace(/,/g,"")
|
||||
}
|
||||
emit("update:modelValue", value);
|
||||
};
|
||||
|
||||
@@ -91,12 +99,16 @@ const onClear = () => {
|
||||
};
|
||||
|
||||
const onFocus = (event: Event) => {
|
||||
currentValue.value = new String(props.modelValue).replace(/,/g,"")
|
||||
emit("focus", event);
|
||||
};
|
||||
|
||||
const onChange = (event: Event) => {
|
||||
const inputElement = event.target as HTMLInputElement;
|
||||
const value = inputElement.value;
|
||||
let value = inputElement.value;
|
||||
if(props.qfw){
|
||||
value = value.replace(/,/g,"")
|
||||
}
|
||||
emit("change", value);
|
||||
};
|
||||
|
||||
@@ -115,6 +127,10 @@ const onNumberBlur = (event: Event) => {
|
||||
if (props.max && props.max < Number(value)) value = props.max.toString();
|
||||
if (props.min && props.min > Number(value)) value = props.min.toString();
|
||||
}
|
||||
if(props.qfw){
|
||||
value = value.replace(/,/g,"")
|
||||
}
|
||||
currentValue.value = new String(props.modelValue).toLocaleString()
|
||||
emit("update:modelValue", value);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user