<template>
  <div class="" style="height:100%;width: 100%;background: #eff0f0;">
    <!--操作-->
    <div class="auto" style="">
      <div class="row app-row auto" style="padding: 0px; background: aliceblue;">
        <div class="col-xs-4" style="text-align: center;margin: 15px 0;" v-show="parameters.salegas && !item.f_meternumber"
             @click="inspectdianhuo(this.item)">
          <div>
            <img src="../../assets/售气1.png" style="width: 40px;height: 40px;margin-bottom: 5px;" alt="">
          </div>
          <label class="input-font" style="padding-right: 0px;">点火</label>
        </div>
        <div class="col-xs-4" style="text-align: center;margin: 15px 0;" v-show="parameters.changetable && item.f_meternumber"
             @click="gotochangemeter(this.item)">
          <div>
            <img src="../../assets/换表1.png" style="width: 40px;height: 40px;margin-bottom: 5px;" alt="">
          </div>
          <label class="input-font" style="padding-right: 0px;">换表</label>
        </div>
        <div class="col-xs-4" style="text-align: center;margin: 15px 0;" v-show="parameters.cardreissue && item.f_meternumber"
             @click="inspectweihu(this.item)">
          <div>
            <img src="../../assets/补卡1.png" style="width: 40px;height: 40px;height:40px;margin-bottom: 5px;" alt="">
          </div>
          <label class="input-font" style="padding-right: 0px;">维护</label>
        </div>
        <div class="col-xs-4" style="text-align: center;margin: 15px 0;" v-show="parameters.readcard && item.f_meternumber"
             @click="inspectxunjian(this.item)">
          <div>
            <img src="../../assets/读卡1.png" style="width: 40px;height: 40px;margin-bottom: 5px;" alt="">
          </div>
          <label class="input-font" style="padding-right: 0px;">巡检</label>
        </div>
        <div class="col-xs-4" style="text-align: center;margin: 15px 0;" v-show="parameters.othercharge && item.f_meternumber"
             @click="insepctshebei(this.item)">
          <div>
            <img src="../../assets/其他收费1.png" style="width: 40px;height: 40px;margin-bottom: 5px;" alt="">
          </div>
          <label class="input-font" style="padding-right: 0px;">设备管理</label>
        </div>
      </div>
    </div>
    <!--用户信息-->
    <div style="" class="auto">
      <div class="row app-row" v-show="item.f_userinfo_code">
        <div class="col-xs-4">
          <!--<img src="../../assets/用户姓名.png" style="width: 20px;margin-bottom: 5px" alt="">-->
          <label class="font text-left">用户编号</label>
        </div>
        <div class="col-xs-8">
          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right"
                 v-model="item.f_userinfo_code" placeholder="用户编号">
        </div>
      </div>
      <div class="row app-row" v-show="item.f_user_name">
        <div class="col-xs-4">
          <label class="font text-left">用户姓名</label>
        </div>
        <div class="col-xs-8">
          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right"
                 v-model="item.f_user_name"
                 placeholder="用户姓名">
        </div>
      </div>
      <div class="row app-row" v-show="item.f_user_phone">
        <div class="col-xs-4">
          <label class="font text-left">用户电话</label>
        </div>
        <div class="col-xs-8">
          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right"
                 v-model="item.f_user_phone"
                 placeholder="用户编号">
        </div>
      </div>
<!--      <div class="row app-row" v-show="item.f_user_type">-->
<!--        <div class="col-xs-4">-->
<!--          <label class="font text-left">用户类型</label>-->
<!--        </div>-->
<!--        <div class="col-xs-8">-->
<!--          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right"-->
<!--                 v-model="item.f_user_type"-->
<!--                 placeholder="用户类型">-->
<!--        </div>-->
<!--      </div>-->
      <div class="row app-row" v-show="item.f_address">
        <div class="col-xs-4">
          <label class="font text-left">用户地址</label>
        </div>
        <div class="col-xs-8">
          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right"
                 v-model="item.f_address" placeholder="用户姓名">
        </div>
      </div>
      <div class="row app-row" v-show="item.f_meternumber">
        <div class="col-xs-4">
          <label class="font text-left">条码</label>
        </div>
        <div class="col-xs-8">
          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right"
                 v-model="item.f_meternumber"
                 placeholder="条码">
        </div>
      </div>
      <div class="row app-row" v-show="item.f_meter_brand">
        <div class="col-xs-4">
          <label class="font text-left">表品牌</label>
        </div>
        <div class="col-xs-8">
          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right"
                 v-model="item.f_meter_brand"
                 placeholder="气表品牌">
        </div>
      </div>
      <div class="row app-row" v-show="item.f_meter_type">
        <div class="col-xs-4">
          <label class="font text-left">表类型</label>
        </div>
        <div class="col-xs-8">
          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right"
                 v-model="item.f_meter_type"
                 placeholder="气表类型">
        </div>
      </div>
