diff --git a/src/assets/css/space/familyTree.css b/src/assets/css/space/familyTree.css new file mode 100644 index 00000000..631070bb --- /dev/null +++ b/src/assets/css/space/familyTree.css @@ -0,0 +1,132 @@ +.background { + display: flex; + align-content: center; + justify-content: center; + background-image: url("../../pictures/space/Inbase3.png"); + background-size: cover; + background-position: center top; + background-repeat: no-repeat; + min-height: calc(100vh - 60px); + width: 100%; + } + + .tree { + display: flex; + flex-direction: column; + background: rgba(255, 255, 255, 0.8); + width: 1100px; + border-radius: 30px; + margin-top: 30px; + margin-left: 240px; + justify-content: center; + align-items: center; + flex-shrink: 0; + } + + .operation-bar { + margin-bottom: 20px; + text-align: center; + } + + .tree-container { + overflow: auto; + padding: 20px; + } + + /* 节点样式 */ + .custom-node { + display: flex; + flex-direction: column; + align-items: center; + padding: 10px; + border: 1px solid #dcdfe6; + border-radius: 8px; + background: white; + min-width: 150px; + } + + .current-user { + border: 2px solid #409EFF; + background: #ecf5ff; + } + + .node-info { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + cursor: pointer; + padding: 10px; + border-radius: 8px; + transition: all 0.3s; + margin-top: 8px; + } + + .node-info:hover { + background: rgba(0, 0, 0, 0.1); + } + + /* 文字样式 */ + .name { + font-weight: bold; + font-size: 16px; + margin-bottom: 4px; + } + + .relation { + color: #666; + font-size: 12px; + } + + .birth-date, + .phone { + color: #999; + font-size: 12px; + } + + /* 头像上传样式 */ + .avatar-uploader { + text-align: center; + } + + .avatar-wrapper { + display: flex; + align-items: center; + justify-content: center; + border: 1px dashed #d9d9d9; + border-radius: 6px; + cursor: pointer; + overflow: hidden; + width: 120px; + height: 120px; + } + + .avatar-wrapper:hover { + border-color: #409EFF; + } + + .avatar { + width: 120px; + height: 120px; + display: block; + object-fit: cover; + } + + .el-icon { + font-size: 28px; + color: #8c939d; + width: 100%; + height: 100%; + line-height: 100px; + text-align: center; + } + + .file-input { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + opacity: 0; + cursor: pointer; + } \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index a6e30db7..574eec5a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,7 +5,7 @@ import community from '@/views/community/trends.vue' import chat from '@/views/chat/chat.vue' import space from '@/views/space/space.vue' import informationPage from '@/views/space/informationPage.vue' -import familyTree from '@/views/space/familyTree1.vue' +import familyTree from '@/views/space/familyTree.vue' import {createRouter ,createWebHashHistory} from 'vue-router' diff --git a/src/utils/treeUtils.js b/src/utils/treeUtils.js new file mode 100644 index 00000000..ec784434 --- /dev/null +++ b/src/utils/treeUtils.js @@ -0,0 +1,26 @@ +// 将树形数据扁平化 +export function flattenTree(tree) { + const result = [] + + function flatten(node) { + if (!node) return + + result.push({ + id: node.id, + name: node.name, + parentId: node.parentId, + avatar: node.avatar, + relation: node.relation, + birthDate: node.birthDate, + phone: node.phone, + isCurrentUser: node.isCurrentUser + }) + + if (Array.isArray(node.children)) { + node.children.forEach(child => flatten(child)) + } + } + + flatten(tree) + return result + } \ No newline at end of file diff --git a/src/views/space/familyTree.vue b/src/views/space/familyTree.vue index 230a45ed..fa2dd958 100644 --- a/src/views/space/familyTree.vue +++ b/src/views/space/familyTree.vue @@ -1,244 +1,399 @@ \ No newline at end of file diff --git a/src/views/space/informationPage.vue b/src/views/space/informationPage.vue index 59a2820a..be84a19b 100644 --- a/src/views/space/informationPage.vue +++ b/src/views/space/informationPage.vue @@ -46,7 +46,7 @@