<!--单据列表页面的状态标签-->
<template>
    <div>
        <lj-status-manager :value="value" :statusDic="statusDic" class="lj-status-text lj-status-badge">
            {{content}}
        </lj-status-manager>
    </div>
</template>

<script>
    import LjStatusManager from "components/lj-status-manager";

    export default {
        name: "lj-status-badge",
        components: {LjStatusManager},
        props: {
            // 当前状态的值，对应statusDic的key
            value: {
                type: [Number, String],
                default: -1
            },
            // 根据value显示当前状态描述与颜色，用法参考默认值
            statusDic: {
                type: Object,
                default: function () {
                    return {
                        0: {dscrp: "待审核", color: "Alert"},
                        1: {dscrp: "已审核", color: "Pass"},
                        "待审核": {color: "Alert"},
                        "在进行": {color: "Normal"},
                        "已完成": {color: "Pass"},
                        "待财审": {color: "Normal"},
                        "已财审": {color: "Pass"},
                        "待确认": {color: "Alert"},
                        "初确认": {color: "Normal"},
                        "已确认": {color: "Pass"},
                        "待审": {color: "Alert"},
                        "在途": {color: "Pass-Sec"},
                        "验收中": {color: "Pass"},
                        "已收货": {color: "Normal"},
                        "退货中": {color: "Alert-Sec"},
                        "退货已收": {color: "gray1"},
                    }
                }
            }
        },
        data() {
            return {
                currentStatusObject: {}
            }
        },
        computed: {
            content() {
                let statusInfo = this.statusDic[this.value];
                if (statusInfo) {
                    if (typeof statusInfo.dscrp === "undefined") {
                        return this.value;
                    }
                    return statusInfo.dscrp;
                }
                return this.value;
            }
        }
    }
</script>

<style scoped>
    .lj-status-badge {
        position: absolute;
        width: 57px;
        border-radius: 15px;
        padding: 3px 2px 2px 2px;
        text-align: center;
    }
</style>