
<template>
  <view class="container">
    <!-- 进度 -->
	<view class="stepcon">
		<u-steps :list="step" :current="current" mode="number" active-color="#3690ff"></u-steps>
	</view>

    <!-- 配送单扫描区域 -->
    <view class="section"> 
	  
	  <!-- #ifdef APP-PLUS -->
	  <view class="scan-area" @click="scanDeliveryOrder">
	    <view class="scan-icon">
	      <uni-icons type="scan" size="20" color="#007AFF"></uni-icons>
	    </view>
	    <text class="scan-title">扫描配送单二维码</text>
	    <text class="scan-desc">请将摄像头对准配送单二维码</text>
	  </view>
	  <!-- #endif -->
	  
	  <!-- #ifdef H5 -->
	  <!-- 配送单扫描 -->
	  <view class="input-group">
	    <text class="label">配送单号</text>
	    <view class="input-container">
	      <input
	        v-model="itemList.deliveryNo"
	        class="input-field"
	        placeholder="请输入配送单号"
	        maxlength="30" 
	      />
	      <view class="scan-btn" @click="scanDeliveryOrder">
	        <uni-icons type="scan" size="20" color="#007AFF"></uni-icons>
	      </view>
	  	<view class="add-pallet-btn" @click="getPsDetail">
	  	  <text class="btn-text">查询</text>
	  	</view>
	    </view>
	  </view>
	  <!-- #endif -->

      <!-- 配送单详情区域 -->
      <view class="order-details"> 
		<!-- 配送单号deliveryNo、工程编号project、制作图号dwgno、托盘表号instno、数量qty（合计）、需求单位requireDepartCode、配送地址requireAddress、
		联系人（联系人requireName+‘ ‘+联系电话requirePhone）、配送日期deliveryDate、配送车辆deliveryCar -->
		 
		<view class="detail-header">
		  <view class="detail-title">
			  配送单详情
		  </view>
		  <view class="detail-tip" @tap="toggleGroup">
			  <uni-icons :type="expanded ? 'arrowup' : 'arrowdown'" size="16" color="#999"></uni-icons>
		  </view>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">配送单号：</text>
		  <text class="item-value">{{ itemList.deliveryNo }}</text>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">工程编号：</text>
		  <text class="item-value">{{ itemList.project }}</text>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">制作图号：</text>
		  <view class="item-value">{{ itemList.dwgno }}<text v-if="itemList.dwgno" class="xqtxt" @click="gotoXQ('1',itemList.dwgno,itemList.instno,itemList.project)">详情</text></view>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">托盘表号：</text>
		  <view class="item-value">{{ itemList.instno }}<text v-if="itemList.instno" class="xqtxt" @click="gotoXQ('2',itemList.dwgno,itemList.instno,itemList.project)">详情</text></view>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">数量：</text>
		  <text class="item-value">{{ itemList.qty }}</text>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">需求单位：</text>
		  <text class="item-value">{{ itemList.requireDepartCode?retType(itemList.requireDepartCode,2):'' }}</text>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">配送地址：</text>
		  <text class="item-value">{{ itemList.requireAddress }}</text>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">联系人：</text>
		  <text class="item-value">{{ itemList.requireName }}</text>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">配送日期：</text>
		  <text class="item-value">{{ itemList.deliveryDate }}</text>
		</view>
		<view class="detail-item" v-if="expanded">
		  <text class="item-label">配送车辆：</text>
		  <text class="item-value">{{ itemList.deliveryCar }}</text>
		</view>
		
		<!-- 存放地址 -->
		<view class="detail-header">
		  <view class="detail-title" style="width: 150rpx;"><text style="color: #fa3534;">*</text>存放地址</view>
		  <view class="detail-tip">
			  <view class="selarr" @click="showaddress()">
			  	<text class="txt" v-if="itemList.departCode">
				{{ retType(itemList.departCode,2)}} {{itemList.workshop}} {{itemList.location}} {{itemList.address}} </text>
			  	<text class="txt" v-else style="color:#999">请选择</text>
			  	<uni-icons type="right" size="20" color="#999"></uni-icons>
			  </view>
		  </view>
		</view>
		
		<view class="detail-header">
		  <text class="detail-title" style="width: 120rpx;">备注</text>
		  <view class="detail-tip">
			  <u-input :border="true" style="width: 100%;" :height="60" placeholder="请输入" input-align="left" v-model="itemList.remark" type="textarea" maxlength="500"></u-input>
		  </view>
		</view>
		
        <!-- 散装管件清单 -->
