feat(tree): 完成树形组件复选框功能
This commit is contained in:
parent
eef31c72af
commit
377171ab94
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -25,8 +23,6 @@ export default {
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -138,9 +134,8 @@ export default {
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
|
||||||
| Name | Description | Accepted Values |
|
| Name | Description | Accepted Values |
|
||||||
| -------- | ---- | ----------------------- |
|
| ------------------- | ------------- | -------------------- |
|
||||||
| name | 原始属性 name | -- |
|
| name | 原始属性 name | -- |
|
||||||
| skin | 主题 | -- |
|
| skin | 主题 | -- |
|
||||||
| label | 选中值 | -- |
|
| label | 选中值 | -- |
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
fluid ? 'layui-btn-fluid' : '',
|
fluid ? 'layui-btn-fluid' : '',
|
||||||
radius ? 'layui-btn-radius' : '',
|
radius ? 'layui-btn-radius' : '',
|
||||||
border ? 'layui-border-' + border : '',
|
border ? 'layui-border-' + border : '',
|
||||||
disabled ? 'layui-btn-disabled': ''
|
disabled ? 'layui-btn-disabled' : '',
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
@ -20,8 +20,7 @@ import { defineProps, useSlots } from 'vue'
|
|||||||
|
|
||||||
const slot = useSlots()
|
const slot = useSlots()
|
||||||
|
|
||||||
const props =
|
const props = defineProps<{
|
||||||
defineProps<{
|
|
||||||
name?: string
|
name?: string
|
||||||
skin?: string
|
skin?: string
|
||||||
label?: string
|
label?: string
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
<script setup name="LayCheckbox" lang="ts">
|
<script setup name="LayCheckbox" lang="ts">
|
||||||
import { defineProps, ref } from 'vue'
|
import { defineProps, ref } from 'vue'
|
||||||
|
|
||||||
const props =
|
const props = defineProps<{
|
||||||
defineProps<{
|
|
||||||
modelValue: string[]
|
modelValue: string[]
|
||||||
label: string
|
label: string
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
@ -14,7 +14,12 @@
|
|||||||
<div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS">
|
<div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS">
|
||||||
<i class="layui-icon layui-icon-cols" />
|
<i class="layui-icon layui-icon-cols" />
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-inline" title="打印" lay-event="LAYTABLE_PRINT" @click="print()">
|
<div
|
||||||
|
class="layui-inline"
|
||||||
|
title="打印"
|
||||||
|
lay-event="LAYTABLE_PRINT"
|
||||||
|
@click="print()"
|
||||||
|
>
|
||||||
<i class="layui-icon layui-icon-print" />
|
<i class="layui-icon layui-icon-print" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -54,9 +59,9 @@
|
|||||||
<td v-if="checkbox" class="layui-table-col-special">
|
<td v-if="checkbox" class="layui-table-col-special">
|
||||||
<div class="layui-table-cell laytable-cell-checkbox">
|
<div class="layui-table-cell laytable-cell-checkbox">
|
||||||
<table-item-checkbox
|
<table-item-checkbox
|
||||||
|
v-model="tableSelectedKeys"
|
||||||
skin="primary"
|
skin="primary"
|
||||||
:label="data[id]"
|
:label="data[id]"
|
||||||
v-model="tableSelectedKeys"
|
|
||||||
>
|
>
|
||||||
</table-item-checkbox>
|
</table-item-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
<script setup name="LayCheckbox" lang="ts">
|
<script setup name="LayCheckbox" lang="ts">
|
||||||
import { defineProps, ref } from 'vue'
|
import { defineProps, ref } from 'vue'
|
||||||
|
|
||||||
const props =
|
const props = defineProps<{
|
||||||
defineProps<{
|
|
||||||
modelValue: string[]
|
modelValue: string[]
|
||||||
label: string
|
label: string
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
@ -25,10 +25,16 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-transfer-active">
|
<div class="layui-transfer-active">
|
||||||
<lay-button @click="add" type="primary" :disabled="leftSelectedKeys.length==0"
|
<lay-button
|
||||||
|
type="primary"
|
||||||
|
:disabled="leftSelectedKeys.length == 0"
|
||||||
|
@click="add"
|
||||||
><i class="layui-icon layui-icon-next"
|
><i class="layui-icon layui-icon-next"
|
||||||
/></lay-button>
|
/></lay-button>
|
||||||
<lay-button @click="remove" type="primary" :disabled="rightSelectedKeys.length==0"
|
<lay-button
|
||||||
|
type="primary"
|
||||||
|
:disabled="rightSelectedKeys.length == 0"
|
||||||
|
@click="remove"
|
||||||
><i class="layui-icon layui-icon-prev"
|
><i class="layui-icon layui-icon-prev"
|
||||||
/></lay-button>
|
/></lay-button>
|
||||||
</div>
|
</div>
|
||||||
@ -106,13 +112,17 @@ const allLeftChange = function ({ checked }: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(leftSelectedKeys, function(){
|
watch(
|
||||||
|
leftSelectedKeys,
|
||||||
|
function () {
|
||||||
if (leftDataSource.value.length === leftSelectedKeys.value.length) {
|
if (leftDataSource.value.length === leftSelectedKeys.value.length) {
|
||||||
allLeftChecked.value = true
|
allLeftChecked.value = true
|
||||||
} else {
|
} else {
|
||||||
allLeftChecked.value = false
|
allLeftChecked.value = false
|
||||||
}
|
}
|
||||||
},{deep:true})
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
const allRightChange = function ({ checked }: any) {
|
const allRightChange = function ({ checked }: any) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
@ -125,25 +135,29 @@ const allRightChange = function ({ checked }: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(rightSelectedKeys, function(){
|
watch(
|
||||||
|
rightSelectedKeys,
|
||||||
|
function () {
|
||||||
if (rightDataSource.value.length === rightSelectedKeys.value.length) {
|
if (rightDataSource.value.length === rightSelectedKeys.value.length) {
|
||||||
allRightChecked.value = true
|
allRightChecked.value = true
|
||||||
} else {
|
} else {
|
||||||
allRightChecked.value = false
|
allRightChecked.value = false
|
||||||
}
|
}
|
||||||
},{deep:true})
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
const add = function () {
|
const add = function () {
|
||||||
// 删除 leftDataSource 选中的元素
|
// 删除 leftDataSource 选中的元素
|
||||||
rightDataSource.value = leftDataSource.value.filter(
|
rightDataSource.value = leftDataSource.value.filter(
|
||||||
item => leftSelectedKeys.value.indexOf(item.id) != -1
|
(item) => leftSelectedKeys.value.indexOf(item.id) != -1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const remove = function () {
|
const remove = function () {
|
||||||
// 删除 rightDataSource 选中的元素
|
// 删除 rightDataSource 选中的元素
|
||||||
leftDataSource.value = rightDataSource.value.filter(
|
leftDataSource.value = rightDataSource.value.filter(
|
||||||
item => rightSelectedKeys.value.indexOf(item.id) != -1
|
(item) => rightSelectedKeys.value.indexOf(item.id) != -1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user