mirror of https://github.com/veops/cmdb.git
fix date picker
This commit is contained in:
parent
e7a31a8dc4
commit
f5d3ed4b8b
|
@ -47,8 +47,8 @@ type_map = {
|
||||||
Attribute.FLOAT: float,
|
Attribute.FLOAT: float,
|
||||||
Attribute.TEXT: str,
|
Attribute.TEXT: str,
|
||||||
Attribute.TIME: str,
|
Attribute.TIME: str,
|
||||||
Attribute.DATE: lambda x: x.strftime("%Y%m%d"),
|
Attribute.DATE: lambda x: x.strftime("%Y-%m-%d"),
|
||||||
Attribute.DATETIME: lambda x: x.strftime("%Y%m%d %H:%M:%S"),
|
Attribute.DATETIME: lambda x: x.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
},
|
},
|
||||||
'serialize2': {
|
'serialize2': {
|
||||||
Attribute.INT: int,
|
Attribute.INT: int,
|
||||||
|
|
|
@ -10,7 +10,9 @@ from api.lib.exception import CommitException
|
||||||
|
|
||||||
class FormatMixin(object):
|
class FormatMixin(object):
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return dict([(k.name, getattr(self, k.name)) for k in getattr(self, "__table__").columns])
|
return dict([(k.name,
|
||||||
|
getattr(self, k.name) if not isinstance(getattr(self, k.name), datetime.datetime) else getattr(
|
||||||
|
self, k.name).strftime('%Y-%m-%d %H:%M:%S')) for k in getattr(self, "__table__").columns])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_columns(cls):
|
def get_columns(cls):
|
||||||
|
@ -18,7 +20,6 @@ class FormatMixin(object):
|
||||||
|
|
||||||
|
|
||||||
class CRUDMixin(FormatMixin):
|
class CRUDMixin(FormatMixin):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, flush=False, **kwargs):
|
def create(cls, flush=False, **kwargs):
|
||||||
return cls(**kwargs).save(flush=flush)
|
return cls(**kwargs).save(flush=flush)
|
||||||
|
|
|
@ -128,6 +128,11 @@ export default {
|
||||||
createInstance (e) {
|
createInstance (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.form.validateFields((err, values) => {
|
this.form.validateFields((err, values) => {
|
||||||
|
Object.keys(values).forEach(k => {
|
||||||
|
if (typeof values[k] === 'object') {
|
||||||
|
values[k] = values[k].format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
}
|
||||||
|
})
|
||||||
if (!err) {
|
if (!err) {
|
||||||
if (this.action === 'update') {
|
if (this.action === 'update') {
|
||||||
this.$emit('submit', values)
|
this.$emit('submit', values)
|
||||||
|
|
|
@ -393,7 +393,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
getAttributes () {
|
getAttributes () {
|
||||||
searchAttributes().then(res => {
|
searchAttributes({ page_size: 10000 }).then(res => {
|
||||||
this.allAttributes = res.attributes
|
this.allAttributes = res.attributes
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue