(component): tree组件 加入半选状态,优化data改变是视图更新,优化checkedKeys支持下级节点,默认开启过渡动画,优化关闭连线后支持行内点击

This commit is contained in:
0o张不歪o0
2022-07-11 11:08:34 +08:00
parent 401bc9db63
commit a2967fb2cb
6 changed files with 282 additions and 64 deletions

View File

@@ -185,7 +185,7 @@ export default {
::: title 半选状态
:::
::: demo 在实现全选效果时,你可能会用到 indeterminate 属性。
::: demo 在实现全选效果时,你可能会用到 isIndeterminate 属性。
<template>
<lay-checkbox name="like" skin="primary" label="1" :isIndeterminate="true" v-model="checked8">半选</lay-checkbox>

View File

@@ -184,7 +184,7 @@ const data = ref([{
}]);
function handleClick(node) {
clickNode.value = node
console.log(node)
}
</script>
@@ -197,17 +197,185 @@ function handleClick(node) {
<template>
<lay-tree
:data="data"
v-model:checkedKeys="checkedKeys"
:showCheckbox="showCheckbox"
:data="data2"
v-model:checkedKeys="checkedKeys"
:showCheckbox="showCheckbox"
collapse-transition
>
</lay-tree>
<br/>
<lay-button @click="updateView">更新视图</lay-button>
<lay-button @click="updateCheckedKeys">更新checkedKeys</lay-button>
</template>
<script setup>
import { ref } from 'vue';
const checkedKeys = ref([30,31])
const updateCheckedKeys=()=>{
checkedKeys.value=[4]
}
const data2 = ref([{
title: '一级1',
id: 1,
field: 'name1',
checked: true,
spread: true,
children: [{
title: '二级1-1 可允许跳转',
id: 3,
field: 'name11',
href: 'https://www.layui.com/',
children: [{
title: '三级1-1-3',
id: 23,
field: '',
children: [{
title: '四级1-1-3-1',
id: 24,
field: '',
children: [{
title: '五级1-1-3-1-1',
id: 30,
field: ''
},
{
title: '五级1-1-3-1-2',
id: 31,
field: ''
}]
}]
},
{
title: '三级1-1-1',
id: 7,
field: '',
children: [{
title: '四级1-1-1-1 可允许跳转',
id: 15,
field: '',
href: 'https://www.layui.com/doc/'
}]
},
{
title: '三级1-1-2',
id: 8,
field: '',
children: [{
title: '四级1-1-2-1',
id: 32,
field: ''
}]
}]
},
{
title: '二级1-2',
id: 4,
spread: true,
children: [{
title: '三级1-2-1',
id: 9,
field: '',
disabled: true
},
{
title: '三级1-2-2',
id: 10,
field: ''
}]
},
{
title: '二级1-3',
id: 20,
field: '',
children: [{
title: '三级1-3-1',
id: 21,
field: ''
},
{
title: '三级1-3-2',
id: 22,
field: ''
}]
}]
},
{
title: '一级2',
id: 2,
field: '',
spread: true,
children: [{
title: '二级2-1',
id: 5,
field: '',
spread: true,
children: [{
title: '三级2-1-1',
id: 11,
field: ''
},
{
title: '三级2-1-2',
id: 12,
field: ''
}]
},
{
title: '二级2-2',
id: 6,
field: '',
children: [{
title: '三级2-2-1',
id: 13,
field: ''
},
{
title: '三级2-2-2',
id: 14,
field: '',
disabled: true
}]
}]
},
{
title: '一级3',
id: 16,
field: '',
children: [{
title: '二级3-1',
id: 17,
field: '',
fixed: true,
children: [{
title: '三级3-1-1',
id: 18,
field: ''
},
{
title: '三级3-1-2',
id: 19,
field: ''
}]
},
{
title: '二级3-2',
id: 27,
field: '',
children: [{
title: '三级3-2-1',
id: 28,
field: ''
},
{
title: '三级3-2-2',
id: 29,
field: ''
}]
}]
}]);
const updateView=()=>{
data2.value[0].title='更新视图'
}
const checkedKeys = ref([2,3])
const showCheckbox = ref(true)
</script>
@@ -234,25 +402,6 @@ const showLine=ref(false)
:::
::: title 过渡动画
:::
::: demo 使用 `collapse-transition` 属性开启展开过渡动画
<template>
<lay-tree
:data="data"
collapse-transition
>
</lay-tree>
</template>
<script setup>
import { ref } from 'vue';
</script>
:::
::: title 定义标题
:::

View File

@@ -11,7 +11,20 @@
<template>
<lay-timeline>
<lay-timeline-item title="1.2.x">
<ul>
<ul>
<a name="1-2-9"></a>
<li>
<h3>1.2.9 <span class="layui-badge-rim">2022-07-12</span></h3>
<ul>
<li>[优化] tree 组件 支持更改data数据后刷新视图。 by @SmallWai</li>
<li>[优化] tree 组件 checkedKeys支持下级节点 by @SmallWai</li>
<li>[优化] tree 组件 关闭连线后启用行内点击 by @SmallWai</li>
<li>[优化] tree 组件 默认启用过渡动画 by @SmallWai</li>
<li>[新增] tree 组件 加入半选状态 by @SmallWai</li>
</ul>
</li>
</ul>
<ul>
<a name="1-2-8"></a>
<li>
<h3>1.2.8 <span class="layui-badge-rim">2022-07-08</span></h3>