<template>
  <form novalidate class="form-horizontal">
    <div class="row">
      <div class="col-sm-4 form-group">
        <label class="font_normal_body">客户名称</label>
        <input class="input_search" style="width:60%" v-model=model.f_user_name readonly>
      </div>
      <div class="col-sm-4 form-group">
        <label class="font_normal_body">表&emsp;&emsp;号</label>
        <input class="input_search" style="width:60%" v-model=model.f_meternumber readonly>
      </div>
      <div class="col-sm-4 form-group">
        <label class="font_normal_body">应交气量</label>
        <input class="input_search" style="width:60%" v-model=model.f_oughtamount readonly>
      </div>
      <div class="col-sm-4 form-group">
        <label class="font_normal_body">应交金额</label>
        <input class="input_search" style="width:60%" v-model=model.f_oughtfee readonly>
      </div>
      <div class="col-sm-4 form-group">
        <label class="font_normal_body">上期底数</label>
        <input class="input_search" style="width:60%" v-model=model.f_last_tablebase readonly>
      </div>
      <div class="col-sm-4 form-group">
        <label class="font_normal_body">本期底数</label>
        <input class="input_search" style="width:60%" v-model=model.f_tablebase readonly>
      </div>
      <div class="col-sm-4 form-group">
        <label class="font_normal_body">剩余金额</label>
        <input class="input_search" style="width:60%" v-model=model.f_balance_amount readonly>
      </div>
    </div>
    <div style="text-align:right;height:auto;">
      <button class="button_search btn-gn" type="button" @click="cancel()">冲正</button>
    </div>
  </form>
</template>
<script>
  let readyGen = async function (self) {
    let param = {
      f_userinfo_id: self.row.f_userinfo_id,
      f_orgid: self.row.f_orgid
    }
    let res = await self.$resetpost(
      'rs/sql/getNewHandplan',
      {data: param},
      {rejectMsg: null, resolveMsg: null})
    self.model = res.data[0]
  }
  export default {
    title: '物联网抄表冲正',
    props: ['row'],
    data () {
      return {
        model: {},
      }
    },
    ready () {
      readyGen(this)
    },
    methods: {
      async cancel (){
        let res = await this.$showMessage('确定要对此条抄表记录进行冲正操作吗？',['confirm', 'cancel'])
        if(res === 'confirm') {
          let param = {
            operInfo: {
              f_operator: this.$login.f.name,
              f_operatorid: this.$login.f.id,
              f_orgid: this.$login.f.orgid,
              f_orgname: this.$login.f.orgs,
              f_depid: this.$login.f.depids,
              f_depname: this.$login.f.deps
            },
            f_hand_id: this.model.id
          }
          await this.$resetpost('rs/logic/iotHandplanCancel',{data: param}).then(res => {
            if(res.data.code === 200) {
              this.$showAlert('抄表记录冲正成功','success', 1500)
            } else {
              this.$showAlert(res.data.msg,'warning',2000)
            }
            readyGen(this)
          })
        }
      }
    }
  }
</script>
