loulijun2021
2023-01-04 0b1837e9b6d1ac8825e9c1acf6f0cd5b2b14a897
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<template>
  <div class="dndList">
    <div :style="{width:'100%'}" class="dndList-list">
      <div style="display: flex;justify-content: space-between;">
        <el-checkbox v-model="checkedAll" @change="checkedAllClick">列展示</el-checkbox>
        <div style="cursor: pointer" :style="{color:$store.state.settings.theme}" @click="resetColumn">重置</div>
      </div>
      <el-checkbox-group v-model="checkedList">
        <draggable :set-data="setData" :list="list1" class="dragArea" animation="300" @end="draggableEnded">
          <div v-for="item in list1" :key="item.id" class="list-complete-item">
            <div style="display: flex">
              <div style="width: 20px;height: 20px;margin-right: 4px;cursor:move"><i class="el-icon-rank" /></div>
              <el-checkbox :label="item.name" class="list-complete-item-handle" />
            </div>
            <div>
              <el-tooltip class="item" effect="dark" content="固定到左侧" placement="bottom">
                <i
                  style="transform:rotate(90deg);cursor:pointer;"
                  class="el-icon-download"
                  @click="fixedToLeft(item.name)"
                />
              </el-tooltip>
              <el-divider direction="vertical" />
              <el-tooltip class="item" effect="dark" content="固定到右侧" placement="bottom">
                <i
                  style="transform:rotate(-90deg);cursor:pointer"
                  class="el-icon-download"
                  @click="fixedToRight(item.name)"
                />
              </el-tooltip>
            </div>
          </div>
        </draggable>
      </el-checkbox-group>
 
    </div>
 
  </div>
</template>
 
<script>
import draggable from 'vuedraggable'
 
export default {
  name: 'DndList',
  components: { draggable },
  props: {
    list1: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      checkedList: ['楼李俊2'],
      checkedAll: true
    }
  },
  methods: {
    setData(dataTransfer) {
      // to avoid Firefox bug
      // Detail see : https://github.com/RubaXa/Sortable/issues/1012
      dataTransfer.setData('Text', '')
    },
    resetColumn() {
      console.log('resetColumn')
    },
    checkedAllClick() {
      console.log('checkedAllClick')
    },
    fixedToLeft(val) {
      console.log('fixedToLeft', val)
    },
    fixedToRight(val) {
      console.log('fixedToRight', val)
    },
    draggableEnded({ to, from, item, clone, oldIndex, newIndex }) {
      console.log(to, from, item, clone, oldIndex, newIndex)
    }
  }
}
</script>
 
<style lang="scss" scoped>
.dndList {
  background: #fff;
  padding-bottom: 40px;
 
  &:after {
    content: "";
    display: table;
    clear: both;
  }
 
  .dndList-list {
    float: left;
    padding-bottom: 30px;
 
    &:first-of-type {
      margin-right: 2%;
    }
 
    .dragArea {
      margin-top: 15px;
      min-height: 50px;
      padding-bottom: 30px;
    }
  }
}
 
.list-complete-item {
  cursor: pointer;
  position: relative;
  font-size: 14px;
  padding: 5px 5px;
  margin-top: 4px;
  //border: 1px solid #bfcbd9;
  transition: all 1s;
  display: flex;
  justify-content: space-between;
}
 
.list-complete-item-handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 50px;
}
 
.list-complete-item.sortable-chosen {
  background: #b0e2f6;
}
 
.list-complete-item.sortable-ghost {
  background: #e6f7ff;
}
 
.list-complete-enter,
.list-complete-leave-active {
  opacity: 0;
}
</style>