需求:
我们在开发过程中,会遇到需要将一个数据选择做成穿梭框,但是要求穿梭框左侧为树形结构、右侧为无层级结构的数据展示,ElementUI自身无法在穿梭框中添加树形结构,网上搜到了大佬封装的插件但是对于右侧的无树形结构一点还是不太满足。以下是我们简单的封装写的组件可以实现此功能
1,封装的treeTransfetr组件如下:
<template>
<div class="treeTransfer">
<!-- 左边 -->
<div class="leftTree">
<div class="list">
<div class="left_lowline">
<div class="leftcheck_con">
<el-checkbox v-model="checkedLeft" :disabled="leftTreeData.length < 1" label="" size="large"
style="margin-right: 12px" @change="leftAllCheck" />
<p class="left_title">{
{
props.title[0] }}</p>
</div>
<div>
{
{
leftOperation.length }}/{
{
leftAllselectIdarry.length }}
</div>
</div>
<el-tree
ref="leftTreeRef"
:data="leftTreeData"
show-checkbox
node-key="id"
:props="props.defaultProps"
v-slot="{ node, data }"
accordion
:check-strictly="true"
@check="onCheckLeft"
default-expand-all>
<div>
{
{
data.label }}
</div>
</el-tree>
</div>
</div>
<!-- 中间按钮 -->
<div class="btnDiv">
<div class="mg10">
<el-button @click="toRight()" icon="ele-Right" type="primary" circle :disabled="leftOperation.length < 1"/>
</div>
<div class="mg10">
<el-button @click="toLeft()" icon="ele-Back" type="primary" circle :disabled="rightOperation.length < 1"/>
</div>
</div>
<!-- 右边 -->
<div class="rightTree">
<div class="list">
<div class="left_lowline">
<div class="leftcheck_con">
<el-checkbox v-model="checkedRight" :disabled="rightTreeData.length < 1" label="" size="large"
style="margin-right: 12px" @change="rightAllCheck" />
<p class="left_title">{
{
props.title[1] }}</p>
</div>
<div>
{
{
rightOperation.length }}/{
{
rightAllselectIdarry.length }}
<<