<template>
	<view class="in-content">
		<view class="in-table">
			<u-table>
				<u-tr class="u-tr">
					<u-th class="u-th" width="10%">序号</u-th>
					<u-th class="u-th" width="35%">盘点单号</u-th>
					<u-th class="u-th" width="15%">总条目12</u-th>
					<u-th class="u-th" width="20%">已盘条目</u-th>
					<u-th class="u-th" width="20%">盘点人</u-th>
				</u-tr>
				<u-tr class="u-tr" v-for="(item, index) in result" :key="index" :class="invOrderNo===item.invOrderNo?'bg':null">
					<u-td class="u-td" width="10%" >
						<span @click="choosed(item.invOrderNo)">{{ index + 1 }}</span>
					</u-td>
					<u-td class="u-td" width="35%">
						<span @click="choosed(item.invOrderNo)">{{ item.invOrderNo || '-' }}</span>
					</u-td>
					<u-td class="u-td" width="15%">
						<span @click="choosed(item.invOrderNo)">{{ item.totalNumber || '-' }}</span>
					</u-td>
					<u-td class="u-td" width="20%">
						<span @click="choosed(item.invOrderNo)">
							{{ item.finishNumber || '-' }}
						</span>
					</u-td>
					<u-td class="u-td" width="20%" style="width:20%;text-overflow:ellipsis;overflow: hidden;">
						<span @click="choosed(item.invOrderNo)">
							{{ item.invUser || '-' }}
						</span>
					</u-td>
				</u-tr>
			</u-table>
		</view>
		<view class="in-operate">
			<u-button class="in-button" size="medium" @click="refreshPages()">刷新</u-button>
			<u-button size="medium" @click="startImplement()">开始盘点</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				result: [],
				invOrderNo: ''
			}
		},
			
		mounted() {
			this.getList()
		},
		methods: {
			choosed(num) {
				console.log(num)
				console.log('这里没执行')
				this.invOrderNo = num
			},
			// 获取list
			getList() {
				this.$u.api.inventoryPlanning.inventoryPlanningList().then(res => {
					console.log(res)
					if(res.code===200) {
						this.result = res.rows
					} else {
						his.$u.toast(res.msg);
					}
				});
			},
			refreshPages() {
				this.$u.toast("页面已刷新");
			},
			startImplement() {
				this.$u.route({
					url: '/pages/inventory/implement',
					type: 'navigateTo',
					params: {
						invOrderNo: this.invOrderNo
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.in-content {
		display: flex;
		flex-direction: column;

		.in-table {
			padding: 20rpx 30rpx 0 30rpx;
		}

		.in-operate {
			position: fixed;
			bottom: 50rpx;
			left: 15%;

			.in-button {
				margin-right: 50rpx;
			}
		}
	}
	.bg {
		background-color: #e2a622;
	}
</style>
