<template>
	<view class="page">
		
		<view class="back"></view>
		<view class="wrapnob">
			
			<!-- 检索  -->
			<view class="searchbg">
				<u-form-item required label="工程" label-width="80rpx"  label-position="left" prop="project">
					<view class="selarr" @click="showgc()">
						<text class="txt" v-if="page.project">{{page.project}}</text>
						<text class="txt" v-else style="color:#999">请选择</text>
						<uni-icons type="right" size="20" color="#999"></uni-icons>
					</view>
					<view class="icon-screen" @click="btnClick()"></view>
				</u-form-item>
			</view>
			
			<!-- tab -->
			<view v-if="ifsearch" class="tabs-box">
				<scroll-view scroll-x class="nav" scroll-with-animation :scroll-left="scrollLeft">
				  <view class="cuitem" :class="index == tabCurrentIndex ? 'cur' : ''" v-for="(item, index) in list" :key="index" @tap="tabSelect" :data-id="index">
					  <view class="cucell">
						  <view class="text-title">
						    <text class="text-titlecolor" :class="index == tabCurrentIndex ? 'cur' : ''" >{{ item.name }}</text>
						  </view>
						  <view class="text-num">
						    <text class="text-numcolor" :class="index == tabCurrentIndex ? 'cur' : ''" >({{ item.slist.length}})</text>
						  </view>
						  <uni-icons :type="item.expanded ? 'arrowup' : 'arrowdown'" size="16" :color="index == tabCurrentIndex ?'#fff':'#999'" @tap="toggleGroupAll(index)"></uni-icons>
					  </view>
				  </view>
				</scroll-view>
			</view>
			<view v-else style="margin: 20rpx;">
				<view class="nosearch">~请输入查询条件查询托盘信息~</view>
			</view>
			
			<!-- 列表 -->
			<swiper class="swiper-box" :duration="300" :current="tabCurrentIndex"  @animationfinish="animationfinish">
				
				<swiper-item class="swiper-item" v-for="tabItem in list" :key="tabItem.id">
					<scroll-view scroll-y style="height: 100%;width: 100%;">
						
						<!-- 装载信息区域 -->
						<view class="loading-section">
						  <!-- 分组信息折叠面板 -->
						  <view class="accordion" v-for="(group, index) in tabItem.slist" :key="index+'-'+group.assemcode">
						    <view class="accordion-header" @tap="toggleGroup(index)">
								<view class="header-list">
									<view class="header-info">
									  <text class="group-title">
									  {{ tabCurrentIndex==0?'托盘表号:':(tabCurrentIndex==1?'制作图:':'') }}{{ tabCurrentIndex==0?group.instno:(tabCurrentIndex==1?group.dwgno:'') }}
									  </text>
									  <view class="group-title"> 配送比例:{{group.percent?group.percent+'%':'0.0%'}} </view>
									</view>
									<view class="header-info">
										<text class="group-title"> 全部:{{group.tabs[0].count}}</text>
										<text class="group-title"> 接收:{{group.tabs[1].count}} </text>
										<text class="group-title"> 配送:{{group.tabs[2].count}} </text>
										<text class="group-title"> 未配:{{group.tabs[3].count}} </text>
										<text class="group-title"> 修改:{{group.tabs[4].count}} </text>
									</view>
								</view>
								<uni-icons :type="group.expanded ? 'arrowup' : 'arrowdown'" size="16" color="#999"></uni-icons>
						    </view> 
						    <view class="accordion-content" v-if="group.expanded">
								
						      <!-- 分组详细信息 -->
						      <view class="group-details">
						        <view class="detail-row">
						          <text class="detail-label">需求单位：</text>
						          <text class="detail-value">{{ retType(group.requireDepartCode,2) }}</text>
						        </view>
						        <view class="detail-row">
						          <text class="detail-label">需求日期：</text>
						          <text class="detail-value">{{ group.requireDate }}</text>
						        </view>
						        <view class="detail-row">
						          <text class="detail-label">需求地址：</text>
						          <text class="detail-value">{{ group.requireAddress }}</text>
						        </view>
						        <view class="detail-row">
						          <text class="detail-label">接收人：</text>
						          <text class="detail-value">{{ group.requireName }}</text>
						        </view>
						        <view class="detail-row">
						          <text class="detail-label">联系电话：</text>
						          <text class="detail-value">{{ group.requirePhone }}</text>
						        </view>
						        <view class="detail-row">
						          <text class="detail-label">部件数量：</text>
						          <text class="detail-value">{{ group.items?group.items.length:0 }}</text>
						        </view>
						        <view class="detail-row">
						          <text class="detail-label">配送时间：</text>
						          <text class="detail-value">{{ group.deliveryDate }}</text>
						        </view>
						        <view class="detail-row">
						          <text class="detail-label">配送车辆：</text>
						          <text class="detail-value">{{ group.deliveryCar }}</text>
						        </view>
								<view class="detail-row">
								  <text class="detail-label">配送数量：</text>
								  <text class="detail-value">{{ group.deliveryNum }}</text>
								</view>
								<view class="detail-row">
								  <text class="detail-label">未配送数量：</text>
								  <text class="detail-value">{{ group.unDeliveryNum }}</text>
								</view>
						        <view class="detail-row">
						          <text class="detail-label">实际接收人：</text>
						          <text class="detail-value">{{ group.receiveName }}</text>
						        </view>
						        <view class="detail-row">
						          <text class="detail-label">实际接收时间：</text>
						          <text class="detail-value">{{ group.receiveDate }}</text>
						        </view>
						      </view>
							  
							  <!-- 状态选项卡 -->
							  <view class="tabs-container">
							    <view class="tabs-scroll">
							      <view class="tabs-wrapper">
							        <view 
							          v-for="(tab, idx) in group.tabs" 
							          :key="idx"
							          class="tab-item"
							          :class="{ active: group.activeTab === idx }"
							          @click="switchTab(index,idx)"
							        >
									<text class="tab-count">{{ tab.count }}</text>
							        <text class="tab-text">{{ tab.name }}</text>
							        </view>
							      </view>
							    </view>
							  </view>
							  
						      <!-- 管件清单明细 -->
							  <view class="item-list">
							    <view class="list-item"
							  		v-for="(item,ii) in group.items" :key="ii"
							  		v-if="(group.activeTab==0||(group.activeTab==1&&item.receiveDate)||(group.activeTab==2&&item.deliveryDate)
							  		||(group.activeTab==3&&!item.deliveryDate)||(group.activeTab==4&&item.modifyMark=='Y'))"
							  		:class="{ red: item.modifyType === 'Y',blue: item.deliveryDate?true:false,green: item.receiveDate?true:false }">
							  		<view class="list-cell">
							  			<view class="item-xuh" >
							  				{{ ii==0?(group.xh=1,group.xh):++group.xh }}. 
							  			</view>
							  			<view class="item-cell" style="padding-left:4rpx;">
							  				件号: {{ item.assemcode || '-' }}
							  			</view>
							  			<view class="item-cell">
							  				数量: {{ item.qty?(1.0*item.qty).toFixed(0) : '-' }}
							  			</view>
							  		</view>
							  		<view class="list-cell">
							  			<view class="item-cell">
							  				规格: {{ item.spec || '-' }}
							  			</view>
							  			<view class="item-cell">
							  				材质: {{ item.grd || '-' }}
							  			</view>
							  		</view>
							  		<view class="list-cell">
							  			<view class="item-cell">
							  				状态: {{ item.status || '-' }}
							  			</view>
							  			<view class="item-cell">
							  				时间: {{ item.statusDate || '-' }}
							  			</view>
							  			<view class="item-cell">
							  				单位: {{ item.statusDept?retType(item.statusDept,2):'-' }}
							  			</view>
							  		</view>
							  		<view class="list-cell">
							  			<view class="item-cell">
							  				配送时间: {{ item.deliveryDate || '-' }}
							  			</view>
							  			<view class="item-cell">
							  				工装托盘: {{ item.palletNo || '-' }}
							  			</view>
							  		</view> 
							        <view class="list-cell" v-if="item.modifyMark=='Y'">
							        	<view class="item-cell">
							        		修改说明: {{ item.modifyType +' ' + item.modifyDwgno }}
							        	</view>
							        </view>
							  		<view class="list-cell">
							  			<view class="item-cell">
							  				备注: {{ item.deliveryRemark || '-' }}
							  			</view>
							  		</view>
							    </view>
							  </view>
						      
							  
						    </view>
						  </view>
						</view> 
						
					</scroll-view>
				</swiper-item>
			
			</swiper>
		
		</view>
		
		<!-- 查看托盘基本信息 -->
		<view class="u-shaixuan">
			<u-popup v-model="show"  @close="close" mode="top" :mask="true" :closeable="trayInfo&&trayInfo.loadId?true:false" close-icon-pos="top-right">
				<view class="popcon"> 
					<view  class="list-itemh">
						<view class="detail-rowh">
							<text class="detail-labelh">外形尺寸:</text>
							<text class="detail-valueh">{{ trayInfo.deliveryRemark || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">载重:</text>
							<text class="detail-valueh">{{ trayInfo.load || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">使用状态:</text>
							<text class="detail-valueh">{{ trayInfo.palletStatus || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">创建日期:</text>
							<text class="detail-valueh">{{ trayInfo.createDate || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">备注:</text>
							<text class="detail-valueh">{{ trayInfo.remark || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">存放部门:</text>
							<text class="detail-valueh">{{ retType(trayInfo.departCode,2) || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">存放工场:</text>
							<text class="detail-valueh">{{ trayInfo.workshop || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">接收/回收确认时间:</text>
							<text class="detail-valueh">{{ trayInfo.confirmTime || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">接收/回收人确认电话:</text>
							<text class="detail-valueh">{{ trayInfo.confirmPhone || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">接收/回收人确认备注:</text>
							<text class="detail-valueh">{{ trayInfo.confirmRemark || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">装盘船只:</text>
							<text class="detail-valueh">{{ trayInfo.loadProject || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">装盘安装托盘表号:</text>
							<text class="detail-valueh">{{ trayInfo.loadInst || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">装盘数量:</text>
							<text class="detail-valueh">{{ trayInfo.loadQty || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">装盘信息:</text>
							<text class="detail-valueh">{{ trayInfo.loadDesc || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">装盘时间:</text>
							<text class="detail-valueh">{{ trayInfo.loadTime || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">装盘人:</text>
							<text class="detail-valueh">{{ trayInfo.loadName || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">配送单号:</text>
							<text class="detail-valueh">{{ trayInfo.deliveryNo || '-' }}</text>
						</view>
						<view class="detail-rowh">
							<text class="detail-labelh">车辆牌号:</text>
							<text class="detail-valueh">{{ trayInfo.deliveryCar || '-' }}</text>
						</view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">配送/转运部门代码:</text>
						    <text class="detail-valueh">{{ retType(trayInfo.fromDepartCode ,2)  || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">配送/转运工场:</text>
						    <text class="detail-valueh">{{ trayInfo.fromWorkshop || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">配送/转运区域:</text>
						    <text class="detail-valueh">{{ trayInfo.fromLocation || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">配送/转运地址:</text>
						    <text class="detail-valueh">{{ trayInfo.fromAddress || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">配送/转运时间:</text>
						    <text class="detail-valueh">{{ trayInfo.fromTime || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">配送/转运人员:</text>
						    <text class="detail-valueh">{{ trayInfo.fromName || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">配送/转运人员电话:</text>
						    <text class="detail-valueh">{{ trayInfo.fromPhone || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">配送/转运备注:</text>
						    <text class="detail-valueh">{{ trayInfo.fromRemark || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">去向部门:</text>
						    <text class="detail-valueh">{{ retType(trayInfo.toDepartCode ,2)  || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">去向工场:</text>
						    <text class="detail-valueh">{{ trayInfo.toWorkshop || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">去向区域:</text>
						    <text class="detail-valueh">{{ trayInfo.toLocation || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">去向地址:</text>
						    <text class="detail-valueh">{{ trayInfo.toAddress || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">去向接收人员:</text>
						    <text class="detail-valueh">{{ trayInfo.toName || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">去向接收人员电话:</text>
						    <text class="detail-valueh">{{ trayInfo.toPhone || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">接收部门:</text>
						    <text class="detail-valueh">{{ retType(trayInfo.receiveDepartCode ,2) || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">接收工场:</text>
						    <text class="detail-valueh">{{ trayInfo.receiveWorkshop || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">接收区域:</text>
						    <text class="detail-valueh">{{ trayInfo.receiveLocation || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">接收地址:</text>
						    <text class="detail-valueh">{{ trayInfo.receiveAddress || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">接收时间:</text>
						    <text class="detail-valueh">{{ trayInfo.receiveTime || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">接收人员:</text>
						    <text class="detail-valueh">{{ trayInfo.receiveName || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">接收人员电话:</text>
						    <text class="detail-valueh">{{ trayInfo.receivePhone || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">接收备注:</text>
						    <text class="detail-valueh">{{ trayInfo.receiveRemark || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">卸盘时间:</text>
						    <text class="detail-valueh">{{ trayInfo.finishTime || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">卸盘人员:</text>
						    <text class="detail-valueh">{{ trayInfo.finishName || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">卸盘人员电话:</text>
						    <text class="detail-valueh">{{ trayInfo.finishPhone || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">卸盘备注:</text>
						    <text class="detail-valueh">{{ trayInfo.finishRemark || '-' }}</text>
						  </view>
						  <view class="detail-rowh">
						    <text class="detail-labelh">操作图片:</text>
						    <text class="detail-valueh">
								
							</text>
						  </view>
					</view>
								 
				</view>
			</u-popup>
		</view>
		
		<u-toast ref="uToast" />
		
		<!-- 筛选 -->
		<view class="u-shaixuan">
			<u-popup v-model="pop1.show" 
				@close="close" :mode="pop1.mode" :mask="pop1.mask"
				:closeable="pop1.closeable"
				:close-icon-pos="pop1.closeIconPos">
				<view class="popcon1"> 
					<u-form-item label="分段" label-width="150rpx" label-position="left" prop="section">
						<u-input :border="true" :height="60" placeholder="请输入" input-align="left" v-model="page.section" @input="input1" type="text" maxlength="200"></u-input>
					</u-form-item>
					<u-form-item label="制作图号" label-width="150rpx" label-position="left" prop="dwgno">
						<u-input :border="true" :height="60" placeholder="请输入" input-align="left" v-model="page.dwgno" @input="input2" type="text" maxlength="200"></u-input>
					</u-form-item>
					<u-form-item label="安装托盘表号" label-width="180rpx" label-position="left" prop="instno">
						<u-input :border="true" :height="60" placeholder="请输入" input-align="left" v-model="page.instno" @input="input3" type="text" maxlength="200"></u-input>
					</u-form-item>
					<view class="cu-form-group">
						<u-button @click="resetClick" shape="square" size="mini" type="warning" style="width: 160rpx;">重置</u-button>
						<u-button @click="searchClick" shape="square" size="mini" type="primary" style="width: 160rpx;">确定</u-button>
					</view>
				</view>
			</u-popup>
		</view>
		
		<!-- 工程 -->
		<tki-tree ref="gctree" :value="page.project" :range="gcs" rangeKey="bm" idKey="bm" @confirm="gctreeConfirm" @hide="gctreeConfirm" ></tki-tree>
		
		
	</view>
	
</template>

<script> 
	import tkiTree from "@/components/areaTree/Linktree.vue";
	export default {
		components: {
		  tkiTree
		},
		data() {
			return {
				show: false,
				ifsearch:false,
				rmbm:"", // 工装托盘编号
				trayInfo:{},// 托盘基本信息
				ifsx: false,
				pop1:{
					title:'筛选',
					text:'',
					name:'',
					show: false,
					mode: 'top',
					mask: true, // 是否显示遮罩
					closeable: false,
					closeIconPos: 'top-right'
				},
				page: {
					project:"",
					section:"",
					palletNo:"",
					dwgno:"",
					instno:"",
				},
				tabCurrentIndex: 0,
				loadStatus:'loadmore',
				scrollLeft: 0,//tabs
				list:[
					// {
					// 	id:'gc',
					// 	loadStatus:'loadmore',
					// 	num: 0,
					// 	name:'工程',
					// 	expanded:false,
					// 	slist:[]
					// },
					{
						id:'tph',
						loadStatus:'loadmore',
						num: 0,
						name:'托盘表号',
						expanded:false,
						slist:[]
					},
					{
						id:'zzt',
						loadStatus:'loadmore',
						num: 0,
						name:'制作图',
						expanded:false,
						slist:[]
					},
				],
				address:[],
				users:[],
				depts:[],
				dicts:[],
				gcs:[],
				status:[],
				
			};
		},
		onLoad(option) {
			console.log(option)
			if(option.project){
				this.page.project=option.project;
				this.$forceUpdate();
			}
			if(option.instno){
				this.page.instno=option.instno;
				this.$forceUpdate();
			}
			if(option.dwgno){
				this.page.dwgno=option.dwgno;
				this.$forceUpdate();
			}
			this.btnClick();
			// 先加载分类
			this.getTypes();
		},
		methods: {
			input1(e){
				if(e){
					this.page.section= e.toUpperCase();
					this.$forceUpdate();
				}
			},
			input2(e){
				console.log(e)
				if(e){
					this.page.dwgno= e.toUpperCase();
					this.$forceUpdate();
				}
			},
			input3(e){
				console.log(e)
				if(e){
					this.page.instno= e.toUpperCase();
					this.$forceUpdate();
				}
			},
			btnClick() {
				this.pop1.show = true;
				this.ifsx=false;
			},
			resetClick() {
				this.page = {
					project:"",
					section:"",
					palletNo:"",
					dwgno:"",
					instno:"",
				};
				// this.reset();
				// this.pop1.show = false;
			},
			searchClick() {
				if(!this.page.project){
					uni.showModal({
						title: "查询提示",
					    content: "请选择工程",
					    showCancel: false,
					    confirmText: "确定"
					});
					return false;
				}
				this.reset();
				this.pop1.show = false;
			},
			// 重新查询数据
			reset(){
				if(!this.page.project&&!this.page.section&&!this.page.palletNo&&!this.page.dwgno){
					uni.showModal({
						title: '提示',
						content: '请输入查询条件查询！确定要查询全部数据吗？',
						cancelText: '取消',
						confirmText: '确定',
						success: ress => {
							if (ress.confirm) {
								this.getYpDetail();
							}
							else{
								return false
							}
						}
					});
				}
				else{
					this.getYpDetail();
				}
			},
			close() {
				this.show = false;
			},
			open() {
				this.show = true;
			},
			// 选择条件
			showgc(e) {
				this.$refs.gctree._show();
			},
			gctreeConfirm(val) {
				// 选择工程
				if (val && val.length > 0) {
					this.page.project = val[val.length - 1].bm;
				}
				else{
					this.page.project = "";
				}
				this.$forceUpdate();
			},
			
			toggleGroupAll(index) {
				var that=this;
				if(index==this.tabCurrentIndex){
					this.list[index].expanded = !this.list[index].expanded;
					this.list[index].slist.forEach((item,ii) => {
						this.list[index].slist[ii].expanded=that.list[index].expanded;
					});
					this.$forceUpdate();
				}
			},
			toggleGroup(index) {
			  this.list[this.tabCurrentIndex].slist[index].expanded = !this.list[this.tabCurrentIndex].slist[index].expanded;
			  this.$forceUpdate();
			},
			async getYpDetail() {
				this.ifsearch=true;
				// 查询托盘明细
				uni.showLoading({
					title: '数据加载中...'
				});
				// 查询 托盘基本信息
				// this.page.project="T300K-106";
				console.log("this.page",this.page)
				const {data: res} = await uni.$http.get('/searchInstdetail',this.page);
				if(res.success){
					this.list[0].slist=[];
					this.list[1].slist=[];
					// this.list[2].slist=[];
					if(res.data&&res.data.length>0){
						// 全部数据加载
						this.list[this.tabCurrentIndex].loadStatus="nomore";
						res.data.forEach((cell,idx)=>{
							
							// 托盘表号
							var findx = this.list[0].slist.findIndex(item => item.instno === cell.instno); // true
							if(findx<0){
								var add = {
									expanded:false,
									activeTab:0,
									items:[cell],
									project:cell.project,
									instno:cell.instno,
									requireDepartCode:cell.requireDepartCode,
									requireRate:cell.requireRate,
									requireAddress:cell.requireAddress,
									requireName:cell.requireName,
									requirePhone:cell.requirePhone,
									qty:cell.qty,
									deliveryNum:0,
									unDeliveryNum:0,
									deliveryDate:cell.deliveryDate,
									requireDate:cell.requireDate,
									deliveryCar:cell.deliveryCar,
									receiveName:cell.receiveName,
									receiveDate:cell.receiveDate,
								};
								this.list[0].slist.push(add);
							}
							else {
								this.list[0].slist[findx].items.push(cell);
							}
							
							// 制作图
							findx = this.list[1].slist.findIndex(item => item.dwgno === cell.dwgno); // true
							if(findx<0){
								var add = {
									expanded:false,
									activeTab:0,
									items:[cell],
									project:cell.project,
									instno:cell.instno,
									dwgno:cell.dwgno,
									requireDepartCode:cell.requireDepartCode,
									requireRate:cell.requireRate,
									requireAddress:cell.requireAddress,
									requireName:cell.requireName,
									requirePhone:cell.requirePhone,
									qty:cell.qty,
									deliveryNum:0,
									unDeliveryNum:0,
									deliveryDate:cell.deliveryDate,
									requireDate:cell.requireDate,
									deliveryCar:cell.deliveryCar,
									receiveName:cell.receiveName,
									receiveDate:cell.receiveDate,
								};
								this.list[1].slist.push(add);
							}
							else {
								this.list[1].slist[findx].items.push(cell);
							}
							
						});
						
						this.list[0].slist.forEach((cell,idx)=>{
							this.list[0].slist[idx]["deliveryNum"]=this.getdeliveryNum(cell.items);
							this.list[0].slist[idx]["unDeliveryNum"]=this.getunDeliveryNum(cell.items);
							this.list[0].slist[idx]["deliveryDate"]=this.getdeliveryDate(cell.items);
							this.list[0].slist[idx]["requireDate"]=this.getrequireDate(cell.items);
							this.list[0].slist[idx]["tabs"]=this.gettabs(cell.items);
							this.list[0].slist[idx]["percent"]=(this.getpercent(cell.items)).toFixed(1);
							this.$forceUpdate();
						});
						
						this.list[1].slist.forEach((cell,idx)=>{
							this.list[1].slist[idx]["deliveryNum"]=this.getdeliveryNum(cell.items);
							this.list[1].slist[idx]["unDeliveryNum"]=this.getunDeliveryNum(cell.items);
							this.list[1].slist[idx]["deliveryDate"]=this.getdeliveryDate(cell.items);
							this.list[1].slist[idx]["requireDate"]=this.getrequireDate(cell.items);
							this.list[1].slist[idx]["tabs"]=this.gettabs(cell.items);
							this.list[1].slist[idx]["percent"]=(this.getpercent(cell.items)).toFixed(1);
							this.$forceUpdate();
						});
						
						this.$forceUpdate();
						console.log(this.list[0].slist,this.list[1].slist)
					}
					else{
						this.list[this.tabCurrentIndex].loadStatus="nomore";
					}
				}
				else{
					this.list[this.tabCurrentIndex].loadStatus="nomore";
				}
			},
			switchTab(ii,kk){
				this.list[this.tabCurrentIndex].slist[ii].activeTab=kk;
				this.list[this.tabCurrentIndex].slist[ii].xh=0;
				this.$forceUpdate(); 
			},
			getpercent(items){
				var all=0,ps=0,xg=0,percent=0;
				if (items&&items.length>0) {
				    items.forEach(cell=>{
						all=all+(1.0*cell.qty); 
						// c)	配送：deliveryDate!=’’
						if(cell.deliveryDate){
							ps=ps+(1.0*cell.qty); 
						}
						// e)	修改：modifyMark=’Y’ （modify_mark为新增字段）
						if(cell.modifyMark== 'Y'){
							xg=xg+(1.0*cell.qty); 
						}
					});
					percent=(all-xg)?(ps-xg)*100/(all-xg):0;
				}
				return percent;
			},
			gettabs(items){
				var tabs=[
					{ name: '全部', count: 0 },
					{ name: '接收', count: 0 },
					{ name: '配送', count: 0 },
					{ name: '未配', count: 0 },
					{ name: '修改', count: 0 }
				];
				if (items&&items.length>0) {
					tabs[0].count=items.length;
				    items.forEach(cell=>{
						// b)	接收：receiveDate!=’’
						if(cell.receiveDate){
							tabs[1].count=tabs[1].count+1;
						}
						// c)	配送：deliveryDate!=’’
						if(cell.deliveryDate){
							tabs[2].count=tabs[2].count+1;
						}
						// d)	未配：deliveryDate=’’
						if(!cell.deliveryDate){
							tabs[3].count=tabs[3].count+1;
						}
						// e)	修改：modifyMark=’Y’ （modify_mark为新增字段）
						if(cell.modifyMark== 'Y'){
							tabs[4].count=tabs[4].count+1;
						}
					});
				}
				return tabs;
			},
			getunDeliveryNum(items){
				var num=0
				if (items&&items.length>0) {
				    items.forEach((cell,idx)=>{
						// console.log(cell.deliveryDate)
						if(cell.deliveryDate==''||cell.deliveryDate==null||cell.deliveryDate==undefined){
							num=num+1.0*(cell.qty?cell.qty:0);
						}
					});
					// console.log(num.toFixed(2))
					return num.toFixed(2);
				}
				else{
					return 0;
				}
			},
			getdeliveryNum(items){
				var num=0
				if (items&&items.length>0) {
				    items.forEach((cell,idx)=>{
						// console.log(cell.deliveryDate)
						if(cell.deliveryDate){
							num=num+1.0*(cell.qty?cell.qty:0);
						}
					});
					// console.log(num.toFixed(2))
					return num.toFixed(2);
				}
				else{
					return 0;
				}
			},
			getdeliveryDate(items){
				var date=''
				if (items&&items.length>0) {
				    items.forEach((cell,idx)=>{
						if(cell.deliveryDate){
							date=this.compareDate(date,cell.deliveryDate);
							if(!date){
								date=cell.deliveryDate;
							}
							else{
								if(this.compareDate(date,cell.deliveryDate)){
									date=cell.deliveryDate;
								}
							}
						}
					});
				}
				return date;
			},
			getrequireDate(items){
				var date=''
				if (items&&items.length>0) {
				    items.forEach((cell,idx)=>{
						if(cell.requireDate){
							date=this.compareDate(date,cell.requireDate);
							if(!date){
								date=cell.requireDate;
							}
							else{
								if(this.compareDate(date,cell.requireDate)){
									date=cell.requireDate;
								}
							}
						}
					});
				}
				return date;
			},
			compareDate(timeStr1,timeStr2){
				let date1 = new Date(timeStr1);
				let date2 = new Date(timeStr2);
				if (date1 < date2) {
				    return true;
				} else if (date1 >= date2) {
				    return false;
				}
			},
			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);
							}
						});
						console.log(this.gcs)
						this.$forceUpdate();
					}
				}
				else{
					this.users=[];
					this.dicts=[];
					this.depts=[];
					this.address=[];
				}
			},
			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;
			},
			tabSelect(e) {
				// 选项卡
				this.tabCurrentIndex = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 200;
			},
			animationfinish({ detail: { current } }) {
				this.tabCurrentIndex = current;
				this.tabsetDx();
			},
			tabsetDx() {
			  this.scrollLeft = (this.tabCurrentIndex - 1) * 200;
			},
			
		}
		
	}
</script>

<style lang="scss" scoped>
	.u-drawer{
		top:calc(var(--window-top) + 100rpx) !important;
		height: calc(100vh - var(--window-top) - 100rpx) !important;
		z-index: 92 !important;
	}
	
	.popcon1{
		padding: 0 20rpx 10rpx;
	}
	.popcon{
		height: calc(100vh - 100rpx) !important;
		/* #ifdef H5 */
		height: calc(100vh - var(--window-top) - 100rpx) !important;
		/* #endif */
		overflow-y: auto;
	}
	::v-deep uni-picker > .uni-picker-container {
	  z-index: 12998 !important;
	}
	::v-deep uni-picker > .uni-mask {
	  z-index: 12999 !important;
	}
	.searchinput {
	  margin-right: 40rpx !important;
	}
	.u-size-default {
	  padding: 10rpx !important;
	}
	.u-shaixuan {
	  text-align: center;
	  z-index: 90 !important;
	}
	.cu-form-group .title {
	  font-size: 26rpx !important;
	}
	.cu-form-group uni-picker .picker {
	  font-size: 26rpx !important;
	}
	.searchbg{
		width: 100%;
		position: relative;
		display: block;
		overflow: hidden;
		padding: 14rpx 20rpx 10rpx 20rpx;
		background-color: #fff;
		margin-bottom: 20rpx;
	}
	.u-drawer.timetip {
	  height: calc(100vh - var(--window-top) - 100rpx) !important;
	  top: 0 !important;
	  bottom: auto !important;
	}
	.cu-form-group {
	  ::v-deep .u-mask {
	    margin-top: -300rpx !important;
	  }
	}
	.icon-screen{
		position: absolute;
		top: 20rpx;
		right: 0;
		width: 36rpx;
		height:35rpx;
		background: url('../../static/images/shaixuan.png') no-repeat center center;
		background-size: 100% auto;
	} 
	.selnodate{
		width: 400rpx;
		height: 30rpx;
		background: url('@/static/images/xiayiji.png') no-repeat center right;
		background-size:auto 88%;
		padding-right: 50rpx;
		text-align: right;
		color: rgb(192, 196, 204);
	}
	::v-deep .u-form-item {
		color: #000;
		font-size: 28rpx !important;
		padding: 6rpx;
		background-color: #fff;
	}
		
	::v-deep .u-form-item--left {
		margin: 0 0 0 18rpx !important;
		width: 150rpx;
	}
	
	.selarr {
	  height: 100%;
	  line-height: 1;
	  text-align: right;
	  display: flex;
	  flex: 1;
	  flex-direction: row;
	  align-items: center;
	  margin-right: 32rpx;
	  .txt{
		  display: flex;
		  justify-content: flex-end;
		  flex: 1;
	  }
	}
	
	
	.info-card {
	  background-color: #fff;
	  border-radius: 12rpx;
	  padding:20rpx 30rpx;
	  margin-bottom: 20rpx;
	  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
	  margin: 10rpx 20rpx 0;
	}
	.info-row {
	  display: flex;
	  justify-content: space-between;
	} 
	.label {
	  display: flex;
	  flex: 1;
	  font-size: 28rpx;
	  color: #666;
	}
	.value {
	  font-size: 28rpx;
	  color: #333;
	}
	.status-01 {
	  color: #1890ff;
	}
	.status-02 {
	  color: #00c853;
	}
	.status-03 {
	  color: #ffab00;
	}
	.status-04 {
	  color: #fa3534;
	}
	
	.loading-section {
	  margin-bottom: 20rpx;
	}
	
	.accordion {
	  background-color: #fff;
	  border-radius: 12rpx;
	  margin-bottom: 20rpx;
	  overflow: hidden;
	  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
	}
	
	.accordion-header {
	  display: flex;
	  justify-content: space-between;
	  align-items: center;
	  padding: 20rpx;
	  background-color: #f5f5f5;
	}
	.header-list {
	  display: flex;
	  flex-direction: column;
	}
	.header-info {
	  display: flex;
	  align-items: center;
	}
	
	.group-title {
	  font-size: 30rpx;
	  font-weight: bold;
	  color: #333;
	  margin-right: 16rpx;
	}
	
	.group-tray {
	  font-size: 26rpx;
	  color: #666;
	  margin-right: 16rpx;
	}
	
	.accordion-content {
	  padding: 30rpx;
	}
	
	.group-details {
	  margin-bottom: 30rpx;
	}
	
	.detail-row {
	  display: flex;
	  margin-bottom: 20rpx;
	}
	
	.detail-row:last-child {
	  margin-bottom: 0;
	}
	
	.detail-label {
	  font-size: 26rpx;
	  color: #666;
	  width: 160rpx;
	}
	
	.detail-value {
	  font-size: 26rpx;
	  color: #333;
	  flex: 1;
	}
	
	.tabs-container {
	  background-color: #ffffff;
	  margin:0 0;
	}
	
	.tabs-scroll {
	  white-space: nowrap;
	  padding: 0 0 20rpx;
	}
	
	.tabs-wrapper {
	  display: inline-flex;
	  width: 100%;
	}
	
	.tab-item {
	  padding: 10rpx 30rpx;
	  margin: 0 10rpx 0 0;
	  border-radius: 20rpx;
	  background-color: #f5f5f5;
	  display: flex;
	  flex-direction: column;
	  align-items: center;
	  width: 20%;
	}
	
	.tab-item.active {
	  background-color: #007aff;
	}
	
	.tab-text {
	  font-size: 28rpx;
	  color: #333;
	  margin-right: 8rpx;
	}
	
	.tab-item.active .tab-text {
	  color: #ffffff;
	}
	
	.tab-count {
	  font-size: 32rpx;
	  font-weight: 600;
	  color: #333;
	}
	
	.tab-item.active .tab-count {
	  color: rgba(255, 255, 255, 0.8);
	}
	
	
	.item-list {
	  width: 100%;
	  display: flex;
	  flex-direction: column;
	}
	.list-item {
		border: 1rpx solid #e0e0e0;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
		border-radius: 8rpx;
		display: flex; 
		flex-direction: column;
		width: 100%;
		margin-bottom: 20rpx;
		padding: 10rpx;
		background-color: #fafafa;
	}
	.list-item {
		border: 1rpx solid #e0e0e0;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
		border-radius: 8rpx;
		display: flex; 
		flex-direction: column;
		width: 100%;
		margin-bottom: 20rpx;
		padding: 10rpx;
		background-color: #fafafa;
	}
	.list-item.red{
		color:#de0000;
	}
	.list-item.blue{
		color:#2196f3;
	}
	.list-item.green{
		color:#18b566;
	}
	.list-cell{
		display: flex;
		flex-direction: row;
		width: 100%;
	}
	.item-xuh{
		text-align: center;
		font-size: 28rpx;
		padding: 6rpx 0 6rpx 0;
		word-break: break-all;
	}
	.item-cell {
	  text-align: center;
	  font-size: 28rpx;
	  padding: 6rpx 0 6rpx 30rpx;
	  word-break: break-all;
	}
	
	.swiper-box {
		flex: 1;
		height: calc(100vh - 230rpx) !important;
		/* #ifdef H5 */
		height: calc(100vh - var(--window-top) - 230rpx) !important;
		/* #endif */
		margin: 0 20rpx;
	}
	.cuitem.cur {
	  background: #007aff !important;
	}
	.tabs-box {
	  padding:20rpx 20rpx 10rpx 20rpx;
	  .cuitem {
	    position: relative;
	    display: inline-block;
	    overflow: hidden;
	    background: #fff;
	    padding: 10rpx;
		width: 48%;
		margin: 0 2% 0 0;
	    border-radius: 12rpx;
		text-align: center;
		.cucell{
			width: 100%;
			display: flex;
			flex-direction: row;
			align-items: center;
			height: 60rpx;
			justify-content: center;
		}
		.text-num {
		  font-size: 26rpx;
		  margin-right: 10rpx;
		  .text-numcolor {
		    color: #33383c;
		  }
		  .text-numcolor.cur {
		    color: #fff;
		  }
		}
		.text-title {
		  font-size: 26rpx;
		  .text-titlecolor {
		    color: #33383c;
		  }
		  .text-titlecolor.cur {
		    color: #ffffff;
		  }
		}
	  }
	  .tabs-all {
	    color: #33383c;
	    font-size: 26rpx;
	    font-weight: 600;
	    margin-top: 16rpx;
	    position: relative;
	    text-align: left;
	  }
	}
	.nosearch{
		background-color: #FFFFFF;
		background-image: url('../../static/image/search.png');
		background-repeat: no-repeat;
		background-position: center center;
		background-size: 66% 66%;
		height: 600rpx;
		border-radius: 0 0 20rpx 20rpx;
		color: #666;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		width: 100%;
		flex-direction: column;
		padding-bottom: 40rpx;
	}
	.nodata{
		background-color: #FFFFFF;
		background-image: url('../../static/image/nodata.jpg');
		background-repeat: no-repeat;
		background-position: center center;
		background-size: 66% 66%;
		height: 600rpx;
		border-radius: 0 0 20rpx 20rpx;
		color: #666;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		width: 100%;
		flex-direction: column;
		padding-bottom: 40rpx;
	}
	
	
	.new-data-box {
		width: 600rpx;
		margin: 60rpx 30rpx;
		overflow-y: auto;
	}
	
	.list-container {
	  flex: 1;
	  overflow-y: auto;
	  height: calc(100vh - 90rpx) !important;
	  /* #ifdef H5 */
	  height: calc(100vh - var(--window-top) - 90rpx) !important;
	  /* #endif */
	}
	
	.list-itemh {
	  background-color: #ffffff;
	  padding: 30rpx;
	  margin: 20rpx;
	  border-radius: 12rpx;
	  overflow: hidden;
	  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
	} 
	.detail-rowh {
	  display: flex;
	  justify-content: space-between;
	  margin-bottom: 15rpx;
	} 
	.detail-labelh {
	  width: 160rpx;
	  font-size: 26rpx;
	  color: #999999;
	  text-align: left;
	}
	
	.detail-valueh {
	  flex: 1;
	  font-size: 26rpx;
	  color: #333333;
	  text-align: left;
	}
	
	.empty-state {
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  height: 400rpx;
	  background-color: #ffffff;
	  border-radius: 12rpx;
	  margin-top: 20rpx;
	}
	
	.empty-text {
	  font-size: 28rpx;
	  color: #999999;
	}

</style>
