<template>
    <view class="card" :class="{ 'card-close': showClose }">
        <view class="flex w100">
            <view class="flex-d">
                <image style="width: 70px;height: 90px;" :src="item.cover" mode="aspectFill"></image>
                <view class="quantity mt-24" v-if="!showClose">数量: {{ item.num }}</view>
            </view>
            <view class="book-info ml-20 flex-1">
                <view class="common-title mb-20">{{ item.bookName }}</view>
                <view class="flex flex-j-b mb-10">
                    <view class="isbn">ISBN: {{ item.isbn }}</view>
                    <view class="set">套装: {{ item.suit == 1 ? '是' : '不是' }}</view>
                </view>

                <view class="flex flex-j-b mb-10">
                    <view class="price">定价: {{ item.price }}</view>
                    <view class="estimate">预估单价: {{ item.expectMoney || 0 }}</view>
                </view>
                <view class="flex flex-j-b mb-10">
                    <view class="discount">回收折扣: {{ item.recycleDiscount }}</view>
                    <view class="review">审核金额: <text class="color-red">{{ item.review || 0 }}</text></view>
                </view>
            </view>
        </view>

        <view class="quantity-icon mt-24" v-if="showClose">
            <u-icon name="close-circle-fill" size="18" color="#999" @click="handleClose"></u-icon>
        </view>
    </view>
</template>

<script setup>
import { defineProps, computed } from 'vue'

const props = defineProps({
    item: Object,
    showClose: {
        type: Boolean,
        default: false
    }
})

const emit = defineEmits(['close'])
const handleClose = () => {
    emit('close', props.item.isbn)
}
</script>

<style scoped>
.card {
    padding: 12px;
    display: flex;
    align-items: center;
    margin-bottom: 20rpx;
    position: relative;

    .quantity-icon {
        position: absolute;
        right: 10px;
        top: 0;
    }

    &.card-close {
        background-color: #ffffff;
        border-radius: 6px;
    }

    .card-content {
        display: flex;
        width: 100%;
    }

    .book-info {
        font-size: 26rpx;
    }

    .color-red {
        color: #bd3124;
    }
}
</style>