From 01ff8853dfdf5c1796e7ad1266c2b30df6fc3c24 Mon Sep 17 00:00:00 2001 From: LKHO Date: Tue, 28 Feb 2017 01:40:16 +0800 Subject: [PATCH] fix #130 --- src/fields/core/fieldInput.vue | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/fields/core/fieldInput.vue b/src/fields/core/fieldInput.vue index fb5ee12a..a0bcb2e0 100644 --- a/src/fields/core/fieldInput.vue +++ b/src/fields/core/fieldInput.vue @@ -43,9 +43,7 @@ mixins: [ abstractField ], methods: { formatValueToField(value) { - if (typeof value === "undefined") { - return value; - } else { + if (value != null) { switch(this.schema.inputType){ case "date": return fecha.format(value, "YYYY-MM-DD"); @@ -53,17 +51,20 @@ return fecha.format(value, "YYYY-MM-DD HH:mm:ss"); case "datetime-local": return fecha.format(value, "YYYY-MM-DDTHH:mm:ss"); - default: - return value; } } + + return value; }, formatValueToModel(value) { if (value != null) { - if (this.schema.inputType === "date" || - this.schema.inputType === "datetime" || - this.schema.inputType === "datetimelocal") { - return new Date(value).getTime(); + switch (this.schema.inputType){ + case "date": + return fecha.parse(value, "YYYY-MM-DD"); + case "datetime": + return fecha.parse(value, "YYYY-MM-DD HH:mm:ss"); + case "datetime-local": + return fecha.parse(value, "YYYY-MM-DDTHH:mm:ss"); } }