<template>
  <div class="binary flex">
    <div class="row binary-left flex" style="width:99%;height:98%;margin-bottom:0px">
      <div class="auto">
        <user-base-info-new :row="row" :buttonshow="buttonshow"
                            @cancel-main="cancel"
                            @cancel-re="cancelRe"
                            @search-main="search"></user-base-info-new>
      </div>
      <saletabbut v-if="row" v-ref:list style="height:72%;margin-top: 1%;overflow-y: scroll">
        <saletab header="流水查询" v-if="permission('流水查询')">
          <record-query-user :row="row"></record-query-user>
        </saletab>
        <saletab header="机表流水查询" v-if="permission('机表流水查询')&&row.f_meter_type.includes('机表')">
          <machine-record-query :row="row" v-if="show == '机表流水查询'" @deal-msg="dealMsg"></machine-record-query>
        </saletab>
        <saletab header="收费查询" v-if="!newWebHand && permission('收费查询')">
          <charge-query-user :row="row" v-if="show == '收费查询'" @deal-msg="dealMsg"></charge-query-user>
        </saletab>
        <saletab header="收费查询" v-if="newWebHand && permission('收费查询')">
          <charge-query-user :row="row" v-if="show == '收费查询'" @deal-msg="dealMsg"></charge-query-user>
        </saletab>
        <saletab header="累购查询" v-if="permission('累购查询')">
          <Repurchase :row="row" v-if="show == '累购查询'" @deal-msg="dealMsg"></Repurchase>
        </saletab>
        <saletab header="下账查询"
                 v-if="!newWebHand && row.f_meter_type.includes('物联网表')&&permission('自动下账查询')">
          <automatic-purse :row="row" @deal-msg="dealMsg"></automatic-purse>
        </saletab>
        <saletab header="下账查询"
                 v-if="newWebHand && row.f_meter_type.includes('物联网表')&&permission('自动下账查询')">
          <web-automatic-purse :row="row" @deal-msg="dealMsg"></web-automatic-purse>
        </saletab>
        <saletab header="抄表记录" v-if="row.f_meter_type.includes('卡表')&&permission('抄表记录')">
          <card-hand-record :row="row" v-if="show == '抄表记录'" @deal-msg="dealMsg"></card-hand-record>
        </saletab>
        <saletab header="抄表记录" v-if="!newWebHand && !row.f_meter_type.includes('卡表')&&permission('抄表记录')">
          <hand-query-user :row="row" v-if="show == '抄表记录'" @deal-msg="dealMsg"></hand-query-user>
        </saletab>
        <saletab header="抄表记录" v-if="newWebHand && !row.f_meter_type.includes('卡表')&&permission('抄表记录')">
          <web-hand-query-user :row="row" v-if="show == '抄表记录'" @deal-msg="dealMsg"></web-hand-query-user>
        </saletab>
        <saletab header="补卡查询" v-if="row.f_meter_type.includes('卡表')&&permission('补卡查询')">
          <fill-card-query-user :row="row" v-if="show == '补卡查询'" @deal-msg="dealMsg"></fill-card-query-user>
        </saletab>
        <saletab header="补气查询" v-if="permission('补气查询')">
          <fill-gas-query-user :row="row" v-if="show == '补气查询'" @deal-msg="dealMsg"></fill-gas-query-user>
        </saletab>
        <saletab header="换表查询" v-if="permission('换表查询')">
          <change-meter-query-user :row="row" v-if="show == '换表查询'" @deal-msg="dealMsg"></change-meter-query-user>
        </saletab>
        <saletab header="其他收费" v-if="permission('其他收费')">
          <other-charge-query-user :row="row" v-if="show == '其他收费'" @deal-msg="dealMsg"></other-charge-query-user>
        </saletab>
        <saletab header="过户查询" v-if="permission('过户查询')">
          <transfer-query-user :row="row" v-if="show == '过户查询'" @deal-msg="dealMsg"></transfer-query-user>
        </saletab>
        <saletab header="价格调整" v-if="permission('价格调整')">
          <price-change-query-user :row="row" v-if="show == '价格调整'" @deal-msg="dealMsg"></price-change-query-user>
        </saletab>
        <saletab header="附件查看" v-if="permission('附件查看')">
          <upload-file-history :row="row" v-if="show == '附件查看'" @deal-msg="dealMsg"></upload-file-history>
        </saletab>
        <saletab header="变更记录" v-if="permission('变更记录')">
          <change-record :row="row" v-if="show == '变更记录'" @deal-msg="dealMsg"></change-record>
        </saletab>
        <saletab header="指令查看" v-if="row.f_meter_type.includes('物联网表')&&permission('指令查看')">
          <query-instruct :row="row" v-if="show == '指令查看'" @deal-msg="dealMsg"></query-instruct>
        </saletab>
        <saletab header="历史指令查看" v-if="row.f_meter_type.includes('物联网表')&&permission('历史指令查看')">
          <query-history-instruct :row="row" v-if="show == '历史指令查看'" @deal-msg="dealMsg"></query-history-instruct>
        </saletab>
        <saletab header="异常报警" v-if="row.f_meter_type.includes('物联网表')&&permission('异常报警')">
          <watch-warning :row="row" v-if="show == '异常报警'" @deal-msg="dealMsg"></watch-warning>
        </saletab>
        <saletab header="表具采集" v-if="row.f_meter_type.includes('物联网表')&&permission('表具采集')">
          <watch-collection :row="row" v-if="show == '表具采集'" @deal-msg="dealMsg"></watch-collection>
        </saletab>
        <saletab header="调价补差" v-if="permission('调价补差')">
          <price-adjustment-query-user :row="row" v-if="show == '调价补差'"
                                       @deal-msg="dealMsg"></price-adjustment-query-user>
        </saletab>
        <saletab header="设备查询" v-if="permission('设备查询')">
          <deveice-record :row="row" v-if="show == '设备查询'" @deal-msg="dealMsg"></deveice-record>
        </saletab>
        <saletab header="流量计参数查看" v-if="permission('流量计参数查看')">
          <meter-param :row="row" v-if="show == '流量计参数查看'" @deal-msg="dealMsg"></meter-param>
        </saletab>
        <saletab header="表使用量图表" v-if="permission('流量计参数查看')">
          <table-usage-chart :row="row" v-if="show == '表使用量图表'" @deal-msg="dealMsg"></table-usage-chart>
        </saletab>
        <saletab header="用户设备查询" v-if="permission('用户设备查看')">
          <user-device-query :row="row" v-if="show == '用户设备查询'" @deal-msg="dealMsg"></user-device-query>
        </saletab>
        <saletab header="合同查看" v-if="permission('合同查看')">
          <contract-signing-list :row="row" v-if="show == '合同查看'" @deal-msg="dealMsg"></contract-signing-list>
        </saletab>
      </saletabbut>
    </div>
  </div>
