From 3acc639ed2a8bd25b04c139f9ff689a9a860df99 Mon Sep 17 00:00:00 2001 From: zyh Date: Mon, 27 Feb 2023 15:55:01 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=97=B6=E9=97=B4=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E6=A3=80=E9=AA=8C=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chart/chartList.vue | 48 ++++++++++++------- .../src/components/common/timePicker.vue | 4 +- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/nezha-fronted/src/components/chart/chartList.vue b/nezha-fronted/src/components/chart/chartList.vue index a79faedcb..1be4a84ff 100644 --- a/nezha-fronted/src/components/chart/chartList.vue +++ b/nezha-fronted/src/components/chart/chartList.vue @@ -44,6 +44,7 @@ @container-resized="containerResizedEvent" > { + this.tempList.forEach(subItem => { + if (item.id == subItem.id) { + subItem.y = item.y + } + }) + }) }, onScroll (scrollTop = 0, groupTop = 0) { + if (!this.variablesInit) { // 变量未加载完成 不请求数据 + return + } const self = this if (this.scrollTopTimer) { clearTimeout(this.scrollTopTimer) @@ -395,7 +405,7 @@ export default { if ((mainOffsetTop + mainHeight / 4) < (windowScrollTop + windowHeight)) { item.loaded = true setTimeout(() => { - this.$refs['chart' + item.id] && this.$refs['chart' + item.id][0].getChartData() + this.$refs['chart' + item.id] && this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].getChartData() }, i * 100) i++ } @@ -481,7 +491,7 @@ export default { // 比较变量 图表是否显示/隐藏 compareVariables () { // 防止group中的chartList执行 - if (this.groupInfo) { + if (this.isGroup) { return } const isRegExp = (v) => { @@ -557,7 +567,6 @@ export default { if (!this.panelLock) { return false } - this.copyDataList = JSON.parse(JSON.stringify(this.tempList)) for (let i = 0; i < this.copyDataList.length; i++) { const item = this.copyDataList[i] if ((this.$loadsh.get(this.showHidden[item.id], 'visibility') && this.$loadsh.get(this.showHidden[item.id], 'visibility') === 'hidden') && item.id !== -2) { @@ -565,18 +574,18 @@ export default { i-- } } - // this.tempList.forEach(item => { - // if ((!this.$loadsh.get(this.showHidden[item.id], 'visibility') || this.$loadsh.get(this.showHidden[item.id], 'visibility') === 'show') && item.id !== -2 && !this.copyDataList.find(chart => chart.id === item.id)) { - // this.copyDataList.push(item) - // } - // }) + this.tempList.forEach(item => { + if ((!this.$loadsh.get(this.showHidden[item.id], 'visibility') || this.$loadsh.get(this.showHidden[item.id], 'visibility') === 'show') && item.id !== -2 && !this.copyDataList.find(chart => chart.id === item.id)) { + this.copyDataList.push(item) + } + }) this.onScroll(this.scrollTop) }, // group设置repeat 便利变量重复渲染图表 repeatVariableFn () { // 防止group中的chartList执行 - if (this.groupInfo) { + if (this.isGroup) { return } // 先删除掉复制的数据 @@ -608,11 +617,13 @@ export default { const item = arr[index] const repeatVariable = this.$loadsh.get(item.param.repeat, 'variable') const repeatEnable = this.$loadsh.get(item.param.enable, 'repeat') - if (item.type === 'group' && repeatVariable && this.$loadsh.get(this.showHidden[item.id], 'visibility') !== 'hidden' && repeatEnable) { + const visibility = this.$loadsh.get(this.showHidden[item.id], 'visibility') !== 'hidden' + if (item.type === 'group' && repeatVariable && repeatEnable && visibility) { const itemPrev = arr[index - 1] const repeatPrevVariable = this.$loadsh.get(itemPrev.param.repeat, 'variable') - const repeatPrevEnable = this.$loadsh.get(item.param.enable, 'repeat') - if (itemPrev && itemPrev.type === 'group' && repeatPrevVariable === repeatVariable && repeatPrevEnable) { + const repeatPrevEnable = this.$loadsh.get(itemPrev.param.enable, 'repeat') + const itemVisibility = this.$loadsh.get(this.showHidden[itemPrev.id], 'visibility') !== 'hidden' + if (itemPrev && itemPrev.type === 'group' && repeatPrevVariable === repeatVariable && repeatPrevEnable && itemVisibility) { const arr = variablesRepeat[repeatVariable] arr[arr.length - 1].repeatArr.push(item) arr[arr.length - 1].lastGroup = item @@ -716,6 +727,10 @@ export default { if (!flag) { this.tempList.forEach(item => { if (!this.copyDataList.find(chart => chart.id === item.id)) { + delete item.repeatIndex + delete item.repeatVariable + delete item.repeatValue + item.y -= 0.03 this.copyDataList.push(item) } }) @@ -746,7 +761,7 @@ export default { const position = getLayoutPosition(n) this.$store.commit('setChartLastPosition', position) } - let tempList = n.map(item => { + const tempList = n.map(item => { let param = '' let height = '' if (this.isPhone && item.type !== 'group') { @@ -809,7 +824,6 @@ export default { this.compareVariables() this.repeatVariableFn() - tempList = null setTimeout(() => { this.gridLayoutShow = true if (!this.isGroup) { diff --git a/nezha-fronted/src/components/common/timePicker.vue b/nezha-fronted/src/components/common/timePicker.vue index 5d9c83c23..320e2b767 100644 --- a/nezha-fronted/src/components/common/timePicker.vue +++ b/nezha-fronted/src/components/common/timePicker.vue @@ -411,10 +411,11 @@ export default { this.oldSearchTime[1] = bus.timeFormate(this.oldSearchTime[1]) } } - // console.log(moment(this.oldSearchTime[0], timeFormatMain).isValid(), moment(this.oldSearchTime[1], timeFormatMain).isValid(), !moment(this.oldSearchTime[0]).isBefore(this.oldSearchTime[1])) if (moment(this.oldSearchTime[0], timeFormatMain).isValid() && moment(this.oldSearchTime[1], timeFormatMain).isValid() && !moment(this.oldSearchTime[0]).isBefore(this.oldSearchTime[1])) { this.oldSearchTimeError[0] = true this.inputError = this.$t('date.fromGreaterTo') + } else if (moment(this.oldSearchTime[0], timeFormatMain).isValid() && moment(this.oldSearchTime[1], timeFormatMain).isValid() && moment(this.oldSearchTime[0]).isBefore(this.oldSearchTime[1])) { + this.oldSearchTimeError[0] = false } }, dateChange () { @@ -422,7 +423,6 @@ export default { this.oldSearchTimeError[1] = false }, setCustomTime (timeGroup, timeRange) { - console.log(timeGroup) if (timeGroup) { this.showTime = this.nowTimeType = this.timeData.find( (item) => item.id == timeGroup.id