<template>
    <el-dialog title="押金退还审核" :visible.sync="dialogVisible" width="500px" class="dialog-info">
        <div class="info-wrp">
            <div class="header">
                <i class="el-icon-warning"></i>
                <p>确定要退还押金吗？</p>
            </div>
            <el-form :model="form" label-width="90px">
                <el-form-item label="退还类型：">
                    <el-radio-group v-model="form.refundStatus" size="medium">
                        <el-radio label="3">立即退还</el-radio>
                        <el-radio label="4">延期退还</el-radio>
                        <el-radio label="5">拒绝退还</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="延期天数：" v-if="form.refundStatus==4">
                    <el-radio-group v-model="form.refundDelayDayCount" size="medium">
                        <el-radio label="7">7天</el-radio>
                        <el-radio label="14">14天</el-radio>
                        <el-radio label="30">30天</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item :label="form.refundStatus==4 ? '延期理由：' : '拒绝理由：'" v-if="form.refundStatus!=3">
                    <el-input type="textarea" :rows="3" placeholder="请输入理由" v-model="form.refundExamineReason">
                    </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="submit">确 定</el-button>
            </span>
        </div>
    </el-dialog>
</template>

<script>
    import api from "@/api/capital"
    export default {
        name: "deposit-audit",
        data() {
            return {
                dialogVisible: false,
                form: {}
            }
        },
        methods: {
            open(bol, id) {
                this.dialogVisible = true
                if(bol) {
                    api.depositResult({ id }).then(res => {
                        console.log(res)
                        this.form = res.results.resultList[0]
                        this.form.refundStatus = this.form.refundStatus+''
                        this.form.refundDelayDayCount = this.form.refundDelayDayCount+''
                    }).catch(error => {
                        console.log(error)
                    })
                } else {
                    this.form = {
                        id,
                        refundStatus: '3',
                        refundDelayDayCount: '7',
                        refundExamineReason: ''
                    }
                }
            },
            submit() {
                api.depositAudit(this.form).then(res => {
                    console.log(res)
                    this.$message({
                        type: 'success',
                        message: '提交成功!'
                    });
                    this.dialogVisible = false
                    this.$emit('updateList')
                }).catch(error => {
                    console.log(error)
                })
            }
        }
    }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dialog-info {
    .header {
        text-align: center;
        i {
            font-size: 50px;
        }
    }
    .dialog-form {
        .form-item {
            padding-bottom: 10px;
        }
    }
    .dialog-footer {
        display: block;
        text-align: center;
    }
}
</style>