<template>
    <el-dialog title="驳回" :visible.sync="dialogVisible" width="50%" :before-close="close">
        <el-form :model="ruleForm" ref="ruleForm" label-width="100px">
            <el-form-item label="驳回原因" prop="notExamineReason">
                <el-input type="textarea" v-model="ruleForm.notExamineReason" maxLength="20"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="close">取 消</el-button>
            <el-button type="primary" @click="submit" :disabled="submitBtndisabled">确 定</el-button>
        </span>
    </el-dialog>
</template>

<script>
import { memberFeeApprove } from '@/apps/mobile/api/memberFee/index';
export default {
    data() {
        return {
            dialogVisible: false,
            ruleForm: {
                notExamineReason: '',
            },
            submitBtndisabled: false,
            formData: {},
        };
    },
    methods: {
        open(data) {
            this.formData = { ...data };
            this.dialogVisible = true;
            this.submitBtndisabled = false;
        },
        close() {
            this.submitBtndisabled = true;
            this.ruleForm.notExamineReason = '';
            this.dialogVisible = false;
        },
        submit() {
            if (!this.ruleForm.notExamineReason) {
                this.$message({
                    type: 'warning',
                    message: '请填写驳回原因',
                });
                return false;
            }
            let obj = {
                examineFlag: 0,
                notExamineReason: this.ruleForm.notExamineReason,
                id: this.formData.id,
            };
            memberFeeApprove(obj)
                .then(res => {
                    if (res.statusCode === '1') {
                        this.$message.success(res.message);
                    } else {
                        this.$message.warning(res.message);
                    }
                    this.$emit('queryListData');
                    this.close();
                })
                .catch(() => {
                    this.submitBtndisabled = false;
                });
        },
    },
};
</script>