<!--      <div class="row app-row" v-show="item.f_total_gas">-->
<!--        <div class="col-xs-4">-->
<!--          <label class="font text-left">累计气量</label>-->
<!--        </div>-->
<!--        <div class="col-xs-8">-->
<!--          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right" v-model="item.f_total_gas"-->
<!--                 placeholder="累计气量">-->
<!--        </div>-->
<!--      </div>-->
<!--      <div class="row app-row" v-show="item.f_total_fee">-->
<!--        <div class="col-xs-4">-->
<!--          <label class="font text-left">累计金额</label>-->
<!--        </div>-->
<!--        <div class="col-xs-8">-->
<!--          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right" v-model="item.f_total_fee"-->
<!--                 placeholder="累计金额">-->
<!--        </div>-->
<!--      </div>-->

      <div class="row app-row">
        <div class="col-xs-4">
          <label class="font text-left">表位置</label>
        </div>
        <div class="col-xs-8">
          <input type="text" readonly style="width: 95%;" class="search_input input-font text-right" v-model="item.f_position"
                 placeholder="表位置">
        </div>
      </div>
    </div>
    <modal :show.sync="model_f" v-ref:modal>
      <div slot="modal-header" class="modal-header">
        <h4 class="modal-title">
          卡信息
        </h4>
      </div>
      <div slot="modal-body" class="modal-body">
        <div class="flex">
          <div class="row">
            <label class="col-sm-2">卡号:</label>
            <span class="col-sm-3">{{ cardinfo.CardID }}</span>
          </div>
          <div class="row">
            <label class="col-sm-2">厂名:</label>
            <span class="col-sm-3">{{ cardinfo.Factory }}</span>
          </div>
          <div class="row">
            <label class="col-sm-2">气量:</label>
            <span class="col-sm-3">{{ cardinfo.Gas }}</span>
          </div>
          <div class="row">
            <label class="col-sm-2">金额:</label>
            <span class="col-sm-3">{{ cardinfo.Money }}</span>
          </div>
          <div class="row">
            <label class="col-sm-2">写卡次数:</label>
            <span class="col-sm-3">{{ cardinfo.Times }}</span>
          </div>
        </div>
      </div>
      <div slot="modal-footer" class="modal-footer">
        <button type="button" name="button" class="col-sm-3 btn btn-primary" @click="cancel()">关闭</button>
      </div>
    </modal>
  </div>

</template>

<script>
import Vue from 'vue'
import {PagedList, HttpResetClass} from 'vue-client'

