<template>
	<view>
		<view class="caigou">
			<view class="top">
				<view class="ipt">
					<input type="text" placeholder="物料名称/物料编码/物料简拼" v-model="form.wlParamInfo" @confirm="search" />
					<image src="/static/index/procurement/x.png" mode="aspectFill" v-if="form.wlParamInfo"
						@click="search(0)"></image>
				</view>
				<view @click="search" class="scr guodu">
					<image src="/static/index/procurement/sh.png" mode="aspectFill" class="sh"></image>
					<image src="/static/index/procurement/shr.png" mode="aspectFill" class="shr"></image>
					检索
				</view>
				<view class="shx guodu" @click="ification=true">
					<image src="/static/index/purchaseorder/select.png" mode="aspectFill" class="sh"></image>
					<image src="/static/index/purchaseorder/selecttarget.png" mode="aspectFill" class="shr"></image>
					筛选
				</view>
				<view class="back guodu" @click="emit('link',0)">
					<image src="/static/index/procurement/bk.png" mode="aspectFill"></image>
					返回
				</view>
			</view>
			
			<scroll-view scroll-y="true" class="caigoulist" scroll-with-animation @scrolltolower="scrolltolower()" lower-threshold="300"
				:enhanced="true" :bounce="true" enable-back-to-top>
					<view class="fler" v-for="(v,index) in InvoicingList" :key="index">
						<view class="fler-view" >
							<!-- @touchend="handleTouchEnd($event,v,index)"
								@touchstart="touchstart($event,v,index)" scroll-with-animation scroll-x="true"
								:scroll-left="v.scrollleft" @scroll="scroll" -->
								
							<view class="carditem guodu"
								:style="openwhitchindex === index? { transform: 'translateX(-15vw)' }: { transform: 'translateX(0)' }">
								<view class="speitem guodu">
									<view class="imghs">
										<image style="border-radius: 1vw;"
											:src="v.materialImg?serverUrl+v.materialImg:'/static/index/procurement/k.png'"
											mode="aspectFill">
										</image>
									</view>
									<view class="cardp">
										<view>复健用品</view>
										<view>复健用品</view>
									</view>
									<!-- <view class="cardp">
										<view v-if="v.categoryId_dictText">{{v.categoryId_dictText}}</view>
										<view v-if="v.typeId_dictText">{{v.typeId_dictText}}</view>
										<view v-if="v.medicationId_dictText">{{v.medicationId_dictText}}</view>
									</view> -->
								</view>
								<view class="msitem guodu">
									<view>
										<view>纸尿裤-拉拉裤纸尿裤拉拉裤纸尿裤</view>
									</view>
									<view style="margin-top:1.8vw;">
										<text style="white-space: nowrap;"> 物料编码: ZHYP044</text>
									</view>
									<view>
										<text style="white-space: nowrap;"> 规格型号: 800mm*680mm</text>
									</view>
									<view>
										<text style="white-space: nowrap;"> 品牌型号：品牌型号名称</text>
									</view>
									<view>
										<text style="white-space: nowrap;"> 生产厂家：吉林省捌零信创科技有限...</text>
									</view>
									<view>
										<text style="white-space: nowrap;"> 供 应 商 ：长春市天林商贸有限公司...</text>
									</view>
								</view>
								<view class="add" @click.stop="addcar(v,index)">
									<image :src="'/static/index/procurement/+.png'" mode="aspectFill"></image>
								</view>
								<!-- <view class="zkadd guodu" >
									<view class="zkadd-white" style="background: #F1F1F1;" @click.stop="pandian(v,index)" @touchend.stop>盘点</view>
									<view class="zkadd-white" @click.stop="crk(v,index)" @touchend.stop>出入库</view>
									<view class="zkadd-blue" @click.stop="addcar(v,index)" v-if="v.isAdd!=1" @touchend.stop>
										<view>
											销售价格
										</view>
									</view>
								</view> -->
								
							</view>
						</view>
					</view>
				<view style="height:3vw;width: 100%;display: flex;align-items: center;justify-content: center;">
					<u-loadmore :status="status" :loadText="{nomore:'暂无更多数据'}" v-if="InvoicingList.length>6" />
				</view>
			</scroll-view>
			 
		</view>
		<view @click="emit(`link`,2)" class="fiedrightview">
			<image src="/static/index/procurement/gc1.png" mode="aspectFill"></image>
			<!-- <text v-if="carnum>0">{{carnum>99?'99+':carnum}}</text> -->
			<view class="mhao" v-if="carnum>0">
				<view class="mhao-font">
					{{carnum}}
				</view>
			</view>
		</view>
		
	</view>
