fix: fix tree cant be chechked

This commit is contained in:
落小梅 2021-12-17 13:15:44 +08:00
parent 4aa945c68b
commit 6a92e6e0ec
5 changed files with 2408 additions and 4 deletions

2400
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ export default {
};
</script>
<script setup name="LayCheckbox" lang="ts">
<script setup lang="ts">
import { computed, defineProps, inject } from "vue";
import "./index.less";
@ -108,4 +108,4 @@ const handleClick = function () {
<i class="layui-icon layui-icon-ok" />
</div>
</span>
</template>
</template>

View File

@ -113,11 +113,12 @@ function handleTitleClick(node: TreeData) {
</span>
<LayCheckbox
v-if="showCheckbox"
v-model:checked="node.isChecked.value"
:modelValue="node.isChecked.value"
:disabled="node.isDisabled.value"
skin="primary"
label=""
@change="
({ checked }) => {
(checked) => {
handleChange(checked, node)
}
"

View File

@ -135,6 +135,7 @@ class Tree {
setChildrenChecked(checked: boolean, nodes: TreeData[]) {
const len = nodes.length
for (let i = 0; i < len; i++) {
console.log(nodes[i], checked);
nodes[i].isChecked.value = checked
nodes[i].children &&
nodes[i].children.length > 0 &&
@ -167,6 +168,7 @@ class Tree {
if (node.children) {
this.setChildrenChecked(checked, node.children)
}
console.log(this.getData());
}
getData() {

View File

@ -29,6 +29,7 @@ export const useTree: UseTree = (props: TreeProps, emit: TreeEmits) => {
const nodeList = computed(() => {
const nodes = tree.getData()
console.log(nodes);
return nodes
})