|
@ -1,40 +1,84 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div v-show="fieldMethodsClass.getShow(props, modelValue)"> |
|
|
<div v-show="fieldMethodsClass.getShow(props, modelValue)"> |
|
|
<q-input |
|
|
<template v-if="props.displayMode === 'dual'"> |
|
|
ref="dateRangeRef" |
|
|
<w-form |
|
|
v-model="displayValueComputed" |
|
|
ref="dateRangeRef" |
|
|
:hide-bottom-space="true" |
|
|
v-model="modelValue" |
|
|
:hide-hint="true" |
|
|
:cols-num="2" |
|
|
:outlined="true" |
|
|
:fields="[ |
|
|
:dense="true" |
|
|
{ |
|
|
v-bind="attrs" |
|
|
label: attrs.label + '(起)', |
|
|
:clearable="false" |
|
|
name: 'from', |
|
|
:rules="fieldMethodsClass.getRules(props, modelValue, dateRangeRef, undefined)" |
|
|
type: 'w-date', |
|
|
:readonly="fieldMethodsClass.getReadOnly(props, modelValue)" |
|
|
autoClose: false, |
|
|
:disable="fieldMethodsClass.getDisable(props, modelValue)" |
|
|
options: (date) => { |
|
|
@update:model-value="fieldMethodsClass.updateValue" |
|
|
if (dateRangeRef) { |
|
|
@focus=" |
|
|
const toValue = dateRangeRef.getFieldValue('to'); |
|
|
() => { |
|
|
if (!Tools.isEmpty(toValue)) { |
|
|
dateRangeRef?.blur(); |
|
|
return date < toValue.replace(/-/g, '/'); |
|
|
} |
|
|
} |
|
|
" |
|
|
return true; |
|
|
> |
|
|
} |
|
|
<template #label> |
|
|
return true; |
|
|
<w-label :required="fieldMethodsClass.getRequired(props, modelValue)" :label="attrs.label"></w-label> |
|
|
}, |
|
|
</template> |
|
|
}, |
|
|
<template v-if="!fieldMethodsClass.getReadOnly(props, modelValue)" #append> |
|
|
{ |
|
|
<q-btn v-if="!Tools.isEmpty(displayValueComputed)" flat square unelevated dense icon="cancel" @click="fieldMethodsClass.clearValue"></q-btn> |
|
|
label: attrs.label + '(止)', |
|
|
<q-icon name="event" class="cursor-pointer"> |
|
|
name: 'to', |
|
|
<q-popup-proxy cover transition-show="scale" transition-hide="scale"> |
|
|
type: 'w-date', |
|
|
<q-date v-model="modelValue" today-btn mask="YYYY-MM-DD" :range="true" @update:model-value="fieldMethodsClass.updateValue"> </q-date> |
|
|
autoClose: false, |
|
|
</q-popup-proxy> |
|
|
options: (date) => { |
|
|
</q-icon> |
|
|
if (dateRangeRef) { |
|
|
</template> |
|
|
const fromValue = dateRangeRef.getFieldValue('from'); |
|
|
<template v-for="slotName in fieldMethodsClass.slotNames" :key="slotName" #[slotName]> |
|
|
if (!Tools.isEmpty(fromValue)) { |
|
|
<slot v-if="fieldMethodsClass.isTemplateSlot" :name="slotName"></slot> |
|
|
return date > fromValue.replace(/-/g, '/'); |
|
|
<FormElementSlot v-else :slot-name="slotName" :slot-content="props['slot'][slotName]"></FormElementSlot> |
|
|
} |
|
|
</template> |
|
|
return true; |
|
|
</q-input> |
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
]" |
|
|
|
|
|
> |
|
|
|
|
|
</w-form> |
|
|
|
|
|
</template> |
|
|
|
|
|
<template v-else> |
|
|
|
|
|
<q-input |
|
|
|
|
|
ref="dateRangeRef" |
|
|
|
|
|
v-model="displayValueComputed" |
|
|
|
|
|
:hide-bottom-space="true" |
|
|
|
|
|
:hide-hint="true" |
|
|
|
|
|
:outlined="true" |
|
|
|
|
|
:dense="true" |
|
|
|
|
|
v-bind="attrs" |
|
|
|
|
|
:clearable="false" |
|
|
|
|
|
:rules="fieldMethodsClass.getRules(props, modelValue, dateRangeRef, undefined)" |
|
|
|
|
|
:readonly="fieldMethodsClass.getReadOnly(props, modelValue)" |
|
|
|
|
|
:disable="fieldMethodsClass.getDisable(props, modelValue)" |
|
|
|
|
|
@update:model-value="fieldMethodsClass.updateValue" |
|
|
|
|
|
@focus=" |
|
|
|
|
|
() => { |
|
|
|
|
|
dateRangeRef?.blur(); |
|
|
|
|
|
} |
|
|
|
|
|
" |
|
|
|
|
|
> |
|
|
|
|
|
<template #label> |
|
|
|
|
|
<w-label :required="fieldMethodsClass.getRequired(props, modelValue)" :label="attrs.label"></w-label> |
|
|
|
|
|
</template> |
|
|
|
|
|
<template v-if="!fieldMethodsClass.getReadOnly(props, modelValue)" #append> |
|
|
|
|
|
<q-btn v-if="!Tools.isEmpty(displayValueComputed)" flat square unelevated dense icon="cancel" @click="fieldMethodsClass.clearValue"></q-btn> |
|
|
|
|
|
<q-icon name="event" class="cursor-pointer"> |
|
|
|
|
|
<q-popup-proxy ref="proxyRef" cover transition-show="scale" transition-hide="scale"> |
|
|
|
|
|
<q-date v-model="modelValue" today-btn mask="YYYY-MM-DD" :range="true" @update:model-value="fieldMethodsClass.updateValue"> </q-date> |
|
|
|
|
|
</q-popup-proxy> |
|
|
|
|
|
</q-icon> |
|
|
|
|
|
</template> |
|
|
|
|
|
<template v-for="slotName in fieldMethodsClass.slotNames" :key="slotName" #[slotName]> |
|
|
|
|
|
<slot v-if="fieldMethodsClass.isTemplateSlot" :name="slotName"></slot> |
|
|
|
|
|
<FormElementSlot v-else :slot-name="slotName" :slot-content="props['slot'][slotName]"></FormElementSlot> |
|
|
|
|
|
</template> |
|
|
|
|
|
</q-input> |
|
|
|
|
|
</template> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
@ -49,15 +93,22 @@ const dateRangeRef = ref(); |
|
|
const attrs = useAttrs(); |
|
|
const attrs = useAttrs(); |
|
|
const slots = useSlots(); |
|
|
const slots = useSlots(); |
|
|
const modelValue = defineModel<object>(); |
|
|
const modelValue = defineModel<object>(); |
|
|
|
|
|
const proxyRef = ref(); |
|
|
|
|
|
|
|
|
interface FieldProps extends FormFieldProps {} |
|
|
interface FieldProps extends FormFieldProps { |
|
|
|
|
|
displayMode?: string; |
|
|
|
|
|
// queryContainsEndDate?: boolean; |
|
|
|
|
|
} |
|
|
const props = withDefaults(defineProps<FieldProps>(), { |
|
|
const props = withDefaults(defineProps<FieldProps>(), { |
|
|
showIf: true, |
|
|
showIf: true, |
|
|
|
|
|
// 显示模式:single(单个组件),dual(并排显示模式) |
|
|
|
|
|
displayMode: 'single', |
|
|
}); |
|
|
}); |
|
|
class FieldMethods extends FormFieldMethods { |
|
|
class FieldMethods extends FormFieldMethods { |
|
|
isTemplateSlot = this.getSlotType(slots); |
|
|
isTemplateSlot = this.getSlotType(slots); |
|
|
slotNames = this.getSlotNames(slots, props); |
|
|
slotNames = this.getSlotNames(slots, props); |
|
|
updateValue = (value_) => { |
|
|
updateValue = (value_) => { |
|
|
|
|
|
proxyRef.value.hide(); |
|
|
if (props['onUpdateValue']) { |
|
|
if (props['onUpdateValue']) { |
|
|
props['onUpdateValue']({ |
|
|
props['onUpdateValue']({ |
|
|
value: value_, |
|
|
value: value_, |
|
|