<template>
	<view class="order">
		<view class="header-toper">
			<!-- <view class="start-bar"></view> -->
			<view class="header-toper-title">
				<image src="../../static/img/back.png" mode="" @click="$request.goPage('../index/index')"></image>
				<text>{{$lang.lang.order.order}}</text>
			</view>
		</view>
		<!-- <view class="start-bar"></view> -->
		<!-- <image @click="screenShow" v-if="selectIndex==3" class="screen_icon" src="../../static/img/screen.png"></image> -->
		<view class="nvs">
			<view class="" v-for="(item, index) in nvs" @click="changeIndex(index)" :key="index">
				<image :src="selectIndex==index?item.icon:item.icons" mode=""></image>
				<text>{{item.name}}{{item.nums>0?'('+item.nums+')':''}}</text>
			</view>
		</view>
		<!-- #ifdef H5 -->
		<input type="password" style='width:0;height:0;min-height:0'/>
		<input type="text" autocomplete="off" style='width:0;height:0;min-height:0'/>
		<!-- #endif -->
		<view class="order-tabs">
			<view class="order-tabs-v2">
				<view class="order-tabs-v2s">
					<image class="search" src="../../static/img/search.png" mode=""></image>
					<input type="text" v-model="searchKey" autocomplete="off" :placeholder="$lang.lang.notices.moreKey" placeholder-style="color: #666666">
					<view class="" @click="changeIndex(selectIndex)">{{$lang.lang.order.search}}</view>
				</view>
			</view>
		</view>
		<view class="order-control-status"  v-if="selectIndex==3">
			<text>{{$lang.lang.order.statusControl}}</text>
			<view class="control-item">
				<picker class="control-status"  :value="config.cargoControlStatus.index" :range="config.cargoControlStatus.label" data-config="cargoControlStatus" data-key="cargoControlStatus" @change="configChange">
					<view>{{config.cargoControlStatus.label[config.cargoControlStatus.index]}}</view>
				</picker>
				<image class="rgt" src="../../static/img/rgt.png"></image>
			</view>
		</view>
		<view class="order-control-status"  v-else>
			<text>{{$lang.lang.exception.orderStatus}}</text>
			<view class="control-item">
				<picker class="control-status"  :value="config.status.index" :range="config.status.label" data-config="status" data-key="status" @change="configChange">
					<view>{{config.status.label[config.status.index]}}</view>
				</picker>
				<image class="rgt" src="../../static/img/rgt.png"></image>
			</view>
		</view>
		<view class="order-list">
			<view v-if="data.length==0&&!loading" class="noData">
				<image src="../../static/img/empty.png" mode="widthFix"></image>
				<text>{{$lang.lang.notices.noData}}~</text>
			</view>
			<view class="order-list-it" v-else v-for="(item,index) in data" :key="index">
				<view class="order-list-tp">
					<image v-if="selectIndex==1||(selectIndex==0&&item.deliverGoods)||(selectIndex==3&&item.consigneePhone==userInfo.mobile)" class="fa" :src="shippingImg" mode=""></image>
					<image v-else class="fa" :src="receivingImg" mode=""></image>
					<view class="order-list-it-v">
						<view class="fa-v">
              <view class="order-no">
                <text>{{item.orderNo}}</text>
                <text>{{formatMsg(item)}}</text>
              </view>
              <view v-if="item.tidanNo">
                <text>{{ item.tidanNo }}</text>
              </view>
							<!-- <text>{{getStatusName(item.status)}}</text> -->
						</view>
					</view>
				</view>
				<view class="order-list-info">
					<view>
						<view class="order-list-user">{{$lang.lang.order.marks}}：{{item.marks}}</view>
						<view class="times sums" v-if="selectIndex==3">
							<text>{{$lang.lang.docException.levite}} :</text>
							<text>{{item.sumNum}}</text>
						</view>
						<view class="times sums" v-if="selectIndex==3">
							<text>{{$lang.lang.order.lendingNum}} :</text>
							<text>{{item.releaseNum}}</text>
						</view>
						<view class="times">
							<image src="../../static/img/time.png" mode=""></image>
							<text>{{getDate(item.createTime)}}</text>
						</view>

					</view>
					<view class="order-btn-list">
						<view v-if="selectIndex==2||(selectIndex==0&&!item.deliverGoods&&!item.isCargoControl)" class="order-btn">
							<view  @click="toOrderInfo(item.orderId)">{{$lang.lang.order.see}}</view>
						</view>
						<view v-if="selectIndex==3||(selectIndex==0&&item.isCargoControl&&!item.deliverGoods)" class="order-btn">
							<view  @click="toOrderInfo(item.orderId)">{{$lang.lang.order.see}}</view>
							<view v-if="item.cargoControlStatus==1&&item.status!=88" @click="seeLending(item.orderId,index)">{{$lang.lang.order.seelending}}</view>

						<!-- 	<view v-if="itme.cargoControlStatus==2">控货中转移</view>
							<view v-if="itme.cargoControlStatus!=1">放贷</view> -->
							<view v-if="item.cargoControlStatus!=1&&item.status>=5&&item.status!=88" @click="tolending(index,1)">{{$lang.lang.order.lending}}</view>
							<view v-if="item.cargoControlStatus!=1&&item.status>=5&&item.status!=88" @click="tolending(index,2)">{{$lang.lang.order.transfer}}</view>
							<view v-if="item.status!=88" @click="showControlLog(item.orderId)">{{$lang.lang.order.controlLog}}</view>
						</view>
						<view v-if="selectIndex==1||(selectIndex==0&&item.deliverGoods)" class="order-btn">
							<view  @click="toOrderInfo(item.orderId)">{{$lang.lang.order.see}}</view>
							<view v-if='(item.status==0||item.status==2)&&isDelivery' @click="toEditOrder(item.orderId, false)">{{$lang.lang.order.edit}}</view>
							<view v-if='item.status==0||item.status==88' @click="delOrder(item.orderId)">{{$lang.lang.order.delete}}</view>
							<view v-if='item.status==2&&item.status!=88' @click="cancelOrder(item.orderId)">{{$lang.lang.order.cancelOrder}}</view>
							<view v-if='item.status==5&&item.status!=88&&isDelivery' @click="returnOrder(index)">{{$lang.lang.order.exit}}</view>
							<view v-if='item.abnormalState!=0&&item.status!=88&&isDelivery' @click="toException(item.orderId)">{{$lang.lang.order.toDeal}}</view>
						</view>
						<view  class="order-btn">
							<view  @click="copy(item.orderId)" v-if="isDelivery">{{$lang.lang.order.copy}}</view>
						</view>
					</view>
				</view>

				<!-- <view class="order-btn">退仓</view> -->

			</view>
		</view>

		<view class="bom" v-if="isDelivery">
			<view class="" @click="toCreatOrders">
				<image src="../../static/img/carFa.png" mode=""></image>
				<text>{{$lang.lang.order.delivery}}</text>
			</view>
		</view>
		<uni-popup ref="apply" type="center" :mask-click="false">
			<view class="apply_content">
				<view class="apply_title">
					<text>{{$lang.lang.order.applyExit}}{{selectOrder.orderNo}}</text>
					<image src="../../static/img/index_close.png" @click="closeApply"></image>
				</view>
				<view class="apply_info">
					<text>{{$lang.lang.order.exitOrderNo}}：</text>
					<text>{{selectOrder.orderNo}}</text>
				</view>
				<view class="apply_reason">
					<text>{{$lang.lang.order.reason}}：</text>
					<textarea v-model="reason" :placeholder="$lang.lang.notices.reason"></textarea>
				</view>
				<view class="apply_reason">
					<text>{{$lang.lang.order.img}}：</text>
					<view class="apply_upload">
						<view class="apply_btn" @click="uploadImg">{{$lang.lang.order.uploadImg}}</view>
						<view class="imgList">
							<view v-if="imgUrl.length>0" class="imgItem" v-for="(imgurl,index) in imgUrl" :key="imgurl">
								<image @click="deleteImg(index)" :src="imgurl"></image>
								<image @click="deleteImg(index)" class="delete" src="../../static/img/delete.png"></image>
							</view>
						</view>
					</view>
				</view>
				<view class="apply-btn">
					<view @click="sumbitApply">{{$lang.lang.order.isExit}}</view>
					<view @click="closeApply">{{$lang.lang.order.consider}}</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="screen" type="right">
			<view class="screen_content">
				<view class="screen_title">{{$lang.lang.order.screen}}</view>
				<view class="screen_list">
					<view @click="configShow('transport')">
						<text>{{$lang.lang.order.transport}}</text>
						<image :src="config.transport.checked?'../../static/img/down1.png':'../../static/img/rgt.png'"></image>
					</view>
					<view :class="config.transport.index==transIndex?'screen_item select_item':'screen_item'" v-if="config.transport.checked" v-for="(transItem,transIndex) in config.transport.label" :key="transIndex" @click="selectConfig('transport',transIndex)">
						<text>{{transItem}}</text>
					</view>
				</view>
				<view class="screen_list">
					<view>
						<text>{{$lang.lang.order.status}}</text>
						<image src="../../static/img/rgt.png"></image>
					</view>
				</view>
				<view class="screen_list">
					<view @click="configShow('tradeCity2')">
						<text>{{$lang.lang.order.endCity}}</text>
						<image :src="config.tradeCity2.checked?'../../static/img/down1.png':'../../static/img/rgt.png'"></image>
					</view>
					<view :class="config.tradeCity2.index==transIndex?'screen_item select_item':'screen_item'" v-if="config.tradeCity2.checked" v-for="(transItem,transIndex) in config.tradeCity2.label" :key="transIndex" @click="selectConfig('tradeCity2',transIndex)">
						<text>{{transItem}}</text>
					</view>
				</view>

				<view class="screen_list">
					<view>
						<text>{{$lang.lang.order.time}}</text>
						<image src="../../static/img/rgt.png"></image>
					</view>
				</view>
				<view class="screen_btns">
					<view @click="screenReset">{{$lang.lang.order.reset}}</view>
					<view @click="toSearch">{{$lang.lang.order.confirm}}</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="lending" type="center" style="overflow-y: auto;">
			<view class="lending_content">
				 <!-- <view class="lending_title">{{type==1?'放货协议':'控货权转移协议'}}</view> -->
				 <view class="lending_info" v-if="type==1">
					<lenging-agreement />
				 </view>
				 <view class="lending_info" v-if="type==2">
				 		<transfer-agreement />
				 </view>
				 <view class="lending_btns" v-if="type==1">
					 <view @click="lendFromShow">{{$lang.lang.order.read}}</view>
					 <view @click="$refs.lending.close()">{{$lang.lang.order.cancel}}</view>
				 </view>
				 <view class="lending_btns" v-if="type==2">
					 <view @click="transferFromShow">{{$lang.lang.order.read}}</view>
					 <view @click="$refs.lending.close()">{{$lang.lang.order.cancel}}</view>
				 </view>
			</view>
		</uni-popup>
		<uni-popup ref="lendFrom" type="center">
			<view class="lendFrom_content">
				<!-- #ifdef H5 -->
				<input type="password" style='width:0;height:0;min-height:0'/>
				<input type="text" autocomplete="off" style='width:0;height:0;min-height:0'/>
				<!-- #endif -->
				 <view class="lending_title">{{selectOrder.orderNo}}{{$lang.lang.order.lending}}</view>
					<view class="lendFrom_order">
						<text>{{$lang.lang.order.sum}}：{{selectOrder.sumNum}}</text>
						<text>{{$lang.lang.order.haveNum}}：{{parseInt(selectOrder.sumNum)-parseInt(selectOrder.releaseNum)}}</text>
						<text>{{$lang.lang.order.sumVolume}}：{{selectOrder.sumVolume}}</text>
						<text>{{$lang.lang.order.sumWeight}}：{{selectOrder.sumWeight}}</text>
            <text style="width:100%">{{$lang.lang.order.unloadTime}}：{{releaseData.unloadTime || '-'}}</text>
            <text style="width:100%">{{$lang.lang.order.lockConsigneeTime}}：{{releaseData.lockConsigneeTime || '-'}}</text>
            <text style="width:100%">{{$lang.lang.order.isLimitUpdateConsignee}}：{{releaseData.isLimitUpdateConsignee ? $lang.lang.order.yes : $lang.lang.order.no}}</text>
					</view>
					<view class="lendFrom_title">{{$lang.lang.order.writeInfo}}</view>
          <!--
          http://czxy.cpolar.top/task-view-818.html
          新增备注信息，逻辑如下：
          1. 当订单限制修改收货人=是&&订单已卸柜/到仓&&当前时间<=放货锁定收货人到期时间
          备注：订单锁定收货人未到期，不允许修改控货收货人
          2. 当订单限制修改收货人=是&&订单已卸柜/到仓&&当前时间>放货锁定收货人到期时间
          备注：订单锁定收货人信息已到期，允许修改控货收货人
          3. 当订单限制修改收货人=是&&订单未卸柜/到仓
          备注：订单未卸柜/到仓，不允许修改控货收货人
          4. 当订单限制修改收货人=否
          备注： 订单允许修改控货收货人
          -->
          <view class="tips" v-if="releaseData.isLimitUpdateConsignee && releaseData.unloadTime && Date.now() <= (new Date(releaseData.lockConsigneeTime)).getTime()">
            {{$lang.lang.order.remark1}}
          </view>
          <view class="tips" v-if="releaseData.isLimitUpdateConsignee && releaseData.unloadTime && Date.now() > (new Date(releaseData.lockConsigneeTime)).getTime()">
            {{$lang.lang.order.remark2}}
          </view>
          <view class="tips" v-if="releaseData.isLimitUpdateConsignee && !releaseData.unloadTime">
            {{$lang.lang.order.remark1}}
          </view>
          <view class="tips" v-if="!releaseData.isLimitUpdateConsignee">
            {{$lang.lang.order.remark4}}
          </view>
					<view class="lendFrom_info">
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.consignee}}<span class="redcolor">*</span></text>
              <view v-if="disableUpdateCongsignee" class="corder-phone">
                {{lendingFrom.consigneeName}}
              </view>
							<input v-else v-model="lendingFrom.consigneeName" type="text" :placeholder="$lang.lang.notices.consignee" />
						</view>
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.consigneeTel}}<span class="redcolor">*</span></text>
							<view class="corder-phone" v-if="disableUpdateCongsignee">
                {{$request.checkAddIcon(config.countrySn.value[config.countrySn.index])}}
                {{lendingFrom.consigneePhone}}
              </view>
              <view class="corder-phone" v-else>
                <view class="countrySn-item">
                  <picker class="countrySn" :value="config.countrySn.index" :range="config.countrySn.label" data-config="countrySn" data-key="consigneeCountryCode" @change="configChange" v-if="config.countrySn.value.length > 0">
                    <view class="uni-input" style="white-space: nowrap;">{{$request.checkAddIcon(config.countrySn.value[config.countrySn.index])}}</view>
                  </picker>
                  <image class="rgt" src="../../static/img/rgt.png" mode="widthFix"></image>
                </view>
                <input class="countrySn-input" :disabled="disableUpdateCongsignee" v-model="lendingFrom.consigneePhone" maxlength="11" type="number" :placeholder="$lang.lang.notices.phone" />
              </view>
						</view>
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.num}}<span class="redcolor">*</span></text>
							<input v-model="lendingFrom.pickNum" disabled type="number" :placeholder="$lang.lang.notices.sum"/>
						</view>
						<view class="corder-tab1-item">
							<text class="corder_weight">{{$lang.lang.order.weight}}<span class="redcolor">KG</span></text>
							<input v-model="lendingFrom.pickWeight" disabled type="number" :placeholder="$lang.lang.order.weight"/>
							<text class="corder_weight corder_volume">{{$lang.lang.order.volume}}<span class="redcolor">m³</span></text>
							<input v-model="lendingFrom.pickVolume" disabled type="number" :placeholder="$lang.lang.order.volume"/>
						</view>
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.remark}}</text>
							<input v-model="lendingFrom.remarks" type="text" :placeholder="$lang.lang.notices.note"/>
						</view>
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.lendingType}}</text>
							<view class="corder-radio-2">
								<radio-group @change="doubleClear">
									<label class="radio">
										<radio value="1" tr :checked="controlType==1" style="transform:scale(0.7)" /><text>{{$lang.lang.order.code}}</text>
									</label>
									<label class="radio">
										<radio value="2"  :checked="controlType==2" style="transform:scale(0.7)" /><text>{{$lang.lang.site.controlPsd}}</text>
									</label>
								</radio-group>
							</view>
						</view>
						<view class="corder-tab1-item" v-if="controlType==1">
							<text>{{$lang.lang.order.code}}</text>
						</view>
						<view class="corder-tab1-item" v-if="controlType==1">
							<input class="vp-input" autocomplete="off" v-model="lendingFrom.code" type="code"  :placeholder="$lang.lang.notices.code">
							<view class="code" v-if="leftTime < 60">{{leftTime}}S</view>
							<picker class="code" :range="smsName" @change="sendCode" v-else>
							  <view class="uni-input">{{ $lang.lang.order.getCode }}</view>
							</picker>
						</view>
						<view class="corder-tab1-item" v-if="controlType==2">
							<text>{{$lang.lang.site.controlPsd}}<span class="redcolor">*</span></text>
							<input v-if="isControlPass" autocomplete="off" type="password" v-model="lendingFrom.controlPassword" />
							<view v-else class="code" @click="$request.goPage('../telcode/telcode')">{{$lang.lang.order.toset}}</view>
						</view>
						<view class="corder-tab1-items">
							<span class="redcolor">*</span>{{$lang.lang.order.controlNotice}}
						</view>
						<view class="lending_btns">
								<view @click="isLending">{{$lang.lang.order.confirm}}</view>
								<view @click="$refs.lendFrom.close()">{{$lang.lang.order.cancel}}</view>
						</view>
					</view>
			</view>
		</uni-popup>
		<uni-popup ref="lendingNotice" type="center">
			<view class="lendFrom_content">
					<view class="lenging_notice">
						<text><span class="redcolor">{{$lang.lang.order.fenLending}}</span>{{$lang.lang.order.lendingNotice}}<span class="redcolor">{{lendingFrom.pickNum}}{{$lang.lang.order.piece}}</span>,{{$lang.lang.order.isConsignee}}:<span class="redcolor">{{lendingFrom.consigneeName}}</span>,{{$lang.lang.order.phone}}：<span class="redcolor">{{$request.checkAddIcon(lendingFrom.consigneeCountryCode)+lendingFrom.consigneePhone}}</span>,{{$lang.lang.order.noError}}</text>
					</view>
					<view class="lending_btns">
						<view @click="ismobileLend">{{$lang.lang.order.confirm}}</view>
						<view @click="$refs.lendingNotice.close()">{{$lang.lang.order.cancel}}</view>
					</view>
			</view>
		</uni-popup>
		<uni-popup ref="transfer" type="center">
			<!-- #ifdef H5 -->
			<input type="password" style='width:0;height:0;min-height:0'/>
			<input type="text" autocomplete="off" style='width:0;height:0;min-height:0'/>
			<!-- #endif -->
			<view class="lendFrom_content">
				 <view class="lending_title">{{selectOrder.orderNo}}{{$lang.lang.order.transfer}}</view>
					<view class="lendFrom_info">
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.oldControl}}<span class="redcolor">*</span></text>
							<input :value="transferFrom.consignorName" type="text" disabled :placeholder="$lang.lang.notices.oldControl" />
						</view>
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.oldControlTel}}<span class="redcolor">*</span></text>
							<view class="corder-phone">
								<input class="countrySn-input" :value="transferFrom.consignorCountryCode+transferFrom.consignorPhone"  maxlength="11" disabled type="text" :placeholder="$lang.lang.notices.phone" />
							</view>
						</view>
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.newControl}}<span class="redcolor">*</span></text>
							<input v-model="transferFrom.name" type="text" :placeholder="$lang.lang.notices.newControl" />
						</view>
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.newControlTel}}<span class="redcolor">*</span></text>
							<view class="corder-phone">
								<view class="countrySn-item">
									<picker class="countrySn"  :value="config.countrySn.indexs" :range="config.countrySn.label" data-config="countrySn" data-key="dialCode" @change="configChange" v-if="config.countrySn.value.length > 0">
										<view class="uni-input">{{$request.checkAddIcon(config.countrySn.value[config.countrySn.indexs])}}</view>
									</picker>
									<image class="rgt" src="../../static/img/rgt.png" mode="widthFix"></image>
								</view>
								<input class="countrySn-input" v-model="transferFrom.phone" maxlength="11" type="number" :placeholder="$lang.lang.notices.phone" />
							</view>
						</view>
						<view class="corder-tab1-item">
							<text>{{$lang.lang.order.lendingType}}</text>
							<view class="corder-radio-2">
								<radio-group @change="doubleClears">
									<label class="radio">
										<radio value="1" tr :checked="controlType==1" style="transform:scale(0.7)" /><text>{{$lang.lang.order.code}}</text>
									</label>
									<label class="radio">
										<radio value="2"  :checked="controlType==2" style="transform:scale(0.7)" /><text>{{$lang.lang.site.controlPsd}}</text>
									</label>
								</radio-group>
							</view>
						</view>
						<view class="corder-tab1-item" v-if="controlType==1">
							<text>{{$lang.lang.order.code}}</text>
						</view>
						<view class="corder-tab1-item" v-if="controlType==1">
							<input class="vp-input" autocomplete="off" v-model="transferFrom.code" type="code"  :placeholder="$lang.lang.notices.code">
							<view class="code" v-if="leftTimes < 60">{{leftTimes}}S</view>
							<picker class="code" :range="smsName" @change="sendTransCode" v-else>
							  <view class="uni-input">{{ $lang.lang.order.getCode }}</view>
							</picker>
						</view>
						<view class="corder-tab1-item" v-if="controlType==2">
							<text>{{$lang.lang.site.controlPsd}}<span class="redcolor">*</span></text>
							<input v-if="isControlPass" autocomplete="off" type="password" v-model="transferFrom.controlPassword" />
							<view v-else class="code" @click="$request.goPage('../telcode/telcode')">{{$lang.lang.order.toset}}</view>
						</view>
						<view class="corder-tab1-items">
							<span class="redcolor">*</span>{{$lang.lang.order.controlNotice}}
						</view>
						<view class="lending_btns">
								<view @click="ismobile">{{$lang.lang.order.confirm}}</view>
								<view @click="$refs.transfer.close()">{{$lang.lang.order.cancel}}</view>
						</view>
					</view>
			</view>
		</uni-popup>
		<uni-popup ref="lendingLog" type="center">
			<view class="lendFrom_content">
				 <view class="lending_title">{{lendingdata.orderNo}}{{$lang.lang.order.lendingLog}}</view>
					<view class="lendFrom_order">
						<text>{{$lang.lang.order.sum}}：{{lendingdata.sumNum}}</text>
						<text>{{$lang.lang.order.haveNum}}：{{parseInt(lendingdata.sumNum)-parseInt(lendingdata.releaseNum)}}</text>
						<text>{{$lang.lang.order.sumVolume}}：{{lendingdata.sumVolume}}</text>
						<text>{{$lang.lang.order.sumWeight}}：{{lendingdata.sumWeight}}</text>
					</view>
					<view class="lendFrom_title">{{$lang.lang.order.lendingLog}}</view>
					<view class="lengingLog_list">
						<view class="lendFrom_order" v-for="(item,index) in lendingdata.cargoControlPickBackVOList" :key="index">
							<text>{{$lang.lang.order.consignee}}：{{item.consigneeName}}</text>
							<text>{{$lang.lang.order.consigneeTel}}：{{$request.checkAddIcon(item.consigneeCountryCode)+item.consigneePhone}}</text>
							<text>{{$lang.lang.order.lendingNum}}：{{item.pickNum}}</text>
							<text>{{$lang.lang.order.volume}}：{{item.pickVolume}}</text>
							<text>{{$lang.lang.order.operation}}：{{lendingdata.name}}</text>
							<text>{{$lang.lang.order.date}}：{{$request.getDate(item.createTime)}}</text>
							<text>{{$lang.lang.order.remark}}：{{item.remarks}}</text>
						</view>
					</view>

					<view class="lending_btns">
						<view @click="$refs.lendingLog.close()">{{$lang.lang.order.confirm}}</view>
						<view @click="$refs.lendingLog.close()">{{$lang.lang.order.cancel}}</view>
					</view>
			</view>
		</uni-popup>
		<uni-popup ref="choiceTransport" type="center" :mask-click="false">
			<view class="ad-conten type-1">
				<image @click="closeTransport" class="ad-bg1" src="../../static/img/colse1.png"></image>

				<view class="transport-title">
					<span>{{$lang.lang.notices.transport}}</span>
				</view>
				<image class="type-bg" src="../../static/img/type-1.png"></image>
				<view class="transport-info">
				     <view v-for="item in transType" @click="toCreatOrder(item.value)" :class="'type'+item.value">{{$lang.locale=='zh'?item.label:$lang.locale=='en'?item.labelEn:item.labelFr}}</view>
				</view>
			</view>
		</uni-popup>
		<declaration-documents ref="declaration" :orderId="selectOrderId" :orderNo="orderNo" @open="open"></declaration-documents>
		<uni-popup ref="controlLog" type="center">
			<view class="lendFrom_content">
					<view class="lendFrom_title">{{$lang.lang.order.controlLog}}</view>
					<view class="lengingLog_list">
						<view class="lendFrom_order" v-for="(item,index) in controlLogData" :key="index">
							<text>{{$lang.lang.order.addtime}}：{{$request.getLocalTime(item.createTime)}}</text>
							<text style="width: 100%;">{{$lang.lang.order.operation}}：{{item.creatorName}}</text>
							<text>{{$lang.lang.order.operatorType}}：{{item.userType==1?$lang.lang.order.member:$lang.lang.order.manager}}</text>
							<text>{{$lang.lang.order.operateType}}：{{$lang.locale=='zh'?item.type:$lang.locale=='en'?item.typeEn:item.typeFr}}</text>
							<text>{{$lang.lang.order.remark}}：{{$lang.locale=='zh'?item.msg:$lang.locale=='en'?item.msgEn:item.msgFr}}</text>
						</view>
					</view>
					<view class="lending_btns">
						<view @click="$refs.controlLog.close()">{{$lang.lang.order.confirm}}</view>
						<view @click="$refs.controlLog.close()">{{$lang.lang.order.cancel}}</view>
					</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import { object } from '@dcloudio/vue-cli-plugin-uni/packages/postcss/tags'
	import lengingAgreement from '../../components/lengingAgreement/index.vue'
	import transferAgreement from '../../components/transferAgreement/index.vue'
	import declarationDocuments from '../../components/declarationDocuments/index.vue'
	export default {
		components: {
			lengingAgreement,transferAgreement,declarationDocuments
		},
		data() {
			return {
        shippingImg:'',
        receivingImg:'',
				nvs: [
					{name: this.$lang.lang.order.allOrder, icon: '../../static/img/order-1.png', nums: 0,icons:'../../static/img/order-5.png'},
					{name: this.$lang.lang.order.form, icon: '../../static/img/order-2.png', nums: 0,icons:'../../static/img/order-6.png'},
					{name: this.$lang.lang.order.received, icon: '../../static/img/order-3.png', nums: 0,icons:'../../static/img/order-7.png'},
					{name: this.$lang.lang.order.control, icon: '../../static/img/order-4.png', nums: 0,icons:'../../static/img/order-8.png'},
				],
				data:[],
				page:1,
				pages:1,
				statusData:[],
				searchKey:'',
				selectIndex:0,
				reason:'',
				imgUrl:[],//退仓图片地址
				params:{},
        isDelivery: true,
				config:{
					transport:{
						index:-1,
						checked:false,
						label:[],
						value:[]
					},
					tradeCity2:{
						index:-1,
						checked:false,
						label:[],
						value:[]
					},
					countrySn:{
						index: 0,
						indexs:0,
						label: [],
						value: [],
					},
					//控货状态
					cargoControlStatus:{
						index:0,
						value:['',0,1,2],
						label:[this.$lang.lang.order.allStatus,this.$lang.lang.order.controling,this.$lang.lang.order.controled,this.$lang.lang.order.controlPartial],
					},
					status:{
						index: 0,
						label: [this.$lang.lang.order.allStatus],
						value: [''],
					},
				},
				selectOrder:{},
				lendingFrom:{},
				leftTime:60,
				leftTimes:60,
				type:1,
				transferFrom:{},
				lendingdata:{},
				releaseData:{},
				userInfo: {},
				index:0,
				selectOrderId:0,
				lengIndex:0,
				isControlPass:false,//是否设置控货密码
				orderNo:null,
				controlLogData:[],
				controlType:1,//放货方式
				transType:[],
				loading:false,
				smsName: ['SMS','WhatsApp'],
				smsData: [1,2],
				smsIndex: 0
			}
		},
    computed:{
      disableUpdateCongsignee(){
        if(!this.releaseData?.isLimitUpdateConsignee) return false
        // 锁定且过期了返回false，其他情况全部是true
        if(this.releaseData.isLimitUpdateConsignee && this.releaseData.lockConsigneeTime && new Date(this.releaseData.lockConsigneeTime).getTime() < Date.now()){
          return false
        }
        return true
      }
    },
		onLoad() {
			this.getStatusData()
			this.getCountrySn()
			this.orderConfig1()
			// this.getTradeCity('tradeCity2')
			// this.orderConfig('transport_type', 'transport')
		},
		onShow() {
			this.getUserInfo()
			this.selectIndex = 0
			this.getData()
			// this.getControl()
			// this.getIssued()
			// this.getReceiver()
			this.getOrderNum()
      this.changeImage();
		},
		onReachBottom() {
			if(this.pages > this.page){
				this.page ++
				if(this.selectIndex==0){
					this.getData()
				}else if(this.selectIndex==1){
					this.getIssued()
				}else if(this.selectIndex==2){
					this.getReceiver()
				}else{
					this.getControl()
				}
			}
		},
		methods: {
      formatMsg(item){
        let val=this.getRealStatus(item)
        console.log("val",val)
        const index=this.config.status.value.findIndex(item=>{
          if (item !== undefined && item !== null && item !== ''){
            return item.split(',').map(Number).includes(val);
          }else {
            return 0;
          }
        })
        return this.config.status.label[index];
      },
      changeImage() {
        if (this.$lang.locale=='zh'){
          this.shippingImg="../../static/img/fa.png"
          this.receivingImg="../../static/img/shou.png"
        }else if(this.$lang.locale=='en'){
          this.shippingImg="../../static/img/fa_en.png"
          this.receivingImg="../../static/img/shou_en.png"
        }else {
          this.shippingImg="../../static/img/fa_fr.png"
          this.receivingImg="../../static/img/shou_fr.png"
        }
      },
			//获取状态
			getStatusData () {
				let that = this
				this.$request.getConfig('app_order_status').then(res => {
					if(res.code==0&&res.data&&res.data.list.length > 0){
						res.data.list.forEach(item=>{
							if(that.$lang.locale=='zh'){
								that.config.status.label.push(item.label)
							}else if(that.$lang.locale=='en'){
								that.config.status.label.push(item.labelEn)
							}else {
                that.config.status.label.push(item.labelFr)
              }
							that.config.status.value.push(item.value)
						})
					}
				})
			},
			getUserInfo() {
				this.$request.get('/app-api/member/user/get').then(res => {
					if(res.code==0&&res.data){
						this.userInfo = res.data
						this.isHavePassword = this.userInfo.isHavePassword
            if (this.userInfo != null){
              this.isDelivery = this.userInfo.areaCode === '86';
            }
					}

				})
			},
			//放贷弹窗
			lendFromShow(){
				this.getLengingEditData()
				this.$refs.lending.close()
			},
			getOrderNum(){
				this.$request.get('/app-api/member/user/angle-mark').then(res=>{
					if(res.code==0&&res.data){
						this.nvs[0].nums = res.data.allOrderNum
						this.nvs[1].nums = res.data.issuedOrderNum
						this.nvs[2].nums = res.data.receivedOrderNum
						this.nvs[3].nums = res.data.cargoControlAllNum
					}
				})
			},
			isLending(){
				if(!this.lendingFrom.consigneeName){
					return uni.showToast({
						title: this.$lang.lang.notices.consignee,
						icon: 'none',
					})
				}
				if(!this.lendingFrom.consigneePhone){
					return uni.showToast({
						title: this.$lang.lang.notices.consigneePhone,
						icon: 'none',
					})
				}
				if(!this.lendingFrom.pickNum){
					return uni.showToast({
						title: this.$lang.lang.notices.sum,
						icon: 'none',
					})
				}
				if(!this.lendingFrom.pickWeight){
					return uni.showToast({
						title: this.$lang.lang.notices.weight,
						icon: 'none',
					})
				}
				if(!this.lendingFrom.pickVolume){
					return uni.showToast({
						title: this.$lang.lang.notices.volume,
						icon: 'none',
					})
				}

				if(!this.lendingFrom.code&&!this.lendingFrom.controlPassword){
					return uni.showToast({
						title: this.$lang.lang.order.controlNotice,
						icon: 'none',
					})
				}
				if(this.lendingFrom.pickNum>(this.selectOrder.sumNum-this.releaseData.releaseNum))
				{
					return uni.showToast({
						title: this.$lang.lang.notices.conNotice,
						icon: 'none',
					})
				}
				this.$refs.lendingNotice.open()
			},
			getLengingEditData(){
				let that = this
				that.$request.get('/app-api/order/order-cargo-control/release/info/'+that.selectOrder.orderId).then(res => {
					if(res.code==0&&res.data){
						that.releaseData = res.data
						that.$set(that.lendingFrom,'consigneeName',res.data.consigneeName)
						that.$set(that.lendingFrom,'consigneePhone',res.data.consigneePhone)
						that.$set(that.lendingFrom,'consigneeCountryCode',res.data.consigneeCountryCode)
						that.$set(that.lendingFrom,'pickNum',parseInt(that.selectOrder.sumNum)-parseInt(that.selectOrder.releaseNum))
						that.$set(that.lendingFrom,'pickVolume',res.data.sumVolume)
						that.$set(that.lendingFrom,'pickWeight',res.data.sumWeight)
						that.getCountryIndex(res.data.consigneeCountryCode,1)
						that.$refs.lendFrom.open()
					}else{
						uni.showToast({
							title:  res.msg,
							icon: 'none',
						})
					}
				})
			},
			//获取控货密码是否设置
			getIsControlPass(id){
				let that = this
				that.$request.get('/app-api/order/order-cargo-control/controlPassword/'+id).then(res => {
					if(res.code==0&&res.data){
						that.isControlPass = true
					}
				})
			},
			//控货转移
			getTransferData(){
				let that = this
				that.$request.get('/app-api/order/order-cargo-control/info/'+that.selectOrder.orderId).then(res => {
					if(res.code==0&&res.data){
						that.transferFrom.name = res.data.name
						that.transferFrom.phone = res.data.phone
						that.getCountryIndex(res.data.dialCode,2)
					}
				})
			},
			ismobile(){
				if(!this.transferFrom.phone){
					return uni.showToast({
						title: this.$lang.lang.notices.newControlTel,
						icon: 'none',
					})
				}
				this.transferFrom.dialCode=this.transferFrom.dialCode||'86',
				this.$request.get('/app-api/param/validator/mobile',{code:this.transferFrom.dialCode,mobile:this.transferFrom.phone}).then(res => {
					if(res.code==0){
						this.addTransfer()
					}else{
						uni.showToast({
							title:  this.$lang.lang.notices.nophone,
							icon: 'none',
						})
					}
				})
			},
			addTransfer(){
				if(!this.transferFrom.name){
					return uni.showToast({
						title: this.$lang.lang.notices.newControl,
						icon: 'none',
					})
				}
				if(!this.transferFrom.controlPassword&&!this.transferFrom.code){
					return uni.showToast({
						title: this.$lang.lang.order.controlNotice,
						icon: 'none',
					})
				}

				this.transferFrom.orderId = this.selectOrder.orderId
				this.transferFrom.orderNo = this.selectOrder.orderNo
				this.$request.post('/app-api/order/order-cargo-control/create',this.transferFrom).then(res => {
					if(res.code==0){

						this.transferFrom = {}
						setTimeout(()=>{
							this.page = 1
							this.getControl()
						},2000)

						this.$refs.transfer.close()
						uni.showToast({
							title:this.$lang.lang.notices.operation,
							icon:'none'
						})
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				})
			},

			transferFromShow(){
				this.$refs.lending.close()
				this.$refs.transfer.open()
			},
			getLendingData(orderId){
				this.$request.get('/app-api/order/order-cargo-control-pick/release/info/'+orderId).then(res => {
					if(res.code==0&&res.data){
						this.lendingdata = res.data
						this.$refs.lendingLog.open()
					}
				})
			},
			//查看放贷记录
			seeLending(id,index){
				this.lendingdata = {}
				this.selectOrder = this.data[index]
				this.getLendingData(id)
			},
			ismobileLend(){
				this.lendingFrom.consigneeCountryCode=this.lendingFrom.consigneeCountryCode||'86',
				console.log(this.lendingFrom.consigneeCountryCode)
				this.$request.get('/app-api/param/validator/mobile',{code:this.lendingFrom.consigneeCountryCode,mobile:this.lendingFrom.consigneePhone}).then(res => {
					if(res.code==0){
						this.addLending()
					}else{
						uni.showToast({
							title:  this.$lang.lang.notices.nophone,
							icon: 'none',
						})
					}
				})
			},
			//添加放贷
			addLending(){
				this.lendingFrom.orderId = this.selectOrder.orderId
				this.lendingFrom.orderNo = this.selectOrder.orderNo


				this.$request.post('/app-api/order/order-cargo-control-pick/create', this.lendingFrom).then(res => {
					if(res.code==0){

						setTimeout(()=>{
							this.page = 1
							this.selectIndex =3
							this.getControl()
							this.seeLending(this.selectOrder.orderId,this.lengIndex)
						},2000)
						this.$refs.lendingNotice.close()
						this.$refs.lendFrom.close()
						uni.showToast({
							title:this.$lang.lang.order.lendSussess,
							icon:'none'
						})
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				})
			},
			sendTransCode(e){
				if (this.leftTimes < 60) {
					return false
				}
				var data = {
				  nodeValue: 'transfer-control-goods',
				  orderId: this.selectOrder.orderId,
				  isTransport: 0,
				  transportId: 0,
				  isOrders: 0,
				  messageType: this.smsData[e.detail.value]
				}
				this.$request.post('/app-api/order/order-cargo-control/send-sms-code', data).then(res => {
					if(res.code == 0){
						this.countDowns()
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
						})
					}
				})
			},
			countDowns() {
				this.leftTimes--
				if (this.leftTimes > 0) {
					setTimeout(this.countDowns, 1000)
				} else {
					this.leftTimes = 60
				}
			},
			sendCode (e) {
				if (this.leftTime < 60) {
					return false
				}

				var data = {
				  nodeValue: 'delivery-verification-sms',
				  orderId: this.selectOrder.orderId,
				  isTransport: 0,
				  transportId: 0,
				  isOrders: 0,
				  messageType: this.smsData[e.detail.value]
				}
				this.$request.post('/app-api/order/order-cargo-control/send-sms-code', data).then(res => {
					if(res.code == 0){
						this.countDown()
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
						})
					}
				})
			},
			countDown() {
				this.leftTime--
				if (this.leftTime > 0) {
					setTimeout(this.countDown, 1000)
				} else {
					this.leftTime = 60
				}
			},
			configChange (e){
				if(e.target.dataset.key == 'dialCode'){
					this.transferFrom[e.target.dataset.key] = this.config[e.target.dataset.config].value[e.detail.value]
					this.config[e.target.dataset.config].indexs = e.detail.value
				}else if(e.target.dataset.key == 'cargoControlStatus'){
					this.config[e.target.dataset.config].index = e.detail.value
					this.changeIndex(this.selectIndex)
				}else if(e.target.dataset.key == 'status'){
          this.config.status.index = e.detail.value
          this.changeIndex(this.selectIndex)
        }else{
					this.config[e.target.dataset.config].index = e.detail.value
					this.lendingFrom[e.target.dataset.key] = this.config[e.target.dataset.config].value[e.detail.value]
				}

			},
			//放贷
			tolending(index,type){
				this.type = type
				this.transferFrom = {}
				this.lendingFrom = {}
				this.controlType = 1
				this.selectOrder = this.data[index]
				this.lengIndex = index
				if(type==2){
					// this.getTransferData()
					this.transferFrom.consignorName=this.selectOrder.cargoControlName
					this.transferFrom.consignorPhone=this.selectOrder.cargoControlPhone
					this.transferFrom.consignorCountryCode = '+'+this.selectOrder.cargoControlCountryCode
				}
				this.getIsControlPass(this.selectOrder.orderId)
				setTimeout(()=>{
					this.$refs.lending.open()
				},500)

			},
			//获取区号
			getCountrySn(){
				let that = this
				that.$request.get('/app-api/ecw/country/list-all').then(res => {
					if(res.code==0&&res.data.length > 0){
						let d = res.data
						for(let i in d){
							if(that.$lang.locale=='zh'){
								that.config['countrySn'].label.push('+'+res.data[i].tel + ' ' + res.data[i].nameZh)
							}else if(that.$lang.locale=='en'){
								that.config['countrySn'].label.push('+'+res.data[i].tel + ' ' + res.data[i].nameEn)
							} else {
								that.config['countrySn'].label.push('+'+res.data[i].tel + ' ' + res.data[i].nameFr)
							}
							// this.config['countrySn'].label.push(d[i].tel)
							that.config['countrySn'].value.push(d[i].tel)
						}
					}
				})
			},
			getCountryIndex(value,type){
				let that = this
				that.config['countrySn'].value.forEach((item,index)=>{
					if(item==value){
						if(type==1){
							that.config.countrySn.index = index
						}else{
							that.config.countrySn.indexs = index
						}

					}
				})
			},
			//获取始发、目的城市
			getTradeCity(key){
				let that = this
				that.$request.get('/app-api/ecw/region/getTradeCityList', {type: 2}).then(res => {
					if(res.code==0&&res.data.length > 0){
						let d = res.data
						for(let i in d){
							if(that.$lang.locale=='zh'){
								that.config[key].label.push(d[i].titleZh)
							}else{
								that.config[key].label.push(d[i].titleEn)
							}
							that.config[key].value.push(d[i].id)
						}
					}
				})
			},
			configShow(key){
				this.config[key].checked = !this.config[key].checked
			},
			selectConfig(key,index){
				this.params[key] = this.config[key].value[index]
				this.config[key].index = index
			},
			screenShow(){
				this.$refs.screen.open()
			},
			screenReset(){
				this.params = {}
				this.config.transport.index = -1
			},
			toSearch(){
				this.getControl()
				this.$refs.screen.close()
			},
			returnOrder(index){
				this.selectOrder = this.data[index]
				setTimeout(()=>{
					this.$refs.apply.open()
				},500)
			},
			closeApply(){
				this.selectOrder = {}
				this.reason = ''
				this.imgUrl = []
				this.$refs.apply.close()
			},
			sumbitApply(){
				var params = {
					orderId:this.selectOrder.orderId,
					orderNo:this.selectOrder.orderNo,
					reason:this.reason,
					imgUrl:this.imgUrl.join(',')
				}
				this.$request.put('/app-api/order/order-warehouse-in/rollback-apply',params).then(res => {
					if(res.code==0){
						uni.showToast({
							title:this.$lang.lang.notices.operation,
							icon:'none'
						})
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				})
				this.closeApply()
			},
			changeIndex(index){
				if(this.selectIndex!=index){
					this.searchKey = ''
					this.config.status.index = 0
				}
				this.selectIndex = index
				this.nvs[index].nums = 0
				this.data = []
				this.page = 1
				this.loading = true
				uni.showLoading({
					title:this.$lang.lang.notices.loading,
				})
				if(index==0){
					this.getData()
				}else if(index==1){
					this.getIssued()
				}else if(index==2){
					this.getReceiver()
				}else{
					this.getControl()
				}
			},
			getControl(){
				this.params.page = this.page
				this.params.rows = 6
				this.params.searchKey = this.searchKey.replace(/\s+/g, '')
				this.params.cargoControlStatus = this.config.cargoControlStatus.value[this.config.cargoControlStatus.index]
				this.$request.get('/app-api/my/order/cargo/control/page',this.params).then(res=>{
					if(res.code==0&&res.data&&res.data.list&&res.data.list.length>0){
						if(this.page == 1){
							if(this.selectIndex==3){
								this.data = res.data.list
								this.pages = res.data.pages
							}
							this.nvs[3].nums = res.data.total
						}else{
							this.data = this.data.concat(res.data.list)
						}
					}
					uni.hideLoading()
					this.showLoading = false
				})
			},
			getIssued(){
				this.$request.get('/app-api/my/order/issued/page',{page:this.page,rows:6,searchKey:this.searchKey.replace(/\s+/g, ''),dynamicStatusList:this.config.status.value[this.config.status.index]}).then(res=>{
					if(res.code==0&&res.data&&res.data.list&&res.data.list.length>0){
						if(this.page == 1){
							if(this.selectIndex==1){
								this.data = res.data.list
								this.pages = res.data.pages
							}
							this.nvs[1].nums = res.data.total
						}else{
							this.data = this.data.concat(res.data.list)
						}
					}
					uni.hideLoading()
					this.showLoading = false
				})
			},
			getReceiver(){
				this.$request.get('/app-api/my/order/received/page',{page:this.page,rows:6,searchKey:this.searchKey.replace(/\s+/g, ''),dynamicStatusList:this.config.status.value[this.config.status.index]}).then(res=>{
					if(res.code==0&&res.data&&res.data.list&&res.data.list.length>0){
						if(this.page == 1){
							if(this.selectIndex==2){
								this.data = res.data.list
								this.pages = res.data.pages
							}
							this.nvs[2].nums = res.data.total
						}else{
							this.data = this.data.concat(res.data.list)
						}
					}
					uni.hideLoading()
					this.showLoading = false
				})
			},
			getStatusDatas () {
				this.$request.getConfig('order_status').then(res => {
					if(res.code==0&&res.data&&res.data.list&&res.data.list.length>0){
						this.statusData = res.data.list
					}
				})
			},
			getDate(time) {
				time = time.replace(/-/g,'/');
				const date = new Date(time);
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			getStatusName (type){
				let that = this
				var status = that.statusData.find(item=>item.value == type)
				if(status) {
					if(that.$lang.locale=='zh'){
						return status.label
					}else{
						return status.labelEn
					}
				}
			},
			getData(){
				this.$request.get('/app-api/my/order/all/order',{page:this.page,rows:6,searchKey:this.searchKey.replace(/\s+/g, ''),dynamicStatusList:this.config.status.value[this.config.status.index]}).then(res=>{
					if(res.code==0&&res.data&&res.data.list&&res.data.list.length>0){
						if(this.page == 1){
							if(this.selectIndex==0){
								this.data = res.data.list
								this.pages = res.data.pages
							}
							this.nvs[0].nums = res.data.total

						}else{
							this.data = this.data.concat(res.data.list)
						}
					}
					uni.hideLoading()
					this.showLoading = false
				})
			},
			toCreatOrders(){
				this.openTransport()
			},
			toOrderInfo(id){
				uni.navigateTo({
					url:'../orderInfo/orderInfo?id='+id
				})
			},
			toEditOrder(id, copy){
        if (copy){
          uni.navigateTo({
            url:'../create_order/create_order?id='+id +'&copy=1'
          })
        }else {
          uni.navigateTo({
            url:'../create_order/create_order?id='+id
          })
        }
			},
			toException(id){
				uni.navigateTo({
					url:'../exception/exception?id='+id
				})
			},
			delOrdered(id){
				this.$request.deleted('/app-api/my/order/delete?orderId='+id).then(res=>{
					if(res.code==0){
						uni.showToast({
							title:this.$lang.lang.notices.deleteSuccess,
							icon:'none'
						})
						setTimeout(()=>{
							this.changeIndex(this.selectIndex)
						},2000)

					}else{
						uni.showToast({
							title:res.msg,
							icon:'error'
						})
					}
				})
			},
			cancelOrdered(id){
				this.$request.put('/app-api/my/order/cancel/'+id).then(res=>{
					if(res.code==0){
						uni.showToast({
							title:this.$lang.lang.notices.cancel,
							icon:'none',
						})
						setTimeout(()=>{
							this.changeIndex(this.selectIndex)
						},2000)
					}else{
						uni.showToast({
							title:res.msg,
							icon:'error'
						})
					}
				})
			},
			delOrder(id){

				let that = this
				uni.showModal({
					title: this.$lang.lang.notices.notice,
					content:this.$lang.lang.notices.delOrder,
					success: function (res) {
						if (res.confirm) {
							that.delOrdered(id)
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			cancelOrder(id){

				let that = this
				uni.showModal({
					title: this.$lang.lang.notices.notice,
					content: this.$lang.lang.notices.cancelOrder,
					success: function (res) {
						if (res.confirm) {
							that.cancelOrdered(id)
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			orderConfig (field, key) {
				this.$request.getConfig(field).then(res => {
					if(res.code==0&&res.data&&res.data.list&&res.data.list.length>0){
						var d = res.data.list
						for(let i in d){
							this.config[key].label.push(d[i].label)
							this.config[key].value.push(d[i].value)
						}
					}
				})
			},
			//移除上传图片
			deleteImg(index){
				this.imgUrl.splice(index,1)
			},
			//上传退仓图片
			uploadImg () {
				let that = this
				uni.chooseImage({
					count: 20,
					success:(res)=> {
						uni.showLoading({
							title: that.$lang.lang.notices.loading,
						})
						const file = res.tempFilePaths
						if((that.imgUrl.length+res.tempFilePaths.length)>20){
							uni.showToast({
								title: that.$lang.lang.order.uploadNotice,
								icon: 'none',
							})
							uni.hideLoading()
							return
						}
						for(var i=0;i<file.length;i++){
							uni.uploadFile({
								url: that.$request.baseUrl + '/app-api/file/upload',
								filePath: file[i],
								name: 'file',
								header: that.$request.getImgHeader(),
								success: (uploadFileRes) => {
									uni.hideLoading()
									let res = JSON.parse(uploadFileRes.data)
									console.log('res', res)
									if(res.code == 0){
										that.imgUrl.push(res.data)
									} else {
										uni.showToast({
											title: res.msg,
											icon: 'none',
										})
									}
								}
							})
						}

					},
					fail: (Error) => {
						console.log(Error)
					}
				})
			},

			openFile(id,no){
				console.log(id)
				this.orderNo = no
				this.selectOrderId = id
				this.$refs.declaration.open()
				setTimeout(()=>{
					this.$refs.declaration.getFileList()
				},200)
			},
			closeTransport(){
				this.$refs.choiceTransport.close()
			},
			openTransport(){
				this.$refs.choiceTransport.open()
			},
			toCreatOrder(id){
				this.closeTransport()
				uni.navigateTo({
					url:'../create_order/create_order?transportId='+id
				})
			},
			//显示控货日志
			showControlLog(id){
				this.$request.get('/app-api/order/order-control-log/list/'+id).then(res => {
					console.log(res)
					if(res.code==0&&res.data&&res.data.length>0){
						this.controlLogData = res.data
					}
					this.$refs.controlLog.open()
				})

			},
			//放货方式
			doubleClear: function(evt) {
				if(evt.detail.value==2){
					this.lendingFrom.code = ''
				}else{
					this.lendingFrom.controlPassword = ''
				}
				this.controlType = evt.detail.value
			},
			doubleClears(evt){
				if(evt.detail.value==2){
					this.transferFrom.code = ''
				}else{
					this.transferFrom.controlPassword = ''
				}
				this.controlType = evt.detail.value
			},
			open(){
				// this.$refs.declaration.open()
			},
			orderConfig1 () {
				let that = this
				that.$request.getConfig('transport_type').then(res => {
					if(res.code==0&&res.data&&res.data.list.length > 0){
						that.transType = res.data.list
					}
				})
			},
      copy(orderId){
        this.toEditOrder(orderId, true)
        // this.$request.post("/app-api/my/order/copy/" + orderId).then(res => {
        //   this.toEditOrder(res.data)
        // })
      },
      getRealStatus(item){
        let status = 0;
        if (item.status === 12 && item.shipmentState === 325){
          status = 12325
        }else if (item.status === 5 && item.airShipment === 1 && item.abnormalState === 0 && item.auditType=== 0 && item.transportId === 3){
          status = 10501
        }else if (item.status === 5 && (item.airShipment === 2 || item.airShipment === 3) && item.abnormalState === 0 && item.auditType=== 0 && item.transportId === 3){
          status = 10502
        }else if (item.status === 5 && item.airShipment === 4 && item.transportId === 3) {
          status = 10503;
        } else if (item.status === 5 && item.abnormalState === 0 && item.auditType === 0 &&
            ((item.transportId === 3 && (item.airShipment === 2 || item.airShipment === 3 || item.airShipment === 4)) ||
                (item.transportId === 1 && (item.airShipment === 0 || item.airShipment === 2 || item.airShipment === 3 || item.airShipment === 4)))) {
          status = 10504;
        } else if (item.status === 32 && item.shipmentState === 411 && item.transportId === 3) {
          status = 132411;
        } else if (item.status === 32 && item.shipmentState === 412 && item.transportId === 3) {
          status = 132412;
        } else if (item.status === 32 && item.shipmentState === 409 && item.transportId === 3) {
          status = 132409;
        } else if (item.status === 32 && item.shipmentState === 428 && item.transportId === 3) {
          status = 118428;
        }else {
          status = item.status;
        }
        return status
      }
		},

	}
</script>

<style>
	@import url("../../static/css/order.css");
  .lendFrom_content .tips{
    color: red;
    padding-left: 12px;
    padding-bottom: 10px;
  }
</style>
