循环数组删除,
确保删除一个后,再删下一个。
在所有数组删除完毕后,提示成功
async batchSureDelTrace() {
let promiseData = []
for (let i = 0; i < this.multipleSelection.length; i++) {
let data = this.multipleSelection[i]
let obj = {
deviceid: data.deviceid,
before: this.delTrackDate + ' 23:59:59'
}
console.log(obj)
await this.batchTrackDel(obj).then(res => {
promiseData.push(res)
})
}
Promise.all(promiseData).then(data => { // 数据
console.log(data)
this.$message({
message: '批量删除轨迹成功!',
type: 'success'
});
})
},
batchTrackDel(obj) { // 批量删
return new Promise((resolved, rej) => {
trackDel(obj).then(res => {
resolved(res)
})
})
},