From 41ba57282d85f6e395a23bfee64500bcf192f009 Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 16 Jan 2019 10:14:58 +0800 Subject: [PATCH 1/2] fix[DndList]: fixed drag bug #1524 --- src/components/DndList/index.vue | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/components/DndList/index.vue b/src/components/DndList/index.vue index 43e0bb2894b..da4afb824f5 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,9 @@ export default { } }, pushEle(ele) { - this.list1.push(ele) + if (this.isNotInList1(ele)) { + this.list1.push(ele) + } } } } From f2ef9548212b76390e90ea601d97a691b96cbf65 Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 16 Jan 2019 10:17:40 +0800 Subject: [PATCH 2/2] fix bug --- src/components/DndList/index.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/DndList/index.vue b/src/components/DndList/index.vue index da4afb824f5..7587daa77b1 100644 --- a/src/components/DndList/index.vue +++ b/src/components/DndList/index.vue @@ -80,6 +80,13 @@ export default { } }, pushEle(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) }