<!--拆单审核中的申请信息部分-->
<template>
    <div v-if="orders">
        <el-table :data="orders">
            <el-table-column :label="$t('订单编号')">
                <template slot-scope="scope">{{scope.row.orderNo}}</template>
            </el-table-column>
            <el-table-column :label="$t('唛头')">
                <template slot-scope="{row}">{{row.marks}}</template>
            </el-table-column>
            <!-- <el-table-column label="已到箱数/总箱数">
                <template slot-scope="{row}">/{{row.sumNum}}/{{row.sumNum}}</template>
            </el-table-column> -->
            <el-table-column :label="$t('填单统计')">
                <template slot-scope="{row}">
                    {{row.costVO.totalNum}}{{$t('箱')}}<br/>{{row.costVO.totalVolume}}m³<br/>{{row.costVO.totalWeight}}kg
                </template>
            </el-table-column>
            <el-table-column :label="$t('入仓统计')">
                <template slot-scope="{row}">
                    {{row.sumNum}}{{$t('箱')}}<br/>{{row.sumVolume}}m³<br/>{{row.sumWeight}}kg
                </template>
            </el-table-column>
            <el-table-column :label="$t('入仓时间')">
                <template slot-scope="{row}">
                    {{row.rucangTime|parseTime}}
                </template>
            </el-table-column>
            <el-table-column :label="$t('运输方式')">
                <template slot-scope="{row}">
                    <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="row.transportId" />
                </template>
            </el-table-column>
            <el-table-column :label="$t('出货渠道')">
                <template slot-scope="{row}">
                    {{getChannelName(row.channelId)}}
                </template>
            </el-table-column>
            <el-table-column :label="$t('始发仓')">
                <template slot-scope="{row}">{{jsonParse(row.departureVO.departure).titleZh}}</template>
            </el-table-column>
            <el-table-column :label="$t('目的仓')">
                <template slot-scope="{row}">
                    {{jsonParse(row.objectiveVO.objective).titleZh}}
                </template>
            </el-table-column>
            <el-table-column :label="$t('发货人')">
                <template slot-scope="{row}">
                    {{row.consignorVO.name}}
                </template>
            </el-table-column>
            <el-table-column :label="$t('收货人')">
                <template slot-scope="{row}">
                    {{row.consigneeVO.name}}
                </template>
            </el-table-column>        
        </el-table>
    </div>
</template>
<script>
import {getApproval, getOrder} from '@/api/ecw/order'
import {getMergeListByMergeId} from '@/api/ecw/orderHandle'
import {getChannelListByIds} from '@/api/ecw/channel'
import {parseTime} from '@/utils/ruoyi'
export default {
    name: 'MergeDetail',
    filters: {parseTime},
    props:{
        id: [String, Number]
    },
    data(){
        return {
            orders: null,
            channels: []
        }
    },
    watch:{
        id(){
            this.getData()
        }
    },
    computed:{
        jsonParse(){
            return d => {
                return JSON.parse(d)
            }
        },
        getChannelName(){
            return id => {
                let channel = this.channels.find(item => item.channelId == id)
                return channel ? channel.nameZh : '/'
            }
        }
    },
    created(){
        if(this.id){
            this.getData()
        }
    },
    methods:{
        getData(){
            getMergeListByMergeId({id: this.id}).then(res => {
                this.orders = res.data
                this.getChannels()
            })
        },
        getChannels(){
            let ids = []
            this.orders.forEach(order => {
                if(order.channelId){
                    ids.push(order.channelId)
                }
            })
            if(!ids.length) return false
            getChannelListByIds({ids: ids.join(',')}).then(res => {
                this.channels = res.data
            })
        }
    }
}
</script>
<style scoped lang="scss">
.title{
    padding: 10px 0;
    span{
        font-size: 14px;
        font-weight: bold;
    }
}
</style>