|
|
@ -1,7 +1,7 @@ |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<q-input |
|
|
|
v-show="!hideIfComputed" |
|
|
|
v-show="showIfComputed" |
|
|
|
ref="numberRef" |
|
|
|
:hide-bottom-space="true" |
|
|
|
:hide-hint="true" |
|
|
@ -28,10 +28,10 @@ const attrs = useAttrs(); |
|
|
|
const inRules = attrs.rules; |
|
|
|
const props = defineProps({ |
|
|
|
precision: { type: Number, default: 0 }, |
|
|
|
hideIf: { |
|
|
|
showIf: { |
|
|
|
type: Function, |
|
|
|
default: () => { |
|
|
|
return false; |
|
|
|
return true; |
|
|
|
}, |
|
|
|
}, |
|
|
|
required: { |
|
|
@ -63,9 +63,9 @@ const props = defineProps({ |
|
|
|
const rulesComputed = computed(() => { |
|
|
|
let rules = inRules || <any>[]; |
|
|
|
rules.push(FormValidators.maxPrecision(props.precision)); |
|
|
|
if (!hideIfComputed.value && requiredIfComputed.value) { |
|
|
|
if (showIfComputed.value && requiredIfComputed.value) { |
|
|
|
rules.push(FormValidators.required()); |
|
|
|
} else if (hideIfComputed.value) { |
|
|
|
} else if (!showIfComputed.value) { |
|
|
|
rules = []; |
|
|
|
} |
|
|
|
if (numberRef?.value) { |
|
|
@ -74,8 +74,8 @@ const rulesComputed = computed(() => { |
|
|
|
return rules; |
|
|
|
}); |
|
|
|
|
|
|
|
const hideIfComputed = computed(() => { |
|
|
|
return props.hideIf(props.form); |
|
|
|
const showIfComputed = computed(() => { |
|
|
|
return props.showIf(props.form); |
|
|
|
}); |
|
|
|
const requiredIfComputed = computed(() => { |
|
|
|
if (props.requiredIf) { |
|
|
|