Compare commits

..

2 Commits

Author SHA1 Message Date
yangws b3b4f29d5d Merge pull request 'add:章节节点选择;' (#23) from yangws_ws into main
Reviewed-on: #23
2024-11-12 09:49:34 +08:00
小杨 5dc9e4e20d add:章节节点选择; 2024-11-12 09:49:09 +08:00
1 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,59 @@
<template>
<div style="padding: 10px;">
<el-dialog
v-model="dialogVisible"
width="30%"
append-to-body
>
<div style="display: flex;justify-content: center;">
<ChooseTextbook @node-click="nodeClick" />
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click.stop="save">确定</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { ref, defineExpose } from 'vue'
import ChooseTextbook from '@/components/choose-textbook/index.vue'
const dialogVisible = ref(false)
const getNodeInfo = ref([])
const openDialog = () => {
dialogVisible.value = true
}
const getFullObj = (node) => {
const obj = []
const recursive = (currentNode) => {
//
if (currentNode.parentNode) {
obj.unshift(Object.assign({curentId: currentNode.id,title:currentNode.itemtitle}, currentNode.parentNode))
recursive(currentNode.parentNode)
} else {
obj.unshift({id: currentNode.id,title:currentNode.itemtitle})
}
}
recursive(node)
return obj
}
const nodeClick = (data) => {
getNodeInfo.value = getFullObj(data.node)
console.log(getNodeInfo.value, 'getNodeInfo.value')
}
const save = () => {
dialogVisible.value = false
}
defineExpose({
openDialog
})
</script>