diff --git a/src/components/EditSites.vue b/src/components/EditSites.vue index f31e70d..5960f2c 100644 --- a/src/components/EditSites.vue +++ b/src/components/EditSites.vue @@ -13,7 +13,7 @@
- + 保存
@@ -33,7 +33,7 @@ + label="启用"> @@ -142,18 +140,14 @@ export default { ], api: [ { required: true, message: 'API地址不能为空', trigger: 'blur' } - ], - download: [ - { required: false, trigger: 'blur' } ] }, enableBatchEdit: false, batchGroupName: '', batchIsActive: 1, multipleSelection: [], - tableKey: 1, checkAllSiteLoading: false, - editeOldkey: '' + editOldkey: '' } }, computed: { @@ -219,9 +213,6 @@ export default { sites: res } }) - for (const i of this.sites) { - delete i.status - } }, getSitesGroup () { const arr = [] @@ -254,7 +245,7 @@ export default { this.dialogType = 'edit' this.dialogVisible = true this.siteInfo = siteInfo - this.editeOldkey = siteInfo.key + this.editOldkey = siteInfo.key }, closeDialog () { this.dialogVisible = false @@ -271,19 +262,8 @@ export default { this.$message.warning('删除源失败, 错误信息: ' + err) }) }, - listUpdatedEvent () { - sites.clear().then(res1 => { - // 重新排序 - var id = 1 - this.sites.forEach(element => { - element.id = id - sites.add(element) - id += 1 - }) - }) - }, checkSiteKey (e) { - if (this.dialogType === 'edit' && this.editeOldkey === this.siteInfo.key) { + if (this.dialogType === 'edit' && this.editOldkey === this.siteInfo.key) { return true } else { for (const i of this.sites) { @@ -326,7 +306,7 @@ export default { this.dialogVisible = false this.getSites() }) - this.editeOldkey = '' + this.editOldkey = '' }, exportSites () { this.getSites() @@ -400,7 +380,8 @@ export default { } }, isActiveChangeEvent (row) { - this.updateDatabase() + sites.remove(row.id) + sites.add(row) }, resetId (inArray) { var id = 1 @@ -437,23 +418,13 @@ export default { }, async checkAllSite () { this.checkAllSiteLoading = true - for (const i of this.sites) { - i.status = '' - this.tableKey = Math.random() - const flag = await zy.check(i.key) - if (flag) { - i.status = '可用' - } else { - i.status = '失效' - i.isActive = 0 - } - this.tableKey = Math.random() - } - this.checkAllSiteLoading = false - this.updateDatabase() + Promise.all(this.sites.map(site => this.checkSingleSite(site))).then(res => { + this.checkAllSiteLoading = false + this.getSites() + }) }, - async checkSimpleSite (row) { - this.checkAllSiteLoading = true + async checkSingleSite (row) { + row.status = ' ' const flag = await zy.check(row.key) if (flag) { row.status = '可用' @@ -461,14 +432,13 @@ export default { row.status = '失效' row.isActive = 0 } - this.updateDatabase() - this.tableKey = Math.random() - this.checkAllSiteLoading = false + sites.remove(row.id) + sites.add(row) + return row.status } }, mounted () { this.rowDrop() - this.checkAllSiteLoading = false }, created () { this.getSites()