diff --git a/nezha-fronted/src/components/common/pickTime.vue b/nezha-fronted/src/components/common/pickTime.vue index 1c6bd59df..2ae80be6c 100644 --- a/nezha-fronted/src/components/common/pickTime.vue +++ b/nezha-fronted/src/components/common/pickTime.vue @@ -149,7 +149,8 @@ export default { } const startTime = bus.timeFormate(timeRange[0], this.pickTimer) const endTime = bus.timeFormate(timeRange[1], this.pickTimer) - return [startTime, endTime] + const timeType = timeRange[2] + return [startTime, endTime, timeType || ''] }, dateChange (time) { this.searchTime = time diff --git a/nezha-fronted/src/components/common/searchBox/searchBox.vue b/nezha-fronted/src/components/common/searchBox/searchBox.vue index 56be7c396..9f7f30cf1 100644 --- a/nezha-fronted/src/components/common/searchBox/searchBox.vue +++ b/nezha-fronted/src/components/common/searchBox/searchBox.vue @@ -20,6 +20,7 @@ :ref="'search-item' + index" :class="{'search-item-select': index === historyIndex}" :title="renderHistoryTitle(item)" + @click="selectHistory(item)" > {{tag.i18n}}: @@ -568,6 +569,10 @@ export default { }) return str }, + selectHistory (item) { + this.selectArr = item + this.emitSearch() + }, contentShow (key) { this.keyShow = false // key 的下拉 this.symbolShow = false // symbol 的下拉 @@ -1034,6 +1039,11 @@ export default { this.where = this.$route.path + this.position } const historyArr = localStorage.getItem('nz-history-' + this.where) ? JSON.parse(localStorage.getItem('nz-history-' + this.where)) : [] + historyArr.forEach(item => { // todo 后续还需要处理枚举类型的中英切换 + item.forEach((searchInfo) => { + searchInfo.i18n = this.$t(searchInfo.code) + }) + }) this.historyArr = historyArr }, calcType () { // 处理各个页面的from targetTab 确定查询的type diff --git a/nezha-fronted/src/components/page/alert/alertMessage.vue b/nezha-fronted/src/components/page/alert/alertMessage.vue index 12ba5a6f0..0a89021a1 100644 --- a/nezha-fronted/src/components/page/alert/alertMessage.vue +++ b/nezha-fronted/src/components/page/alert/alertMessage.vue @@ -231,7 +231,7 @@ export default { chartDatas: [], sameLabels: ['instance', 'module', 'project', 'asset', 'endpoint', 'datacenter'], legend: [], - searchTime: [bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - 24 * 30)), bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime()))), '30d'], + searchTime: [bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - 24 * 30)), bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime()))), '7d'], searchTimeDialog: [], searchTimeSelect: bus.getTimezontDateRange(), currentMsg: {}, @@ -404,7 +404,7 @@ export default { ], errorContent: '', isError: false, - defaultPick: 11 + defaultPick: 10 } }, computed: { @@ -449,9 +449,10 @@ export default { methods: { renderDefaultParams () { const q = JSON.parse(this.$route.query.body) + console.log(q, 'q') this.state = q.state - this.searchTime[0] = q.startAt - this.searchTime[1] = q.endAt + this.searchTime[0] = this.momentTz(q.startAt) + this.searchTime[1] = this.momentTz(q.endAt) this.searchTime[2] = q.timeType switch (q.timeType) { case '7d' : @@ -827,6 +828,8 @@ export default { const path = this.fromRoute.alertMessage const routePathParams = this.$lodash.cloneDeep(param) delete routePathParams.statistics + routePathParams.body.startAt = this.momentStrToTimestamp(this.searchTime[0]) + routePathParams.body.endAt = this.momentStrToTimestamp(this.searchTime[1]) routePathParams.body.timeType = this.searchTime[2] routePathParams.body = JSON.stringify(routePathParams.body) this.updatePath(routePathParams, path)