<template>
  <el-form label-width="90px">
    <el-row class="el-row-table">
      <el-col :span="12">
        <el-form-item label="批次号">
          <span v-if="detailInfo.batchNo">{{ detailInfo.batchNo }}</span>
          <span v-else>-</span>
        </el-form-item>
      </el-col>

      <el-col :span="12">
        <el-form-item label="设备编号">
          <span v-if="detailInfo.deviceNo">{{ detailInfo.deviceNo }}</span>
          <span v-else>-</span>
        </el-form-item>
      </el-col>

      <el-col :span="12">
        <el-form-item label="设备名称">
          <span v-if="detailInfo.title">{{ detailInfo.title }}</span>
          <span v-else>-</span>
        </el-form-item>
      </el-col>

      <el-col :span="12">
        <el-form-item label="设备状态">
          <span v-if="detailInfo.title">{{ statusFormat(detailInfo) }}</span>
          <span v-else>-</span>
        </el-form-item>
      </el-col>

      <el-col :span="12">
        <el-form-item label="创建时间">
          <span v-if="detailInfo.createTime">{{ detailInfo.createTime }}</span>
          <span v-else>-</span>
        </el-form-item>
      </el-col>

      <el-col :span="12">
        <el-form-item label="创建人">
          <span v-if="detailInfo.createBy">{{ detailInfo.createBy }}</span>
          <span v-else>-</span>
        </el-form-item>
      </el-col>

      <el-col :span="24">
        <el-form-item label="设备备注">
          <span v-if="detailInfo.remark">{{ detailInfo.remark }}</span>
          <span v-else>-</span>
        </el-form-item>
      </el-col>

    </el-row>
  </el-form>
</template>

<script>
  import { getDevice } from "@/api/track/device";
  export default {
    name: "device-info",
    props:{
      deviceId:{
        type: Number
      }
    },
    data(){
      return{
        detailOpen: false,
        detailInfo: {},
        statusOptions: []
      }
    },
    created(){
      this.getDeviceInfo();
      this.getDicts("t_produce_device_status").then(response => {
          this.statusOptions = response.data;
      });
    },
    methods:{
      // 设备状态字典翻译
      statusFormat(row, column) {
        return this.selectDictLabel(this.statusOptions, row.status);
      },
      getDeviceInfo(){
        getDevice(this.deviceId).then(res =>{
          if(res.code == 200){
            this.detailInfo = res.data;
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
