完善树结构大数据量的展示

This commit is contained in:
lin 2025-11-11 14:23:45 +08:00
parent 01fa67fee6
commit 3e3a3c202f
4 changed files with 104 additions and 9 deletions

View File

@ -122,3 +122,4 @@ public class CachedBodyHttpServletRequest extends HttpServletRequestWrapper {
} }

View File

@ -16,15 +16,16 @@ export function add(data) {
data: data data: data
}) })
} }
export function getTreeList(params) { export function getTreeList({ query, parent, hasChannel, page, count }) {
const { query, parent, hasChannel } = params
return request({ return request({
method: 'get', method: 'get',
url: `/api/group/tree/list`, url: `/api/group/tree/list`,
params: { params: {
query: query, query: query,
parent: parent, parent: parent,
hasChannel: hasChannel hasChannel: hasChannel,
page: page,
count: count
} }
}) })
} }

View File

@ -141,6 +141,7 @@ export default {
}, },
showCode: false, showCode: false,
showAlert: true, showAlert: true,
treeLimit: 50,
searchStr: '', searchStr: '',
chooseId: '', chooseId: '',
treeData: [], treeData: [],
@ -212,6 +213,7 @@ export default {
type: 0 type: 0
}]) }])
} else { } else {
console.log(node.data)
if (node.data.leaf) { if (node.data.leaf) {
resolve([]) resolve([])
return return
@ -221,10 +223,26 @@ export default {
parent: node.data.id, parent: node.data.id,
hasChannel: this.hasChannel hasChannel: this.hasChannel
}).then(data => { }).then(data => {
console.log(data)
if (data.length > 0) { if (data.length > 0) {
this.showAlert = false this.showAlert = false
} }
resolve(data) if (data.length > this.treeLimit) {
let subData = data.splice(0, this.treeLimit)
subData.push({
treeId: '---',
deviceId: '---',
name: '加载更多...',
isLeaf: true,
leaf: true,
type: 100,
nextData: data.splice(this.treeLimit, data.length)
})
resolve(subData)
}else {
resolve(data)
}
}).finally(() => { }).finally(() => {
this.locading = false this.locading = false
}) })
@ -447,8 +465,37 @@ export default {
}, id) }, id)
}, },
nodeClickHandler: function(data, node, tree) { nodeClickHandler: function(data, node, tree) {
this.chooseId = data.deviceId console.log(data)
this.$emit('clickEvent', data)
if (data && data.nextData && data.nextData.length > 0) {
const parentNode = node.parent
let nextData = data.nextData
if (nextData.length > this.treeLimit) {
let subData = nextData.splice(0, this.treeLimit)
subData.push({
treeId: '---',
deviceId: '---',
name: '加载更多...',
isLeaf: true,
leaf: true,
type: 100,
nextData: nextData.splice(this.treeLimit, nextData.length)
})
this.$refs.veTree.remove(data, parentNode)
for (let item of subData) {
this.$refs.veTree.append(item, parentNode)
}
} else {
this.$refs.veTree.remove(data, parentNode)
for (let item of subData) {
this.$refs.veTree.append(item, parentNode)
}
}
}else {
this.chooseId = data.deviceId
this.$emit('clickEvent', data)
}
}, },
listClickHandler: function(data) { listClickHandler: function(data) {
this.chooseId = data.deviceId this.chooseId = data.deviceId

View File

@ -137,6 +137,7 @@ export default {
searchType: 0, searchType: 0,
showCode: false, showCode: false,
showAlert: true, showAlert: true,
treeLimit: 50,
searchStr: '', searchStr: '',
chooseId: '', chooseId: '',
treeData: [], treeData: [],
@ -220,7 +221,23 @@ export default {
if (data.length > 0) { if (data.length > 0) {
this.showAlert = false this.showAlert = false
} }
resolve(data) if (data.length > this.treeLimit) {
let subData = data.splice(0, this.treeLimit)
subData.push({
treeId: '---',
deviceId: '---',
name: '加载更多...',
isLeaf: true,
leaf: true,
type: 100,
children: [],
nextData: data.splice(this.treeLimit, data.length)
})
resolve(subData)
}else {
resolve(data)
}
}).finally(() => { }).finally(() => {
this.locading = false this.locading = false
}) })
@ -442,8 +459,37 @@ export default {
}, node.data) }, node.data)
}, },
nodeClickHandler: function(data, node, tree) { nodeClickHandler: function(data, node, tree) {
this.chooseId = data.deviceId
this.$emit('clickEvent', data) if (data && data.nextData && data.nextData.length > 0) {
const parentNode = node.parent
let nextData = data.nextData
if (nextData.length > this.treeLimit) {
let subData = nextData.splice(0, this.treeLimit)
subData.push({
treeId: '---',
deviceId: '---',
name: '加载更多...',
isLeaf: true,
leaf: true,
type: 100,
children: [],
nextData: nextData.splice(this.treeLimit, nextData.length)
})
this.$refs.veTree.remove(data, parentNode)
for (let item of subData) {
this.$refs.veTree.append(item, parentNode)
}
} else {
this.$refs.veTree.remove(data, parentNode)
for (let item of subData) {
this.$refs.veTree.append(item, parentNode)
}
}
}else {
this.chooseId = data.deviceId
this.$emit('clickEvent', data)
}
}, },
listClickHandler: function(data) { listClickHandler: function(data) {
this.chooseId = data.deviceId this.chooseId = data.deviceId