<template>
	<uni-popup ref="popupItems">
		<com-popup @onClose="closePopup">
			<view class="">
				<view class="uni-center"  style="font-size: 40rpx;margin-top: 10rpx;margin-bottom: 10rpx;">
					选择零件
				</view>
				<u-line/>
				<view style="margin: 20rpx;" v-for="(item, index) in showList" :key="index" >
					<view class="" style="padding: 10rpx;" @click="selectItem(item)">
						零件: {{item.itemCode}}
					</view>
					<u-line/>
				</view>
			</view>
			<view class="flex uni-center" style="width: 100%;justify-content: center;margin-top: 10rpx;margin-bottom: 10rpx;" >
				<view class="">
					当前页：{{ pageCurrent }}，数据总量：{{ total }}条，每页数据：{{ pageSize }}
				</view>
				
			</view>
			<view class="">
				<uni-pagination :page-size="pageSize" :current="pageCurrent" :total="total" @change="change" />
			</view>
			
			
		</com-popup>
	</uni-popup>
</template>

<script>
	
	import {
		getProductionlineItem,
		getCustomerItemList
	} from '@/api/request2.js';
	import comPopup from '@/mycomponents/common/comPopup.vue'
	export default {
		emits: ["selectedItem"],
		components: {
			comPopup,
		},
		props: {

		},
		data() {
			return {
				showList: [],
				pageCurrent:1,
				pageSize:10,
				total:0
				
			}
		},
		methods: {
			queryList(lineCode){
				var filters =[]
				filters.push({
					column: "customerCode",
					action: "==",
					value: lineCode
				})
				
				var params = {
					filters: filters,
					pageNo: this.pageCurrent,
					pageSize: this.pageSize,
				}
				getCustomerItemList(params).then(res => {
					if (res.data != null && res.data.list.length > 0) {
						this.showList = res.data.list;
						this.total = res.data.total;
						this.$forceUpdate()
						this.$refs['popupItems'].open("center");
					} else {
						//没有查询到生产线对应的零件信息
						// this.showErrorMessage('未查找到生产线【' + lineCode + '】对应的零件');
						this.$refs['popupItems'].open("center");
					}
				}).catch(error => {
					// this.showErrorMessage(error);
				})
			},
			openPopup(items) {
				this.showList = items;
				this.$refs['popupItems'].open("center");
			},
			closePopup() {
				this.$refs.popupItems.close()
			},
			selectItem(item) {
				this.$emit("selectedItem", item);
				this.$refs['popupItems'].close();
			},
			change(e){
				this.pageCurrent = e.current
				console.log("分页",e.current)
			}
			
		}
	}
</script>

<style>
	.fixed-bottom {
	  position: fixed;
	  bottom: 0;
	  width: 100%;
	  text-align: center;
	  background-color: #fff;
	  padding: 10px 0;
	  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
	}
</style>
