<template>
  <el-dialog :close-on-click-modal="false" :visible.sync="dialogFormVisible" title="报警详情" append-to-body>
    <el-form ref="dataForm" :model="alarmForm" label-well-code="right" label-width="110px">
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="设备名称" prop="deviceName">
            <el-input v-model.trim="alarmForm.deviceName" disabled type="text" placeholder=""/>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="报警时间" prop="alarmTime">
            <el-input v-model.trim="alarmForm.alarmTime" disabled type="text" placeholder=""/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="报警类型" prop="alarmTypeName">
            <el-input v-model.trim="alarmForm.alarmTypeName" disabled type="text" placeholder=""/>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="报警数值" prop="alarmValue">
            <el-input v-model.trim="alarmForm.alarmValue" disabled type="text" placeholder=""/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="报警状态" prop="alarmStatusName">
            <el-input v-model.trim="alarmForm.alarmStatusName" disabled type="text" placeholder=""/>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="消警时间" prop="cancelTime">
            <el-input v-model.trim="alarmForm.cancelTime" disabled type="text" placeholder=""/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="设备位置" prop="address">
            <el-input v-model.trim="alarmForm.address" disabled type="text" placeholder=""/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!--<div v-show="isEditMode" slot="footer" class="dialog-footer">-->
    <!--<el-button :loading="btnLoading" type="primary" @click="saveData">保存</el-button>-->
    <!--<el-button @click="cancel">取消</el-button>-->
    <!--</div>-->
  </el-dialog>
</template>

<script>
import { getDetail } from '@/api/system/alarm'

export default {
  name: 'AlarmDetail',
  data() {
    return {
      dialogFormVisible: false, // 对话框是否显示
      alarmForm: {
        id: '', // id
        deviceName: '',
        alarmTime: '',
        alarmTypeName: '',
        alarmValue: '',
        alarmStatusName: '',
        cancelTime: '',
        address: ''
      } // 表单
    }
  },
  created() {
    // this.fetchLampboxList() // 获取灯箱列表
  },
  methods: {
    // 初始化对话框
    initDialog: function(dialogFormVisible, row = null) {
      this.dialogFormVisible = dialogFormVisible
      this.resetForm()
      getDetail(row.id).then(response => {
        if (response.code === 200) {
          var row = response.data
          this.alarmForm = {
            id: row.id,
            deviceName: row.deviceName,
            alarmTime: row.alarmTime,
            alarmTypeName: row.alarmTypeName,
            alarmValue: row.alarmValue,
            alarmStatusName: row.alarmStatusName,
            cancelTime: row.cancelTime,
            address: row.address
          }
        }
      }).catch(() => {
        // this.$message.error('')
      })
    },
    // 清除数据
    resetForm() {
      this.alarmForm = {
        id: '', // id
        deviceName: '',
        alarmTime: '',
        alarmTypeName: '',
        alarmValue: '',
        alarmStatusName: '',
        cancelTime: '',
        address: ''
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .el-select{
    width: 100%;
  }
  .el-date-editor{
    width: 100%;
  }
  .dialog-footer {
    margin-top: -20px;
    text-align: center;
  }
</style>
