<!--拆单审核中的申请信息部分-->
<template>
    <div v-if="detail">
        <el-descriptions :column="4" v-if="order">
            <el-descriptions-item :label="$t('订单号')">{{order.orderNo}}</el-descriptions-item>
            <el-descriptions-item :label="$t('运输方式')">
                <dict-tag class="mr-10" :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="order.transportId" />
            </el-descriptions-item>
            <el-descriptions-item :label="$t('出货方式')">
                {{channel ? channel.nameZh : ''}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('订单状态')">
                <el-tag size="small">
                    {{order.statusMsg}}
                </el-tag>
            </el-descriptions-item>
            <el-descriptions-item :label="$t('唛头')">{{order.marks}}</el-descriptions-item>
            <el-descriptions-item :label="$t('始发仓')">
                {{order.logisticsInfoDto.startTitleZh}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('目的仓')">
                {{order.logisticsInfoDto.destAddressZh}}
            </el-descriptions-item>
        </el-descriptions>

        <template v-for="item in orderSplitBackVOList">
            <div class="title mt-20" :key="item.orderNo">
                <span class="mr-10">{{item.orderNo}}</span>
                <dict-tag class="mr-10" :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="item.transportId" />
                <span class="mr-10" v-if="item.channelName">{{item.channelName}}</span>
                <span>{{$t('发往')}}{{item.dstWarehouseName}}</span>
            </div>
            <el-table :data="item.orderSplitItemBackVOList" :key="'items-' + item.orderNo">
                <el-table-column :label="$t('序号')">
                    <template slot-scope="scope">{{scope.$index+1}}</template>
                </el-table-column>
                <el-table-column :label="$t('中文品名')">
                    <template slot-scope="{row}">{{row.prodTitleZh}}</template>
                </el-table-column>
                <el-table-column :label="$t('英文品名')">
                    <template slot-scope="{row}">{{row.prodTitleEn}}</template>
                </el-table-column>
                <el-table-column :label="$t('品牌')">
                    <template slot-scope="{row}">
                        <template v-if="row.brandName">{{row.brandName}}</template>
                        <dict-tag v-else :type="DICT_TYPE.ECW_IS_BRAND" :value="row.feeType" />
                    </template>
                </el-table-column>
                <el-table-column :label="$t('体积')">
                    <template slot-scope="{row}">{{row.volume}} m³</template>
                </el-table-column>
                <el-table-column :label="$t('重量')">
                    <template slot-scope="{row}">{{row.weight}}kg</template>
                </el-table-column>
                <el-table-column :label="$t('箱数')">
                    <template slot-scope="{row}">{{row.num}}</template>
                </el-table-column>
                <el-table-column :label="$t('数量')">
                    <template slot-scope="{row}">{{row.quantity}}</template>
                </el-table-column> 
                <el-table-column :label="$t('备注')">
                    <template slot-scope="{row}">{{row.remark}}</template>
                </el-table-column>          
            </el-table>
        </template>
    </div>
</template>
<script>
import {getApproval, getOrder} from '@/api/ecw/order'
import {getChannel} from '@/api/ecw/channel'
import {getSplitList} from '@/api/ecw/orderHandle'
export default {
    props:{
        id: [String, Number]
    },
    data(){
        return {
            detail: null,
            order: null,
            channel: null,
            orderSplitBackVOList: []
        }
    },
    watch:{
        id(){
            this.getData()
        },
        detail(){
            this.getSplit()
            this.getOrder()
        },
        order(){
            if(this.order.channelId){
                this.getChannel()
            }
        }
    },
    created(){
        if(this.id){
            this.getData()
        }
    },
    methods:{
        getData(){
            getApproval(this.id).then(res => {
                this.detail = JSON.parse(res.data.details)
            })
        },
        getSplit(){
            getSplitList({orderId: this.detail.orderId, lang: this.$i18n.locale.toLowerCase().indexOf('zh') > -1 ? 0 : 1 }).then(res => {
                console.log('getSplitList', res)
                this.orderSplitBackVOList = res.data.orderSplitBackVOList
            })
        },
        getOrder(){
            getOrder(this.detail.orderId).then(res => {
                this.order = res.data
            })
        },
        getChannel(){
            getChannel(this.order.channelId).then(res => {
                this.channel = res.data
            })
        }
    }
}
</script>
<style scoped lang="scss">
.title{
    padding: 10px 0;
    span{
        font-size: 14px;
        font-weight: bold;
    }
}
</style>