</template>

<script setup lang="ts">
	import { ref, onMounted, reactive, onBeforeUnmount, computed, nextTick, defineComponent, inject, watch } from 'vue';
	 const emit = defineEmits(['link' ])
	 const search = (x : number) => {
	 	if (x === 0) { form.wlParamInfo = '' }
	 	form.pageNo = 1;
	 	// InvoicingList.value = [];
	 	// queryInvo();
	 }
	 const InvoicingList = ref([{},{},{},{},{},])
	 const ification = ref(false)
	 const carnum = ref(2)
	 
	 const form = reactive({
	 	nuId: uni.getStorageSync('nuId'),
	 	pageNo: 1,
	 	pageSize: 30,
	 	categoryId: '',
	 	typeId: '',
	 	medicationId: '',
	 	wlParamInfo: '',
	 	isWaring: 0,
	 	suppliers: ''
	 })
	 const crk = (v, i) => {
	 	emit('crk', v, i)
	 }
	 const startX = ref(0)
	 const openwhitchindex = ref(-1)
	 const ts = (e) => {
	 	startX.value = e.touches[0].clientX;
	 }
	 const scrolltolower = ()=>{
		 
	 }
	 // const canmove = (e : any, index : number) => {
	 // 	const moveX = e.touches[0].clientX
	 // 	const diff = moveX - startX.value
	 // 	// diff 为负值就是向左滑
	 // 	if (diff < -40) {  // 👉 60px 阈值，随便改
	 // 		openwhitchindex.value = index
	 // 	}
	 // 	if (diff > 40) {  // 👉 60px 阈值，随便改
	 // 		openwhitchindex.value = -1
	 // 	}
	 // }
</script>

