This commit is contained in:
2022-12-30 16:13:19 +08:00
parent 379a852aee
commit c5d893ba35
43 changed files with 1468 additions and 1107 deletions

View File

@@ -87,7 +87,8 @@ const _sfc_main = defineComponent({
size: { default: "md" },
maxlength: null,
max: null,
min: null
min: null,
qfw: { type: Boolean, default: false }
},
emits: ["blur", "input", "update:modelValue", "change", "focus", "clear"],
setup(__props, { emit }) {
@@ -105,14 +106,20 @@ const _sfc_main = defineComponent({
type.value = props.type;
});
watch(() => props.modelValue, () => {
if (props.qfw && currentValue.value.indexOf(",") != -1) {
return;
}
currentValue.value = String(props.modelValue == null ? "" : props.modelValue);
});
const onInput = function(event) {
const inputElement = event.target;
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);
};
const onClear = () => {
@@ -120,11 +127,15 @@ const _sfc_main = defineComponent({
emit("clear");
};
const onFocus = (event) => {
currentValue.value = new String(props.modelValue).replace(/,/g, "");
emit("focus", event);
};
const onChange = (event) => {
const inputElement = event.target;
const value = inputElement.value;
let value = inputElement.value;
if (props.qfw) {
value = value.replace(/,/g, "");
}
emit("change", value);
};
const onBlur = (event) => {
@@ -143,6 +154,10 @@ const _sfc_main = defineComponent({
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);
};
const onCompositionstart = () => {