<template>
	<view class="index-container">
		<z-paging ref="paging" @query="queryList" v-model="dataList" :default-page-size="queryParams.pageSize"
		:auto-show-system-loading="true" empty-view-text="抱歉，暂时还没有相关数据！">
			<template #top>
				<custom-nav-bar :left="true" leftText="" @leftClick="" title="签收单据选择">
				</custom-nav-bar>
				<view class="search">
					<u-search placeholder="请输入单据编号或操作人" @search="onSearchValue" @custom='onSearchValue'
						@clear="onSearchClear" shape="square"></u-search>
				</view>
			</template>
			<!--单据列表-->
			<u-radio-group >
				<template v-for="item in dataList">
					<view class="item-container">
						<view >
							<u-radio activeColor="#35842E" :name="item.billId" @change="onSelect($event,item)" ></u-radio>
						</view>
						<view>
							<view class="text">单据编号：{{item.billCode}}</view>
							<view class="text">单据类型：{{item.billTypeName}}</view>
							<view class="text">操作人：{{item.operUser}}</view>
							<view class="text">操作时间：{{item.billTime}}</view>
						</view>
					</view>
				</template>
			</u-radio-group>
			<template #bottom>
				<!--按钮-->
				<view class="buttons">
					<u-button type="success" text="确认" @click="submit"></u-button>
					<u-button text="取消" @click="cancel"></u-button>
				</view>
			</template>
		</z-paging>
	</view>
</template>

<script>
	import {
		getDeviceBillBriefList
	} from "@/api/system/deviceBill"
	export default {
		data() {
			return {
				dataList: [],
				queryParams: {
					billTypeId: 2002,
					pageNum: 1,
					pageSize: 20,
					searchValue: ""
				},
				selectItem:{},
				selectList: []
			};
		},
		onLoad(options) {
			this.queryParams.billtypeId = options.billtypeId
		},
		methods: {
			queryList(pageNo, pageSize) {
				this.queryParams.pageNum = pageNo;
				getDeviceBillBriefList(this.queryParams).then(res => {
					this.$refs.paging.completeByTotal(res.rows, res.total);
				});
			},
			onSearchValue(e) {
				this.queryParams.deviceCode = e;
				this.queryList(1,20);
			},
			onSearchClear() {
				this.queryParams.deviceCode = null;
				this.queryList(1,20);
			},
			onSelect(e, item) {
				this.selectItem = item;
			},
			submit() {
				uni.$emit("selectBill",this.selectItem);
				this.cancel();
			},
			cancel() {
				uni.navigateBack({delta: 1})
			}
		}
	};
</script>

<style lang="scss">
	.index-container {
		background-color: #F6F3F3;
		height: 100%;

		.flex {
			display: flex;
			align-items: center;
			margin-top: 5px;

			.icon {
				margin: 10px 10px;
			}
		}

		.search {
			background-color: white;
			padding: 10px;
		}

		.list-item {
			margin: 10px 10px;
			padding: 10px;
		}

		.buttons {
			display: flex;
			justify-content: space-between;
			background: white;

			button {
				margin: 20px;
			}
		}

		.item-container {
			background: white;
			width: 100%;
			//height: 100%;
			border-radius: 1px;
			box-shadow: 1px 1px 2px 2px rgba(0, 0, 0, 0.05);
			display: flex;
			margin-top: 1px;

			.check-item {
				margin: 0px 10px;
			}

			.icon {
				margin-right: 5px;
			}

			.text {
				margin-bottom: 5px;
			}

			.flex {
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
			
		}
		.u-radio-group .row{
			display: flex;
			flex-flow:row 
		}
	}
</style>