This commit is contained in:
仲么了
2024-02-21 16:41:42 +08:00
4 changed files with 2105 additions and 1332 deletions

View File

@@ -54,3 +54,24 @@ export function nodeAllList() {
method: 'get' method: 'get'
}) })
} }
//修改数据
export function updateTerminal(query:any) {
return createAxios({
url: `/device-boot/device/updateTerminal`,
method: 'put',
data: {
...query,
}
})
}
//提交数据
export function addTerminal(query:any) {
return createAxios({
url: '/device-boot/device/addTerminal',
method: 'post',
data: {
...query,
}
})
}

View File

@@ -13,37 +13,41 @@ defineOptions({
}) })
const emit = defineEmits(['init']) const emit = defineEmits(['init'])
const config = useConfig() const config = useConfig()
const expanded:any = ref([]) const expanded: any = ref([])
const tree = ref() const tree = ref()
const treRef = ref() const treRef = ref()
getTerminalTree().then(res => { const info = (id: any) => {
// let arr: any[] = []
res.data.forEach((item: any) => { expanded.value = [id]
item.icon = 'el-icon-Menu' getTerminalTree().then(res => {
item.level = 0 // let arr: any[] = []
item.children.forEach((item2: any) => { res.data.forEach((item: any) => {
item2.icon = 'el-icon-HomeFilled' item.icon = 'el-icon-Menu'
item2.level = 100 item.level = 0
expanded.value.push(item2.id) item.children.forEach((item2: any) => {
item2.children.forEach((item3: any) => { item2.icon = 'el-icon-HomeFilled'
item3.icon = 'el-icon-CollectionTag' item2.level = 100
item3.level = 200 expanded.value.push(item2.id)
item3.children.forEach((item4: any) => { item2.children.forEach((item3: any) => {
item4.icon = 'el-icon-Flag' item3.icon = 'el-icon-CollectionTag'
item4.level = 300 item3.level = 200
// arr.push(item4) item3.children.forEach((item4: any) => {
item4.children.forEach((item5: any) => { item4.icon = 'el-icon-Flag'
item5.icon = 'el-icon-OfficeBuilding' item4.level = 300
item5.level = 400 // arr.push(item4)
item5.children.forEach((item6: any) => { item4.children.forEach((item5: any) => {
item6.icon = 'el-icon-Film' item5.icon = 'el-icon-OfficeBuilding'
item6.level = 500 item5.level = 400
item6.children.forEach((item7: any) => { item5.children.forEach((item6: any) => {
item7.icon = 'el-icon-Share' item6.icon = 'el-icon-Film'
item7.level = 600 item6.level = 500
item7.children.forEach((item8: any) => { item6.children.forEach((item7: any) => {
item8.icon = 'el-icon-Location' item7.icon = 'el-icon-Share'
item8.level = 700 item7.level = 600
item7.children.forEach((item8: any) => {
item8.icon = 'el-icon-Location'
item8.level = 700
})
}) })
}) })
}) })
@@ -51,21 +55,26 @@ getTerminalTree().then(res => {
}) })
}) })
}) })
tree.value = res.data
nextTick(() => {
treRef.value.setCurrentKey(id)
// if (arr.length) {
// treRef.value.treeRef.setCurrentKey(arr[0].id)
// // 注册父组件事件
// emit('init', {
// level: 2,
// ...arr[0]
// })
// } else {
// emit('init')
// }
})
}) })
tree.value = res.data }
nextTick(() => { info('')
// if (arr.length) {
// treRef.value.treeRef.setCurrentKey(arr[0].id) defineExpose({ info })
// // 注册父组件事件
// emit('init', {
// level: 2,
// ...arr[0]
// })
// } else {
// emit('init')
// }
})
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.el-tree { .el-tree {

View File

@@ -87,7 +87,11 @@ const filterNode = (value: string, data: any) => {
return data.name.includes(value) return data.name.includes(value)
} }
const treeRef = ref<InstanceType<typeof ElTree>>() const treeRef = ref<InstanceType<typeof ElTree>>()
defineExpose({ treeRef }) const setCurrentKey=(e:string)=>{
treeRef.value!.setCurrentKey(e)
}
defineExpose({ treeRef,setCurrentKey })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

File diff suppressed because it is too large Load Diff