From 4e0fa4d980bfafab9e4ed4e6fbf79b48f132f0e5 Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Sat, 17 Oct 2020 23:35:01 +0200 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81sites=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=8B=96=E6=9B=B3=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/EditSites.vue | 38 +++++++++++++++++------------------- src/components/History.vue | 4 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/components/EditSites.vue b/src/components/EditSites.vue index 689ad8e..cb2919d 100644 --- a/src/components/EditSites.vue +++ b/src/components/EditSites.vue @@ -6,13 +6,12 @@ 导出 导入 清空 - 重置 + 重置 -
+
{ + var id = 1 + data.forEach(ele => { + ele.id = id + id += 1 + }) + sites.bulkAdd(data) + }) }, removeAllSites () { sites.clear().then(this.getSites()) }, rowDrop () { - const tbody = document.getElementById('editSites-table').querySelector('.el-table__body-wrapper tbody') - var data = this.sites + const tbody = document.getElementById('sites-table').querySelector('.el-table__body-wrapper tbody') + const _this = this Sortable.create(tbody, { onEnd ({ newIndex, oldIndex }) { - const currRow = data.splice(oldIndex, 1)[0] - data.splice(newIndex, 0, currRow) - sites.clear().then(res => { - var id = data.length - data.forEach(element => { - element.id = id - sites.add(element) - id -= 1 - }) - }) + const currRow = _this.sites.splice(oldIndex, 1)[0] + _this.sites.splice(newIndex, 0, currRow) + _this.updateDatabase(_this.sites) } }) } diff --git a/src/components/History.vue b/src/components/History.vue index c36c35d..c2b01a7 100644 --- a/src/components/History.vue +++ b/src/components/History.vue @@ -5,7 +5,7 @@ 清空
-
+