Files
dvcp_v2_wxcp_app/components/AiTreePath.vue

60 lines
1.3 KiB
Vue
Raw Normal View History

2023-05-25 14:54:46 +08:00
<template>
<section class="AiTreePath">
2023-05-25 16:42:32 +08:00
<b v-text="`全部`" @click="$emit('click','all')"/>
<div flex v-for="p in parents" :key="p.id">
<u-icon name="arrow-right" size="32" color="#ccc"/>
<div class="mar-l8" v-text="p[options.label]" @click="$emit('click',p)"/>
</div>
2023-05-25 14:54:46 +08:00
<u-icon v-if="label" name="arrow-right" size="32" color="#ccc"/>
2023-05-25 16:42:32 +08:00
<div class="active" v-text="label" @click="$emit('click',node)"/>
2023-05-25 14:54:46 +08:00
</section>
</template>
<script>
export default {
name: "AiTreePath",
props: {
prop: {default: () => ({})},
2023-05-25 16:42:32 +08:00
paths: {default: () => ({})},
2023-05-25 15:06:40 +08:00
node: {default: null}
2023-05-25 14:54:46 +08:00
},
computed: {
options: v => ({
id: 'id',
label: 'name',
parent: 'parentId',
...v.prop
}),
2023-05-25 15:06:40 +08:00
label: v => v.node?.[v.options.label] || "",
parent: v => v.paths?.[v.node?.[v.options.parent]],
2023-05-25 16:42:32 +08:00
parents() {
const arr = []
const {id: KEY, parent: PARENT} = this.options
const find = n => {
if (!!n?.[KEY]) {
arr.unshift(n)
find(this.paths[n?.[PARENT]])
}
}
find(this.parent)
return arr
}
2023-05-25 14:54:46 +08:00
}
}
</script>
<style scoped lang="scss">
.AiTreePath {
display: flex;
align-items: center;
gap: 8px;
font-size: 36px;
line-height: 40px;
font-family: PingFang-SC;
2023-05-25 16:01:46 +08:00
flex-wrap: wrap;
2023-05-25 15:06:40 +08:00
.active {
font-weight: bold;
color: #26f
}
2023-05-25 14:54:46 +08:00
}
</style>