<template>
    <div class="card_item" :style="cardStyle">
        <div class="list_item" v-if="!custom">
            <div class="title">{{item.title}}</div>
            <div class="content">
                <div class="row_info" v-for="(rowObj,index) of item.rows">
                    <div class="cell_label" :style="labelStyle">{{rowObj.label}}</div>
                    <div class="cell_content">{{rowObj.content}}</div>
                </div>
            </div>
        </div>
        <div class="list_item" v-else>
            <slot name="content" :item="item"></slot>
        </div>
        <div class="operation_bar" v-show="operation">
            <div class="btn" @click="editorRecord">
                <span class="btn_label">编辑</span>
            </div>
            <div class="split_line"></div>
            <div class="btn" @click="delRecord">
                <span class="btn_label">删除</span>
            </div>
        </div>
    </div>
</template>

<script>

    export default {
        name: "go-card-item-one",
        beforeCreate() {

        },
        props:{
            //是否是自定义内容区域
            custom:{
                type:Boolean,
                default:false
            },
            //card的高度
            height:{
                type:Number,
                default:155
            },
            //card的宽度
            width:{
                type:Number,
                default:350
            },
            labelWidth:{
                type:Number,
                default:70
            },
            //是否可以操作
            operation:{
                type:Boolean,
                default:true,
            },
            //记录集合
            item:{
                type:Object,
                default:()=>{return {};},
            }
        },
        data: function() {
            return {};
        },
        computed: {
            labelStyle(){
                let styles={};
                if(this.labelWidth>0){
                    styles["width"]=this.labelWidth+"px";
                }
                return styles;
            },
            //卡片样式信息
            cardStyle(){
                let styles={};
                styles["width"]=this.width+"px";
                styles["height"]=this.height+"px";
                return styles;
            }
        },
        methods: {
            //编辑记录
            editorRecord(){
                this.$emit("editorRecord",{id:this.item.id,item:this.item});
            },
            //删除记录
            delRecord(){
                this.$WinUtils.executeConfirm("您确定删除该记录吗!", () => {
                    this.$emit("delRecord",{id:this.item.id,item:this.item});
                });
            }
        },
        mounted() {},
        components: {}
    };
</script>
