<template>
  <div class="panel panel-info auto" style="margin-top: auto">
    <div class="panel-heading auto" style="height: 30px">
      <h4 style="display:inline-block;margin-top: auto">安检信息</h4>
    </div>

    <div class="auto info-content" v-if="hasCheck === 1">
      <div class="row">
        <label class="col-sm-6 ">客户名称:</label>
        <span class="col-sm-6">{{model.name}}</span>
      </div>
      <div class="row">
        <label class="col-sm-6 ">客户地址:</label>
        <span class="col-sm-6">{{model.address}}</span>
      </div>
      <div class="row">
        <label class="col-sm-6 ">安检状态:</label>
        <span class="col-sm-6">{{model.taskStatusText}}</span>
      </div>
      <div class="row">
        <label class="col-sm-6 ">上次安检时间:</label>
        <span class="col-sm-6">{{model.lastCheckDate}}</span>
      </div>
      <div class="row">
        <label class="col-sm-6 ">壁挂炉:</label>
        <span class="col-sm-6">{{model.hasFireplace == 0 ? '无': '有'}}</span>
      </div>
      <div class="row">
        <label class="col-sm-6 ">热水器:</label>
        <span class="col-sm-6">{{model.hasCookTool == 0 ? '无': '有'}}</span>
      </div>
      <div class="row">
        <label class="col-sm-6 ">天然气专用灶:</label>
        <span class="col-sm-6">{{model.hasWaterHeater == 0 ? '无': '有'}}</span>
      </div>
    </div>
    <div class="auto info-content" v-if="hasCheck === 0">
      <div class="row">
        <strong>暂无安检信息</strong>
      </div>
    </div>
    <div class="auto info-content" v-if="hasCheck === -1">
      <div class="row">
        <p>正在获取安检信息...</p>
      </div>
    </div>
  </div>
</template>
<script>
  /**
   *用户信息
   *安检信息
   */

  import {HttpResetClass} from 'vue-client'

  let getSafeCheckGen = async function (self) {
    // 获取安检信息
    try {
      let http = new HttpResetClass()

      if (self.data.f_olduserinfo_code) {
        let getSafeCheck = await http.load('POST', 'rs/logic/sale_getSafecheck', {f_olduserinfo_code: self.data.f_olduserinfo_code}, {resolveMsg: null, rejectMsg: null})

        console.log('获取安检信息', getSafeCheck)
        if (getSafeCheck.data) {
          self.model = Object.assign({},self.model, getSafeCheck.data)
        }
        self.hasCheck = 1
      } else {
        self.hasCheck = 0
      }
    } catch (error) {
      self.hasCheck = 0
    }

  }

  export default {
    title: '安检信息',
    data () {
      return {
        model: {},
        hasCheck: -1
      }
    },
    props: ['data'],
    ready () {
      getSafeCheckGen(this)
    }
  }
</script>
