deleteInspectionPoint.vue 1.43 KB
<template>
  <el-dialog
    :title="$t('deleteInspectionPoint.title')"
    :visible.sync="visible"
    width="30%"
    @close="handleClose"
  >
    <p>{{ $t('deleteInspectionPoint.confirmText') }}</p>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">{{ $t('deleteInspectionPoint.cancel') }}</el-button>
      <el-button type="primary" @click="handleConfirm">{{ $t('deleteInspectionPoint.confirm') }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { deleteInspectionPoint } from '@/api/inspection/deleteInspectionPointApi'
import { getCommunityId } from '@/api/community/communityApi'

export default {
  name: 'DeleteInspectionPoint',
  data() {
    return {
      visible: false,
      inspectionPointId: ''
    }
  },
  methods: {
    open(inspectionPointId) {
      this.inspectionPointId = inspectionPointId
      this.visible = true
    },
    
    handleClose() {
      this.inspectionPointId = ''
    },
    
    async handleConfirm() {
      try {
        await deleteInspectionPoint({
          inspectionId: this.inspectionPointId,
          communityId: getCommunityId()
        })
        this.$message.success(this.$t('common.deleteSuccess'))
        this.visible = false
        this.$emit('deleted')
      } catch (error) {
        console.error('删除巡检点失败:', error)
        this.$message.error(error.message || this.$t('common.deleteFailed'))
      }
    }
  }
}
</script>