<template>
    <el-button @click="moveRow"
               type="danger" v-if="this.$route.query.id && !blacklist">移入黑名单
    </el-button>
</template>
<script>

    export default {
        data() {
            return {

            }
        },
        mounted() {

        },
        props:['blacklist'],
        methods: {
            moveRow() {
                this.$prompt('请输入理由', '提示', {
                    inputType: 'textarea'
                })
                    .then(res => {
                        // console.log(res);
                        if (res.value) {
                            this.$alert('确定拉入黑名单？', '提示', {
                                showCancelButton: true
                            })
                                .then(() => {
                                    return this.$http.post('/blackList/move', {
                                        id: this.$route.query.id,
                                        reason: res.value
                                    });
                                })
                                .then(res => {
                                    this.$message.success('拉入黑名单成功');
                                    this.$router.go(-1);
                                })
                                .catch(() => {
                                    this.$message.error(res.error || '拉入黑名单失败');
                                });
                        }
                    })
                    .catch(() => {
                    });
            },
        }
    }
</script>
<style lang="less" scoped>
</style>
