<template>
    <div class="demo_tabs_box" v-loading="props.loading">
        <div class="demo_tabs_boxitem" v-for="(item, index) in ordereData.list" :key="index"
            @click="clickitemboxshow(item)">
            <!-- <div class="demo_tabs_boxitem_oneyt" v-if="item.status == 'refund'  && item.orderType == 'return'">已退款</div> -->

            <div class="demo_tabs_boxitem_one">
                <div class=""
                    style="width: 100px; height: 70px;border-radius: 4px; background:rgb(186 200 239); display: flex; justify-content: center; align-items: center;">
                    <div>{{ item.tableName || "POS" }}</div>
                </div>
                <!-- <el-image style="width: 100px; height: 70px;border-radius: 10px;" :src="item.imgUrl" fit="scale-down" /> -->
                <div class="demo_tabs_boxitem_oneone">
                    <div>
                        {{ dayjs(item.createAt).format("HH:mm:ss") }}
                    </div>
                    <div style="color: #757575;">
                        {{ dayjs(item.createAt).format("YYYY-MM-DD") }}
                    </div>
                </div>
                <div class="demo_tabs_boxitem_onetow">
                    <div style="font-size: 16px; color: #757575;">{{ item.orderNo }}</div>
                    <div class="order_info">
                        <span class="sp1">{{
                            item.names &&
                            item.names[0] }} </span>
                        <span style="margin-left: 6px;">{{ item.names && item.names.length }}项</span>
                    </div>
                </div>
            </div>
            <div class="demo_tabs_boxitem_tow">
                <div>
                    <template v-if="item.discountAmount <= 0">
                        ￥{{ formatDecimal(item.orderAmount) }}
                    </template>
                    <template v-else>
                        <span>￥{{ formatDecimal(item.orderAmount - item.discountAmount) }}</span>
                        <span style="text-decoration: line-through;color: #999;font-size: 14px;">
                            ￥{{ formatDecimal(item.orderAmount) }}
                        </span>
                    </template>
                </div>
                <div style="color:#ff9e01;">
                    <span v-if="item.status == 'pending'">挂单</span>
                    <span style="color: red;" v-if="item.status == 'refund' && item.orderType == 'return'">退单</span>
                    <span style="color:#21c36b;"
                        v-if="item.orderType != 'return' && (item.status == 'closed' || item.status == 'refund')">订单完成</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { dayjs } from 'element-plus'
import { formatDecimal } from '@/utils/index.js'

const props = defineProps({
    ordereData: {
        type: Object,
        default: {
            list: [{
                names: []
            }]
        }
    },
    loading: {
        type: Boolean,
        default: false
    }
})
const emit = defineEmits(["emititemboxshow"])
const clickitemboxshow = (e) => {
    emit('emititemboxshow', e)
}
</script>

<style scoped lang="scss">
.demo_tabs_box {
    width: 100%;
    height: 82%;
    overflow: auto;

    .demo_tabs_boxitem {
        width: 100%;
        padding: 10px 0;
        display: flex;
        justify-content: space-between;
        border-bottom: 1px solid #ececec;
        position: relative;

        .demo_tabs_boxitem_oneyt {
            position: absolute;
            top: 20%;
            transform: translate(-50%, 0);
            transform: rotate(45deg);
            right: 200px;
            display: inline-block;
            border: 3px solid red;
            color: red;
            font-weight: bold;
            border-radius: 6px;
            text-align: center;
            padding: 10px 6px;
        }

        .demo_tabs_boxitem_one {
            display: flex;
            justify-content: flex-start;
            flex-shrink: 0;



            .demo_tabs_boxitem_oneone {
                display: flex;
                margin-left: 20px;
                flex-direction: column;
                height: 70px;
                justify-content: space-around;
            }

            .demo_tabs_boxitem_onetow {
                display: flex;
                flex-direction: column;
                justify-content: space-around;
                flex: 1;
                margin-left: 20px;

                .order_info {
                    display: flex;
                    align-items: center;

                    .sp1 {
                        display: inline-block;
                        width: 100px;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                        overflow: hidden;
                    }
                }
            }
        }
    }

    .demo_tabs_boxitem_tow {
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        height: 70px;
        justify-content: space-around;
        align-items: flex-end;

    }
}
</style>