<template>
  <div class="flex text-center">
    <table border="1">
      <tr class="PanelTR">
        <td class="PanelTD"><label>气表品牌:</label><br><label>{{data.f_meter_brand}}</label></td>
        <td class="PanelTD"><label>厂家名称:</label><br><label>{{data.f_manufacturers}}</label></td>
        <td class="PanelTD"><label>厂家别名:</label><br><label>{{data.f_alias}}</label></td>
      </tr>
      <tr class="PanelTR">
        <td class="PanelTD"><label>气表类型:</label><br><label>{{data.f_meter_type}}</label></td>
        <td class="PanelTD" v-if="data.f_billing!=null"><label>计费方式:</label><br><label>{{data.f_billing}}</label></td>
        <td class="PanelTD"><label>气表型号:</label><br><label>{{data.f_meter_style}}</label></td>
      </tr>
      <tr class="PanelTR">
        <td class="PanelTD"><label>表类型:</label><br><label>{{data.f_type}}</label></td>
        <td class="PanelTD" v-if="data.f_rated_traffic!=null"><label>额定流量:</label><br><label>{{data.f_rated_traffic}}</label></td>
        <td class="PanelTD" v-if="data.f_calculation!=null"><label>结算方式:</label><br><label>{{data.f_calculation}}</label></td>
      </tr>
    </table>
    <!--<div class="panel-group" v-if="data.f_meter_type==='机表'">-->
      <!--&lt;!&ndash;todo  机表抄表记录&ndash;&gt;-->
      <!--<div class="col-sm-12">-->
        <!--<button class="btn btn-success">抄表记录</button>-->
      <!--</div>-->
    <!--</div>-->
  </div>
</template>

<script>


  //同时加载两个组件的请求。
  let getModelInfo = async (self) => {
    await self.$resetpost('rs/sql/getModelInfo', {data: {condition: `f_gasmodel_id='${self.rowdata.f_gasmodel_id}' and f_gasbrand_id='${self.rowdata.f_gasbrand_id}'`}}, {
      resolveMsg: null,
      rejectMsg: null
    }).then((res) => {
        self.data = res.data[0]
        self.$resetpost('rs/sql/getNetWork', {data: {condition: `1=1 AND f_user_id='${self.rowdata.f_user_id}' AND f_userinfo_id='${self.rowdata.f_userinfo_id}'`}}, {
          resolveMsg: null,
          rejectMsg: null
        }).then((res) => {
          if (res.data.length != 0) {
            self.$parent.network.f_network_valve = !res.data[0].f_network_valve ? '否' : res.data[0].f_network_valve == '0' ? '否' : '强制中'
          } else {
            self.$parent.network.f_network_valve = '否'
          }
          self.$resetpost('rs/sql/getAllWebHandPlan', {data: {condition: `1=1 AND f_user_id='${self.rowdata.f_user_id}' AND f_userinfo_id='${self.rowdata.f_userinfo_id}'`}}, {
            resolveMsg: null,
            rejectMsg: null
          }).then((res) => {
            if (res.data.length == 0) {
              console.log("被执行")
              self.$parent.handplan.f_batterylevel = '未查询到该值'
              self.$parent.handplan.f_signal = '未查询到该值'
              self.$parent.handplan.f_insert_date = '未查询到该值'
              self.$parent.handplan.f_valvestate = '未查询到该值'
              self.$parent.handplan.f_tablebase = '未查询到该值'
              self.$parent.handplan.f_last_tablebase = '未查询到该值'
              return
            }
            self.$parent.handplan.f_batterylevel = !res.data[0].f_batterylevel ? '未查询到该值' : res.data[0].f_batterylevel + '/v'
            self.$parent.handplan.f_signal = !res.data[0].f_signal ? '未查询到该值' : res.data[0].f_signal + '/dBm'
            self.$parent.handplan.f_insert_date = !res.data[0].f_insert_date ? '未查询到该值' : res.data[0].f_insert_date
            self.$parent.handplan.f_valvestate = !res.data[0].f_valvestate ? '未查询到该值' : res.data[0].f_valvestate == 1 ? '关阀' : '开阀'
            self.$parent.handplan.f_tablebase = !res.data[0].f_tablebase ? '未查询到该值' : res.data[0].f_tablebase
            self.$parent.handplan.f_last_tablebase = !res.data[0].f_last_tablebase ? '未查询到该值' : res.data[0].f_last_tablebase
          })
        });
      }
    )
  }
  export default {
    title: '品牌型号面板',
    name: "MeterBrandPanel",
    props: ['row'],
    data() {
      return {
        data: {
          f_meter_brand: '',
          f_manufacturers: '',
          f_alias: '',
          f_meter_type: '',
          f_billing: null,
          f_meter_style: '',
          f_type: '',
          f_rated_traffic: null,
          f_calculation: null
        },
        rowdata: {}
      }
    },
    ready() {
      this.rowdata = this.row
      getModelInfo(this)
    },
    watch: {
      'row'(val) {
        this.rowdata = val
        getModelInfo(this)
      }
    }
  }
</script>

<style scoped>
  .PanelTR {
    width: 100%;
    height: 70px;
  }
  .PanelTD {
    width: 33.33%
  }
</style>
