diff --git a/src/components/DndList/index.vue b/src/components/DndList/index.vue index 43e0bb28..7587daa7 100644 --- a/src/components/DndList/index.vue +++ b/src/components/DndList/index.vue @@ -4,7 +4,7 @@

{{ list1Title }}

-
[{{ element.author }}] {{ element.title }}
+
{{ element.id }}[{{ element.author }}] {{ element.title }}
@@ -15,9 +15,9 @@

{{ list2Title }}

- -
-
[{{ element.author }}] {{ element.title }}
+ +
+
{{ element.id }} [{{ element.author }}] {{ element.title }}
@@ -60,16 +60,6 @@ export default { default: '48%' } }, - computed: { - filterList2() { - return this.list2.filter(v => { - if (this.isNotInList1(v)) { - return v - } - return false - }) - } - }, methods: { isNotInList1(v) { return this.list1.every(k => v.id !== k.id) @@ -90,7 +80,16 @@ export default { } }, pushEle(ele) { - this.list1.push(ele) + for (const item of this.list2) { + if (item.id === ele.id) { + const index = this.list2.indexOf(item) + this.list2.splice(index, 1) + break + } + } + if (this.isNotInList1(ele)) { + this.list1.push(ele) + } } } }