<!-- 全部商品弹窗 -->
<template>
    <el-dialog :title="`全部商品（${allOrderGoods.length}）`" width="600px" v-model="allOrderGoodsShow" top="2vh"
        @close="allOrderGoodsShow = false">
        <div class="goods_wrap">
            <div class="row" v-for="item in allOrderGoods" :key="item.id">
                <div class="cover">
                    <el-image :src="item.productImg" fit="cover"
                        style="width: 100px;height: 100px;border-radius: 8px;"></el-image>
                </div>
                <div class="info">
                    <div class="name">
                        <span class="t">{{ item.productName }}</span>
                        <span class="amount">￥{{ formatDecimal(+item.payAmount) }}</span>
                    </div>
                    <div class="num remark">
                        <span>备注: {{ item.remark || "无" }}</span>
                        <div class="n">
                            <span>￥{{ formatDecimal(+item.unitPrice) }}</span>
                            <span>x{{ item.num }}</span>
                        </div>
                    </div>
                    <div class="num">
                        <span>出菜时间：{{ item.dishOutTime }}</span>
                    </div>
                    <div class="num">
                        <span>上菜时间：{{ item.foodServeTime }}</span>
                    </div>
                    <div class="num" v-if="item.returnNum">
                        <span>退菜数量：{{ item.returnNum }}</span>
                    </div>
                    <div class="num" v-if="item.refundNum">
                        <span>退单数量：{{ item.refundNum }}</span>
                    </div>
                </div>
            </div>
        </div>
    </el-dialog>
</template>

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

const allOrderGoods = ref([])
const allOrderGoodsShow = ref(false)

function show(obj) {
    allOrderGoodsShow.value = true
    allOrderGoods.value = obj
}

defineExpose({
    show
})
</script>

<style scoped lang="scss">
.goods_wrap {
    height: 75vh;
    overflow-y: auto;

    .row {
        display: flex;
        padding: 10px 0;

        &:not(:last-child) {
            border-bottom: 1px solid #ececec;
        }

        .info {
            flex: 1;
            padding-left: 10px;

            .name {
                display: flex;
                gap: 10px;
                justify-content: space-between;

                .t {
                    font-size: 16px;
                    font-weight: bold;
                }

                .amount {
                    font-size: 16px;
                    color: var(--el-color-danger);
                }
            }

            .num {
                color: #555;
                font-size: 14px;
                display: flex;
                gap: 10px;
                margin-top: 6px;

                &.remark {
                    color: #999;
                    justify-content: space-between;
                }

                .n {
                    color: #999;
                    display: flex;
                    gap: 4px;
                }
            }
        }
    }
}
</style>