fixed date group issue #aa50y2

This commit is contained in:
Cüneyt Şentürk 2021-07-16 13:36:09 +03:00
parent 926ceb1c38
commit c845749963

View File

@ -45,41 +45,53 @@ export default {
default: '', default: '',
description: "Modal header title" description: "Modal header title"
}, },
dataName: { dataName: {
type: String, type: String,
default: '', default: '',
description: "Modal header title" description: "Modal header title"
}, },
placeholder: { placeholder: {
type: String, type: String,
default: '', default: '',
description: "Modal header title" description: "Modal header title"
}, },
readonly: { readonly: {
type: Boolean, type: Boolean,
default: false, default: false,
description: "Input readonly status" description: "Input readonly status"
}, },
period: { period: {
type: Number, type: [Number, String],
default: 0,
description: "Payment period" description: "Payment period"
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false, default: false,
description: "Input disabled status" description: "Input disabled status"
}, },
formClasses: null, formClasses: null,
formError: null, formError: null,
name: null, name: null,
value: { value: {
default: null, default: null,
description: "Input value defalut" description: "Input value defalut"
}, },
model: { model: {
default: null, default: null,
description: "Input model defalut" description: "Input model defalut"
}, },
dateConfig: { dateConfig: {
type: Object, type: Object,
default: function () { default: function () {
@ -93,17 +105,21 @@ export default {
}, },
description: "FlatPckr date configuration" description: "FlatPckr date configuration"
}, },
icon: { icon: {
type: String, type: String,
description: "Prepend icon (left)" description: "Prepend icon (left)"
}, },
locale: { locale: {
type: String, type: String,
default: 'en', default: 'en',
}, },
hiddenYear: { hiddenYear: {
type: [Boolean, String] type: [Boolean, String]
}, },
dataValueMin: { dataValueMin: {
type: [Boolean, String, Date] type: [Boolean, String, Date]
} }
@ -121,11 +137,11 @@ export default {
this.dateConfig.locale = lang; this.dateConfig.locale = lang;
} }
this.real_model = this.value;
}, },
mounted() { mounted() {
this.real_model = this.value;
if (this.model) { if (this.model) {
this.real_model = this.model; this.real_model = this.model;
} }
@ -142,7 +158,8 @@ export default {
focus() { focus() {
let date_wrapper_html = document.querySelectorAll('.numInputWrapper'); let date_wrapper_html = document.querySelectorAll('.numInputWrapper');
if(this.hiddenYear) {
if (this.hiddenYear) {
date_wrapper_html.forEach((wrapper) => { date_wrapper_html.forEach((wrapper) => {
wrapper.classList.add('hidden-year-flatpickr'); wrapper.classList.add('hidden-year-flatpickr');
}); });
@ -154,13 +171,15 @@ export default {
}, },
addDays(dateInput) { addDays(dateInput) {
if(!this.period) return; if (!this.period) {
return;
}
const dateString = new Date(dateInput); let dateString = new Date(dateInput);
const aMillisec = 86400000; let aMillisec = 86400000;
const dateInMillisecs = dateString.getTime(); let dateInMillisecs = dateString.getTime();
const settingPaymentTermInMs = parseInt(this.period) * aMillisec; let settingPaymentTermInMs = parseInt(this.period) * aMillisec;
const prospectedDueDate = new Date(dateInMillisecs + settingPaymentTermInMs); let prospectedDueDate = new Date(dateInMillisecs + settingPaymentTermInMs);
return prospectedDueDate; return prospectedDueDate;
}, },
@ -172,10 +191,12 @@ export default {
}, },
dateConfig: function() { dateConfig: function() {
if(this.dateConfig.minDate) { if (!this.dateConfig.minDate) {
if(this.real_model < this.dateConfig.minDate){ return;
this.real_model = this.addDays(this.dateConfig.minDate); }
}
if (this.real_model < this.dateConfig.minDate) {
this.real_model = this.addDays(this.dateConfig.minDate);
} }
}, },
} }