<template>
    <view class="card">
        <view class="card-title">
            <view class="left">
                <global-icon :icon="titleIcon" color="#1D2129"></global-icon>
                <text>{{ title }}</text>
            </view>
            <view class="right" v-if="edit">
                <global-button type="text" @tap="handleAdd">{{ calendar != -1 ? '编辑' : '添加' }}</global-button>
            </view>
        </view>
        <view class="card-content">
            <template v-if="type == 'appeal'">
                <slot></slot>
            </template>
            <template v-else>
                <slot></slot>
            </template>
        </view>
        <slot name="footer" v-if="showfooter">
            <view class="card-footer">
                <view class="label">
                    <global-icon icon="idcard" color="#1D2129"></global-icon>
                    <text>{{ idcard || '-' }}</text>
                </view>
                <view class="label">
                    <global-icon icon="calendar" color="#1D2129"></global-icon>
                    <text>{{ calendar != -1 ? timeStampFormat(calendar) : '-' }}</text>
                </view>
            </view>
        </slot>
    </view>
</template>

<script setup>
import { timeStampFormat } from '@/utils/tool'
const es = defineEmits(['handleAdd'])
const ps = defineProps({
    // company,quality,appeal
    type: {
        type: String,
        default: 'company'
    },
    title: {
        type: String,
        default: ''
    },
    titleIcon: {
        type: String,
        default: 'message'
    },
    edit: {
        type: Boolean,
        default: false
    },
    showfooter: {
        type: Boolean,
        default: false
    },
    idcard: {
        type: String,
        default: '-'
    },
    calendar: {
        type: [String, Number],
        default: '-'
    }
})
const handleAdd = () => {
    es('handleAdd')
}
</script>
<style lang="scss" scoped>
.card {
    margin-top: 16rpx;
    padding: 16rpx 24rpx;
    border-radius: 12rpx;
    color: #1d2129;
    background: #ffffff;
    &-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 2rpx solid #f4f4f4;
        padding-bottom: 16rpx;
        .left {
            display: flex;
            align-items: center;
            text {
                margin-left: 8rpx;
            }
        }
    }
    &-content {
        padding-top: 16rpx;
    }
    &-footer {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        .label {
            margin-left: 16rpx;
            text {
                margin-left: 16rpx;
            }
        }
    }
}
</style>