<!--		<view class="detail-header" v-if="itemList.deliveryNo" >
		  <text class="detail-title">散装管件清单</text>
		  <view  class="detail-tip" @click="gotolsDetail">
			  <text class="tip">点击查看</text>
			  <uni-icons type="right" size="16" color="#999"></uni-icons>
		  </view>
		</view>-->
		
		<!-- 配送单照片 -->
		<view class="list-section">
		  <view class="list-title"><text style="color: #fa3534;">*</text>配送单照片</view>
		  <view class="devpicon">
			  <u-upload ref="uUploadps" :auto-upload="false" upload-text='' :max-size="10 * 1024 * 1024" max-count="3" :width="100" :height="100"
			  @on-remove="onRemovePS" @on-choose-complete="onChooseCompletePS" :file-list="itemList.deliveryPhoto0"
			  	:deletable="true" :source-type="sourceType" style="background-color: #ecf5ff;">
			  </u-upload>
		  </view>
		</view>
		
      </view>
    </view>

    <!-- 托盘管理区域 -->
    <view class="section">
		
		<view class="section-header">
		  <text class="section-title">工装托盘</text>
		  <text class="section-count">({{ getcount() }})</text>
		</view>
		
		<!-- 托盘列表 -->
		<uni-collapse  v-if="palletData.length > 0" class="pallet-list" :border="true">
		<u-checkbox-group class="checkBox" v-for="(pallet, index) in palletData" :key="index"  :wrap="true">
			<uni-collapse-item titleBorder="none":open="pallet.isOpen" class="pallet-card">
				<template v-slot:title>
					<view class="pallet-info">
					  <text class="pallet-number" @click="openPalletDetail(pallet)">
						{{index+1}}. [ {{ pallet.palletNo?pallet.palletNo:'无工装托盘'}} ] ( {{ pallet.qty}} )
					  </text>
					  <view class="sright">
					  	<u-checkbox shape="square" :iconSize="30" :size="40" v-model="pallet.checked" @change="checkboxChange($event,index)">
							勾选
						</u-checkbox>
					  </view>
					</view>
				</template>
				<view class="pallet-item" v-for="(pl, idx) in pallet.children" :key="idx" >
					<view class="pallet-info">
					  <text class="pallet-number">
					  {{ pl.assemcode}}
					   <text style="color: #888; margin-left: 20rpx;">({{ pl.qty?parseInt(pl.qty):'0.00' }})</text></text>
					  <view class="sright">
					  	<u-checkbox shape="square" :iconSize="30" :size="40" 
						v-model="pl.checked" @change="childcheckboxChange($event,index,idx)"></u-checkbox>
					  </view>
					</view>
				</view>
				<u-upload ref="uUpload" v-if="pallet.palletNo"  :auto-upload="false" upload-text='' :max-size="10 * 1024 * 1024" :max-count="3" :width="100" :height="100"
				:deletable="true" :source-type="sourceType" class="pallet-item"
				@on-remove="onRemove($event,index)" @on-choose-complete="onChooseComplete($event,index)" :file-list="pallet.files">
				</u-upload>
			</uni-collapse-item>
		</u-checkbox-group>
		</uni-collapse>
		
		<view class="tpcon">
			<view class="input-group">
			  <text class="label">编号</text>
			  <view class="input-container">
			    <input
			      v-model="palletNo"
			      class="input-field"
			      placeholder="请输入"
			      maxlength="50"
            @input="toUpperCase"
			    />
				<view class="scan-btn" @click="scanPallet">
				  <uni-icons type="scan" size="20" color="#007AFF"></uni-icons>
				</view>
			  </view> 
			</view>
			<view class="add-pallet-btn" @click="addPallet">
			  <uni-icons type="plusempty" size="15" color="#fff"></uni-icons>
			  <text class="btn-text">添加</text>
			</view>
		</view>
       
        <view style="height: 100rpx;"></view>
	  
    </view>
	
	<u-toast ref="uToast" />
	
    <!-- 底部操作栏 -->
    <view class="bottom-actions">
      <button class="action-btn complete-btn" @click="finishLoading">接收</button>
    </view>
	
	<!-- 查看托盘详情 -->
	<u-popup v-model="show" mode="center" borderRadius="20" closeable @close="close">
		<scroll-view class="new-data-box" scroll-y>
			<uni-list v-if="palletinfo">
				<uni-list-item :ellipsis="1" v-for="(value, key) in palletinfo" :key="key" :title="palletitem[key]" :rightText="value"></uni-list-item>
			</uni-list>
		</scroll-view>
	</u-popup>
	
	<!-- 提示窗示例 -->
	<uni-popup ref="alertDialog" type="dialog">
		<uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" title="消息" :content="messageText"></uni-popup-dialog>
	</uni-popup>
	
	<!-- 配送单详情/散装管件清单详情 -->
	<u-popup v-model="showps"  @close="closeps" mode="center" :mask="true" :closeable="true" :border-radius="20" close-icon-pos="top-right">
		<view class="ppcon">
			<deliveryDetail :ifother="ifother" :palletAll="pallet"></deliveryDetail>
		</view>
	</u-popup>
	
	<!-- 散装管件清单详情 -->
	<u-popup v-model="showtp"  @close="closetp" mode="center" :mask="true" :closeable="true" :border-radius="20" close-icon-pos="top-right">
		<view class="ppcon">
			<tpDetail :pallet="palletinfo"></tpDetail>
		</view>
	</u-popup>
	
	<!-- 托盘详情 -->
	<u-popup v-model="showpl"  @close="closepl" mode="center" :mask="true" :closeable="true" :border-radius="20" close-icon-pos="top-right">
		<view class="ppcon">
			<psDetail :palletAll="palletAll"></psDetail>
		</view>
	</u-popup>
	
	<!-- 选择存放 -->
	<selXP ref="clsel" :clist="address" :cur="1" :value="itemList.id" @change="selXPDO" @cancel="cancelClDO"></selXP>
	
	<!-- <scanQR ref="scan" @scanSuccess="scanSuccess"></scanQR> -->
	<!-- 扫码组件 html5-qrcode -->
	<scan-code ref="scan"></scan-code>
	
  </view>
</template>


<script>
import utils from "@/common/utils.js";
import UploadzcFile from "@/components/UploadzcFile.vue";
import deliveryDetail from "@/components/deliveryDetail.vue";
import tpDetail from "@/components/tpDetail.vue";
import selXP from "@/components/selXP.vue";

// 托盘详情
import psDetail from "@/components/psDetail.vue";

// 扫二维码 jsQR
	// import scanQR from "@/components/scanQR.vue"; 
	
	// 扫二维码 html5-qrcode
	import scanCode from '@/components/easy-scancode/easy-scancode.vue'

// 图片处理
import EXIF from 'exif-js';
import Compressor from 'compressorjs';

