update 树样式

This commit is contained in:
赵霄
2023-08-25 18:02:42 +08:00
parent c4caed0e3f
commit 5f9726840d
8 changed files with 231 additions and 6 deletions
@@ -1,13 +1,155 @@
<template>
<div></div>
<a-card :bordered="false" class="page-left-right-layout">
<div class="page-left-box">
<!-- $t('standardRegulationLibrary.domesticStandard.treeSearchPlaceholder')-->
<a-input-search v-model="treeInput" :placeholder="$t('standardRegulationLibrary.domesticStandard.treeSearchPlaceholder')"
@search="handleTableSearch" />
<img src="">
<a-tree :show-line="true" :show-icon="true" :tree-data=treeData>
<template #iconCustom="{title}">
<div class="tree-node">
<img src="@/assets/image/common/iconTreeFolder.png" class="tree-node-icon" />
<a-tooltip>
<template #title>
{{ title }}
</template>
<span class="tree-node-title">{{ title }}</span>
</a-tooltip>
</div>
</template>
<template #custom="{title, key}">
<div class="tree-operate-node" @mouseenter="handleTreeMouseover(key)" @mouseleave="handleTreeMouseout(key)">
<a-tooltip>
<template #title>
{{ title }}
</template>
<span class="tree-node-custom-title">{{ title }}</span>
</a-tooltip>
<template v-if="key === mouseInNodeKey">
<a-button icon="plus" class="tree-operate-node-btn">
</a-button>
<a-button class="tree-operate-node-btn">
<img src="@/assets/image/common/iconTreeEdit.png" />
</a-button>
<a-button class="tree-operate-node-btn">
<img src="@/assets/image/common/iconTreeDelete.png" />
</a-button>
</template>
</div>
</template>
</a-tree>
</div>
<div class="page-right-box"></div>
</a-card>
</template>
<script>
import '@assets/less/common.less'
const apiTreeData = [
{
title: 'parent 1',
key: '0-0',
child: [
{
title: '张晨成',
key: '0-0-0',
disabled: true,
child: [
{ title: 'leaf', key: '0-0-0-0' },
{ title: 'leaf', key: '0-0-0-1' }
]
},
{
title: 'parent 1-1',
key: '0-0-1',
child: [{ key: '0-0-1-0', title: 'zcvc' }]
}
]
}
]
export default {
name: 'DomesticStandardList'
name: 'DomesticStandardList',
data () {
return {
treeInput: null, // 树查询绑定值
treeData: [],
mouseInNodeKey: null // 鼠标悬浮的节点key值
}
},
created () {
this.initTreeData()
},
methods: {
initTreeData () {
this.treeData = this.dealTreeData(apiTreeData)
console.log(this.treeData)
},
dealTreeData (treeData) {
return treeData.map(item => {
if (item.child && item.child.length > 0) {
item.scopedSlots = { title: 'iconCustom' }
item.children = this.dealTreeData(item.child)
} else {
item.scopedSlots = { title: 'custom' }
}
return item
})
},
handleTableSearch () {
},
handleTreeMouseover (key) {
this.mouseInNodeKey = key
},
handleTreeMouseout (key) {
if (this.mouseInNodeKey === key) {
this.mouseInNodeKey = null
}
}
}
}
</script>
<style scoped>
<style scoped lang="less">
/deeo/ .ant-tree li span.ant-tree-iconEle {
display: flex;
justify-content: center;
align-items: center;
}
.tree-icon {
line-height: 24px;
}
.tree-operate-node {
display: flex;
width: 100%;
align-items: center;
&-btn {
width: 20px;
height: 20px;
background: rgba(213, 44, 38, 0.08);
border-radius: 2px 2px 2px 2px;
border: none;
display: flex;
align-items: center;
justify-content: center;
margin-left: 4px;
padding: 0;
/deep/ .anticon {
margin-top: 2px;
color: #D52C26;
}
img {
width: 13px;
height: 13px;
}
}
}
</style>