Merge branch 'dev-3.6' of git.mesalab.cn:nezha/nezha-fronted into dev-3.6

This commit is contained in:
zyh
2022-11-29 10:27:08 +08:00
2 changed files with 67 additions and 40 deletions

View File

@@ -585,7 +585,7 @@ export default {
delete item.repeatIndex delete item.repeatIndex
delete item.repeatVariable delete item.repeatVariable
delete item.repeatValue delete item.repeatValue
item.children.forEach(children => { item.children && item.children.forEach(children => {
delete children.repeatIndex delete children.repeatIndex
delete children.repeatVariable delete children.repeatVariable
delete children.repeatValue delete children.repeatValue
@@ -593,47 +593,75 @@ export default {
} }
} }
this.$nextTick(() => { this.$nextTick(() => {
for (let index = 0; index < this.copyDataList.length; index++) { // 先让数组根据 y 排序 之后直接判断顺序 即可判断 Group 是否相邻
const item = this.copyDataList[index] let arr = this.$loadsh.cloneDeep(this.copyDataList)
if (this.$loadsh.get(this.showHidden[item.id], 'visibility') !== 'hidden' && this.$loadsh.get(item.param.enable, 'repeat')) { arr = this.$loadsh.orderBy(arr, function (item) {
this.variablesArr.forEach((variables) => { return item.y
})
const variablesRepeat = {}
for (let index = 0; index < arr.length; index++) { // 遍历找出所有需要 repeat的group 按照 name进行多次的分组
const item = arr[index]
const repeatVariable = this.$loadsh.get(item.param.repeat, 'variable') const repeatVariable = this.$loadsh.get(item.param.repeat, 'variable')
if (item.type === 'group' && variables.name === repeatVariable) { if (item.type === 'group' && repeatVariable) {
variables.checked.forEach((subItem, subIndex) => { const itemPrev = arr[index - 1]
const repeatPrevVariable = this.$loadsh.get(itemPrev.param.repeat, 'variable')
if (itemPrev && itemPrev.type === 'group' && repeatPrevVariable === repeatVariable) {
const arr = variablesRepeat[repeatVariable]
arr[arr.length - 1].repeatArr.push(item)
arr[arr.length - 1].lastGroup = item
} else {
if (variablesRepeat[repeatVariable]) {
variablesRepeat[repeatVariable].push({
repeatArr: [item],
lastGroup: item
})
} else {
variablesRepeat[repeatVariable] = [{
repeatArr: [item],
lastGroup: item
}]
}
}
}
}
Object.keys(variablesRepeat).forEach(key => { // 遍历 variablesRepeat 确定需要插入的数组
const findVariables = this.variablesArr.find(item => item.name == key)
findVariables.checked.forEach((subItem, subIndex) => {
variablesRepeat[key].forEach(group => {
group.repeatArr.forEach(item => {
if (subIndex > 0) { if (subIndex > 0) {
// 复制数据 重新设置id // 复制数据 重新设置id
const repeatItem = this.$loadsh.cloneDeep(item) const repeatItem = this.$loadsh.cloneDeep(item)
repeatItem.id = item.id + '-' + 'repeat-' + subIndex repeatItem.id = item.id + '-' + 'repeat-' + subIndex
repeatItem.i = repeatItem.id repeatItem.i = repeatItem.id
repeatItem.repeatIndex = subIndex repeatItem.repeatIndex = subIndex
repeatItem.repeatVariable = repeatVariable repeatItem.repeatVariable = key
repeatItem.repeatValue = subItem repeatItem.repeatValue = subItem
repeatItem.children.forEach(children => { repeatItem.y = group.lastGroup.y
repeatItem.children && repeatItem.children.forEach(children => {
children.id = children.id + '-' + 'repeat-' + subIndex children.id = children.id + '-' + 'repeat-' + subIndex
children.repeatIndex = subIndex children.repeatIndex = subIndex
children.repeatVariable = repeatVariable children.repeatVariable = key
children.repeatValue = subItem children.repeatValue = subItem
}) })
index += 1
// 复制数据 // 复制数据
this.copyDataList.splice(index, 0, repeatItem) this.copyDataList.push(repeatItem)
} else { } else {
this.$set(item, 'repeatIndex', 0) const findItem = this.copyDataList.find(chart => chart.id === item.id)
this.$set(item, 'repeatVariable', repeatVariable) this.$set(findItem, 'repeatIndex', 0)
this.$set(item, 'repeatValue', subItem) this.$set(findItem, 'repeatVariable', key)
item.children.forEach(children => { this.$set(findItem, 'repeatValue', subItem)
findItem.children && findItem.children.forEach(children => {
this.$set(children, 'repeatIndex', 0) this.$set(children, 'repeatIndex', 0)
this.$set(children, 'repeatVariable', repeatVariable) this.$set(children, 'repeatVariable', key)
this.$set(children, 'repeatValue', subItem) this.$set(children, 'repeatValue', subItem)
}) })
this.$refs['chart' + item.id] && this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].getChartData() this.$refs['chart' + findItem.id] && this.$refs['chart' + findItem.id][0] && this.$refs['chart' + findItem.id][0].getChartData()
} }
}) })
}
}) })
} })
} })
this.onScroll(this.scrollTop)
}) })
} }

View File

@@ -661,9 +661,8 @@ export default {
methods: { methods: {
init () { init () {
// canvasOptions.on = this.onMessage // canvasOptions.on = this.onMessage
clearTimeout(this.timer3)
this.timer3 = null
this.reload() this.reload()
this.popDataShowUpdate('', false)
}, },
reload () { reload () {