export default {
	components: {
	  UploadzcFile,
	  deliveryDetail,
	  tpDetail,
	  psDetail,
	  selXP,
	  // scanQR,
	  scanCode
	},
	data() {
		return {
			current:2,
			step:[
				{
					name:"装盘",
					key:"zp",
				},
				{
					name:"配送",
					key:"ps",
				},
				{
					name:"接收",
					key:"js",
				},
				{
					name:"卸盘",
					key:"xp",
				}
			],
			sourceType:['album', 'camera'], // 选择图片的来源，album-从相册选图，camera-使用相机，默认二者都有（默认['album', 'camera']）
			expanded: false,
			palletNo:'',// 托盘编号
			palletAll:'', // 配送单信息
			pallet:{}, // 托盘信息
			otherinfo:[], // 散装管件列表
			instList:[], // 散装管件列表选择
			insisOpen:false, 
			inschecked:true,
			palletData:[], // 接收托盘列表信息
			show: false,
			showps: false,
			showtp: false,
			showpl: false,
			ifother: false, // 是否查看零散
			messageText: "",
			msgType: "info",//success error warn info
			// 托盘列表
			palletList:[
				{
					palletNo:"TP001",
					status:"ps", // 字典bmlb=’TPZT;闲置/装盘/配送/周转/接收/卸盘
					imgs:[],
					imgurls:'',
					isOpen:true,
					checked:true,
				},
			], 
			palletinfo:{},
			palletitem:{
				project:"工程编号",
				instno:"安装托盘表号",
				dwgno:"制作图号",
				section:"分段号",
				assemcode:"部件代号",
				spec:"规格",
				grd:"材质",
				qty:"数量",
				weight:"重量",
				treatment:"表面处理",
				paintcode:"涂装代码",
				status:"生产状态", // status
				statusDate:"状态日期",
				manuDept:"制作单位",
				treatDept:"处理单位",
				deliverDept:"配送单位",
				palletNo:"工装托盘编号",
				deliveryNo:"配送单号",
				deliveryCar:"配送车辆",
				deliveryDate:"配送日期",
				deliveryRemark:"配送备注",
				requireRate:"需求日期",
				requireDepartCode:"需求单位代码",
				requireAddress:"配送地址",
				requireName:"接收人员",
				requirePhone:"接收人员电话",
				receiveDate:"实际接收日期",
				receiveName:"实际接收人员",
				receiveRemark:"实际接收备注"
			},
			// 闲置/装盘/配送/周转/接收/卸盘
			status:[
				{
					key:"xz",
					value:"闲置",
				},
				{
					key:"zp",
					value:"装盘",
				},
				{
					key:"ps",
					value:"配送",
				},
				{
					key:"zz",
					value:"周转",
				},
				{
					key:"js",
					value:"接收",
				},
				{
					key:"xp",
					value:"卸盘",
				}
			],
			itemList:{
				deliveryNo: '',// 配送单号
				remark: '',
				data: [],
				deliveryCar:'',// 车牌号
				files: [],
				deliveryPhoto:[], // 配送单图片
        deliveryPhoto0:[],
				departCode:"",
				workshop:"",
				location:"",
				address:"",
				id:"",
				qty:0,
			},
			selids:[], // 选中托盘
			deliveryimgs:[], // 配送单照片
			deliveryurls:'', // 配送单照片地址
			// 扫码
			scantype:1, // 1配送单 2 托盘 
			address:[],
			
		};
	},
	onLoad(options) {
		// 获取操作数据
		this.getTypes();
	}, 
	onReady() {
		// h5 扫码
		// #ifdef H5
		// 页面准备好后先尝试初始化，如果被浏览器拦截，用户点击按钮可再次触发
		// this.initScanner();
		// #endif
	},
	methods: {
    toUpperCase(e){
      this.palletNo = e.toUpperCase()
      this.$forceUpdate();
    },
		// 选择接收地址
		showaddress(e) {
			this.$refs.clsel._show();
		},
		selXPDO(e){
			// 选择接收地址
			console.log(e);
			if(e){
				this.itemList.id=e.id?e.id:'';
				this.itemList.departCode=e.departCode?e.departCode:'';
				this.itemList.workshop=e.workshop?e.workshop:'';
				this.itemList.location=e.location?e.location:'';
				this.itemList.address=e.address?e.address:'';
			}
			else{
				this.itemList.id='';
				this.itemList.departCode='';
				this.itemList.workshop='';
				this.itemList.location='';
				this.itemList.address='';
			}
			this.$forceUpdate();
		},
		cancelClDO(e){
			// 取消选择接收
			console.log(e);
			this.$forceUpdate();
		},
		closepl() {
			this.showpl = false;
		},
		openpl() {
			this.showpl = true;
		},
		// 显示托盘详情
		async openPalletDetail(pallet) {
			if(pallet.palletNo){
				uni.showLoading({
					title: '数据加载中...'
				});
				const {data: res} = await uni.$http.get('/getPalletAll',{
					code: pallet.palletNo,
					type: '20'
				});
				if(res.success){ 
					if(res.data)
					{
						this.palletAll=res.data;
						this.$forceUpdate();
						// 打开托盘详情弹框
						this.openpl();
					}
				}
				else{
					this.$refs.uToast.show({
					  title: "暂无托盘详情信息！",
					  type: "warning",
					  duration: 3000,
					});
				}
			}
		},
		
		gotoXQ(type,dwgno,instno,project){
			uni.navigateTo({
				url:  `/pages/pallet/tpcxtk?type=${type}&dwgno=${dwgno}&instno=${instno}&project=${project}`
			});
		},
		toggleGroup() {
			this.expanded = !this.expanded;
			this.$forceUpdate();
		},
		onChooseComplete(files,ii){
			console.log("onChooseComplete")
			console.log(files)
			files.forEach((item,index)=>{
				//区分APP与H5不同端调用不同的方法
				// #ifdef APP-PLUS
					/**
					 * APP端图片压缩
					 *  参数说明：
					 *  img 图片url
					 *  scale缩放比例 1-100
					 *  callback 回调设置返回值 
					*/
				    var that = this;
				    this.translateapp(item.url, 60, imgUrl => {
					    // 打印压缩后返回的图片url
						console.log("imgUrl",imgUrl); 
						that.ploadFilePromiseSync(imgUrl,index,ii);
					});
				// #endif
								
				// #ifdef H5
					if(item.file){
						this.uploadAndCompressImage(item.file,index,ii);
					}
				// #endif 
			});
		},
		translateapp(img, scale, callback) {
			plus.io.resolveLocalFileSystemURL(img, (entry) => { //通过URL参数获取目录对象或文件对象
				entry.file((file) => { // 可通过entry对象操作图片 
					console.log('压缩前图片信息:' + JSON.stringify(file)); //压缩前图片信息
					if (file.size > 512000) { //   如果大于500Kb进行压缩
						plus.zip.compressImage({ // 5+ plus.zip.compressImage 了解一下，有详细的示例
							src: img, //src: 压缩原始图片的路径    
							dst: img.replace('.png', 'yasuo.png').replace('.PNG',
									'yasuo.PNG').replace('.jpg', 'yasuo.jpg')
								.replace('.JPG', 'yasuo.JPG'),
							width: '40%', //dst: (String 类型 )压缩转换目标图片的路径，这里先在后面原始名后面加一个yasuo区分一下
							height: '40%', //width,height: (String 类型 )缩放图片的宽度,高度
							quality: scale, //quality: (Number 类型 )压缩图片的质量
							overwrite: true, //overwrite: (Boolean 类型 )覆盖生成新文件
							// format:'jpg'   //format: (String 类型 )压缩转换后的图片格式
						}, (event) => {
							console.log('压缩后图片信息:' + JSON.stringify(event)); 
							//返回压缩后的图片路径
							callback(event.target);
						}, function(err) {
							 console.log('Resolve file URL failed: ' + err.message);
						});
					} else { //else小于500kb跳过压缩，直接返回现有的src
						callback(img);
						
					}
				});
			}, (e) => { // 返回错误信息
				 console.log('Resolve file URL failed: ' + e.message);
			});
		},
		ploadFilePromiseSync(url,index,ii){
			var that = this;
			return new Promise((resolve, reject) => {
				// #ifdef APP-PLUS
				plus.io.resolveLocalFileSystemURL(url, (entry) => {
				entry.file((file) => {
				let fileReader = new plus.io.FileReader();
				
				fileReader.onloadend = (evt) => {
				const base64 = evt.target.result.substr(22)
				console.log("base64",base64)
				resolve(base64)
				that.palletData[ii].files[index]="data:image/png;base64"+base64;
				that.$forceUpdate();
				};
				
				fileReader.readAsDataURL(file)
				
				});
				
				}, (e) => {
				reject("Resolve file URL failed: " + e.message)
				
				});
				
				// #endif
			});
		},
		uploadAndCompressImage(file,index,ii) {
			var that = this;
			return new Promise((resolve, reject) => {
		      new Compressor(file, {
		        quality: 0.3, // 压缩质量，范围是0-1
		        convertSize: 1048576, // 如果大于1M(1024*1024)进行压缩 转换后的图片大小，单位是字节。如果图片大小小于这个值，则不进行压缩。
		        success: (compressedFile) => {
		          // 读取压缩后的图片文件为base64
		          const reader = new FileReader();
		          reader.onload = (e) => {
		            const base64 = e.target.result;
		            resolve(base64);
					that.palletData[ii].files[index]={
						url:base64
					};
					that.$forceUpdate();
		          };
		          reader.onerror = (error) => {
		            reject(error); 
		          };
		          reader.readAsDataURL(compressedFile);
		        },
		        error(err) {
		          reject(err);
		        },
		      });
		    }); 
		},
		onRemove(index,ii) {
			delete this.palletData[ii].files[index];
			this.$forceUpdate();
		},
		onRemovePS(index) {
			delete this.itemList.deliveryPhoto[index];
			this.$forceUpdate();
		},
		onChooseCompletePS(files){
			console.log(files)
			files.forEach((item,index)=>{
				// this.uploadAndCompressImagePS(item.file,index);
				// #ifdef APP-PLUS
					/**
					 * APP端图片压缩
					 *  参数说明：
					 *  img 图片url
					 *  scale缩放比例 1-100
					 *  callback 回调设置返回值 
					*/
				    var that = this;
				    this.translateapp(item.url, 60, imgUrl => {
					    // 打印压缩后返回的图片url
						console.log("imgUrl",imgUrl); 
						that.ploadFilePromiseSyncPS(imgUrl,index);
					});
				// #endif
								
				// #ifdef H5
					this.uploadAndCompressImagePS(item.file,index);
				// #endif 
			});
		},
		ploadFilePromiseSyncPS(url,index){
			var that = this;
			return new Promise((resolve, reject) => {
				// #ifdef APP-PLUS
				plus.io.resolveLocalFileSystemURL(url, (entry) => {
				entry.file((file) => {
				let fileReader = new plus.io.FileReader();
				
				fileReader.onloadend = (evt) => {
				const base64 = evt.target.result.substr(22)
				console.log("base64",base64)
				resolve(base64)
				that.itemList.deliveryPhoto0[index]['url']="data:image/png;base64"+base64;
				that.$forceUpdate();
				};
				
				fileReader.readAsDataURL(file)
				
				});
				
				}, (e) => {
				reject("Resolve file URL failed: " + e.message)
				
				});
				
				// #endif
			});
		},
		uploadAndCompressImagePS(file,index) {
			var that = this;
			return new Promise((resolve, reject) => {
		      new Compressor(file, {
		        quality: 0.3, // 压缩质量，范围是0-1
				convertSize: 1048576, // 如果大于1M(1024*1024)进行压缩 转换后的图片大小，单位是字节。如果图片大小小于这个值，则不进行压缩。
		        success: (compressedFile) => {
		          // 读取压缩后的图片文件为base64
		          const reader = new FileReader();
		          reader.onload = (e) => {
		            const base64 = e.target.result;
		            resolve(base64);
					that.itemList.deliveryPhoto0[index]={
						url:base64
					};
					that.$forceUpdate();
					console.log(base64);
					console.log(that.itemList.deliveryPhoto)
		          };
		          reader.onerror = (error) => {
		            reject(error); 
		          };
		          reader.readAsDataURL(compressedFile);
		        },
		        error(err) {
		          reject(err);
		        },
		      });
		    }); 
		},
		
		closeps() {
			this.showps = false;
		},
		openps() {
			this.showps = true;
		},
		closetp() {
			this.showtp = false;
		},
		opentp() {
			this.showtp = true;
		},
		prviewImage(imgs,index) {
			if(imgs){
				uni.previewImage({
					urls: imgs,
					current: index
				});
			}
		},
		// 散装管件列表选中
		inscheckboxChange(e) {
			// console.log(e,this.inschecked) 
			this.instList.forEach((cell,index)=>{
				this.instList[index].checked=this.inschecked;
			});
			this.$forceUpdate();
		},
		// 托盘选中
		checkboxChange(e,index) {
			console.log("checkboxChange",e,index)
			this.palletData[index].children.forEach((cell,ii)=>{
				this.palletData[index].children[ii].checked=e.value;
			});
			this.$forceUpdate();
		},
		// 管件选中
		childcheckboxChange(e,index,idx) {
			console.log("childcheckboxChange",e,index,idx);
			// if(e.value){
			// 	this.palletData[index].checked=e.value;
			// 	this.$forceUpdate();
			// }
			this.palletData[index].children[idx].checked=e.value
			var m=0,n=0;
			this.palletData[index].children.forEach((cell,ii)=>{
				console.log(cell.checked)
				if(cell.checked){
					m++;
				}
				if(!cell.checked){
					n++;
				}
			});
			if(m>0){
				this.palletData[index].checked=true;
				this.$forceUpdate();
			}
			if(n==this.palletData[index].children.length){
				this.palletData[index].checked=false;
				this.$forceUpdate();
			}
		},
		openinfo(pallet){
			this.palletinfo=pallet;
			this.$forceUpdate();
			this.opentp();
		},
		dialogToggle(type) {
			this.msgType = type
			this.$refs.alertDialog.open()
		},
		close() {
			this.show = false;
		},
		open() {
			this.show = true;
		},
		gotoDetail(pallet){
			this.ifother=false;
			this.pallet={pallet:pallet};
			this.$forceUpdate();
			this.openps();
		},
		// 散装管件
		gotolsDetail(){
			this.pallet={other:this.otherinfo};
			this.ifother=true;
			this.$forceUpdate();
			this.openps();
		},
		// 配送单照片
		deliverypics(val) {
			console.log("deliverypics");
			console.log(val);
			this.deliveryurls=val.join(",");
			this.$forceUpdate();
		},
		// 托盘照片
		palletpics(val,index) {
			console.log(val,index);
			this.palletList[index].imgurls=val.join(",");
			this.$forceUpdate();
			console.log(this.palletList);
		},
		// 扫描配送单
		scanDeliveryOrder(){
			const _that = this;
			// #ifdef H5
			// 扫码识别配送单
			this.scantype = 1; // 配送单扫码
			this.$refs.scan.start({
			    success: (val, res)=> {
					console.log('扫描成功',val,res);
					if(_that.scantype==2){
					  _that.palletNo=val;
					  _that.$forceUpdate();
					  _that.getPalletDetail();
					}
					else{
					  _that.itemList.deliveryNo=val; // GJ2602000002 20260100024 20260100025
					  _that.$forceUpdate();
					  _that.getPsDetail();
					}
			    },
			    fail: (rej)=>{
			        console.log('扫描失败',rej);
					uni.showToast({
						title: '请在HTTPS环境下点击开启',
						icon: 'none',
						duration: 3000
					});
			    }
			})
			// #endif
			
			// #ifdef APP-PLUS
			// 允许从相机和相册扫码
			//qrCode,barCode
			// uni.scanCode({
			// 	scanType: ['qrCode', 'barCode'],
			// 	success: function(res) {
			// 		_that.itemList.deliveryNo=res.result;
			// 		_that.getPsDetail();
			// 	}
			// });
			var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
			mpaasScanModule.mpaasScan({
			    // 扫码识别类型，参数可多选，qrCode、barCode，不设置，默认识别所有
			    'scanType':  ['qrCode','barCode'],
			    // 是否隐藏相册，默认false不隐藏
			    'hideAlbum': false,
			    //ios需要设置这个参数，只支持中英文 zh-Hans、en，默认中文                       
			    'language' : 'en',
			    //相册选择照片识别错误提示(ios)
			    'failedMsg': '未识别到二维码，请重试',
			    //Android支持全屏需要设置此参数
			    'screenType': 'full' ,
			    'timeoutInterval':'10', //设置超时时间
			    'timeoutText':'未识别到二维码？' //超时提醒文本             
			},(ret) => {
				if(ret.resp_code==1000){
					// 扫码成功
					_that.itemList.deliveryNo=ret.resp_result;
					_that.getPsDetail();
				}
			})
			// #endif
		},
		
		// 获取配送单详情
		async getPsDetail() {
			if(this.itemList.deliveryNo){
				uni.showLoading({
					title: '数据加载中...'
				});
				const {data: res} = await uni.$http.get('/getPalletAll',{
					code: this.itemList.deliveryNo,
					type: '10'
				});
				if(res.success){ 
					if(res.data)
					{
						this.expanded=true;
						
						// 散装管件列表
						this.otherinfo=res.data.other&&res.data.other.length>0?res.data.other:[];
						this.instList = this.otherinfo.map(item => ({
							...item,
							checked:true
						}));
						// 配送图片
						this.itemList.deliveryPhoto=[];
						if(res.data.files&&res.data.files.length>0){
							res.data.files.forEach(item=>{
								this.itemList.deliveryPhoto.push({
									url:item
								})
							});
						}
						this.$forceUpdate();
						this.getByDelivery();
					}
					else{
						uni.showModal({
						    title: "扫码提示",
						    content: "托盘二维码【"+this.itemList.deliveryNo+"】无效",
						    showCancel: false,
						    confirmText: "确定"
						})
					}
				}
				else{
					this.$refs.uToast.show({
					  title: "暂无配送单【"+this.itemList.deliveryNo+"】信息！",
					  type: "warning",
					  duration: 2000,
					});
				}
			}
			else{
				this.$refs.uToast.show({
				  title: "请输入配送单号查询！",
				  type: "warning",
				  duration: 2000,
				});
			}
		},
		// 配送管件查询
		async getByDelivery(){
			// 托盘详情
			uni.showLoading({
				title: '数据加载中...'
			});
			const {data: res} = await uni.$http.get('/getDetailByDelivery',{deliveryNo:this.itemList.deliveryNo});
			if(res.success){
				if(res.data){
					
					// 托盘列表信息
					var pallets = res.data;
					var palletDetails = pallets.palletDetails?pallets.palletDetails:[];
					this.palletData=[]; 
					let _qty=0
					palletDetails.forEach((item,index)=>{
						_qty+=parseInt(item.qty||'0')
						item["checked"]=true;
						var findx = this.palletData.findIndex(cell => item.palletNo === cell.palletNo);
						// 新增
						if(findx<0){
							var files=[];
							if(item.files&&item.files.length>0){
								item.files.forEach(ii=>{
									files.push({
										url:ii
									})
								});
							}
							var pallet={
								palletNo: item.palletNo,
								files:files,
								isOpen: true,
								checked:true,
								children:[item],
								qty:parseInt(item.qty||'0')
							}
							this.palletData.push(pallet);
							this.$forceUpdate();
						}
						else{
							// 添加到此托盘明细列表
							this.palletData[findx].children.push(item);
							this.palletData[findx].qty+=parseInt(item.qty||'0')
							this.$forceUpdate();
						}
					});
					
					// 无托盘
					var noPalletDetails = pallets.noPalletDetails?pallets.noPalletDetails:[];
					
					noPalletDetails.forEach((item,index)=>{
						_qty+=parseInt(item.qty||'0')
						item["checked"]=true;
						var findx = this.palletData.findIndex(cell => item.palletNo === cell.palletNo);
						// 新增
						if(findx<0){
							var files=[];
							if(item.files&&item.files.length>0){
								item.files.forEach(ii=>{
									files.push({
										url:ii
									})
								});
							}
							var pallet={
								palletNo: item.palletNo,
								files:files,
								isOpen: true,
								checked:true,
								children:[item],
								qty:parseInt(item.qty||'0')
							}
							this.palletData.push(pallet);
							this.$forceUpdate();
						}
						else{
							// 添加到此托盘明细列表
							this.palletData[findx].children.push(item);
							this.palletData[findx].qty+=parseInt(item.qty||'0')
							this.$forceUpdate();
						}
					});
					
					console.log(this.palletData);
					
					//配送单配送管件数量
					this.itemList.qty=_qty
					this.palletAll=res.data;
					this.pallet=res.data.palletDetails;
					// 配送单号deliveryNo、工程编号project、制作图号dwgno、托盘表号instno、数量qty（合计）、
					// 需求单位requireDepartCode、配送地址requireAddress、联系人（联系人requireName+‘ ‘+联系电话requirePhone）、
					// 配送日期deliveryDate、配送车辆deliveryCar；（显示信息取第一条数据即可（每个配送单中的上述信息一致），数量需合计）
					var firstpallet=this.pallet.length>0?this.pallet[0]:(noPalletDetails.length>0?noPalletDetails[0]:null);
					if(!firstpallet){
						this.$refs.uToast.show({
						  title: "配送单【"+this.itemList.deliveryNo+"】暂无托盘明细信息！\n 请重新扫码!",
						  type: "warning",
						  duration: 2000,
						});
					}
					// 工程编号project
					this.itemList.project=firstpallet?firstpallet.project:'';
					// 制作图号dwgno
					this.itemList.dwgno=firstpallet?firstpallet.dwgno:'';
					// 托盘表号instno
					this.itemList.instno=firstpallet?firstpallet.instno:''; 
					// 需求单位requireDepartCode
					this.itemList.requireDepartCode=firstpallet?firstpallet.requireDepartCode:'';
					// 配送地址requireAddress
					this.itemList.requireAddress=firstpallet?firstpallet.requireAddress:'';
					// 联系人（联系人requireName+‘ ‘+联系电话requirePhone）
					this.itemList.requireName=firstpallet&&firstpallet.requireName?firstpallet.requireName:''+' '+firstpallet&&firstpallet.requirePhone?firstpallet.requirePhone:'';
					// 配送日期deliveryDate
					this.itemList.deliveryDate=firstpallet?firstpallet.deliveryDate:''; 
					// 配送车辆deliveryCar
					this.itemList.deliveryCar=firstpallet?firstpallet.deliveryCar:''; 
					
				}
				console.log(this.palletData)
			}
			this.$forceUpdate();
		},
		// 扫描托盘
		scanPallet(){
			var that = this;
			const _that = this;
			// #ifdef H5
			// 扫码识别托盘
			// _that.palletNo="XZG0005"; // XZG0004 XZG0005
			// _that.getPalletDetail();
			this.scantype=2; // 扫码托盘
			// this.$refs.scan.showScan();
			this.$refs.scan.start({
			    success: (val, res)=> {
			        console.log('扫描成功',val,res);
					if(_that.scantype==2){
						_that.palletNo=val;
						_that.$forceUpdate();
						_that.getPalletDetail();
					}
					else{
						_that.itemList.deliveryNo=val; // GJ2602000002 20260100024 20260100025
						_that.$forceUpdate();
						_that.getPsDetail();
					}
			    },
			    fail: (rej)=>{
			        console.log('扫描失败',rej);
					uni.showToast({
						title: '请在HTTPS环境下点击开启',
						icon: 'none',
						duration: 3000
					});
			    }
			})
			// #endif
			
			// #ifdef APP-PLUS
			// 允许从相机和相册扫码
			//qrCode,barCode
			// uni.scanCode({
			// 	scanType: ['qrCode', 'barCode'],
			// 	success: function(res) {
			// 		_that.palletNo=res.result;
			// 		_that.getPalletDetail();
			// 	}
			// });
			var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
			mpaasScanModule.mpaasScan({
			    // 扫码识别类型，参数可多选，qrCode、barCode，不设置，默认识别所有
			    'scanType':  ['qrCode','barCode'],
			    // 是否隐藏相册，默认false不隐藏
			    'hideAlbum': false,
			    //ios需要设置这个参数，只支持中英文 zh-Hans、en，默认中文                       
			    'language' : 'en',
			    //相册选择照片识别错误提示(ios)
			    'failedMsg': '未识别到二维码，请重试',
			    //Android支持全屏需要设置此参数
			    'screenType': 'full' ,
			    'timeoutInterval':'10', //设置超时时间
			    'timeoutText':'未识别到二维码？' //超时提醒文本             
			},(ret) => {
				if(ret.resp_code==1000){
					// 扫码成功
					_that.palletNo=ret.resp_result;
					_that.getPalletDetail();
				}
			    // uni.showModal({
			    //     title: "弹窗标题",
			    //     // 返回值中，resp_code 表示返回结果值，10：用户取消，11：其他错误，1000：成功
			    //     // 返回值中，resp_message 表示返回结果信息
			    //     // 返回值中，resp_result 表示扫码结果，只有成功才会有返回
			    //     content: JSON.stringify(ret),
			    //     showCancel: false,
			    //     confirmText: "确定"
			    // })
			})
			// #endif
		},
		// 添加托盘
		addPallet(){
			if(!this.palletNo){
				this.$refs.uToast.show({
				  title: "请先输入托盘编号!",
				  type: "warning",
				  duration: 3000,
				});
			}
			else {
				this.getPalletDetail();
			}
		},
		// 扫码托盘详情
		async getPalletDetail(){
			if(!this.palletNo){
				this.$refs.uToast.show({
				  title: "托盘编码为空!请扫码添加托盘信息!",
				  type: "warning",
				  duration: 3000,
				});
				return false
			}
			
			var ifexit=0;
			this.palletData.forEach((item,index)=>{
				if(this.palletNo==item.palletNo){
					ifexit++;
				}
			});
			if(ifexit>0){
				this.$refs.uToast.show({
				  title: "托盘编码已存在!不可重复添加!",
				  type: "warning",
				  duration: 3000,
				});
				this.palletNo='';
				this.$forceUpdate();
				return false;
			}
			
			// 托盘详情
			uni.showLoading({
				title: '数据加载中...'
			});
			const {data: res} = await uni.$http.get('/getPallet',{palletNo:this.palletNo});
			if(res.success){
				if(res.data){
					var data =res.data;
					if(!data.files){
						data["files"]=[];
					}
					else{
						var files=[]
						data.files.forEach(item=>{
							files.push({
								url:item
							})
						});
						data.files=files;
					}
					var ifexit=0;
					this.palletData.forEach((item,index)=>{
						if(data.palletNo==item.palletNo){
							ifexit++;
						}
					});
					if(ifexit>0){
						this.$refs.uToast.show({
						  title: "托盘编码已存在!不可重复添加!请扫码重试!",
						  type: "warning",
						  duration: 3000,
						});
					}
					else{
						var palletadd={
							palletNo: data.palletNo,
							files:data.files,
							isOpen: true,
							checked:true,
							children:[]
						};
						this.getInstListdetail(palletadd);
						this.$forceUpdate();
					}
				}
				else{
					this.$refs.uToast.show({
					  title: "托盘获取失败!请重试!",
					  type: "warning",
					  duration: 3000,
					});
				}
			}
			else{
				this.$refs.uToast.show({
				  title: "托盘获取失败!请重试!",
				  type: "warning",
				  duration: 3000,
				});
			}
			this.palletNo='';
			this.$forceUpdate();
		},
		async getInstListdetail(pallet){
			// 托盘详情
			uni.showLoading({
				title: '数据加载中...'
			});
			const {data: res} = await uni.$http.get('/getInstdetail',{palletNo:pallet.palletNo}); 
			if(res.success){
				pallet.children=res.data?res.data:[];
				this.palletData.push(pallet);
				this.$forceUpdate();
			}
		},
		// 完成接收
		finishLoading(){
			console.log('完成接收');
			console.log(this.itemList.deliveryPhoto)
			if(!this.itemList.deliveryNo){
				this.$refs.uToast.show({
				  title: "配送单为空!请扫码添加配送单!",
				  type: "warning",
				  duration: 3000,
				});
				return false
			}
			
			if(!this.itemList.departCode||!this.itemList.workshop||!this.itemList.location||!this.itemList.address){
				this.$refs.uToast.show({
				  title: "请选择正确的存放地址!",
				  type: "warning",
				  duration: 3000,
				});
				return false
			}
			
			if(!this.itemList.deliveryPhoto0&&this.itemList.deliveryPhoto0.length<1){
				this.$refs.uToast.show({
				  title: "请上传配送单图片!",
				  type: "warning",
				  duration: 3000,
				});
				return false
			}
			
			// 配送单图片
			this.itemList.files=[];
			this.itemList.deliveryPhoto0.forEach(item=>{
				this.itemList.files.push(item.url);
			});
      this.itemList.deliveryPhoto=this.itemList.files
			this.$forceUpdate();
			
			var data=[];
			this.itemList.instList=[];
			this.palletData.forEach((item,index)=>{
				if(item.checked){
					// 图片重新设置
					var files=[];
					item.files.forEach(item=>{
						files.push(item.url);
					});
					
					// 托盘
					if(item.palletNo){
						var ilist=[];
						if(item.children){
							item.children.forEach(cell=>{
								if(cell.checked){
									ilist.push({id:cell.id});
								}
							});
						}
						data.push({
							palletNo:item.palletNo,
							instList:ilist,
							files: files,
						});
					}
					else{
						// 散管
						if(item.children){
							item.children.forEach(cell=>{
								if(cell.checked){
									this.itemList.instList.push({id:cell.id});
									this.$forceUpdate();
								}
							});
						}
					}
				}
			});
			
			if(data.length<1&&this.itemList.instList.length<1){
				this.$refs.uToast.show({
				  title: "请选择托盘进行接收!",
				  type: "warning",
				  duration: 3000,
				});
				return false
			}
			
			this.itemList.data=data;
			this.$forceUpdate();
			
			console.log(this.itemList)
			uni.showModal({
				title: '提示',
				content: '确定要配送接收吗？',
				cancelText: '取消',
				confirmText: '确定',
				success: ress => {
					if (ress.confirm) {
						this.jsdo();
					}
					else{
						return false
					}
				}
			});
			
		},
		async jsdo(){
			uni.showLoading({
				title: '接收提交中...'
			});
			const {data: res} = await uni.$http.post('/sendReceiveData',this.itemList);
			if(res.success){
				this.$refs.uToast.show({
				  title: "配送接收成功！",
				  type: "success",
				  duration: 2000,
				});
				setTimeout(() => {
				  uni.navigateBack({
				    //返回
				    delta: 1,
				  });
				}, 3000);
			}
			else{
				this.$refs.uToast.show({
				  title: res.message? res.message:"配送接收失败！",
				  type: "warning",
				  duration: 3000,
				});
			}
		},
		getcount(){
			var ifexit=0;
			this.palletData.forEach((item,index)=>{
				if(item.checked){
					ifexit++;
				}
			});
			return ifexit;
		},
		getTypes() {
			//获取数据字典
			this.gcs=[];
			this.status=[];
			var commondata = uni.getStorageSync("commondata");
			if(commondata){
				var data = JSON.parse(commondata);
				if(data){
					this.users=data.users;
					this.dicts=data.dicts;
					this.depts=data.depts;
					// this.address=data.address;
					this.dicts.forEach(cell=>{
						if("PJCD"==cell.bmlb&&cell.zfbz!=='1'){
							// 工程
							this.gcs.push(cell);
						}
						if("TPZT"==cell.bmlb){
							// 托盘转运状态
							this.status.push(cell);
						}
					});
					this.$forceUpdate();
				}
			}
			else{
				this.users=[];
				this.dicts=[];
				this.depts=[];
				// this.address=[];
			}
			this.getList();
		},
		retType(type,str) {
			var rets = '';
			if(str==1){
				// 状态
				this.status.forEach((cell,idx)=>{
					if(type==cell.bm){
						rets=cell.bmsm;
						return;
					}
				});
				if(!rets){
					rets="其他"
				}
			}
			else if(str==2){
				// 部门
				this.depts.forEach((cell,idx)=>{
					if(type==cell.departCode){
						rets=cell.departName;
						return;
					}
				});
			}
			if(!rets){
				rets=type
			}
			return rets;
		},
		async getList() {
			const {data: res} = await uni.$http.get('/userAddr/myAddr');
			if(res.data&&res.data.length>0){
				this.address=res.data;
				this.$forceUpdate();
				if(this.address.length==1){
					var e=this.address[0];
					this.itemList.id=e.id?e.id:'';
					this.itemList.departCode=e.departCode?e.departCode:'';
					this.itemList.workshop=e.workshop?e.workshop:'';
					this.itemList.location=e.location?e.location:'';
					this.itemList.address=e.address?e.address:'';
					this.$forceUpdate();
				}
				 
			}
			else{
				this.address=[];
				this.$forceUpdate();
			}
		},
		
		
		/**
		 * h5扫码返回
		*/
		scanSuccess(qrcode){
			console.log("qrcode",qrcode);
			if(this.scantype==2){
				this.palletNo=qrcode;
				this.$forceUpdate();
				this.getPalletDetail();
			}
			else{
				this.itemList.deliveryNo=qrcode; // GJ2602000002 20260100024 20260100025
				this.$forceUpdate();
				this.getPsDetail();
			}
		}
		
	}
}; 
 
