From d84a17688d3717a649dabf72e5e2213d0887f2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Wed, 16 Jan 2019 10:18:32 +0800 Subject: [PATCH] fix[DndList]: fixed drag bug (#1527) https://github.com/PanJiaChen/vue-element-admin/issues/1524 --- src/components/DndList/index.vue | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) 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) + } } } }