<template>
    <div v-loading="loading">
        <div class="white-box">
            <el-form ref="form"  label-width="250px" class="form-page">

                <el-form-item label="充值状态">
                    <el-select v-model="form.auditStatus" placeholder="充值状态">
                        <el-option v-for="(item,index) in statusArray" :key="index" :label="item"
                                   :value="index"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input v-model="form.createRemark"></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 network from '@/utils/network'
    import tool from '@/utils/tool'
    import baseInfo from '@/utils/baseInfo'
    export default {
        name: "recharge-status",
        created(){
            this.getParams()
        },
        mounted() {
            this.getData();
        },

        data(){
            return{
                loading: false,
                form:{

                    auditStatus:'',
                    createRemark:'',
                    selectedIds:'',

                },
                submitButtonStat: false,
                statusArray: null,
            }
        },
        methods: {
            getParams(){
                // 取到路由带过来的参数
                this.form.selectedIds = this.$route.query.mallCode.ID
                // 将数据放在当前组件的数据内
                //this.form.selectedIds = routerParams;

            },
            getData() {
                network.getData(`finance/recharge-status`).then(response => {
                    console.log(response)
                    this.loading = false;
                    this.statusArray = response.statusArray;
                    console.log(statusArray)
                }).catch(() => {
                });


            },
            onSubmit() {
                this.submitButtonStat = true
                let path = 'finance/recharge-status';
                let postData = {

                    auditStatus: this.form.auditStatus,
                    createRemark: this.form.createRemark,
                    selectedIds: this.form.selectedIds,

                }

                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
                })
            },



        },
        watch: {
            '$route': 'getParams'
        }
    }
</script>

<style>
    .el-button--small, .el-button--small.is-round{padding: 9px 10px;}
</style>