<template>
	<view :style="{paddingTop:`${uni.getStorageSync('moveHeight')+40}px`}">
		<view class="title-back" :style="{height:`${uni.getStorageSync('moveHeight')+40}px`}">
			<view class="left-father" @click="goBack">
				<image class="back-img" src="https://www.focusnu.com/media/directive/index/left.png" />
				<view style="font-size: 30rpx;">采购单详情</view>
			</view>
		</view>
		<view class="cgdxx">
			<view class="top">
				<view class="left">
					<image src="https://www.focusnu.com/media/xcx/cgd.png" mode="aspectFill"></image> 
					<text>采购单信息</text>
				</view>
				<view class="righs">
					<view class="rs l"  :class="{'l':list.cgdType==0,'h':list.cgdType==1,'b':list.cgdType==2}">{{list?.cgdType_dictText}}</view>
				</view>
			</view>
			<view class="center">
				<view class="tspo">
					<view class="bx" style="align-items: left;">
						<view>采购单号</view>
						<text>{{list.cgdNo}}</text>
					</view>
					<view class="bx" style="align-items: flex-end;">
						<view>采购日期</view>
						<text>{{list.qgDate?.substring(0,10)}}</text>
					</view>
				</view>
				<view class="top">
					<view class="left">
						<image src="https://www.focusnu.com/media/xcx/cc.png" mode="aspectFill"></image>
						<text>采购方信息</text>
					</view>
				</view>
			</view>
			<view class="contweo">
				<view class="lan">
					<view></view>
					机构名称：{{list.departName}}
				</view>
				<!-- <view class="lan">
					<view></view>
					收货地址：
					<text>
						吉林省长春市朝阳区开运街41号吉林省长春市朝阳区开运街41号
					</text>
				</view> -->
				<view class="lan">
					<view></view>
					联系人：  {{list.qgBy}}
				</view>
				<view class="lan">
					<view></view>
					电   话 ： {{list.createBy}}
				</view>
				<view class="top">
					<view class="left">
						<image src="https://www.focusnu.com/media/xcx/jc.png" mode="aspectFill"></image>
						<text>供应商信息</text>
					</view>
				</view>
			</view>
			<view class="contweo">
				<view class="lan">
					<view></view>
					供应商名称：{{list.gysName}}
				</view>
			</view>
		</view>
		<view class="swtab"  >
			<view  v-for="(v,i) in ['全部',' 挂账','销账']" :key="i" :class="dex==i?'act guodu':'guodu'" @click="naurl(i)">{{v}}</view>
		</view>
		<!-- 详细信息 -->
		<view class="xxxx" v-for="(v,i) in listarr" :key="i">
			<view class="top">
				<view class="left">{{v.wlName}}</view>
				<view class="rishs">
					<text>采购数量</text>
					<view>{{v.purchaseQuantity}}</view>
				</view>
			</view>
			<view class="cents">
				<view>规格型号 ：<view>{{v.wlSpecificationModel}}</view></view>
				<view>采购单位 ：{{v.wlUnits}}</view>
			</view>
			<view class="sfj">
				<view>
					<view>{{v.rksl}}</view>
					<text>已入库数量</text>
				</view>
				<view>
					<view :style="v.wrksl>0? 'color: red;font-weight: bold;':''">{{v.wrksl}}</view>
					<text>挂账数量</text>
				</view>
				<view>
					<view>{{v.xzsl}}</view>
					<text>销账数量</text>
				</view>
			</view>
		</view>
		 <view class="none" v-if="!listarr.length">
		 	<image style="width: 300rpx;height: 300rpx;"
		 		src="https://www.focusnu.com/media/directive/index/none.png" mode="widthFix" lazy-load="false" />
		 	<view class="">暂无信息</view>
		 </view>
		
	</view>
</template>

<script setup lang="ts">
	import { reactive, ref, nextTick } from 'vue';
	import { onLoad, onPullDownRefresh,onReachBottom } from '@dcloudio/uni-app'
	import { getEmployeesOrgRela,getCgdListByGysId } from './api.js'
	const goBack = () => {
		uni.navigateBack()
	}
	const list = ref({})
	onLoad((e)=>{
		let obj = {
			id:e.id
		}
		let header = {
		  'X-Access-Token': uni.getStorageSync('token') || '',
		  'Content-Type': 'application/json;charset=UTF-8',
		  'Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0',
		}
		let timeout = 5000
		uni.request({
		  url: uni.getStorageSync('serverUrl2') + '/api/pad/invoicing/getCgdInfoByCgdId',
		  method: 'GET',
		  header: header,
		  data: obj,
		  timeout,
		  success(response) {
		    const res = response.data;
			list.value = res.result;
			naurl(dex.value)
		}})
	})
	const dex = ref(0);
	const listarr = ref([]);
	const naurl = (e)=>{
		dex.value = e;
		if(e==0){
			listarr.value = list.value.list
		}
		if(e==1){
			listarr.value = [];
			list.value.list.map(v=>{
				if(v.wrksl>0){
					listarr.value.push(v)
				}
			})
		}
		if(e==2){
			listarr.value = [];
			list.value.list.map(v=>{
				if(v.xzsl>0){
					listarr.value.push(v)
				}
			})
		}
	}
</script>

