<template>
  <div class="flex-row">
    <div class="span" style="overflow-y: auto;">
        <form novalidate class="form-horizontal">
          <div class="row">
            <div class="col-sm-4" v-if="row.f_remanent_gas > 0">
              <label for="f_pregas" class=" font_normal_body">应补气量</label>
              <input class="input_search" style="width:60%" type="number"
                     v-model="row.f_remanent_gas" disabled>
            </div>
            <div class="col-sm-4" v-if="row.f_remanent_money > 0">
              <label for="f_pregas" class=" font_normal_body">应补金额</label>
              <input class="input_search" style="width:60%" type="number"
                     v-model="row.f_remanent_money" disabled>
            </div>
          </div>
          <div class="row" style="padding-top: 0.5em;">
            <div class="col-sm-12">
              <label for="f_comments" class="font_normal_body">&nbsp;&nbsp;&nbsp;备注&nbsp;&nbsp;&nbsp;</label>
              <input class="input_search" style="width:87%" v-model="model.f_comments" rows="1" placeholder="备注">
            </div>
          </div>
        </form>
        <div style="text-align:right;height: 25%;margin-top: 2%">
          <button class="button_search btn-gn" @click="confirm()">确认</button>
          <button class="button_clear btn-gn" @click="clean()">取消</button>
        </div>
    </div>
  </div>
  <upload :blodid="blodid" v-if="false" isremark="true" fusetype="机表补气"></upload>
</template>
<script>
  /**
   *综合业务
   *物联网表收费组件
   */

  export default {
    title: '机表补气',
    data () {
      return {
        model: {
          f_fill_gas: 0,
          f_comments: ''
        },
        blodid: '',
        remanentfalg: false,
        remanentstr: ''
      }
    },
    props: ['row'],
    ready () {
      this.blodid = this.row.f_userinfo_id
      this.calRemanentMoney()
    },
    methods: {
      async confirm () {
        this.model.f_operator = this.$login.f.name
        this.model.f_operatorid = this.$login.f.id
        this.model.f_orgid = this.$login.f.orgid
        this.model.f_orgname = this.$login.f.orgs
        this.model.f_depid = this.$login.f.depids
        this.model.f_depname = this.$login.f.deps

        // 保存补气记录
        await this.$resetpost('rs/logic/sale_machineChangeFill', {data: {model: this.model, row: this.row}}, {resolveMsg: '补气成功！！', rejectMsg: '补气失败！！'})
        this.$dispatch('success')
      },
      clean () {
        this.$info('取消操作')
        this.$dispatch('refresh', this.row)
      },
      calRemanentMoney () {
      // 计算 应补气量
        if (this.row.f_remanent_gas > 0 && this.row.f_remanent_money > 0) {
          this.$showAlert('旧表剩余量有问题！！请联系开发人员处理！！', 'warning', 3000)
        }
      }
    }
  }
</script>
