<template>
  <div id="unit" class="flex-row">
    <div :class="{'basic-main': !iseditmetetinfo,'binary-left': iseditmetetinfo}"
         :style="{width:iseditmetetinfo ? '50%' : '100%'}">
      <web-meter-exception-list style="width:auto;"
                                :styles="iseditmetetinfo ? 'form-group col-sm-3' : 'form-group col-sm-2'"
                                :showfields="iseditmetetinfo ? false : true"
                                v-ref:list :error-types="errorTypes"
                                @search="search()"
                                @issue-work-order="IssueWorkOrder">
      </web-meter-exception-list>
    </div>
    <div class="binary-right" style="width:50%" v-if="iseditmetetinfo">
      <web-meter-exception-handle :row="row"
                                  :error-types="errorTypes"
                                  v-if="ismeterinfo"
                                  @close="closeedit"
                                  style="overflow-y: auto;">
      </web-meter-exception-handle>
    </div>
  </div>
</template>
<script>

import {HttpResetClass} from 'vue-client'

export default {
  title: '物联网异常待办',
  data () {
    return {
      f_filialeid: '',
      errorTypes: [],
      iseditmetetinfo: false,
      row: {},
      criteriaShow: false,
      show: false,
      isUseMeter: false,
      meterinfos: [],
      ismeterinfo: false
    }
  },
  ready () {
    this.getErrorType()
  },
  methods: {
    IssueWorkOrder (obj) {
      if (obj) {
        this.row = obj
        this.iseditmetetinfo = true
        this.ismeterinfo = true
        this.isUseMeter = false
      }
    },
    getErrorType () {
      let load = new HttpResetClass()
      load.load('POST', 'rs/sql/querySingleTable', {
        data: {
          items: 'f_error_type',
          tablename: 't_exception',
          condition: '1=1 group by f_error_type'
        }
      }, {warnMsg: null, resolveMsg: null}).then((res) => {
        let rows = res.data
        let array = []
        array.push({label: '全部', value: ''})
        for (let i = 0; i < rows.length; i++) {
          array.push({label: rows[i].f_error_type, value: rows[i].f_error_type})
        }
        this.errorTypes = array
      })
    },
    search(){
      this.iseditmetetinfo = false
      this.isUseMeter = false
      this.ismeterinfo = false
      this.row = null
    },
    closeedit () {
      this.iseditmetetinfo = false
      this.isUseMeter = false
      this.ismeterinfo = false
      this.row = null
      this.$refs.list.search()
    }
  }
}
</script>
<style>
.form-input-group label {
  text-align: right;
  width: auto;
}
</style>
