NEZ-1702 fix:alert silence 时间选择出错

This commit is contained in:
zhangyu
2022-03-18 14:15:46 +08:00
parent 80198c9dad
commit 6b7762723b
2 changed files with 10 additions and 7 deletions

View File

@@ -39,7 +39,6 @@
<span class="datepicker-title">{{ $t("overall.startTime") }}</span> <span class="datepicker-title">{{ $t("overall.startTime") }}</span>
<my-date-picker ref="calendar" v-model="editAlertSilence.startAt" :clearable="false" :placeholder="$t('dashboard.panel.startTime')" <my-date-picker ref="calendar" v-model="editAlertSilence.startAt" :clearable="false" :placeholder="$t('dashboard.panel.startTime')"
align="right" class=" " align="right" class=" "
:value-format="timeFormatStrToDatePickFormat(timeFormatMain)"
:format="timeFormatStrToDatePickFormat(timeFormatMain)" :format="timeFormatStrToDatePickFormat(timeFormatMain)"
popper-class="panel-time-picker-popper right-box-select-top" popper-class="panel-time-picker-popper right-box-select-top"
prefix-icon=" " prefix-icon=" "
@@ -53,7 +52,6 @@
<span class="datepicker-title">{{ $t("overall.endTime") }}</span> <span class="datepicker-title">{{ $t("overall.endTime") }}</span>
<my-date-picker ref="calendar" v-model="editAlertSilence.endAt" :clearable="false" :placeholder="$t('dashboard.panel.startTime')" <my-date-picker ref="calendar" v-model="editAlertSilence.endAt" :clearable="false" :placeholder="$t('dashboard.panel.startTime')"
align="right" class=" " align="right" class=" "
:value-format="timeFormatStrToDatePickFormat(timeFormatMain)"
:format="timeFormatStrToDatePickFormat(timeFormatMain)" :format="timeFormatStrToDatePickFormat(timeFormatMain)"
popper-class="panel-time-picker-popper right-box-select-top" popper-class="panel-time-picker-popper right-box-select-top"
prefix-icon=" " prefix-icon=" "
@@ -243,6 +241,8 @@ export default {
return return
} }
const params = { ...this.editAlertSilence, matchers: JSON.stringify(this.editAlertSilence.matchers) } const params = { ...this.editAlertSilence, matchers: JSON.stringify(this.editAlertSilence.matchers) }
params.startAt = bus.formateTimeToTime(params.startAt)
params.endAt = bus.formateTimeToTime(params.endAt)
if (valid) { if (valid) {
params.startAt = bus.timeFormate(new Date(this.timezoneToUtcTime(params.startAt)), 'YYYY-MM-DD HH:mm:ss') 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') params.endAt = bus.timeFormate(new Date(this.timezoneToUtcTime(params.endAt)), 'YYYY-MM-DD HH:mm:ss')
@@ -299,10 +299,10 @@ export default {
}, },
dateChange (val, type) { dateChange (val, type) {
if (type === 'startAt') { if (type === 'startAt') {
this.editAlertSilence.startAt = bus.timeFormate(new Date(val), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') this.editAlertSilence.startAt = new Date(val).getTime()
this.startAtTamp = new Date(val).getTime() this.startAtTamp = new Date(val).getTime()
} else if (type === 'endAt') { } else if (type === 'endAt') {
this.editAlertSilence.endAt = bus.timeFormate(new Date(val), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') this.editAlertSilence.endAt = new Date(val).getTime()
this.endAtTamp = new Date(val).getTime() this.endAtTamp = new Date(val).getTime()
} }
this.$forceUpdate() this.$forceUpdate()
@@ -317,7 +317,10 @@ export default {
} }
}, },
rangeTimeChange (val) { rangeTimeChange (val) {
const arr = [bus.timeFormate(bus.getOffsetTimezoneData(), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss'), bus.timeFormate(bus.getOffsetTimezoneData(val * 1), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss')] const arr = [
bus.getOffsetTimezoneData(),
bus.getOffsetTimezoneData(val * 1)
]
this.$set(this.editAlertSilence, 'startAt', arr[0]) this.$set(this.editAlertSilence, 'startAt', arr[0])
this.$set(this.editAlertSilence, 'endAt', arr[1]) this.$set(this.editAlertSilence, 'endAt', arr[1])
this.startAtTamp = new Date(this.editAlertSilence.startAt).getTime() this.startAtTamp = new Date(this.editAlertSilence.startAt).getTime()

View File

@@ -202,8 +202,8 @@ export default {
}) })
}, },
add () { add () {
this.blankObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') this.blankObject.startAt = bus.getOffsetTimezoneData()
this.blankObject.endAt = bus.timeFormate(bus.getOffsetTimezoneData(1), 'YYYY-MM-DD HH:mm:ss') this.blankObject.endAt = bus.getOffsetTimezoneData(1)
this.object = JSON.parse(JSON.stringify(this.blankObject)) this.object = JSON.parse(JSON.stringify(this.blankObject))
this.rightBox.show = true this.rightBox.show = true
}, },