fix: persian Date

pull/1/head
Saeid 4 years ago
parent 3db7ba0c7c
commit a4c840daab

@ -14,15 +14,16 @@
v-model="dateShow"
locale="fa,en"
:locale-config="localeConfig"
:format="displayFormat"
@change="$emit('input', $event.format(format))"
:format="defaultDisplayFormat"
:inputFormat="defaultInputFormat"
@change="$emit('input', $event.format(defaultFormat))"
:type="type"
:auto-submit="true"
:element="'my-custom-date-' + uniqueId"
:editable="true"
:show="show"
:min="min"
:max="max"
:min="minimum"
:max="maximum"
@close="show = false"
:color="color"
/>
@ -38,24 +39,30 @@
},
props: {
color: {default: 'black'},
defaultDate: {
default: 'now',
type: String,
validator: (val) => ['now', 'empty'].includes(val)
},
min: {default: null},
max: {default: null},
displayFormat: {default: 'jDD jMMMM jYYYY ساعت HH:mm'},
format: {default: 'YYYY-MM-DD HH:mm'},
type: {default: 'datetime'},
displayFormat: {default: null},
inputFormat: {default: null},
format: {default: null},
type: {
default: 'datetime',
type: String,
validator: (val) => ['datetime', 'time', 'date'].includes(val)
},
label: {default: 'در تاریخ '},
value: {default: null},
},
data: () => ({
localeConfig: {
fa: {
displayFormat: 'jYYYY/jMM/jDD HH:mm',
inputFormat: 'YYYY-MM-DD HH:mm',
lang: {label: 'شمسی'}
},
en: {
displayFormat: 'YYYY/MM/DD HH:mm',
inputFormat: 'YYYY-MM-DD HH:mm',
lang: {label: 'Gregorian'}
}
},
@ -66,12 +73,68 @@
dateShow: {
get() {
if (this.value) {
return moment(new Date(this.value)).format(this.displayFormat);
return moment(new Date(this.value)).format(this.defaultDisplayFormat);
} else {
if (this.defaultDate === 'now' ) {
this.$emit('input', moment(new Date()).format(this.defaultFormat));
return moment(new Date()).format(this.defaultDisplayFormat);
} else {
return '';
}
}
return moment(new Date()).format(this.displayFormat);
},
set(value) {
}
},
defaultDisplayFormat() {
if (!this.displayFormat) {
if (this.type === 'datetime') {
return 'jDD jMMMM jYYYY ساعت HH:mm';
} else if(this.type === 'date') {
return 'jDD jMMMM jYYYY';
} else if(this.type === 'time') {
return 'HH:mm';
}
}
return this.displayFormat
},
defaultInputFormat() {
if (!this.inputFormat) {
if (this.type === 'datetime') {
return 'YYYY-MM-DD HH:mm';
} else if(this.type === 'date') {
return 'YYYY-MM-DD';
} else if(this.type === 'time') {
return 'HH:mm';
}
}
return this.inputFormat
},
defaultFormat() {
if (!this.format) {
if (this.type === 'datetime') {
return 'YYYY-MM-DD HH:mm';
} else if(this.type === 'date') {
return 'YYYY-MM-DD';
} else if(this.type === 'time') {
return 'HH:mm';
}
}
return this.format
},
minimum() {
if (this.min === 'now') {
return moment(new Date()).format(this.defaultInputFormat);
} else {
return this.min;
}
},
maximum() {
if (this.max === 'now') {
return moment(new Date()).format(this.defaultInputFormat);
} else {
return this.max;
}
},
}

@ -74,6 +74,8 @@ Vue.component("we-hint-text", HintText);
import HintBlock from "@Global/components/Blocks/Hint.vue";
Vue.component("hint-block", HintBlock);
import PersianDate from '@Global/components/Inputs/PersianDate'
Vue.component("we-persian-date", PersianDate);

@ -1,7 +1,7 @@
export default class Cron {
constructor(options) {
this.date_time = options['date_time'] ? options.date : '';
this.date_time = options['date_time'] ? options.date_time : '';
this.date = options['date'] ? options.date : '';
this.time = options['time'] ? options.time : '';
this.cron = options['cron'] ? options.cron : '';

Loading…
Cancel
Save