</template>

<script>
import {HttpResetClass} from 'vue-client'
// 导入IC卡相关查询界面
import ChangeMeterQueryUser from '../../components/common/userinfo_detail/ic_detail/ChangeMeterQueryUser'
import ChargeQueryUser from '../../components/common/userinfo_detail/ic_detail/ChargeQueryUser'
import ChargeRecordQueryUser from '../../components/common/userinfo_detail/ic_detail/ChargeRecordQuery'
import FillCardQueryUser from '../../components/common/userinfo_detail/ic_detail/FillCardQueryUser'
import HandQueryUser from '../../components/common/userinfo_detail/ic_detail/HandQueryUser'
import OtherChargeQueryUser from '../../components/common/userinfo_detail/ic_detail/OtherChargeQueryUser'
import RecordQueryUser from '../../components/common/userinfo_detail/ic_detail/RecordQueryUser'
import TransferQueryUser from '../../components/common/userinfo_detail/ic_detail/TransferQueryUser'
import CardHandRecord from '../../components/common/userinfo_detail/ic_detail/CardHandRecord'
import AutomaticPurse from '../../components/common/userinfo_detail/ic_detail/AutomaticPurse'
import Repurchase from '../../components/common/userinfo_detail/ic_detail/Repurchase'
import MachineRecordQuery from '../../components/common/userinfo_detail/ic_detail/MachineRecordQuery'
import WebAutomaticPurse from '../../components/common/userinfo_detail/ic_detail/WebAutomaticPurse'
import WebChargeQueryUser from '../../components/common/userinfo_detail/ic_detail/WebChargeQueryUser'
import WebHandQueryUser from '../../components/common/userinfo_detail/ic_detail/WebHandQueryUser'
import UserDeviceQuery from '../../components/common/userinfo_detail/ic_detail/UserDeviceQuery'
import contractSigningList from '../../components/common/userinfo_detail/ic_detail/contractSigningList'

