<template>
    <Button :type="btnType" class="goBtn" :class="btnExtClass" :disabled="btnDisabled"
            v-show="showFlag" :size="buttonSize" :loading="btnItemObj.loading" :style="btnStyle"
            :shape="shape" @click="btnClick($event)" :custom-icon="btnItemObj.img">{{btnItemObj.text}}<slot></slot></Button>
</template>

<script>
    import {AssertUtils} from "goingutils";
    import btnMixin from './mixins/btnMixin';

    export default {
        name: "goBtn",
        mixins: [btnMixin],
        props: {
            shape: {
                type: String,
                default: 'circle'
            },
        },
        computed: {
            btnExtClass(){
                if(this.btnItemObj.text===''){
                    return 'emptyText';
                }
            },
            //如果用户传入来宽度
            btnStyle(){
                let style={};
                if(this.width>0){
                    style["width"]=this.width+"px";
                }
                if(this.btnItemObj.color){
                    style["color"]=this.btnItemObj.color;
                }
                if(this.btnItemObj.bgColor){
                    style["backgroundColor"]=this.btnItemObj.bgColor;
                }
                return style;
            },
            //获取按钮类型
            btnType(){
                if(this.btnItemObj["type"]==='submit'){
                    return 'primary';
                }
                if(this.btnItemObj["type"]==='gray'){
                    return 'default';
                }
                return this.btnItemObj["type"];
            },
            _lbStyle(){
                let backJson = {};
                //如果指定了宽度则 采用用户指定的宽度来初始化
                if (this.width) {
                    backJson = {margin:"auto"};
                }
                return backJson;
            }
        },
        methods: {
            //设置按钮的颜色
            btnColorStyle(btnItem) {
                if (AssertUtils.isNotEmpty(btnItem.color)) {
                    return {color: btnItem.color};
                } else {
                    return {};
                }
            },
            //点击模板下载按钮
            tempDown() {
            },
        },
        mounted() {

        },
        components: {},
        watch: {

        }
    };
</script>
