<template>
  <div v-loading="loading">
    <div class="white-box">
      <el-form ref="form"  label-width="250px" class="form-page">
        <el-form-item label="Currency">
          <el-select v-model="form.currency" placeholder="请选择">
            <el-option
              v-for="item in currencyList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="Recharge amount">
            <el-input v-model="form.applyAmount"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmits" :loading="submitButtonStat">SAVE</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import network from '@/utils/network'
import baseInfo from '@/utils/baseInfo'
import store from '@/utils/vuexStore'
export default {
  name: "recharge-add",
  mounted() {
    this.getData()
  },
  data(){
    return{
      currencyList: {
        'NGN': {
          'value': 'NGN',
          'label': 'Nigeria naira (NGN)'
        }
      },
      form:{
        currency: 'NGN',
        applyAmount: '',
        // bankNo: '',
        // bankAddress: '',
        // openBank: '',
      },
      loading: false,
      allOpenBank: null,
      submitButtonStat: false
    }
  },
  methods: {
    getData () {
      network.getData(`/finance/recharge-add`).then(response => {
        console.log(response)
        this.loading = false;
        this.allOpenBank = response.allOpenBank;
      }).catch(() => {
      });
    },
    onSubmits() {
      this.submitButtonStat = true
      let path = '/finance/recharge-add'
      let postData = {
        currency: this.form.currency,
        applyAmount: this.form.applyAmount,
      };
      return network.postData(path, postData).then(response => {
        // console.log(postData)
        // console.log(response);
        this.$message({
          message: response,
          type: 'success'
        })
        this.submitButtonStat = false
        this.$router.go(-1)
      }).catch(() => {
        this.submitButtonStat = false
      })
    },
  }
}
</script>

<style scoped>

</style>
