mirror of https://github.com/veops/cmdb.git
pref(cmdb-ui):ci upload&delete concurrent 6
This commit is contained in:
parent
0414121c27
commit
4b03485d41
|
@ -63,20 +63,23 @@ export default {
|
||||||
this.success = 0
|
this.success = 0
|
||||||
this.errorNum = 0
|
this.errorNum = 0
|
||||||
this.errorItems = []
|
this.errorItems = []
|
||||||
for (let i = 0; i < this.total; i++) {
|
const floor = Math.ceil(this.total / 6)
|
||||||
// await this.sleep(20)
|
for (let i = 0; i < floor; i++) {
|
||||||
const item = this.upLoadData[i]
|
const itemList = this.upLoadData.slice(6 * i, 6 * i + 6)
|
||||||
await uploadData(this.ciType, item)
|
const promises = itemList.map((x) => uploadData(this.ciType, x))
|
||||||
|
await Promise.allSettled(promises)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res)
|
res.forEach((r) => {
|
||||||
this.success += 1
|
if (r.status === 'fulfilled') {
|
||||||
})
|
this.success += 1
|
||||||
.catch((err) => {
|
} else {
|
||||||
this.errorNum += 1
|
this.errorItems.push(r?.reason?.response?.data.message ?? '请求出现错误,请稍后再试')
|
||||||
this.errorItems.push(((err.response || {}).data || {}).message || '请求出现错误,请稍后再试')
|
this.errorNum += 1
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.complete += 1
|
this.complete += 6
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -654,13 +654,19 @@ export default {
|
||||||
let errorNum = 0
|
let errorNum = 0
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.loadTip = `正在删除...`
|
this.loadTip = `正在删除...`
|
||||||
for (let i = 0; i < this.selectedRowKeys.length; i++) {
|
const floor = Math.ceil(this.selectedRowKeys.length / 6)
|
||||||
await deleteCI(this.selectedRowKeys[i], false)
|
for (let i = 0; i < floor; i++) {
|
||||||
.then(() => {
|
const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6)
|
||||||
successNum += 1
|
const promises = itemList.map((x) => deleteCI(x, false))
|
||||||
})
|
await Promise.allSettled(promises)
|
||||||
.catch(() => {
|
.then((res) => {
|
||||||
errorNum += 1
|
res.forEach((r) => {
|
||||||
|
if (r.status === 'fulfilled') {
|
||||||
|
successNum += 1
|
||||||
|
} else {
|
||||||
|
errorNum += 1
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.loadTip = `正在删除,共${this.selectedRowKeys.length}个,成功${successNum}个,失败${errorNum}个`
|
this.loadTip = `正在删除,共${this.selectedRowKeys.length}个,成功${successNum}个,失败${errorNum}个`
|
||||||
|
|
|
@ -1084,13 +1084,19 @@ export default {
|
||||||
let errorNum = 0
|
let errorNum = 0
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.loadTip = `正在删除...`
|
this.loadTip = `正在删除...`
|
||||||
for (let i = 0; i < this.selectedRowKeys.length; i++) {
|
const floor = Math.ceil(this.selectedRowKeys.length / 6)
|
||||||
await deleteCI(this.selectedRowKeys[i], false)
|
for (let i = 0; i < floor; i++) {
|
||||||
.then(() => {
|
const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6)
|
||||||
successNum += 1
|
const promises = itemList.map((x) => deleteCI(x, false))
|
||||||
})
|
await Promise.allSettled(promises)
|
||||||
.catch(() => {
|
.then((res) => {
|
||||||
errorNum += 1
|
res.forEach((r) => {
|
||||||
|
if (r.status === 'fulfilled') {
|
||||||
|
successNum += 1
|
||||||
|
} else {
|
||||||
|
errorNum += 1
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.loadTip = `正在删除,共${this.selectedRowKeys.length}个,成功${successNum}个,失败${errorNum}个`
|
this.loadTip = `正在删除,共${this.selectedRowKeys.length}个,成功${successNum}个,失败${errorNum}个`
|
||||||
|
|
Loading…
Reference in New Issue