<template>
  <div class="panel panel-default auto repair-info-content">
    <div class="panel-body">
      <div class="auto repair-info-content compatible ">
        <div class="row auto">
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">用户名称</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_user_name">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">用户编号</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_userid">
          </div>
          <div class="col-xs-12 col-sm-12 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">地址</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_address">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
          <label class="text-justify lb-left">表号</label>
          <input type="text" class="form-control" readonly v-model="bukadata.f_meternumber">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">表厂</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_changjia">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">气表品牌</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_gaswatchbrand">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">气表型号</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_metertype">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">气表类型</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_gasmeterstyle">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">气量</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_gasbill">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">次数</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_times">
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 form-input-group mg8">
            <label class="text-justify lb-left">卡号</label>
            <input type="text" class="form-control" readonly v-model="bukadata.f_cardid">
          </div>
        </div>
        <div class="row auto flex-between">
          <button type="button" name="button" class="btn btn-primary pull-right" @click="xiaka">写卡</button>
          <button type="button" name="button" class="btn btn-primary pull-left" @click="upload">补气</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import Vue from 'vue'
export default {
  title:'add-gas',
  data(){
    return{
      userinfo:{
        test:''
      }
    }
  },
  props: {
    bukadata:{
      type:Object
    },
    isbuka:{
      type:String,
      default:'buka'
    }
  },
  ready () {
    // 获取用户档案
    this.$resetpost(Vue.dataUrl + 'rs/sql/singleTable', {
      data: {
        tablename: 'T_USERFILES',
        condition: "f_userid = '" + this.bukadata.f_userid + "'"
      }
    }).then((res) => {
      this.userinfo = Object.assign({}, this.userinfo, res.data[0])
    })
    // //  获取卡号
    // this.$resetpost(Vue.dataUrl + 'rs/sql/singleTable', {
    //   data: {
    //     tablename: 'T_USERFILES',
    //     condition: "f_userid = '" + this.bukadata.f_userid + "'"
    //   }
    // }).then((res) => {
    //   this.userinfo = Object.assign({}, this.userinfo, res.data[0])
    // })
  },
  data () {
    return {

    }
  },
  methods: {
    xiaka(){
      var json = {
        kzt: '0',  //卡状态
        yhh: '1', //user no
        tm: '0',  //barcode
        bkcs: '0', //make up count
        ljyql: '0', //used gas quantity
        klx: this.bukadata.klx, //卡类型
        meterid: this.bukadata.f_meternumber,
        stairprice1: this.userinfo.f_stair1price,
        stairgas1: this.userinfo.f_stair1amount,
        stairprice2: this.userinfo.f_stair2price,
        stairgas2: this.userinfo.f_stair2amount,
        stairprice3: this.userinfo.f_stair3price,
        stairgas3: this.userinfo.f_stair3amount,
        factory: this.userinfo.f_aliasname,
        kmm: '000000',
        kh: '1000000001',
        dqdm: '0',
        ql: '0',
        csql: '0',
        ccsql: '0',
        cs: 1,
        ljgql:this.userinfo.f_cumulativepurchase,
        bjql: this.userinfo.f_metergasnums,
        czsx: '9999',  //recharge limit
        tzed: '0',
        sqrq: '0',
        cssqrq: '0',
        oldprice: '0',
        newprice: '0',
        sxrq: '0',
        sxbj: '0'
      }
      var jo = HostApp.issue(JSON.stringify(json))
      HostApp.alert('写卡结果：JSON.stringify(jo):' + JSON.stringify(jo))
    }

  }
}
</script>

