From 9eed5ce0b7e7abe44c372ff902499d32d2b8ecdb Mon Sep 17 00:00:00 2001
From: buvta <12312540+buvta@users.noreply.github.com>
Date: Thu, 5 Nov 2020 21:54:08 +0800
Subject: [PATCH] =?UTF-8?q?=E6=BA=90=E6=A3=80=E6=B5=8B=E5=B9=B6=E5=8F=91?=
=?UTF-8?q?=E6=89=A7=E8=A1=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/EditSites.vue | 72 +++++++++++-------------------------
1 file changed, 21 insertions(+), 51 deletions(-)
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="启用">
-
- {{scope.row.group}}
-
-
+
检测中...
- {{scope.row.status}}
+ {{scope.row.status}}
置顶
编辑
- 检测
+
+ 检测
删除
@@ -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()