<template>
    <div>
        <el-dialog
            title="新建品牌"
            width="422px"
            :visible.sync="dialogVisible">
            <p>请输入品牌名称</p>
            <el-input v-model="brandName" class="m-t-20"></el-input>
            <!-- <p class="danger-tip">
                <i class="el-icon-info"></i>
                下列两项选择后将无法修改，请谨慎选择
            </p>
            <p class="m-t-20">请选择所要关联gic的品牌</p>
            <el-select v-model="brand" placeholder="请选择" class="select-brand select-div">
                <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
            </el-select>
            <p class="m-t-20">首次同步主题设置</p>
            <el-select v-model="brand" placeholder="请选择"  class="select-type select-div">
                <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
            </el-select> -->
            <div class="btn-box t-rt m-t-20 m-b-10">
                <el-button @click="dialogVisible = false;">取消</el-button>
                <el-button type="primary" @click="saveFn">确定</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
    import { getRequest } from '@/api/api';
    export default {
        name: "add-brand-dialog",
        data() {
            return {
                dialogVisible: false,
                brandName: "",
                options: [
                    {
                        value: '选项1',
                        label: '黄金糕'
                    },
                    {
                        value: '选项2',
                        label: '双皮奶'
                    },
                    {
                        value: '选项3',
                        label: '蚵仔煎'
                    },
                    {
                        value: '选项4',
                        label: '龙须面'
                    },
                    {
                        value: '选项5',
                        label: '北京烤鸭'
                    }
                ],
                brand: ""
            };
        },
        methods: {
            saveFn() {
                if (!this.brandName) {
                    this.$message.error({
                        message: "请输入品牌名称"
                    });
                } else {
                    let ths = this;
                    let params = {
                        name: ths.brandName
                    };
                    getRequest("/haoban-manage-web/brand/insert", params)
                    .then(res => {
                        if (res.data.errorCode == 1) {
                            console.log(res);
                            ths.$emit("addSuccess");
                        } else {
                            ths.$message.error({
                                message: res.data.message
                            });
                        }
                    })
                    .catch(e => {
                        ths.$message.error({
                            message: e.message
                        });
                    });
                }
            }
        }
    };
</script>
<style lang="scss">
    .danger-tip {
        width:100%;
        height:36px;
        line-height: 36px;
        background:rgba(253,246,236,1);
        border-radius:4px;
        padding: 0 14px;
        box-sizing: border-box;
        margin-top: 24px;
        color: #E6A23C;
        font-size: 13px;
        .el-icon-info {
            font-size: 16px;
            margin-right: 7px;
            vertical-align: middle;
        }
    }
    .select-div {
        width: 100%;
        margin-top: 20px;
    }
</style>

