diff --git a/nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue b/nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue index 26f270737..71ab0d13c 100644 --- a/nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue @@ -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 diff --git a/nezha-fronted/src/components/page/config/system/apiKeyTable.vue b/nezha-fronted/src/components/page/config/system/apiKeyTable.vue index f8e1cd4fe..54a31bd06 100644 --- a/nezha-fronted/src/components/page/config/system/apiKeyTable.vue +++ b/nezha-fronted/src/components/page/config/system/apiKeyTable.vue @@ -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 } diff --git a/nezha-fronted/src/main.js b/nezha-fronted/src/main.js index bd451fd50..aaba598af 100644 --- a/nezha-fronted/src/main.js +++ b/nezha-fronted/src/main.js @@ -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) {