<template>
    <div>

        <div class="row">
            <div class="col-lg-12">
                <div class="pd-t-20">
                    <div class="main-content-label">Thông tin địa chỉ</div>

                </div>
                <div class="d-flex pd-l-10 pd-t-10 border-top" v-if="orderItem.Addresses != null">
                    <div v-for="addressItem in orderItem.Addresses">
                        <div v-if="addressItem.AddressType == 2">
                            <h6 class="tx-16">
                                <i class="far fa-user mg-r-10"></i>
                                {{ addressItem.Name }} | {{ addressItem.PhoneNumber1 }}
                            </h6>
                            <p class="tx-14 mg-b-5">
                                <i class="fas fa-map-marker-alt mg-r-10"></i>
                                {{ addressItem.FullAddress }}
                            </p>
                            <p class="tx-14 mg-b-5"
                                v-if="addressItem.ScheduledTimeStr != null && addressItem.ScheduledTimeStr.length > 0">
                                <i class="fas fa-calendar-day mg-r-10"></i>
                                {{ addressItem.ScheduledTimeStr }}
                            </p>
                            <p class="tx-14" v-if="addressItem.Note != null && addressItem.Note.length > 0">
                                <i class="">Ghi chú: </i>
                                <i>{{ addressItem.Note }}</i>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-6">
                <div class="pd-t-20">
                    <div class="main-content-label">Thông tin đơn hàng</div>
                </div>
                <div class="d-flex pd-l-10 pd-t-10 border-top">
                    <label>
                        <span>Mã đơn hàng</span>
                    </label>
                    <b class="ms-auto">
                        {{ orderItem.Code }}
                    </b>
                </div>
                <div class="d-flex  pd-l-10 pd-t-10 border-top">
                    <label>
                        <span>Sale quản lý</span>
                    </label>
                    <b class="ms-auto">
                        {{ orderItem.SaleUserName }}
                    </b>
                </div>
                <div class="d-flex  pd-l-10 pd-t-10 border-top">
                    <label>
                        <span>Tuyến</span>
                    </label>
                    <b class="ms-auto">
                        {{ orderItem.RouteName }}
                    </b>
                </div>
            </div>
            <div class="col-lg-6" v-if="orderItem.OrderFin != null">
                <div class="pd-t-20">
                    <div class="main-content-label">Thông tin tài chính</div>

                </div>
                <div class="d-flex pd-l-10 pd-t-10 border-top">
                    <label>
                        <span>Tiền thu hộ</span>
                    </label>
                    <b class="ms-auto">
                        {{ vueNumberFormat(orderItem.OrderFin.CollectAmount,
                            { precision: 0, prefix: '', suffix: 'đ', decimal: ',', thousand: '.' }) }}
                    </b>
                </div>
                <div class="d-flex  pd-l-10 pd-t-10 border-top">
                    <label>
                        <span>Tiền cước</span>
                    </label>
                    <b class="ms-auto" v-if="detailType == 1">
                        {{ vueNumberFormat(orderItem.OrderFin.SourceFee,
                            { precision: 0, prefix: '', suffix: 'đ', decimal: ',', thousand: '.' }) }}
                    </b>
                    <b class="ms-auto" v-if="detailType == 2">
                        {{ vueNumberFormat(orderItem.OrderFin.DestFee,
                            { precision: 0, prefix: '', suffix: 'đ', decimal: ',', thousand: '.' }) }}
                    </b>
                </div>
                <div class="d-flex  pd-l-10 pd-t-10 border-top">
                    <label>
                        <span>TỔNG THU</span>
                    </label>
                    <b class="ms-auto" v-if="detailType == 1">
                        {{ vueNumberFormat(orderItem.OrderFin.SourceFee,
                            { precision: 0, prefix: '', suffix: 'đ', decimal: ',', thousand: '.' }) }}
                    </b>
                    <b class="ms-auto" v-if="detailType == 2">
                        {{ vueNumberFormat(orderItem.OrderFin.CollectAmount + orderItem.OrderFin.DestFee,
                            { precision: 0, prefix: '', suffix: 'đ', decimal: ',', thousand: '.' }) }}
                    </b>
                </div>
                <!-- <div class="d-flex  pd-l-10 pd-t-10 border-top">
                    <label>
                        <span>Thanh toán cước</span>
                    </label>
                    <b class="ms-auto">
                        {{ orderItem.OrderFin.PayFeeTypeStr }}
                    </b>
                </div> -->
            </div>
            <div class="col-lg-12" v-if="orderItem.Packages != null">
                <div class="pd-t-20">
                    <div class="main-content-label">Thông tin hàng hóa</div>

                </div>
                <div class="table-responsive bd-t">
                    <table class="table mg-b-0 text-md-nowrap">
                        <thead>
                            <tr>
                                <th class="wd-10p">Ảnh</th>
                                <th class="wd-30p">Hàng hóa</th>
                                <th class="wd-20p">Trọng lượng đơn vị</th>
                                <th class="wd-10p">Số kiện</th>
                                <th class="wd-20p">Trọng lượng tính cước</th>

                            </tr>
                        </thead>
                        <tbody>
                            <tr v-for="item in orderItem.Packages">
                                <th scope="row">
                                    <viewer v-if="item.Picture != null && item.Picture.length > 0">
                                        <img class="avatar-md mg-sm-r-20 mg-b-20 mg-sm-b-0 align-self-center"
                                            :key="item.Picture" :src="item.Picture" style="cursor: pointer;">
                                    </viewer>

                                    <img v-if="item.Picture == null || item.Picture.length <= 0"
                                        src="@/assets/images/48x48.svg"
                                        class="avatar-md mg-sm-r-20 mg-b-20 mg-sm-b-0 align-self-center">

                                </th>
                                <td>
                                    <p>{{ item.Name }}</p>
                                    <i>{{ item.Note }}</i>
                                </td>
                                <td>
                                    <div class="d-flex">
                                        <i class="fas fa-weight mg-r-5 mg-t-2"></i>
                                        <span>{{ item.Weight / 1000 }}</span>
                                        <span>(kg)</span>
                                    </div>
                                    <div class="d-flex mg-t-10">
                                        <i class="fas fa-text-height mg-r-5 mg-t-2"></i>
                                        <span>
                                            {{ item.Length / 10 }} x {{ item.Width / 10 }} x {{ item.Height / 10 }} /
                                            6000
                                            = {{ item.WeightBySize }} (kg)
                                        </span>
                                        <!-- <span>(dài x rộng x cao) (cm)</span> -->
                                    </div>
                                </td>
                                <td>{{ item.Quantity }}</td>
                                <td>{{ item.SubTotalWeight / 1000 }}</td>

                            </tr>

                            <tr v-if="orderItem.Packages.length <= 0">
                                <td :colspan="colspan">
                                    <Empty message="Hiện chưa có bản ghi nào" :border="false"></Empty>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';

const props = defineProps({
    orderItem: Object,
    detailType: Number
});

onMounted(() => {
    console.log(props.orderItem);
});


</script>