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