feiyu02
2025-09-17 b330e57051e54789eb83d10dc58c4d9d10c608e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
  <el-row justify="center" class="t-title">{{ title }}</el-row>
  <el-row justify="center">
    <el-transfer
      class="t-transfer"
      v-model="rightData"
      filterable
      :titles="titles"
      :button-texts="buttonTexts"
      :format="{
        noChecked: '${total}',
        hasChecked: '${checked}/${total}',
      }"
      :data="leftData"
      target-order="push"
      @change="handleChange"
    >
      <template #default="{ option }">
        <div class="t-transfer-item">
          <span>{{ option.label }}</span>
          <div>
            <el-icon><ArrowUp /></el-icon>
            <el-icon><ArrowDown /></el-icon>
          </div>
        </div>
      </template>
      <!-- <template #left-footer>
        <el-button class="transfer-footer" size="small">Operation</el-button>
      </template>
      <template #right-footer>
        <el-button class="transfer-footer" size="small">Operation</el-button>
      </template> -->
    </el-transfer>
  </el-row>
</template>
 
<script>
export default {
  props: {
    title: {
      type: String,
      default: '标题',
    },
    titleJustify: {
      type: String,
      default: 'start',
    },
    leftValue: {
      type: Array,
    },
    rightValue: {
      type: Array,
    },
  },
  data() {
    return {
      leftData: [],
      rightData: [],
    };
  },
  watch: {
    leftValue(nV) {
      this.leftData = nV;
    },
    rightValue(nV) {
      this.rightData = nV;
    },
  },
  computed: {
    titles() {
      return this.titleJustify == 'left'
        ? ['场景列表', '已选择']
        : ['已选择', '场景列表'];
    },
    buttonTexts() {
      return this.titleJustify == 'left' ? ['移除', '添加'] : ['添加', '移除'];
    },
  },
  methods: {
    handleChange(value, direction, movedKeys) {
      console.log(value, direction, movedKeys);
    },
  },
  created() {
    const data = [];
    for (let i = 1; i <= 15; i++) {
      data.push({
        key: i,
        label: `Option ${i}`,
        disabled: i % 4 === 0,
      });
    }
    this.leftData = data;
  },
};
</script>
<style>
.t-title {
  font-size: 20px;
  margin-bottom: 10px;
}
 
.t-transfer {
  /* background-color: aliceblue; */
  --el-transfer-panel-width: 300px;
  --el-transfer-panel-body-height: 600px;
}
 
.t-transfer-item {
  background-color: aliceblue;
  display: flex;
  justify-content: space-between;
}
</style>