Skip to content

TreeTransfer

Allows selection within a tree structure.

Basic

filterable:

List 1
List 2

hl.transfer.noData

The filter function uses the filterNodeMethod defined in treeProps for both the left and right sides.
vue
<template>
  <p>filterable: <el-checkbox v-model="filterable" /></p>
  <epp-tree-transfer v-model="value" :filterable="filterable" :tree-props="treeProps" />
</template>

<script lang="ts" setup>
import { ref, reactive } from 'vue';

const filterNode = (value: string, data: { label: string }) => {
  if (!value) return true;
  return data.label.indexOf(value) !== -1;
};

const value = ref(['2']);
const filterable = ref(true);
const treeProps = reactive({
  nodeKey: 'id',
  checkStrictly: true,
  showCheckbox: false,
  filterNodeMethod: filterNode,
  data: [
    {
      label: 'xxxx自治区',
      id: '1',
      childrens: [
        {
          label: '城市1',
          id: '2',
          childrens: [
            { label: '区域1', id: '7', childrens: [] },
            { label: '区域2', id: '8', childrens: [] },
            {
              label: '县级1',
              id: '9',
              childrens: [
                {
                  label: '测试乡镇测试乡镇测试乡镇测试乡镇测试乡镇测试乡镇测试乡镇',
                  id: '8-1',
                  childrens: [],
                },
                { label: '测试乡镇2', id: '8-2', childrens: [] },
                { label: '测试乡镇3', id: '8-3', childrens: [] },
              ],
            },
          ],
        },
        {
          label: '城市2',
          id: '3',
          disabled: true,
          childrens: [
            {
              label: '区域1',
              id: '10',
              disabled: true,
              childrens: [],
            },
            {
              label: '区域2',
              id: '11',
              disabled: true,
              childrens: [],
            },
            {
              label: '区域3',
              id: '12',
              disabled: true,
              childrens: [],
            },
          ],
        },
        { label: '城市3', id: '4', childrens: [] },
        { label: '城市4', id: '5', childrens: [] },
        { label: '城市5', id: '6', childrens: [] },
      ],
    },
  ],
  props: {
    children: 'childrens',
    label: 'label',
  },
});
</script>

Attributes

ParameterDescriptionTypeOptional ValuesDefault Value
model-value / v-modelBound valuearray
tree-propsTree properties for the left side. See the Tree component. nodeKey is set to id by default.object--
titlesCustom list titlesarray-['List 1', 'List 2']
filter-placeholderSearch box placeholderstringEnter keyword
render-contentCustom data item rendering function. Parameters are: h function; tree node data; left/right identifier. Applies to both sides.function(h, data, mark)-
filterableWhether searching is enabledbooleanfalse

Slots

NameDescription
left-footerContent at the bottom of the left list
right-footerContent at the bottom of the right list

Methods

方法名说明参数
clearQueryClears the search keywords for a specific panel'left' / 'right', specifies the panel to clear