<template>
  <div v-loading="loading">
    <div class="white-box">
      <el-form ref="form" :model="form" label-width="100px" style="width:500px;">
        <el-form-item label="会员编号">
          <el-input v-model="form.userName" @change="getData"></el-input>
        </el-form-item>
        <el-form-item label="是否合格">
          <el-radio-group v-model="form.isPass">
            <el-radio-button :label="1">合格</el-radio-button>
            <el-radio-button :label="0">不合格</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea" :rows="2" placeholder="备注" v-model="form.remark">
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">提交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import store from '@/utils/vuexStore'
import network from '@/utils/network'
import tool from '@/utils/tool'

export default {
  name: 'reconsume_deduct',
  mounted () {
    this.getData()
  },
  data () {
    return {
      form: {
        userName: null,
        isPass: 1,
        remark: null,
      },
      balance: {
        unusedPV: 0,
        unusedMonth: 0,
      },
      loading: true,
      submitButtonStat: false,
    }
  },
  methods: {
    onSubmit () {
      this.submitButtonStat = true
      let path = 'reconsume/deduct'
      network.postData(path, this.form).then(response => {
        this.$message({
          message: response,
          type: 'success'
        })
        this.submitButtonStat = false
      }).catch(response => {
        this.submitButtonStat = false
      })
    },
    getData(){
      if(this.form.userName !== null && this.form.userName !== ''){
        network.getData('reconsume/deduct-audit-add', {userName: this.form.userName}).then(response => {
          this.balance = response
          this.loading = false
        })
      } else {
        this.loading = false
      }
    },
  }
}
</script>

<style scoped>

</style>