<template>
  <div class="app-container">
    <!-- 搜索工作栏 -->
    <el-card>
        <div slot="header" class="card-title">{{$t('查看')}}</div>
        <el-descriptions :column="4">
          <el-descriptions-item :label="$t('订单号')">
              {{orderData.orderNo||''}}
          </el-descriptions-item>
            <el-descriptions-item :label="$t('唛头')">
                {{orderData.marks?orderData.marks:$t('无')}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('已到箱数/总箱数')">
                {{orderData.sumNum||0}}/{{orderData.costVO?orderData.costVO.totalNum:0}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('订单状态')">
              <dict-tag :type="DICT_TYPE.ORDER_STATUS" :value="orderData.status" />
            </el-descriptions-item>
            <el-descriptions-item :label="$t('送货日期')">
               {{orderData.deliveryDate||$t('无')}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('运输方式')">
                <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="orderData.transportId" />
                 <!-- v2.0空运专线，显示出货渠道 -->
                <!-- <span v-if="getDictData(DICT_TYPE.ECW_TRANSPORT_TYPE, orderData.transportId).cssClass == 'channel'" style="margin-left:10px">{{$t('出货渠道')}}:{{orderData.channelName}}</span> -->
              </el-descriptions-item>
            <!-- v2.0空运专线，显示出货渠道 -->
             <el-descriptions-item :label="$t('出货渠道')" v-if="getDictData(DICT_TYPE.ECW_TRANSPORT_TYPE, orderData.transportId).cssClass == 'channel'">
                  {{orderData.channelName}}
              </el-descriptions-item>
            <el-descriptions-item :label="$t('始发地')">
                 {{orderData.logisticsInfoDto?orderData.logisticsInfoDto.startTitleZh:$t('无')}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('目的地')">
               {{orderData.logisticsInfoDto?orderData.logisticsInfoDto.destTitleZh:$t('无')}}
            </el-descriptions-item>
        </el-descriptions>
        <el-descriptions :column="4">
            <el-descriptions-item :label="$t('发货人')">
                {{orderData.consignorVO?orderData.consignorVO.name||$t('无'):$t('无')}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('发货公司')">
                {{orderData.consignorVO?orderData.consignorVO.company||$t('无'):$t('无')}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('发货电话')">
                {{orderData.consignorVO?((orderData.consignorVO.countryCode?checkCode(orderData.consignorVO.countryCode):'')+orderData.consignorVO.phone)||$t('无'):$t('无')}}
            </el-descriptions-item>
          </el-descriptions>
          <el-descriptions :column="4">
            <el-descriptions-item :label="$t('收货人')">
                {{orderData.consigneeVO?orderData.consigneeVO.name||$t('无'):$t('无')}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('收货公司')">
                {{orderData.consigneeVO?orderData.consigneeVO.company||$t('无'):$t('无')}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('收货电话')">
                {{orderData.consigneeVO?((orderData.consigneeVO.countryCode?checkCode(orderData.consigneeVO.countryCode):'')+orderData.consigneeVO.phone)||$t('无'):$t('无')}}
            </el-descriptions-item>
        </el-descriptions>
    </el-card>
    <el-card class="card">
      <!-- 列表 -->
      <div slot="header" class="card-title">{{$t('问题详情')}}</div>
      <el-table v-loading="loading" border :data="list">
        <el-table-column :label="$t('序号')" align="center" prop="id" type="index">
          <template slot-scope="scope">
              <span>{{scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('异常类型')" align="center" >
        <template slot-scope="scope">
            <dict-tag :type="DICT_TYPE.ORDER_ERROR_TYPE" :value="scope.row.orderExceptionType" />
          </template>
        </el-table-column>
        <el-table-column :label="$t('异常描述')" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.orderExceptionDescVO">{{$l(scope.row.orderExceptionDescVO, 'desc')}}</span>
            </template>
        </el-table-column>
        <el-table-column :label="$t('金额')" align="center" scope="orderExceptionAmount">
          <template slot-scope="{row}">
            {{row.orderExceptionAmount}}
            {{currencyMap[row.orderExceptionAmountCurrencyId]}}
            </template>
        </el-table-column>
        </el-table-column>
        <el-table-column :label="$t('状态')" align="center">
          <template slot-scope="scope">
              <dict-tag :type="DICT_TYPE.ORDER_EXCEPTION_STATUS" :value="scope.row.orderExceptionStatus" />
            </template>
        </el-table-column>
        <el-table-column :label="$t('附件')" align="center">
          <template slot-scope="scope">
            <div class="filelist">
              <span v-for="(item,index) in scope.row.orderExceptionAttr" :key="index" @click="onClickOpenPreview(item,scope.$index)">{{'附件'+(index+1)}}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column :label="$t('备注')" align="center">
          <template slot-scope="{row}">
            <el-tooltip class="item" effect="dark" :content="row.orderExceptionNotes" placement="top-start">
              <div class="clamp3">{{row.orderExceptionNotes}}</div>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column :label="$t('处理人')" align="center" prop="userName" />
        <el-table-column :label="$t('处理备注')" align="center" prop="handlerRemark" />
        <el-table-column :label="$t('创建时间')" align="center">
          <template slot-scope="scope">
             <span>{{parseTime(scope.row.createTime)}}</span>
            </template>
          </el-table-column>
        <el-table-column :label="$t('处理时间')" align="center">
          <template slot-scope="scope">
             <span>{{parseTime(scope.row.handlerTime)}}</span>
            </template>
          </el-table-column>
        <el-table-column :label="$t('操作')" align="center">
          <template slot-scope="scope">
            <!-- <el-button v-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType!='order_no_quote_exception'" v-hasPermi="['ecw:exception:seeExceptionInfo']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button> -->
            <el-button v-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_superfluous_box_exception'" v-hasPermi="['ecw:exception:superfluousBox']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_lack_box_exception'" v-hasPermi="['ecw:exception:lackBox']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_pay_exception'" v-hasPermi="['ecw:exception:pay']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_miss_exception'" v-hasPermi="['ecw:exception:miss']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_superfluous_goods_exception'" v-hasPermi="['ecw:exception:superfluousGoods']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_in_water_exception'" v-hasPermi="['ecw:exception:inWater']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_damage_exception'" v-hasPermi="['ecw:exception:damaged']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_heavy_cargo_exception'" v-hasPermi="['ecw:exception:heavyCargo']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_doc_exception'" v-hasPermi="['ecw:exception:doc']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_consignor_exception'" v-hasPermi="['ecw:exception:consignor']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_other_exception'" v-hasPermi="['ecw:exception:other']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_cod_exception'" v-hasPermi="['ecw:exception:cod']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_bulky_cargo_exception'" v-hasPermi="['ecw:exception:bulkyCargo']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='order_pick_up_exception'" v-hasPermi="['ecw:exception:pickUp']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='not_customer_service_exception'" v-hasPermi="['ecw:exception:notCustomer']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='goods_add_exception'" v-hasPermi="['ecw:exception:goodsAddException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='fee_exception'" v-hasPermi="['ecw:exception:feeException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>

            <!-- v2.0 -->
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='line_loop_exception'" v-hasPermi="['ecw:exception:lineLoopException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='customs_fee_not_quote_exception'" v-hasPermi="['ecw:exception:notQuoteException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='overweight_exception'" v-hasPermi="['ecw:exception:overweightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='not_shipping_channel_exception'" v-hasPermi="['ecw:exception:notChannelException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='goods_weight_exception'" v-hasPermi="['ecw:exception:goodsWeightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='in_warehousing_diff_exception'" v-hasPermi="['ecw:exception:inWarehousingException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='stock_up_exception'" v-hasPermi="['ecw:exception:stockUpException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='channel_exception'" v-hasPermi="['ecw:exception:channelException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='channel_packaging_overweight_exception'" v-hasPermi="['ecw:exception:channelPackagingException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            <!-- v2.0.2 -->
            <el-button v-else-if="scope.row.orderExceptionStatus==2&&scope.row.orderExceptionType=='line_Weight_exception'" v-hasPermi="['ecw:exception:lineWeightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('查看')}}</el-button>
            
            <el-tag style="margin-left:10px" v-if="scope.row.orderExceptionStatus==2">{{$t('已完成')}}</el-tag>
            <el-button v-else-if="scope.row.orderExceptionType=='order_superfluous_box_exception'" v-hasPermi="['ecw:exception:superfluousBox']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_lack_box_exception'" v-hasPermi="['ecw:exception:lackBox']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_pay_exception'" v-hasPermi="['ecw:exception:pay']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_miss_exception'" v-hasPermi="['ecw:exception:miss']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_superfluous_goods_exception'" v-hasPermi="['ecw:exception:superfluousGoods']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_in_water_exception'" v-hasPermi="['ecw:exception:inWater']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_damage_exception'" v-hasPermi="['ecw:exception:damaged']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_heavy_cargo_exception'" v-hasPermi="['ecw:exception:heavyCargo']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_doc_exception'" v-hasPermi="['ecw:exception:doc']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_consignor_exception'" v-hasPermi="['ecw:exception:consignor']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_other_exception'" v-hasPermi="['ecw:exception:other']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_cod_exception'" v-hasPermi="['ecw:exception:cod']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_no_quote_exception'" v-hasPermi="['ecw:exception:noQuote']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_bulky_cargo_exception'" v-hasPermi="['ecw:exception:bulkyCargo']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='order_pick_up_exception'" v-hasPermi="['ecw:exception:pickUp']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='not_customer_service_exception'" v-hasPermi="['ecw:exception:notCustomer']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='goods_add_exception'" v-hasPermi="['ecw:exception:goodsAddException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='fee_exception'" v-hasPermi="['ecw:exception:feeException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <!-- v2.0 -->
            <el-button v-else-if="scope.row.orderExceptionType=='line_loop_exception'" v-hasPermi="['ecw:exception:lineLoopException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='customs_fee_not_quote_exception'" v-hasPermi="['ecw:exception:notQuoteException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='overweight_exception'" v-hasPermi="['ecw:exception:overweightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='not_shipping_channel_exception'" v-hasPermi="['ecw:exception:notChannelException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='goods_weight_exception'" v-hasPermi="['ecw:exception:goodsWeightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='in_warehousing_diff_exception'" v-hasPermi="['ecw:exception:inWarehousingException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='stock_up_exception'" v-hasPermi="['ecw:exception:stockUpException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='channel_exception'" v-hasPermi="['ecw:exception:channelException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
            <el-button v-else-if="scope.row.orderExceptionType=='channel_packaging_overweight_exception'" v-hasPermi="['ecw:exception:channelPackagingException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
          <!-- v2.0.2 -->
          <el-button v-else-if="scope.row.orderExceptionType=='line_weight_exception'" v-hasPermi="['ecw:exception:lineWeightException']" size="mini" type="text" icon="el-icon-edit" @click="handEdit(scope.row)">{{$t('处理')}}</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <div class="preview" v-if="IsPreview">
      <file-preview :key="timers" :TragetPic="TragetPic" :FilePreAll="FilePreAll" @Close="onClickClosePreview"></file-preview>
    </div>
  </div>
</template>

<script>
import {getExceptionListByOrderId} from "@/api/ecw/orderException"
import { getCurrencyList } from '@/api/ecw/currency'
import {getOrder} from '@/api/ecw/order'
import FilePreview from '@/components/FilePreview'
import {getProduct} from '@/api/ecw/product'
import {getProductPriceGetPrice} from '@/api/ecw/productPrice'
import { getChannel } from '@/api/ecw/channel';
import {getDictData, getDictDatas} from  '@/utils/dict'

export default {
  name: "Pending",
  components: {
    FilePreview
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      orderData:{},
      // 订单异常列表
      list: [],
      orderId:0,
      IsPreview:false, // 控制预览弹窗字段
      timers:"", //时间戳
      FilePreAll:[], // 预览数组
      TragetPic:{},
      currencyList:[],
      channelName:'/'
    };
  },
  computed:{
    currencyMap(){
        let map = {}
        this.currencyList.forEach(item => {
          map[item.id] = this.$l(item, 'title')
        })
        return map
      },
      getDictData(){
          return (type, value) => getDictData(type, value) || {}
      },
  },
  created() {
    getCurrencyList().then(res => this.currencyList = res.data)
    if(this.$route.query.id){
      this.orderId = this.$route.query.id
      this.getList()
      this.getOrders()
    }
  },
  watch:{
      'orderData.channelId'(){
        this.getChannel()
      },
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 执行查询
      getExceptionListByOrderId(this.orderId).then(response => {
        this.list = response.data;
        this.list.forEach((item)=>{
          if(item.orderExceptionAttr){
            item.orderExceptionAttr = item.orderExceptionAttr.split(',')
          }else{
            item.orderExceptionAttr = []
          }
        })
        this.loading = false;
      });
    },
    getChannel(){
      if(!this.order || !this.order.channelId || this.order.transportId == 1 || this.order.transportId == 2) return
      getChannel(this.order.channelId).then(res => {
        this.channelName = res.data.nameZh
      })
    },
    checkCode(data){
      if(data.indexOf('+')==-1){
      	return '+'+data
      }
      return data
    },
    getOrders(){
      getOrder(this.orderId).then(response => {
        this.orderData = response.data
      });
    },

    handEdit(row){
      // 未报价异常
      if(row.orderExceptionType=='order_no_quote_exception'||row.orderExceptionType=='customs_fee_not_quote_exception'){

        if(row.orderItemId){
          var productData = this.orderData.orderItemVOList.find(item=>item.orderItemId==row.orderItemId)
          if(productData){
            // if(row.orderExceptionType=='customs_fee_not_quote_exception'&&productData.prodId){
            //   this.$router.push('/product/product-list?prodId=' + productData.prodId)
            //   return
            // }else{
              getProduct(productData.prodId).then(res=>{
                  let params = {
                    product_id: productData.prodId,
                    product_type: res.data.typeId,
                    transportId: this.orderData.transportId,
                    importCity: this.orderData.objectiveVO.objectiveId,
                    exportCity: this.orderData.departureVO.departureId,
                    startWarehouseId: this.orderData.departureVO.id,
                    destWarehouseId: this.orderData.objectiveVO.id,
                    lineId: this.orderData.logisticsInfoDto.lineId,
                    channelId: this.orderData.logisticsInfoDto.channelId
                  }
                  let queryParams = {
                    productId: productData.prodId,
                    lineId: this.orderData.logisticsInfoDto.lineId,
                    channelId: this.orderData.logisticsInfoDto.channelId
                  }
                  let url = ''
                  if([3,4].indexOf(this.orderData.transportId) > -1){
                    url = '../../lineProject/product-price/edit-air?' + (new URLSearchParams(params)).toString()
                  }else{
                    url = '../../lineProject/product-price/edit-sea?' + (new URLSearchParams(params)).toString()
                  }

                  getProductPriceGetPrice(queryParams).then(res=>{
                    console.log(res)
                    if(res.data){
                       if([3,4].indexOf(+this.orderData.transportId) > -1){
                          url =  '../../lineProject/product-price/edit-air?action=update&id='+res.data.id
                       }else{
                          url =  '../../lineProject/product-price/edit-sea?action=update&id='+res.data.id
                       }

                    }
                    return this.$router.push(url)
                  })
                /* +productData.prodId
                +'&product_type='+res.data.typeId
                +'&transportId='+this.orderData.transportId
                +'&exportCity='+this.orderData.logisticsInfoDto.startCityId+'&importCity='+this.orderData.logisticsInfoDto.destCityId */

            })
          // }
          }
        }else{
          return this.$confirm(this.$t('数据缺少orderItemId参数，确定要跳转设置路线价格么？')).then(res => {
              let url = ''
              if([3,4].indexOf(this.orderData.transportId) > -1){
                  url = '../../lineProject/product-price/edit-air?'
              }else{
                  url = '../../lineProject/product-price/edit-sea?'
              }
            this.$router.push(url)
          })

        }

      }
      // 重泡货异常
      else if(row.orderExceptionType == 'order_heavy_cargo_exception'||row.orderExceptionType=='order_bulky_cargo_exception'){
        this.$router.push({
          path:"/order/weightDeal?id="+row.id+'&type='+row.orderExceptionType,
        })
       }
       // 其他异常
       else{
        this.$router.push({
          path:"/order/prepayDeal?id="+row.id,
        })
       }

    },
    getFileName(fileName){
      var fileArr = fileName.split('/')
      return fileArr[fileArr.length-1]
    },
    getFileFormat(fileName){
      var fileArr = this.getFileName(fileName).split('.')
      return fileArr[fileArr.length-1]
    },
    	// 打开预览
    onClickOpenPreview(val,index){
      this.TragetPic  = { // 当前点击的文件
        FileName: this.getFileName(val), // 文件名称
        name: this.getFileName(val), // 文件名称（可以不传）
        format:this.getFileFormat(val), // 文件格式
        url: val,  // 预览地址
        downUrl:"", // 下载地址
      } // 目标对象
        var fileArr = this.list[index].orderExceptionAttr
        fileArr.forEach(item =>{ // 需要预览的文件数组（可以传空数组就是单张预览）
          let obj = {
            FileName: this.getFileName(item),
            name: this.getFileName(item),
            format:this.getFileFormat(item),
            url: item,
            downUrl:"",
          }
          this.FilePreAll.push(obj)
        })
        console.log(this.fileArr)
      this.IsPreview = true // 打开预览弹窗
      this.timers = new Date().getTime() // 刷新预览地址
    },
  // 关闭预览
    onClickClosePreview(val){
      this.IsPreview = val  // 由组件内部传入的关闭数据赋值关闭
    },
  }
}
</script>
<style scoped>
  .filelist{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    flex-direction: column
  }
  .filelist span{
    color: #1E98D7;
  }
  .card-title{
      font-size: 18px;
      font-weight: bold;
      margin-top: 10px;
  }
  .card{
    margin-top: 20px;
  }
  .clamp3{
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }
</style>
