add 删除

This commit is contained in:
赵霄
2023-09-14 18:16:49 +08:00
parent 5239d48bce
commit d301c249c7
3 changed files with 23 additions and 3 deletions
+19 -2
View File
@@ -29,7 +29,7 @@
<script>
import AddFileModal from './modules/AddFileModal.vue'
import { getList } from '../api/fileApi.js'
import { getList, deleteFile } from '../api/fileApi.js'
export default {
name: 'List',
@@ -137,7 +137,24 @@ export default {
})
},
handleDelete (id) {
console.log(id)
this.$confirm({
title: '确认删除?',
content: '确定删除吗?',
onOk: () => {
deleteFile({ id: id }).then((res) => {
if (res.success) {
this.$message.success(res.message)
// 判断当前删除的数据是否是最后一页的最后一条数据,如果是的话页码减一
if (this.ipagination.current > 1 && ((this.ipagination.current - 1) * this.ipagination.pageSize) + 1 === this.ipagination.total) {
this.ipagination.current -= 1
}
this.loadData()
} else {
this.$message.warning(res.message)
}
})
}
})
},
modalFormOk () {
this.loadData()