pref(cmdb-ui):ci upload&delete concurrent 6 (#286)

This commit is contained in:
wang-liang0615 2023-12-06 14:33:25 +08:00 committed by GitHub
parent 0414121c27
commit 10527bf9b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 25 deletions

View File

@ -63,20 +63,23 @@ export default {
this.success = 0
this.errorNum = 0
this.errorItems = []
for (let i = 0; i < this.total; i++) {
// await this.sleep(20)
const item = this.upLoadData[i]
await uploadData(this.ciType, item)
const floor = Math.ceil(this.total / 6)
for (let i = 0; i < floor; i++) {
const itemList = this.upLoadData.slice(6 * i, 6 * i + 6)
const promises = itemList.map((x) => uploadData(this.ciType, x))
await Promise.allSettled(promises)
.then((res) => {
console.log(res)
res.forEach((r) => {
if (r.status === 'fulfilled') {
this.success += 1
})
.catch((err) => {
} else {
this.errorItems.push(r?.reason?.response?.data.message ?? '请求出现错误,请稍后再试')
this.errorNum += 1
this.errorItems.push(((err.response || {}).data || {}).message || '请求出现错误,请稍后再试')
}
})
})
.finally(() => {
this.complete += 1
this.complete += 6
})
}
},

View File

@ -654,13 +654,19 @@ export default {
let errorNum = 0
this.loading = true
this.loadTip = `正在删除...`
for (let i = 0; i < this.selectedRowKeys.length; i++) {
await deleteCI(this.selectedRowKeys[i], false)
.then(() => {
const floor = Math.ceil(this.selectedRowKeys.length / 6)
for (let i = 0; i < floor; i++) {
const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6)
const promises = itemList.map((x) => deleteCI(x, false))
await Promise.allSettled(promises)
.then((res) => {
res.forEach((r) => {
if (r.status === 'fulfilled') {
successNum += 1
})
.catch(() => {
} else {
errorNum += 1
}
})
})
.finally(() => {
this.loadTip = `正在删除${this.selectedRowKeys.length}成功${successNum}失败${errorNum}`

View File

@ -1084,13 +1084,19 @@ export default {
let errorNum = 0
this.loading = true
this.loadTip = `正在删除...`
for (let i = 0; i < this.selectedRowKeys.length; i++) {
await deleteCI(this.selectedRowKeys[i], false)
.then(() => {
const floor = Math.ceil(this.selectedRowKeys.length / 6)
for (let i = 0; i < floor; i++) {
const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6)
const promises = itemList.map((x) => deleteCI(x, false))
await Promise.allSettled(promises)
.then((res) => {
res.forEach((r) => {
if (r.status === 'fulfilled') {
successNum += 1
})
.catch(() => {
} else {
errorNum += 1
}
})
})
.finally(() => {
this.loadTip = `正在删除${this.selectedRowKeys.length}成功${successNum}失败${errorNum}`