</script>

<style lang="scss" scoped>
page {
  height: 100%;
  background-color: #f5f5f5;
}

.ppcon{
		width: calc(100vw - 60rpx);
		height: calc(100vh - 100rpx) !important;
		/* #ifdef H5 */
		height: calc(100vh - var(--window-top) - 100rpx) !important;
		/* #endif */
		overflow-y: auto;
	}
::v-deep .uni-collapse-item__wrap{
	background-color: #f9f9f9 !important;
}
::v-deep .uni-collapse-item__wrap-content.uni-collapse-item--border{
	border-bottom-width:0 !important;
}
::v-deep .uni-collapse-item__title-arrow{
	margin-right: 0 !important;
}
::v-deep .u-list-item{
	background-color: #ffffff !important;
}
::v-deep .u-checkbox-group{
	display: flex !important;
	flex-direction: column;
	width: 100%;
}

.new-data-box {
	width: calc(100vw - 80rpx);
	height: calc(100vh - 150rpx) !important;
	/* #ifdef H5 */
	height: calc(100vh - var(--window-top) - 150rpx) !important;
	/* #endif */ 
	margin-top: 50rpx;
}
.container {
  min-height: 100%;
  padding-bottom: 0;
  box-sizing: border-box;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 88rpx;
  padding: 0 30rpx;
  background-color: #fff;
  position: relative;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.nav-left {
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-title {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
}

.nav-right .complete-btn {
  font-size: 30rpx;
  color: #007aff;
}
.stepcon{
	margin: 20rpx;
}
.section {
  margin: 20rpx;
  background-color: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.tpcon{
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	padding:30rpx 20rpx;
	border: 4rpx dashed #ddd;
	border-radius: 16rpx;
	cursor: pointer;
}

.input-group {
	display: flex;
	flex-direction: row;
	align-items: center;
	width: 100%;
	.label {
	  color: #333;
	  font-weight: 600;
	  margin-right: 10rpx;
	  font-size: 30rpx;
	  font-weight: 600;
	}
}

 

.input-container {
  display: flex;
  flex:1;
  align-items: center;
  border: 2rpx solid #ddd;
  border-radius: 12rpx;
  padding: 10rpx 16rpx;
}

.input-field {
  flex: 1;
  font-size: 30rpx;
  color: #333;
}
.qd-btn{
	color:#007AFF;
}
.scan-btn {
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hint {
  display: block;
  font-size: 24rpx;
  color: #999;
  margin-top: 10rpx;
}

.scan-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 450rpx;
  border: 4rpx dashed #ddd;
  border-radius: 16rpx;
  cursor: pointer;
  position: relative;
}
 
.scan-icon {
  margin-bottom: 20rpx;
}

.scan-title {
  font-size: 32rpx;
  color: #333;
  margin-bottom: 10rpx;
}

.scan-desc {
  font-size: 26rpx;
  color: #999;
}

.order-details {
  margin-top: 20rpx;
}

.detail-header {
	display: flex;
	flex-direction: row;
  padding-bottom: 20rpx;
  border-bottom: 2rpx solid #eee;
  margin-bottom: 20rpx;
  align-items: center;
}

.detail-title {
  font-size: 30rpx;
  font-weight: bold;
  color: #333;
  display: flex;
  align-items: center;
}
.detail-tip {
  font-size: 28rpx;
  color: #666;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  flex:1;
}
.selarr {
  width: 100%;
  height: 100%;
  line-height: 1;
  text-align: right;
  display: flex;
  flex-direction: row;
  align-items: center;
  .txt{
	  display: flex;
	  justify-content: flex-end;
	  flex: 1;
  }
}
.tip{
	display: flex;
	flex: 1;
	justify-content: flex-end;
	align-items: center;
	margin-right: 10rpx;
}
.detail-item {
  display: flex;
  align-items: center;
  margin-bottom: 15rpx;
}

.item-label {
  font-size: 28rpx;
  color: #666;
  width: 150rpx;
}

.item-value {
  font-size: 28rpx;
  color: #333;
  flex: 1;
}
.xqtxt{
	font-size: 28rpx;
	color: #007aff;
	margin-left: 10rpx;
}

.list-section {
  margin-top: 25rpx;
}

.list-title {
  font-size: 30rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 15rpx;
}

.list-item {
  padding: 15rpx 0;
  border-bottom: 1rpx solid #f0f0f0;
}
.devpicon{
	padding: 15rpx 0;
}
.item-text {
  font-size: 28rpx;
  color: #555;
}

.section-header {
  display: flex;
  align-items: center;
  margin-bottom: 25rpx;
}

.section-title {
  font-size: 30rpx;
  font-weight: bold;
  color: #333;
}

.section-count {
  font-size: 28rpx;
  color: #999;
  margin-left: 10rpx;
}

.pallet-list {
  margin-bottom: 30rpx;
}

.pallet-card {
  background-color: #f9f9f9;
  border-radius: 12rpx;
  padding: 20rpx;
  margin-bottom: 20rpx;
}
.pallet-item{
	background-color: #ecf5ff;
	border-top: 1rpx solid #e0e0e0;
	padding: 10rpx 0 10rpx 15rpx;
}
.pallet-info {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-bottom: 10rpx;
  margin-right: 10rpx;
}

.pallet-number {
  font-size: 30rpx;
  font-weight: bold;
  color: #333;
  display: flex;
  flex: 1;
}

.pallet-status {
  font-size: 24rpx;
  color: #999;
  padding: 5rpx 15rpx;
  border-radius: 20rpx;
  background-color: #f0f0f0;
  margin-right: 10rpx;
}

.pallet-status.status-zp{
  color: #4cd964;
  background-color: #f0faf4;
}
.pallet-status.status-ps{
  color: #e6a23c;
  background-color: #faecd8;
}
.pallet-status.status-zz{
  color: #6366F1;
  background-color: #E0E7FF;
}
.pallet-status.status-js{
  color: #8B5CF6;
  background-color: #EDE9FE;
}
.pallet-status.status-xp{
  color: #EC4899;
  background-color: #FDF2FB;
}

.pallet-materials {
  margin-bottom: 10rpx;
}

.material-text {
  display: block;
  font-size: 26rpx;
  color: #666;
  margin-bottom: 5rpx;
}

.pallet-time {
  text-align: right;
}

.time-text {
  font-size: 24rpx;
  color: #999;
}

.add-pallet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80rpx;
  background-color: #007aff;
  border-radius: 12rpx;
  color: #fff;
  font-size: 28rpx;
  cursor: pointer;
  width: 140rpx;
  margin-left: 10rpx;
}

.btn-text {
  margin-left: 2rpx;
}

.bottom-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  padding: 20rpx 30rpx;
  background-color: #fff;
  border-top: 2rpx solid #eee;
  box-sizing: border-box;
}

.image-grid {
	  display: grid;
	  grid-template-columns: repeat(3, 1fr);
	  gap: 20rpx;
	  padding: 10rpx 0;
	}
	
	.image-item {
	  border-radius: 12rpx;
	  overflow: hidden;
	  aspect-ratio: 1;
	}
	
	.image {
	  width: 100%;
	  height: 100%;
	}
	
.action-btn {
  flex: 1;
  height: 80rpx;
  border-radius: 12rpx;
  font-size: 32rpx;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.continue-btn {
  background-color: #007aff;
  color: #fff;
  margin-right: 20rpx;
}

.complete-btn {
  background-color: #4cd964;
  color: #fff;
}
</style>

