feat: 添加日期验证功能,确保发行日期不早于当前日期,申购截止日期不早于发行日期
This commit is contained in:
@@ -2,16 +2,23 @@
|
||||
import type { FieldBindingObject } from "vee-validate";
|
||||
|
||||
interface Props extends FieldBindingObject {
|
||||
datetime: string;
|
||||
label?: string;
|
||||
formatterValue?: (value: string) => string;
|
||||
format?: (value: string) => string;
|
||||
min?: string;
|
||||
max?: string;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<{
|
||||
(e: "update:value", value: string): void;
|
||||
}>();
|
||||
|
||||
function handleChange(value: string) {
|
||||
const formattedValue = props.formatterValue ? props.formatterValue(value) : new Date(value).toISOString();
|
||||
props.onChange(formattedValue);
|
||||
emit("update:value", formattedValue);
|
||||
}
|
||||
|
||||
function formatDisplay(value: string) {
|
||||
@@ -24,18 +31,20 @@ function formatDisplay(value: string) {
|
||||
<ion-label class="text-sm font-bold color-(--ion-text-color-secondary) mb-3.5">
|
||||
{{ props.label }}
|
||||
</ion-label>
|
||||
<ion-datetime-button datetime="datetime" color="primary">
|
||||
<ion-datetime-button :datetime="datetime" color="primary">
|
||||
<div slot="date-target">
|
||||
{{ formatDisplay(props.value) }}
|
||||
</div>
|
||||
</ion-datetime-button>
|
||||
<ion-modal :keep-contents-mounted="true">
|
||||
<ion-datetime
|
||||
id="datetime"
|
||||
:id="datetime"
|
||||
class="ui-datetime"
|
||||
done-text="Done"
|
||||
presentation="date"
|
||||
:show-default-buttons="true"
|
||||
:min="props.min"
|
||||
:max="props.max"
|
||||
@ion-change="handleChange($event.detail.value as string)"
|
||||
/>
|
||||
</ion-modal>
|
||||
|
||||
Reference in New Issue
Block a user