定义一个方法
getChildren(arr) {
let children = []
for (let i = 0
if (arr[i].children) {
children = children.concat(this.getChildren(arr[i].children))
} else {
children.push(arr[i])
}
}
return children
},
listAisle().then((response) => {
this.data = response
let obj = response[0].children[0].children[0]
const children = this.getChildren(this.data)
children.forEach(r => {
const path = "rtsp://218.94.14.202" + 、
":XXXX/XXXX/XXXX/XXXX?XXXX=" + r.deviceNo + '%24'
+ r.aisleNum + '&substream=1&trackID=701'
//节点点击事件 tree节点点击事件
channelchange(value, data) {
// 通道号
this.channel1 = value.deviceNo
// rtsp地址
const path = "XXXX“
// 判断是否需要清空数组
// 如果窗口数量为1,则清空数组
// 选中窗口切换url
// isChangeUrl为true就是从切换url否则就是直接切换tree数据
if (this.isChangeUrl) {
this.$refs[this.videoType].videoPlayer.chooseWindow(this.currentNum)
// 如果当前点击的窗口号为0且窗口数量不为0,则替换第一个窗口的数据
if (this.currentNum === 0 && this.pathList.length !== 0) {
this.pathList[this.currentNum] = path
console.log(' 如果当前点击的窗口号为0且窗口数量不为0,则替换第一个窗口', this.pathList)
}
// 则判断当前点击的窗口号是否超出数组长度,
// 如果超出,则将数据push到数组末尾;如果没有超出,则使用splice方法将数据插入到指定位置。最后调用setRealTime方法将数据传递给
else if (this.currentNum >= this.pathList.length) {
for (let i = this.pathList.length
this.pathList.push('')
}
this.pathList[this.currentNum] = path
console.log('当前点击的窗口号是否超出数组长度,', this.pathList)
}
// 如果当前点击的窗口号在 pathList 数组的长度范围内,且之前补充了空位
else if (this.pathList[this.currentNum] === '') {
console.log(' this.pathList[this.currentNum] = ', this.pathList[this.currentNum])
this.pathList[this.currentNum] = path
console.log('如果当前点击的窗口号在 pathList 数组的长度范围内,', this.pathList)
}
else {
this.pathList.splice(this.currentNum, 0, path)
console.log(' else', this.pathList)
}
this.$refs[this.videoType].setRealTime({ channelId: this.channel1, path: path, snum: this.currentNum, redirect: this.isRedir
} else {
// 触发第一个事件 如果窗口数量为1,则清空数组,然后push最新点击的node节点数据
// this.pathList.splice(0, this.pathList.length)
console.log('触发第一个事件')
this.pathList = []
this.pathList.push(path)
}
//修改url
changeUrl(num, node) {
// 选中窗口
this.isChangeUrl = true
},