Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1d684b7632 | ||
|
cbdad9cb1b | ||
|
1a345a7c65 | ||
|
ec58373a52 | ||
|
bf2629ffba |
@@ -118,6 +118,7 @@ Understanding and learning this knowledge in advance will greatly help the use o
|
||||
- Avatar Upload
|
||||
- Back To Top
|
||||
- Drag Dialog
|
||||
- Drag Select
|
||||
- Drag Kanban
|
||||
- Drag List
|
||||
- SplitPane
|
||||
|
@@ -130,6 +130,7 @@
|
||||
- 头像上传
|
||||
- 返回顶部
|
||||
- 拖拽Dialog
|
||||
- 拖拽Select
|
||||
- 拖拽看板
|
||||
- 列表拖拽
|
||||
- SplitPane
|
||||
|
@@ -9,7 +9,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
// const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
|
||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
|
||||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
||||
|
||||
function resolve(dir) {
|
||||
@@ -140,7 +140,7 @@ const webpackConfig = merge(baseWebpackConfig, {
|
||||
}),
|
||||
// Compress extracted CSS. We are using this plugin so that possible
|
||||
// duplicated CSS from different components can be deduped.
|
||||
// new OptimizeCSSAssetsPlugin()
|
||||
new OptimizeCSSAssetsPlugin()
|
||||
]
|
||||
}
|
||||
})
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-element-admin",
|
||||
"version": "3.9.2",
|
||||
"version": "3.9.3",
|
||||
"description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features",
|
||||
"author": "Pan <panfree23@gmail.com>",
|
||||
"license": "MIT",
|
||||
|
61
src/components/DragSelect/index.vue
Normal file
61
src/components/DragSelect/index.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<el-select v-model="selectVal" v-bind="$attrs" class="drag-select" multiple>
|
||||
<slot/>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Sortable from 'sortablejs'
|
||||
|
||||
export default {
|
||||
name: 'DragSelect',
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
selectVal: {
|
||||
get() {
|
||||
return [...this.value]
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('input', [...val])
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.setSort()
|
||||
},
|
||||
methods: {
|
||||
setSort() {
|
||||
const el = document.querySelectorAll('.el-select__tags > span')[0]
|
||||
this.sortable = Sortable.create(el, {
|
||||
ghostClass: 'sortable-ghost', // Class name for the drop placeholder,
|
||||
setData: function(dataTransfer) {
|
||||
dataTransfer.setData('Text', '')
|
||||
// to avoid Firefox bug
|
||||
// Detail see : https://github.com/RubaXa/Sortable/issues/1012
|
||||
},
|
||||
onEnd: evt => {
|
||||
const targetRow = this.value.splice(evt.oldIndex, 1)[0]
|
||||
this.value.splice(evt.newIndex, 0, targetRow)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.drag-select >>> .sortable-ghost{
|
||||
opacity: .8;
|
||||
color: #fff!important;
|
||||
background: #42b983!important;
|
||||
}
|
||||
|
||||
.drag-select >>> .el-tag{
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
@@ -22,6 +22,7 @@ export default {
|
||||
componentMixin: 'Mixin',
|
||||
backToTop: 'BackToTop',
|
||||
dragDialog: 'Drag Dialog',
|
||||
dragSelect: 'Drag Select',
|
||||
dragKanban: 'Drag Kanban',
|
||||
charts: 'Charts',
|
||||
keyboardChart: 'Keyboard Chart',
|
||||
|
@@ -22,6 +22,7 @@ export default {
|
||||
componentMixin: 'Mixin',
|
||||
backToTop: 'Ir arriba',
|
||||
dragDialog: 'Drag Dialog',
|
||||
dragSelect: 'Drag Select',
|
||||
dragKanban: 'Drag Kanban',
|
||||
charts: 'Gráficos',
|
||||
keyboardChart: 'Keyboard Chart',
|
||||
|
@@ -22,6 +22,7 @@ export default {
|
||||
componentMixin: '小组件',
|
||||
backToTop: '返回顶部',
|
||||
dragDialog: '拖拽 Dialog',
|
||||
dragSelect: '拖拽 Select',
|
||||
dragKanban: '可拖拽看板',
|
||||
charts: '图表',
|
||||
keyboardChart: '键盘图表',
|
||||
|
@@ -78,6 +78,12 @@ const componentsRouter = {
|
||||
name: 'DragDialogDemo',
|
||||
meta: { title: 'dragDialog' }
|
||||
},
|
||||
{
|
||||
path: 'drag-select',
|
||||
component: () => import('@/views/components-demo/dragSelect'),
|
||||
name: 'DragSelectDemo',
|
||||
meta: { title: 'dragSelect' }
|
||||
},
|
||||
{
|
||||
path: 'dnd-list',
|
||||
component: () => import('@/views/components-demo/dndList'),
|
||||
|
43
src/views/components-demo/dragSelect.vue
Normal file
43
src/views/components-demo/dragSelect.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div class="components-container">
|
||||
|
||||
<el-drag-select v-model="value" style="width:500px;" multiple placeholder="请选择">
|
||||
<el-option v-for="item in options" :label="item.label" :value="item.value" :key="item.value" />
|
||||
</el-drag-select>
|
||||
|
||||
<div style="margin-top:30px;">
|
||||
<el-tag v-for="item of value" :key="item" style="margin-right:15px;">{{ item }}</el-tag>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ElDragSelect from '@/components/DragSelect' // base on element-ui
|
||||
|
||||
export default {
|
||||
name: 'DragSelectDemo',
|
||||
components: { ElDragSelect },
|
||||
data() {
|
||||
return {
|
||||
value: ['Apple', 'Banana', 'Orange'],
|
||||
options: [{
|
||||
value: 'Apple',
|
||||
label: 'Apple'
|
||||
}, {
|
||||
value: 'Banana',
|
||||
label: 'Banana'
|
||||
}, {
|
||||
value: 'Orange',
|
||||
label: 'Orange'
|
||||
}, {
|
||||
value: 'Pear',
|
||||
label: 'Pear'
|
||||
}, {
|
||||
value: 'Strawberry',
|
||||
label: 'Strawberry'
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@@ -121,11 +121,21 @@ export default {
|
||||
this.$router.push('/')
|
||||
},
|
||||
openMenu(tag, e) {
|
||||
const menuMinWidth = 105
|
||||
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
|
||||
const offsetWidth = this.$el.offsetWidth // container width
|
||||
const maxLeft = offsetWidth - menuMinWidth // left boundary
|
||||
const left = e.clientX - offsetLeft + 15 // 15: margin right
|
||||
|
||||
if (left > maxLeft) {
|
||||
this.left = maxLeft
|
||||
} else {
|
||||
this.left = left
|
||||
}
|
||||
this.top = e.clientY
|
||||
|
||||
this.visible = true
|
||||
this.selectedTag = tag
|
||||
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
|
||||
this.left = e.clientX - offsetLeft + 15 // 15: margin right
|
||||
this.top = e.clientY
|
||||
},
|
||||
closeMenu() {
|
||||
this.visible = false
|
||||
|
@@ -24,8 +24,9 @@
|
||||
border
|
||||
fit
|
||||
highlight-current-row
|
||||
style="width: 100%;">
|
||||
<el-table-column :label="$t('table.id')" align="center" width="65">
|
||||
style="width: 100%;"
|
||||
@sort-change="sortChange">
|
||||
<el-table-column :label="$t('table.id')" prop="id" sortable="custom" align="center" width="65">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.id }}</span>
|
||||
</template>
|
||||
@@ -233,6 +234,20 @@ export default {
|
||||
})
|
||||
row.status = status
|
||||
},
|
||||
sortChange(data) {
|
||||
const { prop, order } = data
|
||||
if (prop === 'id') {
|
||||
this.sortByID(order)
|
||||
}
|
||||
},
|
||||
sortByID(order) {
|
||||
if (order === 'ascending') {
|
||||
this.listQuery.sort = '+id'
|
||||
} else {
|
||||
this.listQuery.sort = '-id'
|
||||
}
|
||||
this.handleFilter()
|
||||
},
|
||||
resetTemp() {
|
||||
this.temp = {
|
||||
id: undefined,
|
||||
|
Reference in New Issue
Block a user