<template>
	<view>
		<view class="title-back" :style="{height:`${uni.getStorageSync('moveHeight')+40}px`}">
			<view class="left-father" @click="uni.navigateBack()">
				<image class="back-img" src="https://www.focusnu.com/media/directive/index/left.png" />
				<view style="font-size: 30rpx;">物料信息</view>
			</view>
		</view>
		<view :style="{height:`${uni.getStorageSync('moveHeight') + 40}px`}"></view>
		<view class="scr"></view>
		<view class="scr"  :style="{top:`${uni.getStorageSync('moveHeight')+40}px`}" style="position: fixed; left: 0;">
			<view class="serch">
				<image class="bacimg" src="https://www.focusnu.com/media/directive/index/search.png" />
				<input type="text" v-model="value" @confirm="sousuo" placeholder="请输入物料名称"/>
				<view class="right-img"  v-if="value" @click="value='';sousuo()">
					<image src="https://www.focusnu.com/media/directive/index/x.png" />
				</view>
			</view>
		</view>
		
		<view class="box" v-for="(v,i) in list" :key='i' :class="act==i?'act':''" @click="act=i">
			<view class="cont">
				<text class="tit">{{v.materialName}}</text>
				<view class="bianj" @click.stop="uni.navigateTo({ url:`/pages/supplierindex/mtdetails?obj=${JSON.stringify(v)}&index=${i}`});act=i">
					编辑
				</view>
			</view>
			<view class="cont" style="margin-top: 23rpx;">
				<text class="hui">品牌型号</text>
				<text class="hui">规格型号</text>
			</view>	
			<view class="cont" style="margin-top: 13rpx;">
				<text class="hei">{{v.brandType}}</text>
				<text class="hei">{{v.specificationModel}}</text>
			</view>	
			<view class="xian"></view>
			<view class="cont" >
				<text class="hui">销售单位</text>
				<text class="hui">销售单价</text>
			</view>	
			<view class="cont" style="margin-top: 13rpx;">
				<text class="hei" style="font-size: 30rpx;">{{v.salesUnit}}</text>
				<text class="hei" style="font-size: 30rpx;">￥{{v.salesUnitPrice}}</text>
			</view>	
		</view>
		<view style="height:3vw;width: 100%;display: flex;align-items: center;justify-content: center;margin: 30rpx 0;">
			<u-loadmore :status="status" :loadText="{nomore:'暂无更多数据'}" v-if="list.length>0" />
			<view style="height: 30rpx;"></view>
		</view>
		<view class="none" v-if="!list.length&&status=='nomore'">
			<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   class="fiedrightview">
			+
		</view>
	</view>
</template>

<script setup lang="ts">
	 import {
	 	reactive,
	 	ref,
	 	onMounted,
	 	onUnmounted,
		defineExpose
	 } from 'vue';
	 import {
	 	onLoad,
	 	onShow,
	 	onPullDownRefresh,
		onReachBottom
	 } from '@dcloudio/uni-app';
	 import {
	 	getSuppliersWlInfo,
	 } from './api.js'
	 const status = ref('loadmore')
	 const list = ref([])
	 const value = ref('')
	 const id = ref('')
	 const pageNo = ref(1)
	 const act = ref(-1)
	 onLoad((e)=>{
		 id.value = e.id;
		 search()
	 })
	 const sousuo = ()=>{
		 act.value = -1;
		 list.value = [];
		 pageNo.value = 1;
		 search()
	 }
	 
	 const search = ()=>{
		 let obj = {
			 pageSize:10,
			 pageNo:pageNo.value,
			 title:value.value,
			 suppliersId:id.value
		 }
		 getSuppliersWlInfo(obj).then(res=>{
			 list.value.push(...res.result.records) 
			 status.value = (res.result.total == list.value.length ? 'nomore' : 'loadmore')
		 })
	 }
	 onReachBottom(()=>{
		 if(status.value=='loading'|| status.value=='nomore'){return}
		 status.value = 'loading';
		 pageNo.value++;
		 search()
	 })
	 const swih = (e,i)=>{
		 console.log(e.salesUnitPrice,i,111111111111)
		 list.value[i] = e;
		 console.log(list.value[i])
	 }
	 defineExpose({swih})
</script>

<style lang="scss" scoped>
	.fiedrightview {
		width: 100rpx;
		height: 100rpx;
		background: rgba(255, 255, 255, 0.86);
		border-radius: 50%;
		border: 1px solid #D9DADC;
		display: flex;
		justify-content: center;
		// align-items: center;
		position: relative;
		font-size: 60rpx;
		position: fixed;
		right: 30rpx;
		bottom: 90rpx;
		line-height: 86rpx;
	
		text {
			min-width: 1.8vw;
			height: 1.8vw;
			border-radius: 0.8vw;
			border: 2px solid #E81D1D;
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 0 0.5vw;
			font-weight: 400;
			font-size: 1.3vw;
			color: #E81D1D;
			position: absolute;
			top: -0.8vw;
			right: -0.8vw;
		}
	
		image {
			width: 3.3vw;
			height: 3.3vw;
		}
	}
	.act{
		border: 2rpx dashed #0083FA !important;
	}
	.box{
		width: 700rpx;
		min-height: 108rpx;
		padding: 20rpx 35rpx;
		background: #fff;
		border-radius: 25rpx;
		overflow: hidden;
		margin: 24rpx auto ;
		border: 2rpx solid #fff;
		.xian{
			width: 100%;
			height: 1px;
			background: #E5E5E5;
			margin: 16rpx auto;
		}
		.cont{
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.bianj{
				width: 120rpx;
				height: 56rpx;
				border-radius: 28rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				background: linear-gradient(90deg, #E6F4FE,#CCE8FE,#CAE6FE);
				color: #0083FA;
				font-size: 31rpx;
			}
			.hei{
				font-size: 26rpx;
				color: #222;
				font-weight: 500;
			}
			.hui{
				font-size: 26rpx;
				color: #646464;
			}
		}
		.tit{
			font-size: 36rpx;
			color: #222222;
			font-weight: 700;
		}
	}
	.scr{
		width: 100%;
		height: 110rpx;
		background: RGBA(247, 247, 247, 1);
		z-index: 10;
		padding-bottom: 10rpx;
	}
	.serch{
		width: 700rpx;
		height: 80rpx;
		margin: 15rpx auto 0;
		border: 1px solid rgba(229, 229, 229, 1);
		display: flex;
		align-items: center;
		border-radius: 40rpx;
		position: relative;
		.right-img {
			width: 50rpx;
			height: 100%;
			position: absolute;
			top: 0;
			right: 19rpx;
			z-index: 999;
			display: flex;
			justify-content: center;
			align-items: center;
			
			image{
				width: 40rpx;
				height: 40rpx;
			}
		}
		
		.bacimg{
			width: 42rpx;
			height: 42rpx;
			margin: 0 38rpx;
			
		}
	}

.gray-font {
		padding: 20rpx 60rpx;
		padding-bottom: 35rpx;
		color: #999999;
	}

	.title-back {
		background-color: #F7F7F7;
		width: 100%;
		height: 70rpx;
		display: flex;
		justify-content: space-between;
		align-items: flex-end;
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid #cbd1d2;
		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;
		}
	}
	.none {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			display: flex;
			align-items: center;
			flex-direction: column;
			color: #999;
		}
</style>
<style>
	page{
		background: RGBA(247, 247, 247, 1);
	}
</style>