<template>
	<page-meta root-font-size="16px"></page-meta>
	<view class="">
		<view style="view-noData" v-if="itemList.length==0">
			<image class="default_nodata" src="@/static/icons_ui/default_data.png"></image>
		</view>
		<scroll-view class="uni-scroll-view" scroll-y="true">
			<view v-for="(item, index) in itemList" :key="item.id" @click="openDetail(item)">
				<com-tj-deliver :datacontent="item"></com-tj-deliver>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		getJobStatuStyle,
		getJobStatuDesc,
		compare,
		showConfirmMsg,
		goHome,
		getCurrDate,
		toYYYY_MM_DD
	} from '@/common/basic.js';

	import {
		getJisDeliverList,
	} from '@/api/index.js';

	import comTjDeliver from '@/mycomponents/coms/comTjDeliver.vue';
	import comMessage from '@/mycomponents/common/comMessage.vue'
	export default {
		name: 'deliverRandom',
		components: {
			comMessage,
			comTjDeliver
		},
		data() {
			return {
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				pageSize: 100,
				pageIndex: 1,
				itemList: []
			};
		},
		props: {
			// itemList: {
			// 	type: [Array],
			// 	value: []
			// },
			//全部发货
			isDeliverAll: {
				type: Boolean,
				value: false
			}
		},
		filters: {
			statusStyle: function(val) {
				return getJobStatuStyle(val);
			},
			statusColor: function(val) {
				return getJobStatuDesc(val);
			},
		},
		mounted: function() {
			this.getList();
			// console.log('isDeliverAll', this.isDeliverAll == true ? '是' : '否')
		},
		onLoad() {

		},

		// //返回首页
		// onNavigationBarButtonTap(e) {
		// 	if (e.index === 0) {
		// 		goHome();
		// 	}
		// },
		methods: {
			getList() {
				let that = this;
				uni.showLoading({
					title: "加载中....",
					mask: true
				});
				let params = {
					pageSize: that.pageSize,
					pageIndex: that.pageIndex
				};
				getJisDeliverList(params)
					.then(res => {
						console.log('list', res);
						let items = [];
						this.itemList = res.items;
						if (res.items != null) {
							res.items.forEach(item => {
								if (item.details != null && item.details.length > 0) {
									let endIndex = item.details.length - 1;
									item.BeginContainer = item.details[0].containerCode;
									item.EndContainer = item.details[endIndex].containerCode;
								}
							});
						}
						uni.hideLoading();
					})
					.catch(err => {
						console.log('list err', err);
						uni.hideLoading();
					});
			},

			openDetail(item) {
				uni.navigateTo({
					url: './tjDeliver_detail?isDeliverAll=' + this.isDeliverAll + '&id=' + item.id +
						'&jobStatus=' + item.jobStatus
				})
				// uni.navigateTo({
				// 	url: './tjDeliver_detail?id=' + item.masterID + '&jobStatus=' + item.jobStatus
				// })
			},

			showMessage(message) {
				this.$refs.comMessage.showMessage(message);
			},

			upper: function(e) {
				// console.log(e)
			},
			lower: function(e) {
				// console.log(e)
			},
			scroll: function(e) {
				// console.log(e)
				this.old.scrollTop = e.detail.scrollTop;
			},
		}
	};
</script>

<style scoped lang="scss">
	.display-input {
		padding: 5rpx 5rpx;
	}

	/deep/ .input-value {
		font-size: 16px;
	}

	/deep/ .uni-collapse-item__title-text {
		font-size: 16px;
	}
</style>
