update
This commit is contained in:
parent
0885b4deef
commit
8e4a4132e6
@ -42,6 +42,14 @@
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button type="link" @click="handleEdit(record)">修改</a-button>
|
||||
<a-popconfirm
|
||||
title="确定要删除该驿站吗?"
|
||||
ok-text="确定"
|
||||
cancel-text="取消"
|
||||
@confirm="handleDelete(record)"
|
||||
>
|
||||
<a-button type="link" danger>删除</a-button>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
@ -96,12 +104,23 @@
|
||||
@cancel="handleEditCancel"
|
||||
>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="handleEditCancel">取消</a-button>
|
||||
<a-button type="primary" :loading="editLoading" @click="handleEditSubmit">
|
||||
保存
|
||||
</a-button>
|
||||
</a-space>
|
||||
<div class="modal-footer-with-delete">
|
||||
<a-popconfirm
|
||||
title="确定要删除该驿站吗?"
|
||||
ok-text="确定"
|
||||
cancel-text="取消"
|
||||
@confirm="handleDelete({ id: currentEditId })"
|
||||
:disabled="deleteLoading"
|
||||
>
|
||||
<a-button danger :loading="deleteLoading">删除驿站</a-button>
|
||||
</a-popconfirm>
|
||||
<a-space>
|
||||
<a-button @click="handleEditCancel">取消</a-button>
|
||||
<a-button type="primary" :loading="editLoading" @click="handleEditSubmit">
|
||||
保存
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<a-form
|
||||
@ -136,6 +155,7 @@ import { message } from 'ant-design-vue'
|
||||
import { getStationList, createStation, updateStation } from '@/api/station'
|
||||
import { getCommunityList } from '@/api/community'
|
||||
import PageContainer from '@/components/PageContainer.vue'
|
||||
import request from '@/utils/request'
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -286,6 +306,7 @@ export default defineComponent({
|
||||
// 修改驿站相关
|
||||
const editModalVisible = ref(false)
|
||||
const editLoading = ref(false)
|
||||
const deleteLoading = ref(false)
|
||||
const editFormRef = ref(null)
|
||||
const editFormState = ref({
|
||||
name: '',
|
||||
@ -331,6 +352,29 @@ export default defineComponent({
|
||||
editModalVisible.value = false
|
||||
}
|
||||
|
||||
// 删除驿站
|
||||
const handleDelete = async (record) => {
|
||||
try {
|
||||
deleteLoading.value = true
|
||||
const res = await request.delete(`/api/station/${record.id}`)
|
||||
if (res.code === 200) {
|
||||
message.success('删除成功')
|
||||
// 如果是从编辑模态框中删除,则关闭模态框
|
||||
if (editModalVisible.value) {
|
||||
editModalVisible.value = false
|
||||
}
|
||||
fetchData() // 刷新列表
|
||||
} else {
|
||||
message.error(res.message || '删除失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除驿站失败:', error)
|
||||
message.error('删除失败')
|
||||
} finally {
|
||||
deleteLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
fetchCommunityOptions()
|
||||
@ -355,11 +399,13 @@ export default defineComponent({
|
||||
handleCancel,
|
||||
editModalVisible,
|
||||
editLoading,
|
||||
deleteLoading,
|
||||
editFormRef,
|
||||
editFormState,
|
||||
handleEdit,
|
||||
handleEditSubmit,
|
||||
handleEditCancel
|
||||
handleEditCancel,
|
||||
handleDelete
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -430,4 +476,12 @@ export default defineComponent({
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding: 16px 24px;
|
||||
}
|
||||
|
||||
/* 带删除按钮的模态框底部样式 */
|
||||
.modal-footer-with-delete {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user