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 @@ 清空
-
+