25.删除管理员-async、await 实践
This commit is contained in:
parent
bca57d42ce
commit
46ce3c8fbf
|
@ -8,7 +8,7 @@
|
||||||
<el-table-column label="操作" width="150">
|
<el-table-column label="操作" width="150">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button size="small" type="primary">编辑</el-button>
|
<el-button size="small" type="primary">编辑</el-button>
|
||||||
<el-button size="small">删除</el-button>
|
<el-button size="small" @click="del(scope.row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import AxiosDR from "@/utils/AxiosDr.js";
|
import AxiosDR from "@/utils/AxiosDr.js";
|
||||||
import {ElMessage} from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
list:[
|
list:[
|
||||||
|
@ -41,9 +41,34 @@
|
||||||
console.log("err:",err)
|
console.log("err:",err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const del = async (row) => {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm('确认删除?', '标题', {
|
||||||
|
type: 'warning',
|
||||||
|
confirmButtonText: '确认',
|
||||||
|
cancelButtonText: '取消'
|
||||||
|
})
|
||||||
|
|
||||||
|
//删除
|
||||||
|
//let delResult = await AxiosDR.post('/api/adm/del',{id: row.id})
|
||||||
|
let delResult = await AxiosDR.post('/api/adm/del', {id: String(row.id)})
|
||||||
|
if (!delResult.status) {
|
||||||
|
ElMessage.error(delResult.msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//重新获取列表
|
||||||
|
let getListResult = await AxiosDR.get('/api/adm/list')
|
||||||
|
if (!getListResult.status) {
|
||||||
|
ElMessage.error(getListResult.msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data.list = getListResult.data.list //重置
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue