<template>
  <div class="auto">
    <validator name='v'>
      <form novalidate class="form-horizontal">
        <label class=" font_normal_body">旧表剩余金额:</label>
          <input class="input_search" style="width:60%" type="number" v-model="model.f_tablebase" placeholder="表底数" :disabled="disabled">
      </form>
      <div class="col-sm-4" style="margin-left:8%" v-if="!message">
        <button class="button_search" @click="confirm()"  :disabled='!$v.valid'>确认</button>
        <button class="button_clear" @click="clean()" >取消</button>
      </div>
    </validator>
  </div>
</template>
<script>
/**
*换表管理
*处理旧表为金额卡表的旧表信息
*/
export default {
  data () {
    return {
      model: {},
      disabled: false
    }
  },
  props: ['row', 'message'],
  methods: {
    confirm () {
      if (this.model.f_tablebase < 0) {
        this.$ChangeMeterService.changeMeter(this.model, this.row)
        .then((res) => {
          this.$dispatch('firstsuccess', 'hand', res.data)
          this.disabled = true
        }).catch((error) => {
          this.$dispatch('error', '换表管理', this.data, error)
        })
      } else {
        this.row.f_newremanent_amount = (this.model.f_tablebase - 0)
        this.row.f_tablebase = (this.model.f_tablebase - 0)
        this.$dispatch('firstsuccess', 'nohand')
      }
    },
    clean () {
      this.$dispatch('clean', this.row)
    }
  }
}
</script>