// 导入物联网相关查询
import QueryInstruct from '../../components/common/userinfo_detail/iot_detail/QueryInstruct'
import QueryHistoryInstruct from '../../components/common/userinfo_detail/iot_detail/QueryHistoryInstruct'
import WatchCollection from './WatchCollection'
import WatchWarning from '../../components/common/userinfo_detail/iot_detail/WatchWarning'
import PriceChangeQueryUser from '../../components/common/userinfo_detail/ic_detail/PriceChangeQueryUser'
import ChangeRecord from '../../components/common/userinfo_detail/ic_detail/ChangeRecord'
import PriceAdjustmentQueryUser from '../../components/common/userinfo_detail/ic_detail/PriceAdjustmentQueryUser'
import MeterParam from '../../components/common/userinfo_detail/ic_detail/MeterParam'
import DeveiceRecord from '../../components/common/userinfo_detail/ic_detail/DeveiceRecord'

export default {
  title: '用户详细信息',
  props: ['f_userfiles_id', 'f_userinfo_id', 'f_userinfo_code', 'parentname', 'buttonshow'],
  components: {
    PriceAdjustmentQueryUser,
    PriceChangeQueryUser,
    AutomaticPurse,
    WebAutomaticPurse,
    WebChargeQueryUser,
    WebHandQueryUser,
    Repurchase,
    ChangeMeterQueryUser,
    ChargeQueryUser,
    ChargeRecordQueryUser,
    FillCardQueryUser,
    HandQueryUser,
    OtherChargeQueryUser,
    RecordQueryUser,
    TransferQueryUser,
    WatchWarning,
    WatchCollection,
    QueryInstruct,
    QueryHistoryInstruct,
    ChangeRecord,
    CardHandRecord,
    MeterParam,
    DeveiceRecord,
    MachineRecordQuery,
    UserDeviceQuery,
    contractSigningList
  },
  data () {
    return {
      row: null,
      name: '自动下账查询',
      newWebHand: this.$appdata.getSingleValue('新抄表'),
      show: ''
    }
  },
  ready () {
    this.search()
    console.log(this.$login)
  },
  methods: {
    permission (name) {
      if (this.$login.r.find(value => value == '收费综合查询')) {
        if (!this.$login.r.find(value => value == name)) {
          return false
        }
      }
      return true
    },
    async search () {
      let http = new HttpResetClass()
      let condition = ' 1 = 1'
      if (this.f_userfiles_id) {
        condition = `f_userfiles_id = '${this.f_userfiles_id}'`
      } else if (this.f_userinfo_id) {
        condition = `f_userinfo_id = '${this.f_userinfo_id}'`
      } else if (this.f_userinfo_code) {
        condition = `f_userinfo_code = '${this.f_userinfo_code}'`
      }

      let getBaseInfo = await http.load('POST', 'rs/sql/iot_getUserBaseData',
        {data: {condition: condition}}, {resolveMsg: null, rejectMsg: '获取基本信息出错'})
      this.row = getBaseInfo.data[0]
      this.row.parentname = this.parentname || ''
    },

    cancel (val) {
      this.$emit('cancel-main', val)
    },

    cancelRe (val) {
      this.$emit('cancel-re', val)
    },

    butOper (val) {
      this.name = val
    }
  },
  watch: {
    'f_userinfo_id' () {
      this.search()
    }
  }
}
</script>
