4
4
<h3 >{{ list1Title }}</h3 >
5
5
<draggable :list =" list1" :options =" {group:'article'}" class =" dragArea" >
6
6
<div v-for =" element in list1" :key =" element.id" class =" list-complete-item" >
7
- <div class =" list-complete-item-handle" >[{{ element.author }}] {{ element.title }}</div >
7
+ <div class =" list-complete-item-handle" >{{ element.id }} [{{ element.author }}] {{ element.title }}</div >
8
8
<div style =" position :absolute ;right :0px ;" >
9
9
<span style =" float : right ;margin-top : -20px ;margin-right :5px ;" @click =" deleteEle(element)" >
10
10
<i style =" color :#ff4949 " class =" el-icon-delete" />
15
15
</div >
16
16
<div :style =" {width:width2}" class =" dndList-list" >
17
17
<h3 >{{ list2Title }}</h3 >
18
- <draggable :list =" filterList2 " :options =" {group:'article'}" class =" dragArea" >
19
- <div v-for =" element in filterList2 " :key =" element.id" class =" list-complete-item" >
20
- <div class =" list-complete-item-handle2" @click =" pushEle(element)" > [{{ element.author }}] {{ element.title }}</div >
18
+ <draggable :list =" list2 " :options =" {group:'article'}" class =" dragArea" >
19
+ <div v-for =" element in list2 " :key =" element.id" class =" list-complete-item" >
20
+ <div class =" list-complete-item-handle2" @click =" pushEle(element)" >{{ element.id }} [{{ element.author }}] {{ element.title }}</div >
21
21
</div >
22
22
</draggable >
23
23
</div >
@@ -60,16 +60,6 @@ export default {
60
60
default: ' 48%'
61
61
}
62
62
},
63
- computed: {
64
- filterList2 () {
65
- return this .list2 .filter (v => {
66
- if (this .isNotInList1 (v)) {
67
- return v
68
- }
69
- return false
70
- })
71
- }
72
- },
73
63
methods: {
74
64
isNotInList1 (v ) {
75
65
return this .list1 .every (k => v .id !== k .id )
@@ -90,7 +80,16 @@ export default {
90
80
}
91
81
},
92
82
pushEle (ele ) {
93
- this .list1 .push (ele)
83
+ for (const item of this .list2 ) {
84
+ if (item .id === ele .id ) {
85
+ const index = this .list2 .indexOf (item)
86
+ this .list2 .splice (index, 1 )
87
+ break
88
+ }
89
+ }
90
+ if (this .isNotInList1 (ele)) {
91
+ this .list1 .push (ele)
92
+ }
94
93
}
95
94
}
96
95
}
0 commit comments