| | |
| | | <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> |
| | | <el-checkbox v-model="checkedAll" @change="checkedAllChange">列展示</el-checkbox> |
| | | <div style="cursor: pointer" :style="{color:$store.state.settings.theme}" @click="resetColumn">重置</div> |
| | | </div> |
| | | <el-checkbox-group v-model="checkedList"> |
| | | <el-checkbox-group v-model="checkedList" @change="checkedListChange"> |
| | | <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" /> |
| | | <el-checkbox :label="item.label" class="list-complete-item-handle" /> |
| | | </div> |
| | | <div> |
| | | <el-tooltip class="item" effect="dark" content="固定到左侧" placement="bottom"> |
| | | <i |
| | | style="transform:rotate(90deg);cursor:pointer;" |
| | | style="transform:rotate(90deg);cursor:pointer;font-weight: bolder" |
| | | class="el-icon-download" |
| | | @click="fixedToLeft(item.name)" |
| | | :style="{color:item.fixed==='left'?$store.state.settings.theme:''}" |
| | | @click="fixedToLeft(item.label)" |
| | | /> |
| | | </el-tooltip> |
| | | <el-divider direction="vertical" /> |
| | | <el-tooltip class="item" effect="dark" content="固定到右侧" placement="bottom"> |
| | | <i |
| | | style="transform:rotate(-90deg);cursor:pointer" |
| | | style="transform:rotate(-90deg);cursor:pointer;font-weight: bolder" |
| | | class="el-icon-download" |
| | | @click="fixedToRight(item.name)" |
| | | :style="{color:item.fixed==='right'?$store.state.settings.theme:''}" |
| | | @click="fixedToRight(item.label)" |
| | | /> |
| | | </el-tooltip> |
| | | </div> |
| | |
| | | return [] |
| | | } |
| | | } |
| | | |
| | | }, |
| | | data() { |
| | | return { |
| | | checkedList: ['楼李俊2'], |
| | | checkedList: this.list1.map(i => i.show ? i.label : '').filter(i => i !== ''), // 列展示值 |
| | | checkedListDefaultLabel: this.list1.map(i => i.show ? i.label : '').filter(i => i !== ''), // 重置默认值label |
| | | // checkedListDefaultFixed: this.list1.map(i => i.show ? i.label : '').filter(i => i !== ''), // 重置默认值fixed |
| | | checkedAll: true |
| | | } |
| | | }, |
| | | created() { |
| | | }, |
| | | mounted() { |
| | | }, |
| | | methods: { |
| | | setData(dataTransfer) { |
| | |
| | | // Detail see : https://github.com/RubaXa/Sortable/issues/1012 |
| | | dataTransfer.setData('Text', '') |
| | | }, |
| | | // 重置 |
| | | resetColumn() { |
| | | console.log('resetColumn') |
| | | this.checkedList = this.checkedListDefaultLabel |
| | | this.list1.forEach((i, j) => { |
| | | i.show = !!this.checkedListDefaultLabel.includes(i.label) |
| | | }) |
| | | this.$emit('tableColumnUpdate', this.checkedListDefaultLabel) |
| | | }, |
| | | checkedAllClick() { |
| | | console.log('checkedAllClick') |
| | | // 列展示 |
| | | checkedAllChange() { |
| | | this.list1.forEach(i => { |
| | | if (this.checkedAll) { |
| | | i.show = true |
| | | this.checkedList = this.list1.map(j => j.label) |
| | | } else { |
| | | i.show = false |
| | | this.checkedList = [] |
| | | } |
| | | }) |
| | | this.$emit('tableColumnUpdate', this.checkedList) |
| | | }, |
| | | // 固定到左侧 |
| | | fixedToLeft(val) { |
| | | console.log('fixedToLeft', val) |
| | | this.list1.find(i => i.label === val).fixed = this.list1.find(i => i.label === val).fixed !== 'left' ? 'left' : false |
| | | this.$emit('tableColumnUpdate', this.checkedList) |
| | | }, |
| | | // 固定到右侧 |
| | | fixedToRight(val) { |
| | | console.log('fixedToRight', val) |
| | | this.list1.find(i => i.label === val).fixed = this.list1.find(i => i.label === val).fixed !== 'right' ? 'right' : false |
| | | this.$emit('tableColumnUpdate', this.checkedList) |
| | | }, |
| | | // 拖动结束事件 |
| | | draggableEnded({ to, from, item, clone, oldIndex, newIndex }) { |
| | | console.log(to, from, item, clone, oldIndex, newIndex) |
| | | |
| | | // console.log(this.list1, 123456789) |
| | | this.$emit('tableColumnUpdate', this.list1, true)// 传给爷爷 isCopyTrue:复值给爷爷 |
| | | }, |
| | | // 多选框值改变事件 |
| | | checkedListChange(val) { |
| | | console.log(val, 1) |
| | | this.checkedAll = val.length !== 0 |
| | | this.list1.forEach((i, j) => { |
| | | i.show = !!val.includes(i.label) |
| | | }) |
| | | this.$emit('tableColumnUpdate', val) |
| | | } |
| | | } |
| | | } |
| | |
| | | <style lang="scss" scoped> |
| | | .dndList { |
| | | background: #fff; |
| | | padding-bottom: 40px; |
| | | //padding-bottom: 40px; |
| | | |
| | | &:after { |
| | | content: ""; |
| | |
| | | |
| | | .dndList-list { |
| | | float: left; |
| | | padding-bottom: 30px; |
| | | //padding-bottom: 30px; |
| | | |
| | | &:first-of-type { |
| | | margin-right: 2%; |