<template>
    <div v-loading="loading">
        <div class="white-box">
            <el-form ref="form"  label-width="250px" class="form-page">
                <el-form-item label="充值金额">
                    <el-input v-model="form.applyAmount"></el-input>
                </el-form-item>
                <el-form-item label="银行账号">
                    <el-input v-model="form.bankNo"></el-input>
                </el-form-item>
                <el-form-item label="汇款银行">
                    <el-select v-model="form.openBank" placeholder="请选择开户行">
                        <el-option v-for="(item,index) in allOpenBank" :key="index" :label="item.BANK_NAME"
                                   :value="item.BANK_CODE"></el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="开户支行">
                    <el-input v-model="form.bankAddress"></el-input>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" @click="onSubmits" :loading="submitButtonStat">保存</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{

                form:{
                    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 = {
                    openBank: this.form.openBank,
                    bankAddress: this.form.bankAddress,
                    bankNo: this.form.bankNo,
                    applyAmount: this.form.applyAmount,


                };

                return network.postData(path, postData).then(response => {
                    console.log(response);
                    this.$message({
                        message: response,
                        type: 'success'
                    })
                    this.submitButtonStat = false
                    this.$router.go(-1)
                }).catch(() => {
                    this.submitButtonStat = false
                })
            },
        }


    }
</script>

<style scoped>

</style>