sortTab-editor.vue
1.41 KB
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
<template>
<div>
<draggable v-model="list" @start="drag=true" @end="drag=false">
<div class="item" v-for="(i,index) in list" :key="i.id">
<sort-tab-item :value="i" @on-remove="onDeleteBtn(index)" @on-change="(v) => (onChange(index, v))"></sort-tab-item>
</div>
</draggable>
<Button style="margin-top:20px" @click="onAddBtn">添加一组</Button>
</div>
</template>
<script>
import sortTabItem from './sortTab-editor-item'
import util from '@/libs/util'
import draggable from 'vuedraggable'
export default {
props: ["value"],
data() {
return {
list: util.clone(this.value),
drag: false,
};
},
methods: {
onAddBtn() {
this.list.push({
category_name: '',
product_ids: '',
more_url: {
action: "go.ufo",
params: {
pagename: "productList",
productListTitle: '',
listparams: { sort: 0}
}
},
id: this.$bus.genId()
})
},
onDeleteBtn(i, index) {
this.list.splice(index, 1);
},
getValue() {
return this.list;
},
onChange(i, v) {
this.$set(this.list, i, v);
}
},
components: {
sortTabItem,
draggable
}
};
</script>
<style>
.item {
border: 1px solid #dddee1;
padding-top: 30px;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
}
.item:hover {
background-color: #ebf7ff;
}
</style>