<style scoped lang="scss">
	.swtab{
		width: 700rpx;
		margin: 28rpx auto 0;
		height: 50px;
		background-color: #fff;
		display: flex;
		justify-content: space-around;
		border-radius: 40rpx;
		view{
			font-weight: 400;
			font-size: 30rpx;
			color: #666666;
			height: 40px;
			width: auto;
			line-height: 30px;
			margin-top: 5px;
		}
		view::after{
			content: '';
			width: 0%;
			left: 50%;
		}
		.act{
			font-weight: bold;
			font-size: 30rpx;
			color: #222222;
			position: relative;
		}
		.act::after{
			content: '';
			position: absolute;
			width: 50%;
			left: 21%;
			bottom: 0;
			background: #0074E1;
			border-radius: 5rpx;
			border: 2px solid #0074E1;
			transition: .4s;
			-webkit-transform-style: preserve-3d;
			-webkit-overflow-scrolling: touch;
		}
	}
	.none {
			display: flex;
			align-items: center;
			flex-direction: column;
			color: #999;
			margin-top: 30rpx;
		}
	.xxxx{
		width: 705rpx;
		min-height: 359rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 13rpx 0rpx rgba(105,129,178,0.05);
		border-radius: 40rpx;
		margin: 24rpx auto 0;
		padding:20rpx 46rpx;
		.sfj{
			width: 560rpx;
			min-height: 88rpx;
			display: flex;
			justify-content: space-between;
			margin: 0 auto;
			>view{
				display: flex;
				flex-direction: column;
				align-items: center;
				view{
					font-weight: bold;
					font-size: 38rpx;
					color: #555555;
				}
				text{
					font-weight: 400;
					font-size: 28rpx;
					color: #666666;
				}
			}
		}
		.cents{
			width: 100%;
			margin: 37rpx auto 50rpx;
			padding-left: 8rpx;
			display: flex;
			justify-content: space-between;
			flex-wrap: nowrap;
			>view{
				font-weight: 400;
				font-size: 30rpx;
				color: #555555;
				display: flex;
				>view{
					width: 220rpx;
				}
			}
		}
		.top{
			width: 100%;
			height: 80rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-bottom: 1px solid #D2D2D2;
			.left{
				font-weight: bold;
				font-size: 35rpx;
				color: #222222;
				max-width: 430rpx;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
			.rishs{
				display: flex;
				align-items: center;
				view{
					font-weight: bold;
					font-size: 38rpx;
					color: #333333;
					margin-left: 17rpx;
				}
				text{
					font-weight: 400;
					font-size: 27rpx;
					color: #555555;
					margin-top: 5rpx;
				}
			}
		}
	}
	.cgdxx{
		width: 700rpx;
		min-height: 60rpx;
		background: #FFFFFF;
		border-radius: 40rpx;
		margin: 28rpx auto 0;
		padding: 28rpx;
		.contweo{
			width: 100%;
			min-height: 40rpx;
			.lan{
				display: flex;
				min-height: 30rpx;
				font-weight: 400;
				font-size: 30rpx;
				color: #333333;
				margin-top: 26rpx;
				text{
					max-width: 444rpx;
				}
				view{
					width: 10rpx;
					height: 10rpx;
					background: #999999;
					border-radius: 50%;
					margin: 17rpx 30rpx 0 20rpx;
					
				}
			}
		}
		.center{
			width: 100%;
			min-height: 40rpx;
			.tspo{
				width: 578rpx;
				height: 62rpx;
				margin-left: 57rpx;
				margin-top: 28rpx;
				display: flex;
				justify-content: space-between;
				.bx{
					display: flex;
					justify-content: space-between;
					flex-direction: column;
					width: 50%;
					font-weight: 400;
					font-size: 28rpx;
					view{
						color: #888888;
					}
					text{
						color: #555555;
						margin-bottom: 15rpx;
					}
				}
				
			}
		}
		.top{
			width: 100%;
			height: 90rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1px solid #D2D2D2;
			.righs{
				.rs{
					width: 116rpx;
					height: 49rpx;
					border-radius: 15rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					font-weight: 400;
					font-size: 28rpx;
				}
				.l{
					border: 1px solid #0074E1;
					color: #0074E1;
				}
				.h{
					border: 1px solid #EE2C35;
					color: #EE2C35;
				}
				.b{
					border: 1px solid #333333;
					color: #333;
				}
			}
			.left{
				display: flex;
				align-items: center;
				image{
					width: 30rpx;
					height: 30rpx;
				}
				text{
					font-weight: bold;
					font-size: 30rpx;
					color: #333333;
					margin-left: 21rpx;
				}
				
			}
			
		}
	}
	.title-back {
		background-color: #fff;
		width: 100%;
		height: 70rpx;
		display: flex;
		justify-content: space-between;
		align-items: flex-end;
		padding-bottom: 20rpx;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9999;
	}
	
	.left-father {
		display: flex;
		align-items: center;
		z-index: 1;
	
		.back-img {
			width: 45rpx;
			height: 40rpx;
			margin-left: 40rpx;
			margin-right: 15rpx;
		}
	}
	.guodu {
		transition: .4s;
		-webkit-transform-style: preserve-3d;
		-webkit-overflow-scrolling: touch;
	}
</style>
<style>
	page{
		background: #F0F0F3;
	}
</style>