<!--拆单审核中的申请信息部分-->
<template>
    <div v-if="order">
        <el-descriptions :column="4" v-if="order" :colon="false">
            <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('订单状态')">
                {{order.statusMsg}}
            </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('目的仓')" :span="2">
                {{order.logisticsInfoDto.destAddressZh}}
            </el-descriptions-item>
        </el-descriptions>
        <el-form v-if="orderFee" class="prepay_exception_detail">
            <el-row>
                <el-form-item :label="$t('订单总金额')+':'">
                    <span style="margin-left: 8px;" v-for="(item, key) of orderFee.totalAmountList" :key="key">
                        {{item}}
                        {{currencyMap[key]}}
                    </span>
                </el-form-item>
            </el-row>
            <el-row>
                <el-form-item :label="$t('应付预付金额')+':'">
                    <span style="margin-left: 8px;" v-for="(item, key) of orderFee.totalPaymentAmount" :key="key">{{item}}{{currencyMap[key]}}</span>
                </el-form-item>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-form-item :label="$t('已核销预付金额')+':'">
                        <span style="margin-left: 8px;" v-for="(item, key) of orderFee.writeOffAmount" :key="key">{{item}}{{currencyMap[key]}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item :label="$t('已核销预付金额占总金额比例')+':'" label-width="320px">
                        {{orderFee.writeOffAmountScale}}%
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-form-item :label="$t('预付商品货值')+':'">
                        {{orderFee.paymentGoodsWorth}} {{$t('人民币')}}
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item :label="$t('预付商品货值占总货值比例')+':'" label-width="320px">
                        {{orderFee.paymentGoodsWorthScale}}%
                    </el-form-item>
                </el-col>
            </el-row>
             <el-row>
                <el-col :span="6">
                   <el-form-item :label="$t('预付商品方数')+':'">
                       {{orderFee.paymentGoodsVolume}} {{$t('立方米')}}
                   </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item :label="$t('预付商品货值占订单总运费+清关费比例')+':'" label-width="320px">
                        {{orderFee.needWorthScale}}%
                    </el-form-item>
                  </el-col>
                </el-row>
              <el-row>
                <el-col :span="6">
                    <el-form-item :label="$t('订单总方数')+':'">
                        {{orderFee.totalVolume}} {{$t('立方米')}}
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item :label="$t('预付商品方数占总方数比例')+':'" label-width="320px">
                        {{orderFee.paymentGoodsVolumeScale}}%
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-form-item :label="$t('备注')+':'">
                    {{orderFee.notes}}
                </el-form-item>
            </el-row>
        </el-form>
    </div>
</template>
<script>
import {getOrder} from '@/api/ecw/order'
import {getChannel} from '@/api/ecw/channel'
import {getUnitList} from "@/api/ecw/unit"
import { getCurrencyList } from '@/api/ecw/currency'
import Decimal from 'decimal.js'
import {getBmpDetailByBusinessId} from '@/api/ecw/orderException'

export default {
    name: 'PrepayExceptionDetail',
    props:{
        id: [String, Number],
        path: String
    },
    data(){
        return {
            orderFee: null,
            order: null,
            channel: null,
            unitList:[],
            currencyList:[],
        }
    },
    watch:{
        id(){
            this.getData()
        },
        order(){
            if(this.order.channelId){
                this.getChannel()
            }
        },
        orderFee(){

        }
    },
    computed:{
        currencyMap(){
            let map = {}
            this.currencyList.forEach(item => {
                map[item.id] = this.$l(item, 'title')
            })
            return map
        },
        unitMap(){
            let map = {}
            this.unitList.forEach(item => {
                map[item.id] = this.$l(item, 'title')
            })
            return map
        }
    },
    created(){
        getCurrencyList().then(res => this.currencyList = res.data)
        if(this.id){
            this.getData()
        }
    },
    methods:{
        Decimal,
        getData(){
            getBmpDetailByBusinessId(this.id).then(res => {
                this.orderFee = res.data
                if(res.data.orderId){
                    getOrder(res.data.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;
    }
}
.bold{
    font-weight: bold;
}
::v-deep .prepay_exception_detail .el-form-item{
    margin-bottom: 0;
}
</style>
