mirror of https://github.com/veops/cmdb.git
pref(cmdb-ui):ci upload&delete concurrent 6 (#286)
This commit is contained in:
parent
0414121c27
commit
10527bf9b8
|
@ -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
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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}个`
|
||||
|
|
|
@ -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}个`
|
||||
|
|
Loading…
Reference in New Issue