<style scoped>
.bg {
  background-color: blue;
  height: 1px;
  border: 0;
}
.app-row {
  background-color: white;
  padding: 10px 10px 0 10px;
  border-bottom: 1px solid rgba(235, 235, 235, 0.5);
}
.search_input {
  border: 0;
  outline: none;
}
.font{
  font: 15px PingFang-SC-Medium;
  color: #666666;
}
.input-font{
  font: 15px PingFang-SC-Medium;
  color: #333333;
}
.btn-font{
  font:600 16px PingFang-SC-Bold;
  color: #499EDF;
}
.btn-color{
  background-color: #FFFFFF;
  border-radius: 10px ;
  border: 1px solid #499EDF;
}
.app-text {
  font-size: 12px;
}
.panel-self{
  border-radius: 10px;
  border:1px solid #499EDF;
  background-color: #F8F8F8;
}
.btn_cz {
  background-color: #499edf;
  color:#FFFFFF;
  width: 55px;
  margin-right: 2%;
  margin-top: 10px;
  height: 38px;
  border-radius: 9px;
  font: 600 17px PingFang-SC-Bold;
}

.button_shrink_top {width: 35px; height: 35px; background-size:100%;background-image: url("../../../static/newStyle/stretch_top.png")}
.button_shrink_bottom {width: 35px; height: 35px;  background-size:100%;background-image: url("../../../static/newStyle/stretch_bottom.png")}
.button_shrink_left {width: 35px; height: 35px;  background-size:100%;background-image: url("../../../static/newStyle/stretch_left.png")}
.button_shrink_right {width: 35px; height: 35px; background-size:100%;background-image: url("../../../static/newStyle/stretch_right.png")}
</style>

