NEZ-1692 fix:修改 state为All 时 删除接口报错的问题

This commit is contained in:
zhangyu
2022-03-23 10:56:43 +08:00
parent 5f3d16f29f
commit 88e3553c51
2 changed files with 33 additions and 9 deletions

View File

@@ -285,7 +285,7 @@ export default {
cancelButtonText: this.$t('tip.no'), cancelButtonText: this.$t('tip.no'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$delete(this.url + '?ids=' + row.id + '&state=' + this.state).then(response => { this.$delete(this.url + '?ids=' + row.id + '&state=' + row.state).then(response => {
if (response.code === 200) { if (response.code === 200) {
self.delFlag = true self.delFlag = true
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') }) this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })

View File

@@ -526,15 +526,39 @@ export default {
cancelButtonText: this.$t('tip.no'), cancelButtonText: this.$t('tip.no'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$delete(this.url + '?ids=' + this.batchDeleteObjs.map(m => m.id).join(',') + '&state=' + this.state).then(response => { const arrState = []
if (response.code === 200) { const promiseArr = []
this.delFlag = true this.batchDeleteObjs.forEach(item => {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') }) if (arrState.indexOf(item.state) === -1) {
this.getTableData() arrState.push(item.state)
} else {
this.$message.error(response.msg)
} }
}) })
arrState.forEach(state => {
const batchDeleteArr = this.batchDeleteObjs.filter(m => m.state === state)
promiseArr.push(this.$delete(this.url + '?ids=' + batchDeleteArr.map(m => m.id).join(',') + '&state=' + state))
})
Promise.all(promiseArr)
.then(res => {
let error = ''
let flag = false
for (let i = 0; i < res.length; i++) {
if (res[i].code !== 200 && !flag) {
error = res[i].msg
flag = true
}
}
if (!flag) {
this.delFlag = true
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
this.getTableData()
} else {
this.$message.error(error)
}
})
.catch(response => {
console.log(response)
this.$message.error(response.msg)
})
}) })
}, },
del (row) { del (row) {
@@ -543,7 +567,7 @@ export default {
cancelButtonText: this.$t('tip.no'), cancelButtonText: this.$t('tip.no'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$delete(this.url + '?ids=' + row.id + '&state=' + this.state).then(response => { this.$delete(this.url + '?ids=' + row.id + '&state=' + row.state).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.delFlag = true this.delFlag = true
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') }) this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })