<template>
	<view class="detail wrap">
		<view class="detail-bg"></view>
		<view class="detail-main" v-if="boxInfo">
			<view class="items items-border">
				<view class="items-lf">
					<image src="../../static/images/no.png" mode=""></image>
					<text>{{$t('自编号')}}:</text>
				</view>
				<view class="items-rf">{{boxInfo.selfNo}}</view>
			</view>
<!-- 			<view class="items">
				<view class="items-lf">
					<image src="../../static/images/xiegui-2.png" mode=""></image>
					<text>{{$t('货柜号')}}:</text>
				</view>
				<view class="items-rf">{{boxInfo.cubNo}}</view>
			</view> -->
			<view class="items items-border">
				<view class="items-lf">
					<image src="../../static/images/xiegui-3.png" mode=""></image>
					<text>{{$t('运输方式')}}:</text>
				</view>
				<view class="items-rf">
					<dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="boxInfo.transportType" />
				</view>
			</view>
<!--			<view class="items items-border">-->
<!--				<view class="items-lf">-->
<!--					<image src="../../static/images/xiegui-4.png" mode=""></image>-->
<!--					<text>{{$t('柜型')}}:</text>-->
<!--				</view>-->
<!--				<view class="items-rf">{{boxInfo.cabinetRespVO ?  boxInfo.cabinetRespVO.name : ''}}</view>-->
<!--			</view>-->
			<view class="items items-border" v-if="boxInfo.transportType == 3 || boxInfo.transportType == 4">
				<view class="items-lf">
					<image src="../../static/images/xiegui-5.png" mode=""></image>
					<text>{{$t('出货渠道')}}:</text>
				</view>
				<view class="items-rf">{{boxInfo.channelRespVO.nameZh}}</view>
			</view>
			<view class="items items-border">
				<view class="items-lf">
					<image src="../../static/images/xiegui-6.png" mode=""></image>
					<text>{{$t('始发地')}}:</text>
				</view>
				<view class="items-rf">{{boxInfo.startWarehouseResp[isChinese ? 'titleZh' : 'titleEn']}}</view>
			</view>
			<view class="items">
				<view class="items-lf">
					<image src="../../static/images/xiegui-7.png" mode=""></image>
					<text>{{$t('目的地')}}:</text>
				</view>
				<view class="items-rf">{{boxInfo.destWarehouseResp.titleZh}}</view>
			</view>
			<view class="items items-border">
				<view class="items-lf">
					<image src="../../static/images/xiegui-8.png" mode=""></image>
					<text>{{$t('方数')}}（{{$t('已装/已卸')}}）:</text>
				</view>
				<view class="items-rf">{{boxInfo.boxStatistics.loadVolume}}/{{boxInfo.boxStatistics.unloadVolume}}</view>
			</view>
			<view class="items items-border">
				<view class="items-lf">
					<image src="../../static/images/xiegui-9.png" mode=""></image>
					<text>{{$t('重量')}}（{{$t('已装/已卸')}}）:</text>
				</view>
				<view class="items-rf">{{boxInfo.boxStatistics.loadWeight}}/{{boxInfo.boxStatistics.unloadWeight}}</view>
			</view>
			<view class="items items-border">
				<view class="items-lf">
					<image src="../../static/images/xiegui-10.png" mode=""></image>
					<text>{{$t('状态')}}:</text>
				</view>
				<view class="items-rf">{{boxInfo.shipmentStatusText}}</view>
			</view>
			<view class="items items-border">
				<view class="items-lf">
					<image src="../../static/images/xiegui-11.png" mode=""></image>
					<text>{{$t('单证状态')}}:</text>
				</view>
				<view class="items-rf" v-if="boxInfo.documentInfo">
					<dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="boxInfo.documentInfo" />
				</view>
				<view class="items-rf" v-else>/</view>
			</view>
			<view class="items" v-if="boxInfo.customsInfo&&boxInfo.customsInfo.overMachineStatus==2&&boxInfo.customsInfo.overMachineAbnormalStatus==2">
				<view class="items-lf">
					<image src="../../static/images/xiegui-5.png" mode=""></image>
					<text style="color:#D9001B;width:90%" v-if="boxInfo.customsInfo.weightMisreport==1">
					  {{$t('过机重量异常')}}:{{$t('机场误差3%以内')}}
					</text>
					<text style="color:#D9001B;width:90%" v-if="boxInfo.customsInfo.weightMisreport==2">
					  {{$t('过机重量异常')}}:{{$t('我司误差超10kg')}}
					</text>
					<text style="color:#D9001B;width:90%" v-if="boxInfo.customsInfo.overWeight>0">
					  {{$t('过机重量异常')}}:{{$t('超过机场重量')}}{{boxInfo.customsInfo.overWeight}}kg
					</text>
				</view>
			</view>
		</view>
		<view class="detail-order">
			<view class="detail-order-title">
				<view class="detail-order-title-lf">
					<image src="../../static/images/xiegui-12.png" mode=""></image>
					<text>{{$t('订单列表')}}</text>
				</view>
				<view class="detail-order-tab-rf" @click="allOrderUnload">
					<image src="../../static/images/yijian.png" mode=""></image>
					<text>{{$t('一键到仓')}}</text>
				</view>
			</view>

			<template v-for="(i, v) in loadDetail">
				<template v-if="i.sectionOrderList && i.sectionOrderList.length > 0">
					<view class="detail-order-tab">
						<view class="detail-order-tab-lf">{{$t("第{k}部分", {k: v+1})}}</view>
					</view>
					<view class="detail-order-items" v-for="(item, index) in i.sectionOrderList">
						<view class="detail-order-items-no">{{$t('序号')}}：{{index+1}}</view>
						<view :class="item.exceptionList ? 'detail-order-items-list no-border-bottom' : 'detail-order-items-list'">
							<view class="detail-order-items-list-v">
								<view class="">{{$t('订单号')}}: {{item.orderNo}}</view>
								<view class="">{{$t('实装箱数')}}/{{$t('已卸箱数')}}: {{item.installNum}}/{{item.unloadNum}}</view>
								<view class="">{{$t('提货点')}}: {{item.destWarehouseName}}</view>
								<view class="">{{$t('重量')}}: {{item.weight}}</view>
								<view class="">
									{{$t('报关方式')}}:
									<dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="item.customsType" />
								</view>
							</view>
							<view class="detail-order-items-list-v">
								<view class="">
									{{$t('货物信息')}}:
									<template>
										<text v-for="(itm, idx) in item.goodsList">{{index + 1}}.{{itm.prodTitleZh}}</text>
									</template>
								</view>
								<view class="">
									<template v-if="item.unloadNum < 1">
										{{$t('状态')}}: {{$t('待到仓')}}
										<template v-if="item.exceptionList">,<text class="errorText">{{$t('存在异常')}}</text></template>
									</template>
									<template v-if="item.unloadNum > 1 && item.unloadNum < item.installNum">
										{{$t('状态')}}: {{$t('部分到仓')}}
										<template v-if="item.exceptionList">,<text class="errorText">{{$t('存在异常')}}</text></template>
									</template>
									<template v-if="item.unloadNum >= item.installNum">
										{{$t('状态')}}: {{$t('已到仓')}}
										<template v-if="item.exceptionList">,<text class="errorText">{{$t('存在异常')}}</text></template>
									</template>
								</view>
								<view class="">{{$t('体积')}}: {{item.volume}}</view>
								<view class="">{{$t('货值')}}: {{item.totalWorth}}</view>
								<view class="">{{$t('报关费用')}}: {{item.customsFee}}</view>
							</view>
						</view>
						<view class="detail-order-item-btns">
							<view class="" @click="unloadApply(item)">{{$t('到仓')}}</view>
							<view class="" @click="orderModelToggle(item.orderId, v, index)">{{$t('异常')}}</view>
						</view>
					</view>
				</template>
			</template>
			<view class="detail-order-time">
				<view class="detail-order-time-lf">
					<image src="../../static/images/err-2.png" mode=""></image>
					<text><span style="color: red">*</span>{{$t('到仓时间')}}</text>
				</view>
				<view class="detail-order-time-rf">
					<leeDatetime @change="bindLeeDateTimeChange" :field="'ulBoxTime'" :placeholder="$t('请选择日期时间')" :value="date.ulBoxTime"></leeDatetime>
				</view>
			</view>
			<view class="detail-order-title">
				<image src="../../static/images/xiegui-13.png" mode=""></image>
				<text>{{$t('到仓影像')}}</text>
			</view>
			<view class="img-wrap">
				<uni-grid :column="4" :highlight="true" :show-border="false">
				  <uni-grid-item v-for="(item, index) in imageList" :index="index" :key="index">
				    <view class="grid-item-box" style="height: 100%;position: relative;">
				      <image :src="iconpath" style="position: absolute;top:4px;right:4px;height:24px;width:24px;z-index:9" @tap="delimage(index)" mode="widthFix"></image>
				      <image v-if="item.type === 'image'" :src="item.url" mode="scaleToFill" style="height: 100%" @tap="previewImage(item.url)" />
				      <video v-else-if="item.type === 'video'" :id="`video_${index}`" style="width: 100%;height: 100%" :src="item.url" @play="playVideo(index)" @tap="playVideo(index)" @fullscreenchange="fullscreenchange"></video>
				    </view>
				  </uni-grid-item>
				  <uni-grid-item>
				    <view class="grid-item-box" style="height: 100%">
				      <view class="grid-item-box-add" @tap="chooseVideoImage">
				        <uni-icons type="plusempty" size="30" color="#eae8eb"></uni-icons>
				        <!-- <text>添加视频或图片</text> -->
				      </view>
				    </view>
				  </uni-grid-item>
				</uni-grid>
			</view>
		</view>
		<view class="detailbtns">
			<view class="">
				<text @click="shipmentModelToggle">{{$t('转异')}}</text>
			</view>
			<view class="">
				<text @click="allUnloadReply">{{$t('完成全部到仓')}}</text>
			</view>
		</view>

		<!-- 订单异常柜型弹窗 -->
		<view class="cu-modal" :class="orderModel ? 'show' : ''" style="z-index: 999;">
			<view class="cu-main">
				<view class="cu-title">{{$t('异常')}}</view>
				<view class="cu-tips">
					<image src="../../static/images/zhyi.png" mode=""></image>
					<text>{{$t('异常类型')}}</text>
				</view>
				<view class="cu-reson">
					<view class="" v-for="(i, v) in shippingUnloadingError" @click="shippingUnloadingChoose(i.value)">
						<image :src="shippingUnloadingValue == i.value ? '../../static/images/radio-true.png' : '../../static/images/radio-false.png'" mode=""></image>
						<text>{{i.label}}</text>
					</view>
				</view>
				<view class="cu-goods-view">
					<view class="cu-goods">
						<image src="../../static/images/pinm.png" mode=""></image>
						<text>{{$t('品名')}}</text>
					</view>
					<view class="cu-select">
						<picker :value="goodsIndex" :range="goodsData" @change="goodsChange" v-if="goodsData.length > 0">
							<view class="uni-input">{{goodsData[goodsIndex]}}</view>
						</picker>
					</view>
				</view>
				<view class="cu-goods-view">
					<view class="cu-goods">
						<image src="../../static/images/number.png" mode=""></image>
						<text>{{$t('件数')}}</text>
					</view>
					<view class="cu-select">
						<input type="number" v-model="productNum" :placeholder="$t('请输入件数')">
					</view>
				</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods-info">
						<image src="../../static/images/yichang.png" mode=""></image>
						<text>{{$t('异常详情')}}</text>
					</view>
					<view class="cu-goods-textarea">
						<textarea name="" v-model="exceptionDetail"></textarea>
					</view>
				</view>
				<view class="cu-btns">
					<view class="">
						<text @click="unloadCabinetOrderCreate">{{$t('提交')}}</text>
					</view>
					<view class="">
						<text @click="orderModelToggle()">{{$t('关闭')}}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 货柜异常柜型弹窗 -->
		<view class="cu-modal" :class="shipmentModel ? 'show' : ''" style="z-index: 999;">
			<view class="cu-main" style="top: 10%">
				<view class="cu-title">{{$t('转异')}}</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods">
						<image src="../../static/images/err-1.png" mode=""></image>
						<text>{{$t('操作步骤')}}</text>
					</view>
					<view class="cu-select">
						<picker :value="shippingProcessIndex" :range="shippingProcessData" @change="shippingProcessChange" v-if="shippingProcessData.length > 0">
							<view class="uni-input">
								<text>{{shippingProcessData[shippingProcessIndex]}}</text>
								<image src="../../static/images/rgt.png" mode=""></image>
							</view>
						</picker>
					</view>
				</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods">
						<image src="../../static/images/pinm.png" mode=""></image>
						<text>{{$t('票异常')}}</text>
					</view>
					<view class="cu-select">
						<picker :value="ticketIndex" :range="ticketData" @change="ticketChange" v-if="ticketData.length > 0">
							<view class="uni-input">
								<text>{{ticketData[ticketIndex]}}</text>
								<image src="../../static/images/rgt.png" mode=""></image>
							</view>
						</picker>
					</view>
				</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods">
						<image src="../../static/images/err-2.png" mode=""></image>
						<text>{{$t('异常开始时间')}}</text>
					</view>
					<view class="cu-date">
						<leeDatetime @change="bindLeeDateTimeChange" :field="'abnStartTime'" :placeholder="$t('请选择日期时间')" :value="date.abnStartTime"></leeDatetime>
					</view>
				</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods">
						<image src="../../static/images/err-2.png" mode=""></image>
						<text>{{$t('异常结束时间')}}</text>
					</view>
					<view class="cu-date">
						<leeDatetime @change="bindLeeDateTimeChange" :field="'abnEndTime'" :placeholder="$t('请选择日期时间')" :value="date.abnEndTime"></leeDatetime>
					</view>
				</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods">
						<image src="../../static/images/err-3.png" mode=""></image>
						<text>{{$t('是否更新动态')}}</text>
					</view>
					<view class="cu-select">
						<radio-group @change="orderStatusChange" >
							<label class="radio" v-for="(i, v) in orderStatusData" style="margin-left: 20upx;display: flex;align-items: center;float: left;">
								<radio :value="i.value" :checked="i.value === orderStatus" color="#FDB23D" style="transform:scale(0.6);margin-bottom: 0upx" />
								<text>{{i.label}}</text>
							</label>
						</radio-group>
					</view>
				</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods-info">
						<image src="../../static/images/yichang.png" mode=""></image>
						<text>{{$t('异常情况')}}</text>
					</view>
					<view class="cu-goods-textarea">
						<textarea name="" v-model="abnDetail"></textarea>
					</view>
				</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods-info">
						<image src="../../static/images/yichang.png" mode=""></image>
						<text>{{$t('中文内容')}}</text>
					</view>
					<view class="cu-goods-textarea">
						<textarea name="" v-model="contentZh"></textarea>
					</view>
				</view>
				<view class="cu-goods-view no-border-bottom">
					<view class="cu-goods-info">
						<image src="../../static/images/yichang.png" mode=""></image>
						<text>{{$t('英文内容')}}</text>
					</view>
					<view class="cu-goods-textarea">
						<textarea name="" v-model="contentEn"></textarea>
					</view>
				</view>
				<view class="cu-btns">
					<view class="">
						<text @click="boxAbnormalCreate">{{$t('提交')}}</text>
					</view>
					<view class="">
						<text @click="shipmentModelToggle">{{$t('关闭')}}</text>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>
<script>
	import leeDatetime from "@/components/lee-datetime/lee-datetime.vue"
	import * as types from '../../store/mutations-types.js';
	import { uniLoadMore } from '@dcloudio/uni-ui';
	import { cabinetUnloadDetail } from './api';
	import { unloadCabinetOrder } from './api';
	import { boxAbnormal } from './api';
	import { allUnload } from './api';
	import { unloadApply } from './api';
	import { appSecret, apiBaseUrl } from '../../util/config.js'
	import { updateImg } from '@/api/system';
	import iconpath from '../../static/images/close.png'

	export default {
		name: 'detail',
		components: { uniLoadMore, leeDatetime },
		data() {
			return {
				boxInfo: null,
				loadDetail: [],
				iconpath:iconpath,
				cabinetUnloadInfo: null,
				shipmentId: 0,
				page: 1,
				loadDetailIndex: '', // 哪笔订单异常
				sectionOrderListIndex: '', // 哪笔订单异常
				shippingUnloadingError: [], //订单异常
				shippingUnloadingValue: '', //订单异常值
				orderModel: false, //订单异常弹框
				orderId: 0, //异常订单ID
				goodsData: [], //品名
				goodsIndex: 0,
				goodsIds: [],
				productNum: '', //件数
				exceptionDetail: '', //异常详情

				// shippingTicketException: [], //票异常
				ticketData: [],  //票异常标签
				ticketIndex: 0, //票异常索引
				ticketValue: [], //票异常值
				// shippingProcess: [], //步骤
				shippingProcessData: [], //步骤
				shippingProcessIndex: 0, //步骤索引
				shippingProcessValue: [], //步骤值
				shipmentModel: false,
				date: {
					abnStartTime: '', //异常开始时间
					abnEndTime: '', //异常结束时间
					ulBoxTime: '', //入仓时间
				},
				orderStatusData: [{label: this.$t('是'), value: '1'}, {label: this.$t('否'), value: '2'}],

				contentZh: '', //中文内容,
				contentEn: '', //英文内容,
				abnDetail: '', //票异常详情
				orderStatus: '', //是否更新订单状态
				ulBoxTime: '', //整体提交时间
				imageList: [], //整体提交图片,
			}
		},
		onLoad (op) {
			uni.setNavigationBarTitle({
				title:this.$t('出货单详情')
			})
			this.shipmentId = op.shipmentId || 0
			this.shippingUnloadingError =  this.$store.getters.dict_datas.shipping_unloading_error
		},
		onShow () {
			this.getDetail()
		},
		onPullDownRefresh() {
		},
		onReachBottom() {
		},
		methods: {
			//一键卸柜
			allOrderUnload () {
				let t = this
				let params = {shipmentId: this.shipmentId}
				uni.showModal({
					title: this.$t('提示'),
					content: this.$t('确定一键卸柜操作'),
					success: function (res) {
						if (res.confirm) {
							allUnload(params).then(res => {
								if(res > 0){
									uni.showModal({
										title: this.$t('提示'),
										content: res.msg || this.$t('操作成功'),
										showCancel: false,
										success: function (res) {
											if (res.confirm) {
												t.getDetail()
											}
										}
									})
								} else {
									uni.showToast({
										title: res.msg || this.$t('操作失败'),
										icon: 'none'
									})
								}
							})
						}
					}
				})
			},
			delimage(index){
				this.imageList.splice(index,1)
			},
			//订单卸柜
			unloadApply (ob) {
				uni.navigateTo({
					url: '/pages/unloadCabinet/apply?orderId=' + ob.orderId + '&shipmentId=' + this.shipmentId
				})
			},
			getDetail () {
				cabinetUnloadDetail(this.shipmentId).then(res => {
					console.log('111', res)
					this.boxInfo = res.boxInfo
					this.loadDetail = res.loadDetail
					this.cabinetUnloadInfo = res.cabinetUnloadInfo || null
					if(res.cabinetUnloadInfo) {
						this.imageList = res.cabinetUnloadInfo.ulImgs ? res.cabinetUnloadInfo.ulImgs.split(',').map((srcStr)=>{
							return {
								type:"image",
								url:srcStr
							}
						}) : [];
					}
				})
			},
			//订单异常显示
			orderModelToggle (id, idx1 = -1, idx2 = -1) {
				this.orderModel = !this.orderModel
				this.orderId = id || 0
				this.shippingUnloadingValue = ''
				this.loadDetailIndex = idx1 || ''
				this.sectionOrderListIndex = idx2 || ''
				if(idx1 >= 0 && idx2 >= 0){
					if(this.loadDetail[idx1].sectionOrderList[idx2]){
						for(let i = 0; i < this.loadDetail[idx1].sectionOrderList[idx2].goodsList.length; i++){
							this.goodsData.push(this.loadDetail[idx1].sectionOrderList[idx2].goodsList[i].prodTitleZh)
							this.goodsIds.push(this.loadDetail[idx1].sectionOrderList[idx2].goodsList[i].orderItemId)
						}
					}
				} else {
					this.goodsData = []
					this.goodsIds = []
					this.productNum = ''
					this.exceptionDetail = ''
				}
			},
			shippingUnloadingChoose (e) {
				this.shippingUnloadingValue = e
			},
			goodsChange (e) {
				this.goodsIndex = e.detail.value
				console.log('goodsid', this.goodsIds[this.goodsIndex])
			},
			//提交异常
			unloadCabinetOrderCreate () {
				if(this.shippingUnloadingValue == ''){
					return uni.showToast({
						title: this.$t('请选择异常类型'),
						icon: 'error',
					})
				}
				if(this.productNum == ''){
					return uni.showToast({
						title: this.$t('请输入件数'),
						icon: 'error',
					})
				}
				// if(this.exceptionDetail == ''){
				// 	return uni.showToast({
				// 		title: '请输入异常详情',
				// 		icon: 'error',
				// 	})
				// }
				let params = {
					exceptionDetail: this.exceptionDetail,
					exceptionType: this.shippingUnloadingValue,
					orderId: this.orderId,
					productId: this.goodsIds[this.goodsIndex],
					productNum: this.productNum,
					shipmentId: this.shipmentId
				}
				let t = this
				unloadCabinetOrder(params).then(res => {
					if(res > 0){
						uni.showModal({
							title: this.$t('提示'),
							content: res.msg || this.$t('提交异常成功'),
							showCancel: false,
							success: function (res) {
								if (res.confirm) {
									t.orderModelToggle()
									t.getDetail()
								}
							}
						})
					} else {
						uni.showToast({
							title: res.msg || this.$t('提交失败'),
							icon: 'none'
						})
					}
				})
			},

			//货柜异常
			shipmentModelToggle() {
				const shippingTicketException =  this.$store.getters.dict_datas.shipping_ticket_exception
				const shippingProcess =  this.$store.getters.dict_datas.air_shipment_process
				this.shipmentModel = !this.shipmentModel;
				if(this.ticketData.length == 0){
					for(let i = 0; i < shippingTicketException.length; i++){
						this.ticketData.push(this.$lang.locale=='zh-Hans'? shippingTicketException[i].label:shippingTicketException[i].labelEn)
						this.ticketValue.push(shippingTicketException[i].value)
					}
				}
				if(this.shippingProcessData.length == 0){
					for(let i = 0; i < shippingProcess.length; i++){
						this.shippingProcessData.push(this.$lang.locale=='zh-Hans'?shippingProcess[i].label:shippingProcess[i].labelEn)
						this.shippingProcessValue.push(shippingProcess[i].value)
					}
				}

				if(!this.shipmentModel){
					this.shippingProcessIndex = 0;
					this.ticketIndex = 0;
					this.orderStatus = '';
					this.abnDetail = ''
					this.contentEn = ''
					this.contentZh = ''
				}
			},
			ticketChange (e) {
				this.ticketIndex = e.detail.value
			},
			shippingProcessChange (e) {
				this.shippingProcessIndex = e.detail.value
			},
			bindLeeDateTimeChange (e) {
				console.log(e)
				this.date[e.field] = e.value
			},
			orderStatusChange (e) {
				this.orderStatus = e.detail.value
			},
			boxAbnormalCreate () {
				if(this.date.abnStartTime == ''){
					return uni.showToast({
						title: this.$t('请选择开始时间'),
						icon: 'error',
					})
				}
				if(this.date.abnEndTime == ''){
					return uni.showToast({
						title: this.$t('请选择结束时间'),
						icon: 'error',
					})
				}
				if(this.orderStatus == ''){
					return uni.showToast({
						title: this.$t('请选择是否更新动态'),
						icon: 'error',
					})
				}
				if(this.abnDetail == ''){
					return uni.showToast({
						title: this.$t('请输入异常详情'),
						icon: 'error',
					})
				}
				if(this.contentZh == ''){
					return uni.showToast({
						title: this.$t('请输入中文内容'),
						icon: 'error',
					})
				}
				if(this.contentEn == ''){
					return uni.showToast({
						title: this.$t('请输入英文内容'),
						icon: 'error',
					})
				}
				let params = {
					abnDetail: this.abnDetail,
					abnStartTime: this.date.abnStartTime,
					abnEndTime: this.date.abnEndTime,
					billAbnId: this.ticketValue[this.ticketIndex],
					opStep: this.shippingProcessValue[this.shippingProcessIndex],
					contentEn: this.contentEn,
					contentZh: this.contentZh,
					orderStatus: this.orderStatus,
					shipmentId: this.shipmentId
				}
				let t = this
				boxAbnormal(params).then(res => {
					console.log(res)
					if(res > 0){
						uni.showModal({
							title: this.$t('提示'),
							content: res.msg || this.$t('提交异常成功'),
							showCancel: false,
							success: function (res) {
								if (res.confirm) {
									t.shipmentModelToggle()
									t.getDetail()
								}
							}
						})
					} else {
						uni.showToast({
							title: res.msg || this.$t('提交失败'),
							icon: 'none'
						})
					}
				})
			},
			chooseVideoImage() {
				uni.showActionSheet({
					title: this.$t('选择上传类型'),
					itemList: [this.$t('图片')/* , this.$t('视频') */],
					success: res => {
						console.log(res);
						if (res.tapIndex == 0) {
							this.chooseImages(true);
						} else {
							this.chooseVideo();
						}
					}
				});
			},
			//上传图片
			chooseImages(flag) {
				uni.chooseImage({
					count: 9, //默认是9张
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], //从相册选择
					success: res => {
						console.log(res, 'ddddsss')
						let imgFile = res.tempFilePaths;
						imgFile.forEach((item, index) => {
							updateImg(item).then(data => {
								console.log(data, '--------res--------');
								if (flag) {
									// const type = res.tempFiles[index].type.split('/')[0]
									this.imageList.push({ type:'image', url: data.data })
								}
							})
						})
					}
				})
			},
			//上传视频
			chooseVideo(index) {
				uni.chooseVideo({
					maxDuration: 60, //拍摄视频最长拍摄时间，单位秒。最长支持 60 秒
					count: 9,
					success: res => {
						let videoFile = res.tempFilePath;
						console.log(res, 'ddddsss')
						updateImg(videoFile).then(data => {
							// const type = res.tempFile.type.split('/')[0]
							this.imageList.push({ type:'video', url: data.data })
						})
					},
					fail:(error)=>{
						uni.hideLoading();
						uni.showToast({
							title: error,
							icon: 'none'
						})
					}
				})
			},
			previewImage(url) {
			  //uniapp预览轮播图
			  uni.previewImage({
			    current: 0, //预览图片的下标
			    urls: [url] //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
			  })
			},
			playVideo(index) {
			  setTimeout(() => {
			    this.videoContext = uni.createVideoContext(`video_${index}`)
			    this.videoContext.play()
			    this.videoContext.requestFullScreen()
			  }, 500)
			},
			fullscreenchange(event) {
			  if (!event.detail.fullScreen) {
			    this.videoContext.pause()
			  }
			},
			//提交整体卸柜
			allUnloadReply () {
				if(this.date.ulBoxTime == ''){
					return uni.showToast({
						title: this.$t('请选择到仓时间'),
						icon: 'error',
					})
				}
				// if(this.imageList.length == 0){
				// 	return uni.showToast({
				// 		title: '请上传卸柜影像',
				// 		icon: 'error',
				// 	})
				// }
				let ulImgs = []
				this.imageList.forEach((item, index) => {
					ulImgs.push(item.url)
				})
				let params = {
					ulBoxTime: this.date.ulBoxTime,
					ulImgs: ulImgs.join(','),
					shipmentId: this.shipmentId
				}
				//有提交则带入ID
				if(this.cabinetUnloadInfo) {
					params.id = this.cabinetUnloadInfo.id
				}
				let t = this
				unloadApply(params).then(res => {
					if(res > 0){
						uni.showModal({
							title: this.$t('提示'),
							content: res.msg || this.$t('操作成功'),
							showCancel: false,
							success: function (res) {
								if (res.confirm) {
									// t.getDetail()
									setTimeout(() => {
										uni.redirectTo({
											url: "./list",
										});
									}, 500);
								}
							}
						})
					} else {
						uni.showToast({
							title: res.msg || this.$t('操作失败'),
							icon: 'none'
						})
					}
				})
			}
		},
    computed: {
      isChinese(){
        return uni.getLocale() === 'zh-Hans'
      }
    }
	}
</script>
<style>
	@import url(../unloadCabinet/detail.css);
</style>