<style lang="less" scoped>
.caigou{
	width: 100%;
	height: 100%;
	.caigoulist{
		width: 100%;
		height: calc(60.4vw - 5vw);
		padding: 0 1.4vw;
		 
		
		.fler {
			width: 59.5vw;
			height: 19vw;
			position: relative;
			.fler-view {
				width: 59vw;
				height: 18vw;
				border: 1px solid #E5E5E5;
				border-radius: 1.6vw;
				position: relative;
				margin-bottom: 1.1vw;
				overflow: hidden;
				white-space: nowrap;
			}
		}
	}
	
	.top{
		width: 100%;
		height: 4.7vw;
		position: relative;
		display: flex;
		align-items: center;
		padding: 0 1.4vw;
		.ipt {
			display: flex;
			align-items: center;
			width: 28vw;
			border-radius: 1.65vw;
			height: 3.3vw;
			background: #FFFFFF;
			border: 1px solid #D2D2D2;
		
			image {
				width: 2.2vw;
				height: 2.2vw;
				// margin: 0 0.5vw;
				margin-right: 1.5vw;
			}
		
			input {
				width: 25vw;
				height: 3.3vw;
				font-size: 1.4vw;
				padding-left: 1.6vw;
		
			}
		}
		
		.back {
			width: 7.3vw;
			height: 3.3vw;
			border-radius: 1.6vw;
			background: rgba(255, 255, 255, 1);
			border-radius: 1.65vw;
			font-weight: 400;
			font-size: 1.4vw;
			color: rgba(85, 85, 85, 1);
			display: flex;
			justify-content: center;
			align-items: center;
			border: 1px solid #D9DADC;
			margin-left: auto;
		
			image {
				width: 1.5vw;
				height: 1.3vw;
				margin: 0 0.5vw 0 0;
			}
		
		}
		
		.back:active,
		.shx:active,
		.scr:active {
			color: #1083F8;
			background: linear-gradient(-45deg, rgba(223, 244, 252, 1), rgba(204, 228, 249, 0.43));
			border: 1px solid #1083F8;
		}
		
		.scr {
			border-radius: 1.65vw;
			font-weight: 400;
			font-size: 1.4vw;
			display: flex;
			justify-content: center;
			align-items: center;
			width: 8.5vw;
			height: 3.3vw;
			margin: 0 0 0 0.7vw;
			background: rgba(255, 255, 255, 1);
			border: 1px solid #D9DADC;
			color: #555555;
		
			image {
				width: 1.6vw;
				height: 1.6vw;
				margin: 0 0.5vw 0 0;
			}
		}
		
		.shr {
			display: none;
		}
		
		.scr:active .sh {
			display: none;
		}
		
		.shx:active .shr {
			display: inline-block;
		}
		
		.shx:active .sh {
			display: none;
		}
		
		.scr:active .shr {
			display: inline-block;
		}
		
		.shx {
			width: 8.5vw;
			height: 3.3vw;
			background: #FFFFFF;
			border-radius: 1.65vw;
			border: 1px solid #D9DADC;
			font-weight: 400;
			font-size: 1.4vw;
			color: #222;
			display: flex;
			justify-content: center;
			align-items: center;
			margin: 0 0 0 0.7vw;
			color: #555555;
		
			image {
				width: 1.6vw;
				height: 1.6vw;
				margin: 0 0.5vw 0 0;
			}
		}
	}
}

	.carditem {
		height: 100%;
		display: flex;
		transition: transform 500ms cubic-bezier(.2, .8, .2, 1);
		will-change: transform;
		width: 59vw;

		.add {
			width: 6.5vw;
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			>view {
				width: 5.5vw;
				height: 2.2vw;
				background: #fff;
				border-radius: 0.9vw;
				border: 1px solid #1083F8;
				font-weight: 400;
				font-size: 1.4vw;
				color: #1083F8;
				display: flex;
				justify-content: center;
				align-items: center;
				position: absolute;
				top: 2.3vw;
				right: 0.8vw;
			}

			image {
				width: 2.5vw;
				height: 2.5vw;
			}
		}

		.msitem {
			 width: 38vw;
			 margin-left: 2vw;
			>view {

				&:nth-child(2),
				&:nth-child(3),
				&:nth-child(4),
				&:nth-child(6),
				&:nth-child(5) {
					margin-top: 0.25vw;
					max-width: 25vw;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;

					text {
						font-weight: 400;
						font-size: 1.3vw;
						color: #777777;
						margin-top: 0.25vw;
					}
				}

				&:nth-child(1) {
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 2vw;
					margin-top:2.4vw;

					>view {
						width: 100%;
						height: 2vw;
						font-weight: bold;
						font-size: 1.8vw;
						color: #222222;
						text-overflow: ellipsis;
						overflow: hidden;
						white-space: nowrap;
					}

					text {
						width: 6vw;
						font-weight: 300;
						font-size: 1.4vw;
						color: #222222;
					}
				}
			}

		}
		.speitem {
			width: 16.8vw;
			height: 14vw;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.cardp {
				width: 12.5vw;
				height: 4vw;
				display: flex;
				flex-wrap: wrap;
				margin: 0 auto;
				align-items: center;

				view {
					min-width: 5.5vw;
					height: 1.8vw;
					border-radius: 0.9vw;
					border: 1px solid #D2D2D2;
					margin: 0.5vw 0 0 0.5vw;
					display: flex;
					justify-content: center;
					align-items: center;
					font-weight: 400;
					font-size: 1vw;
					color: #555555;
					padding: 0 0.25vw;

					&:nth-child(1),
					&:nth-child(2) {
						max-width: 6vw;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						display: block;
						line-height: 1.8vw;
						text-align: center;
					}

					&:nth-child(3) {
						max-width: 11.5vw;
						padding: 0 0.8vw;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						display: block;
						line-height: 1.8vw;
						text-align: center;
					}
				}
			}

			.imghs {
				width: 10vw;
				height: 9.1vw;
				margin: 3vw auto 1.25vw;
				padding: 0.2vw;
				background: #fff;
				border-radius: 1.1vw;
				
				>image {
					width: 100%;
					height: 100%;
					border-radius: 1.1vw;
				}
			}

		}
	}
	
	
	.fiedrightview {
		width: 5vw;
		height: 5vw;
		background: rgba(255, 255, 255, 0.86);
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		position: fixed;
		z-index: 200;
		right: 1.2vw;
		bottom:2vw;
		box-shadow: 0rpx 0rpx 0.5vw 0rpx rgba(136, 148, 167, 0.19);
		.mhao {
			position: absolute;
			top: -0.2vw;
			right: -0.2vw;
			box-sizing: border-box;
			width: 1.8vw;
			height: 1.8vw;
			border-radius: 50%;
			background: #1083F8;
			color: #fff;
			display: flex;
			align-items: center;
			justify-content: center;
			writing-mode: horizontal-tb;
			overflow: hidden;
		
			.mhao-font {
				font-size: 25rpx;
				letter-spacing: -0.05em;
				/* 负值 = 字符之间更近 */
			}
		}
		
		text {
			min-width: 1.8vw;
			height: 1.8vw;
			border-radius: 0.8vw;
			border: 2px solid #1083F8;
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 0 0.5vw;
			font-weight: 400;
			font-size: 1.3vw;
			color: #fff;
			position: absolute;
			top: -0.8vw;
			right: -0.8vw;
		}
	
		image {
			width: 3.3vw;
			height: 3.3vw;
		}
	}
</style>