<template>
  <div style="height: auto;width: 100%">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfsearch' v-ref:cri>
        <div partial>
          <form>
            <div class="row app-row">
              <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  class="search_input input-font" v-model="model.f_user_name" condition="ui.f_user_name = '{}'" />
              </div>
            </div>
            <div class="row app-row">
              <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  class="search_input input-font" v-model="model.f_userinfo_code" condition="ui.f_userinfo_code = '{}'" />
              </div>
            </div>
            <div class="row app-row">
              <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  class="search_input input-font" v-model="model.f_meternumber" condition=" uf.f_meternumber = '{}'" />
              </div>
            </div>
            <div class="row app-row">
              <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  class="search_input input-font" v-model="model.f_card_id" condition=" uf.f_card_id = '{}'" />
              </div>
            </div>
            <div class="row text-center" style="margin-top: 20px;text-align: center">
              <button type="button" class="btn btn-lg btn-font" style="width: 25%;margin-right: 3%; background-color: #499edf;color:#FFFFFF;border-radius: 10px ;" @click="search()">查询</button>
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 25%;margin-right: 3%" @click="$parent.$parent.Scanningtable">扫条码</button>
            </div>
            <!--<div class="row text-center" style="margin-top: 20px;">
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 25%;" @click="$parent.$parent.searchBluetooth">扫描蓝牙</button>
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 25%;" @click="$parent.$parent.gotoReadCard">蓝牙读卡</button>
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 25%;" @click="$parent.$parent.poscard" v-if="$parent.$parent.ispos">POS读卡</button>
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 25%;" @click="$parent.$parent.Scanningtable">扫表号</button>
            </div>-->
            <div style="height:20px;"></div>
          </form>
        </div>
      </criteria>
      <list :model="model" partial='list'>
        <div partial>
          <div  class="auto app-text" style="margin-top: 5px;" @click="$parent.$parent.$parent.selectopt(row)">
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self">
                <div class="col-xs-12" v-show="row.f_userinfo_code">
                  <p class="panel-title col-xs-5 text-left font" style="float: left"><b>用户编号:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" >{{ row.f_userinfo_code }}</p>
                </div>
                <div class="col-xs-12" v-show="row.f_user_name">
                  <p class="panel-title col-xs-5 text-left font" style="float: left" ><b>用户名称:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" >{{ row.f_user_name }}</p>
                </div>
                <div class="col-xs-12" v-show="row.f_user_phone">
                  <p class="panel-title col-xs-5 text-left font"><b>用户电话:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" >{{ row.f_user_phone }}
                  </p>
                </div>
                <div class="col-xs-12" v-show="row.f_address">
                  <p class="panel-title col-xs-5 text-left font"><b>用户地址:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" >{{ row.f_address }}</p>
                </div>
                <div class="col-xs-12" v-show="row.f_meternumber">
                  <p class="panel-title col-xs-5 text-left font"><b>条码:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_meternumber }}</p>
                </div>
                <div class="col-xs-12" v-show="row.f_meter_brand">
                  <p class="panel-title col-xs-5 text-left font"><b>气表品牌:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_meter_brand }}</p>
                </div>
                <div class="col-xs-12" v-show="row.f_meter_type">
                  <p class="panel-title col-xs-5 text-left font"><b>气表类型:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_meter_type }}</p>
                </div>
                <div class="col-xs-12" v-show="row.f_collection_type">
                  <p class="panel-title col-xs-5 text-left font"><b>表位置:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_position }}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </list>
    </criteria-paged>

    <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: '在线操作',
  data() {
    return {
      model_f: false,
      ispos: false,
      cardinfo: {},
      userinfo: {},
      operation: '',
      model:new PagedList( `${this.$androidUtil.getProxyUrl()}/rs/sql/onlinequeryuser`,5),
      f_operator: Vue.user.name,
      f_orgid : Vue.user.orgid

    }
  },
  ready(){
    //tag

  },

  methods: {
    selfsearch(args){
      if(args.condition == ' 1=1 '){
        this.$showMessage('     请输入条件...')
        return
      }else {
        //args.condition += ` and uf.f_orgid = '${this.f_orgid}' and f_table_state = '正常' `
        // 取消分公司
        // args.condition += ` and f_table_state = '正常' `
        // args.condition += ` and uf.f_orgid = '454' and f_table_state = '正常'  `
        //tag
        //tag
        this.model.search(args.condition)
      }


    },
    poscard() {
      //tag
      if (this.ispos) {
        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('该设备暂不支持')
      }

    },
    selectopt(row) {
      let _this = this
      //tag
      //tag)
      var pardate = {
        _this:this,
        title:'在线操作',
        safe:true
      }
      _this.$dispatch('gotoson',pardate)
      _this.$goto('online-operations', {item: row}, 'self')
    },
    openvalve (f_meternumber) {
      //tag
      var data = {
        f_meternumber: `${f_meternumber}`,
        type: '开阀',
        f_operator: `${this.f_operator}`
      }
      //tag)
      this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/openfileorvalve`, {data: data}).then((row) => {
        //tag)
        this.$showMessage(row.data.msg)
      }).catch((e) => {
        //tag
        //tag)
      })
    },
    clonevalve (f_meternumber) {
      //tag
      var data = {
        f_meternumber: `${f_meternumber}`,
        type: '关阀',
        f_operator: `${this.f_operator}`
      }
      //tag)
      this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/openfileorvalve`, {data: data}).then((row) => {
        //tag
        this.$showMessage(row.data.msg)
      }).catch((e) => {
        //tag
        //tag)
      })
    },
    cancel() {
      //tag
      this.model_f = false
    },
    searchBluetooth() {
      //tag
      HostApp.searchPRMT()
    },
    gotoReadCard() {
      //tag
      let isConnect = HostApp.isConnect().data
      //tag)
      if(isConnect) {
        //tag
        let blueinfo = HostApp.read("XianYang")
        //tag)
        if(blueinfo.code == 200){
          this.$showMessage('读卡成功,请点击查询按钮')
          this.$refs.paged.$refs.cri.model.f_card_id = blueinfo.msg.CardID // 卡号
          this.$refs.paged.$refs.cri.model.f_alias = blueinfo.msg.Factory // 表别名
        }else {
          this.$showMessage(posinfo.msg)
        }
      }else {
        //tag
        this.$showMessage('连接失败！请打开蓝牙或蓝牙读卡器')
      }
    },
    gotoPOSSingle() {
      //tag
      let posinfo = HostApp.read("XianYang")
      //tag)
      if(posinfo.code == 200){
        this.$showMessage('读卡成功,请点击查询按钮')
        this.$refs.paged.$refs.cri.model.f_card_id = posinfo.msg.CardID // 卡号
        this.$refs.paged.$refs.cri.model.f_alias = posinfo.msg.Factory // 表别名
      }else {
        this.$showMessage(posinfo.msg)
      }
    },
    Scanningtable() {
      //tag
      HostApp.__this__=this
      HostApp.scanCode({callback:"javascript:HostApp.__this__.getCode();"})
    },
    getCode(){
      var datapa = HostApp.getCode().data;
      //tag
      this.$refs.paged.$refs.cri.model.f_meternumber = datapa
      this.$showMessage(`扫码返回值为：${datapa}`)

    }

  }
}



</script>
