0
0
Fork 0

feat: VnInputDate & VnInputTime improviments

This commit is contained in:
Alex Moreno 2024-07-15 12:33:58 +02:00
parent 1ccf515509
commit ea3effd7f4
2 changed files with 21 additions and 9 deletions

View File

@ -407,7 +407,7 @@ defineExpose({
<VnTableColumn <VnTableColumn
:column="col" :column="col"
:row="row" :row="row"
:is-editable="false" :is-editable="col.isEditable ?? isEditable"
v-model="row[col.name]" v-model="row[col.name]"
component-prop="columnField" component-prop="columnField"
/> />

View File

@ -44,12 +44,15 @@ const formattedDate = computed({
let newDate; let newDate;
if (value) { if (value) {
// parse input // parse input
if (value.includes('/') && value.length >= 10) { if (value.includes('/')) {
if (value.at(2) == '/') value = value.split('/').reverse().join('/'); if (value.length == 6) value = value + new Date().getFullYear();
value = date.formatDate( if (value.length >= 10) {
new Date(value).toISOString(), if (value.at(2) == '/') value = value.split('/').reverse().join('/');
'YYYY-MM-DDTHH:mm:ss.SSSZ' value = date.formatDate(
); new Date(value).toISOString(),
'YYYY-MM-DDTHH:mm:ss.SSSZ'
);
}
} }
let ymd = value.split('-').map((e) => parseInt(e)); let ymd = value.split('-').map((e) => parseInt(e));
newDate = new Date(ymd[0], ymd[1] - 1, ymd[2]); newDate = new Date(ymd[0], ymd[1] - 1, ymd[2]);
@ -107,7 +110,12 @@ watch(
isPopupOpen = false; isPopupOpen = false;
" "
/> />
<QIcon name="event" class="cursor-pointer" /> <QIcon
name="event"
class="cursor-pointer"
@click="isPopupOpen = !isPopupOpen"
:title="t('Open date')"
/>
</template> </template>
<QMenu <QMenu
transition-show="scale" transition-show="scale"
@ -116,6 +124,7 @@ watch(
anchor="bottom left" anchor="bottom left"
self="top start" self="top start"
:no-focus="true" :no-focus="true"
:no-parent-event="true"
> >
<QDate <QDate
v-model="popupDate" v-model="popupDate"
@ -132,7 +141,6 @@ watch(
</QInput> </QInput>
</div> </div>
</template> </template>
<style lang="scss"> <style lang="scss">
.vn-input-date.q-field--standard.q-field--readonly .q-field__control:before { .vn-input-date.q-field--standard.q-field--readonly .q-field__control:before {
border-bottom-style: solid; border-bottom-style: solid;
@ -142,3 +150,7 @@ watch(
border-style: solid; border-style: solid;
} }
</style> </style>
<i18n>
es:
Open date: Abrir fecha
</i18n>