update DatePicker

update DatePicker
This commit is contained in:
梁灏 2016-12-19 23:40:39 +08:00
parent f92ef70f46
commit 7c5ccdab4d
3 changed files with 73 additions and 27 deletions

View file

@ -73,8 +73,11 @@
});
}
},
cells (cells) {
this.readCells = cells;
cells: {
handler (cells) {
this.readCells = cells;
},
immediate: true
}
},
computed: {

View file

@ -248,21 +248,47 @@
const value = event.target.value;
let correctValue = '';
const format = this.format || DEFAULT_FORMATS[this.type];
const parsedDate = parseDate(value, format);
let correctDate = '';
const type = this.type;
const format = this.format || DEFAULT_FORMATS[type];
if (parsedDate instanceof Date) {
const options = this.options;
if (options.disabledDate && typeof options.disabledDate === 'function' && options.disabledDate(new Date(parsedDate))) {
correctValue = oldValue;
if (type === 'daterange' || type === 'timerange' || type === 'datetimerange') {
const parser = (
TYPE_VALUE_RESOLVER_MAP[type] ||
TYPE_VALUE_RESOLVER_MAP['default']
).parser;
const formatter = (
TYPE_VALUE_RESOLVER_MAP[type] ||
TYPE_VALUE_RESOLVER_MAP['default']
).formatter;
const parsedValue = parser(value, format);
if (parsedValue) {
// todo disabledDate
correctValue = formatter(parsedValue, format);
} else {
correctValue = formatDate(parsedDate, format);
correctValue = oldValue;
}
} else {
correctValue = oldValue;
}
const correctDate = parseDate(correctValue, format);
correctDate = parsedValue;
} else {
const parsedDate = parseDate(value, format);
if (parsedDate instanceof Date) {
const options = this.options;
if (options.disabledDate && typeof options.disabledDate === 'function' && options.disabledDate(new Date(parsedDate))) {
correctValue = oldValue;
} else {
correctValue = formatDate(parsedDate, format);
}
} else {
correctValue = oldValue;
}
correctDate = parseDate(correctValue, format);
}
this.visualValue = correctValue;
event.target.value = correctValue;