NEZ-1479 feat:保存接口 查询接口 统一时间格式为YYYY-MM-DD HH:mm:ss

This commit is contained in:
zhangyu
2022-01-06 13:50:56 +08:00
parent f939e58ccc
commit d7690e3dcd
3 changed files with 12 additions and 7 deletions

View File

@@ -153,6 +153,8 @@ export default {
obj.linkId = null
}
this.editAlertSilence = Object.assign(this.editAlertSilence, obj)
this.editAlertSilence.startAt = new Date(this.editAlertSilence.startAt)
this.editAlertSilence.endAt = new Date(this.editAlertSilence.endAt)
this.startAtTamp = new Date(this.editAlertSilence.startAt).getTime()
this.endAtTamp = new Date(this.editAlertSilence.endAt).getTime()
this.editAlertSilence.time = this.startAtTamp
@@ -230,7 +232,6 @@ export default {
if (this.prevent_opt.save) {
return
}
;
this.prevent_opt.save = true
this.$refs.alertSilenceForm.validate((valid) => {
if (this.endAtTamp < this.startAtTamp) {
@@ -243,8 +244,8 @@ export default {
}
const params = { ...this.editAlertSilence, matchers: JSON.stringify(this.editAlertSilence.matchers) }
if (valid) {
params.startAt = bus.timeFormate(new Date(this.timezoneToUtcTime(params.startAt)))
params.endAt = bus.timeFormate(new Date(this.timezoneToUtcTime(params.endAt)))
params.startAt = bus.timeFormate(new Date(this.timezoneToUtcTime(params.startAt)), 'YYYY-MM-DD HH:mm:ss')
params.endAt = bus.timeFormate(new Date(this.timezoneToUtcTime(params.endAt)), 'YYYY-MM-DD HH:mm:ss')
if (this.editAlertSilence.id) {
this.$put('/alert/silence', params).then(response => {
this.prevent_opt.save = false

View File

@@ -56,7 +56,6 @@
v-model="scope.row[item.prop]"
prefix-icon=" " size="small" ref="calendar"
:format="timeFormatStrToDatePickFormat(timeFormatMain)"
:value-format="timeFormatStrToDatePickFormat(timeFormatMain)"
type="datetime"
popper-class="item-system-table right-public-box-dropdown-top right-box-select-top"
:picker-options="pickerOptions"
@@ -194,7 +193,9 @@ export default {
},
save: function (obj) {
const copy = JSON.parse(JSON.stringify(obj))
copy.expireAt = this.timezoneToUtcTimeStr(copy.expireAt)
console.log(copy.expireAt)
copy.expireAt = new Date(copy.expireAt).getTime()
copy.expireAt = this.timezoneToUtcTimeStr(copy.expireAt, 'YYYY-MM-DD HH:mm:ss')
if (copy.role) {
copy.roleId = copy.role.id
}

View File

@@ -114,9 +114,12 @@ Vue.mixin({
return bus.configTimezoneToUTCTime(time)
}
},
timezoneToUtcTimeStr: function (time) {
timezoneToUtcTimeStr: function (time, fmt) {
if (!fmt) {
fmt = localStorage.getItem('nz-default-dateFormat') || 'YYYY-MM-DD HH:mm:ss'
}
if (time) {
return bus.timeFormate(this.timezoneToUtcTime(time), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss')
return bus.timeFormate(this.timezoneToUtcTime(time), fmt)
}
},
timestampStr: function (time) {