export default {
  title: '在线操作',
  props: ['item'],
  data() {
    return {
      parameters: {
        "salegas": true,
        "changetable": true,
        "cardreissue": true,
        "readcard": true,
        "othercharge": true
      },
      ispos: 'false',
      model_f: false,
      // f_operator: Vue.user.name,
      // f_orgid : Vue.user.orgid
      f_operator: '温艺轩',
      f_orgid: '21142'

    }
  },
  methods: {
    inspectxunjian(info) {
      info.id = ''
      info.f_state = '未检'
      info.f_no_checkplan = '无计划安检'
      //tag
      var pardate = {
        _this: this,
        tittle: '巡检详情',
        safe: true
      }
      this.$dispatch('gotoson', pardate)
      this.$goto('inspectionOrderV', {item: info, role: 'inspect'}, 'self', this.reload)
    },
    inspectweihu(info) {
      info.id = ''
      info.f_state = '未检'
      info.f_no_checkplan = '无计划安检'
      //tag
      var pardate = {
        _this: this,
        tittle: '巡检详情',
        safe: true
      }
      this.$dispatch('gotoson', pardate)
      this.$goto('inspectionOrderVs', {item: info, role: 'inspect'}, 'self', this.reload)
    },
    inspectdianhuo(info) {
      info.id = ''
      info.f_state = '未检'
      info.f_no_checkplan = '无计划安检'
      //tag
      var pardate = {
        _this: this,
        tittle: '巡检详情',
        safe: true
      }
      this.$dispatch('gotoson', pardate)
      this.$goto('inspectionOrderVss', {item: info, role: 'inspect'}, 'self', this.reload)
    },


    insepctshebei(info) {
      let _this = this
      //tag
      //tag
      //tag
      new HttpResetClass().load('post', `${this.$androidUtil.getProxyUrl()}/rs/logic/getSheBei`, {
        data: {
          f_userinfo_id: info.f_userinfo_id
        }
      }).then(res=>{
        //tag
        if (res.data.code=='200'){
          let userinfo=[res.data.msg]
          //tag
          //tag)
          let pardate = {
            _this: this,
            title: '设备管理',
            safe: true
          }
          _this.$dispatch('gotoson', pardate)
          //tag
          userinfo[0].f_userinfo_id=info.f_userinfo_id
          _this.$goto('equipment-management', {item: userinfo[0]}, 'self')
        }else{
          this.$showMessage('获取设备信息失败'+res.data.msg)
          return
        }

      })

    },
    gotobygas(row) {
      //tag)
      let _this = this
      let param = {
        condition: `u.f_filialeid in ('${_this.f_orgid}') and  1=1  and f_userinfo_code = '${row.f_userinfo_code}' and 1=1`,
        orderitem: "f_userinfo_id desc DESC"
      }
      _this.$resetpost(`${_this.$androidUtil.getProxyUrl()}/rs/sql/sale_getUser`, {data: param}).then((row) => {
        //   this.$resetpost(`rs/sql/sale_getUser`, {data: param}).then((row) => {
        //tag + '参数')
        let item = row.data[0]
        let pardate = {
          _this: this,
          title: '在线购气',
          safe: true
        }
        _this.$dispatch('gotoson', pardate)
        //tag
        _this.$goto('online_buy_gas', {row: item}, 'self')
      }).catch((e) => {
        //tag)
        this.$showMessage('参数获取失败！')
      })

    },
    gotochangemeter(row) {
      //tag
      let _this = this
      var pardate = {
        _this: this,
        title: '在线换表',
        safe: true
      }
      _this.$dispatch('gotoson', pardate)
      //tag
      _this.$goto('online-change-meters', {item: row}, 'self')
    },
    otherCharge(row) {
      //tag
      let _this = this
      var pardate = {
        _this: this,
        title: '其他收费',
        safe: true
      }
      _this.$dispatch('gotoson', pardate)
      //tag
      _this.$goto('other_charge', {row: row}, 'self')

    },
    poscard() {
      //tag
      if (this.ispos == 'true') {
        let posinfo2 = HostApp.read("XianYang")
        //tag)
        if (posinfo2.code == 200) {
          //tag
          this.cardinfo = posinfo2.msg
          this.$refs.paged.$refs.cri.model.f_card_id = posinfo2.msg.CardID // 卡号
          this.$refs.paged.$refs.cri.model.f_alias = posinfo2.msg.Factory // 表别名
          this.model_f = true
        } else {
          this.$showMessage(posinfo2.msg)
        }
      } else {
        this.$showMessage('该设备暂不支持')
      }

    },
    gotomakecard(row) {
      //tag
      let _this = this
      var pardate = {
        _this: this,
        title: 'POS补卡',
        safe: true
      }
      _this.$dispatch('gotoson', pardate)
      _this.$goto('pos-onlinemakecard', {item: row}, 'self')
    },

  },
  ready() {
    /*
    this.ispos = this.$androidUtil.getPreference('pos')
    //tag)
    //tag)
    // 获取配置项
    if(Vue.config.safecheck != undefined){
      if(Vue.config.safecheck.ApproveConfig != undefined){
          this.parameters = Vue.config.safecheck.ApproveConfig
        //tag)
      }else {
        //tag
      }
    }*/
  }
}
</script>

<style scoped>
.app-row {
  background-color: white;
  padding: 5px 10px 0 10px;
  border-bottom: 1px solid rgba(235, 235, 235, 0.5);
}

.search_input {
  border: 0;
  outline: none;
}

.font {
  font: 16px PingFang-SC-Medium;
  color: #958e8e;
}

.input-font {
  font: 15px PingFang-SC-Medium;
  color: #333333;
}
</style>
