deleteFloor.vue
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
<el-dialog
:title="$t('room.deleteFloor.title')"
:visible.sync="visible"
width="30%"
:before-close="handleClose"
>
<p>{{ $t('room.deleteFloor.confirmMessage') }}</p>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">{{ $t('room.deleteFloor.cancelText') }}</el-button>
<el-button type="danger" @click="handleDelete">{{ $t('room.deleteFloor.confirmDelete') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { deleteFloor } from '@/api/room/deleteFloorApi'
export default {
name: 'DeleteFloor',
data() {
return {
visible: false,
floorInfo: {
floorId: '',
communityId: this.getCommunityId()
}
}
},
methods: {
open(floorInfo) {
this.floorInfo = {
...floorInfo,
communityId: this.getCommunityId()
}
this.visible = true
},
handleClose() {
this.visible = false
},
async handleDelete() {
try {
const response = await deleteFloor(this.floorInfo)
if (response.code === 0) {
this.$message.success(this.$t('room.deleteFloor.deleteSuccess'))
this.handleClose()
this.$emit('refresh-data')
this.$emit('refresh-tree')
} else {
this.$message.error(response.msg || this.$t('room.deleteFloor.deleteFailed'))
}
} catch (error) {
this.$message.error(this.$t('room.deleteFloor.deleteError'))
}
},
getCommunityId() {
// 实际项目中替换为获取社区ID的逻辑
return 'your-community-id'
}
}
}
</script>