<template>
	<!-- 调拨记录 -->
	<view>
		<u-navbar title="调拨记录" autoBack placeholder></u-navbar>
		<view style="padding-bottom: 30rpx;" v-if="list.length > 0">
			<view class="transfer_card_item" v-for="(item,index) in list" :key="index">
				<view class="title_status" :style="{color:getColor(item.status)}">{{ getstatus(item.status) }}</view>
				<view class="item_title_record1">
					<span>调拨人：</span>
					{{item.allotUser.nickName}}
				</view>
				<view class="item_title_record">
					<span>接收人：</span>
					{{item.acceptUser.nickName}}
				</view>
				<view class="item_title_record">
					<span>调拨时间：</span>
					{{item.createdAt}}
				</view>
				<view class="item_title_record">
					<span>钢瓶编号：</span>
					<span class="examine_title" @click="clickToView(item)">点击查看</span>
				</view>
			</view>
		</view>
		<view style="margin-top: 40%;" v-else>
			<u-empty mode="list" text="暂无调拨记录"></u-empty>
		</view>
		<u-popup :show="innerCodeShow" round="10" @close="close">
			<view>
				<view class="headlinetitle">钢瓶编号</view>
				<view class="card_inner_item" v-for="(item,index) in innerCodeData" :key="index">
					<view class="title_index_item">{{index + 1}}</view>
					<view>{{item}}</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				Pagination: {
					PageIndex: 1,
					PageSize: 20,
					Total: 0,
				},
				loadingMore: true,
				innerCodeShow: false,
				innerCodeData: []
			}
		},
		onReachBottom() {
			if (!this.loadingMore) {
				this.getList()
			}
		},
		mounted() {
			this.getList()
		},
		methods: {
			getList() {
				this.loadingMore = true
				this.$api.get('/api/gas-cylinder-allot', {
					page: this.Pagination.PageIndex,
					pageSize: this.Pagination.PageSize,
				}).then(res => {
					if (res.code == 200) {
						const data = res.data.list
						if (this.loadingMore == true && data) {
							this.list = this.list.concat(data);
						}
						if (data.length < this.Pagination.PageSize) {
							this.loadingMore = true
						} else {
							this.loadingMore = false
							this.Pagination.PageIndex++
						}
					}
				})
			},
			// 点击查看
			clickToView(value) {
				this.innerCodeShow = true
				this.innerCodeData = value.innerCodeList
			},
			getstatus(value) {
				if (value == 1) {
					return '调拨中'
				} else if (value == 2) {
					return '调拨完成'
				} else if (value == 3) {
					return '取消调拨'
				} else if (value == 4) {
					return '超时取消'
				}
			},
			getColor(value) {
				if (value == 1) {
					return '#3c9cff'
				} else if (value == 2) {
					return '#5ac725'
				} else if (value == 3) {
					return '#909399'
				} else if (value == 4) {
					return '#909399'
				}
			},
			close() {
				this.innerCodeShow = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f4f4f5;
	}

	.transfer_card_item {
		position: relative;
		background-color: #fff;
		margin: 30rpx;
		padding: 30rpx;
		border-radius: 10rpx;
	}

	.title_status {
		position: absolute;
		right: 20rpx;
		top: 20rpx;
		display: flex;
		justify-content: flex-end;
		font-size: 28rpx;
	}

	.item_title_record1 {
		font-size: 30rpx;

		span {
			font-size: 28rpx;
			color: #909399;
		}

		.examine_title {
			cursor: pointer;
			color: #2979ff;
		}
	}

	.item_title_record {
		font-size: 30rpx;
		margin-top: 10rpx;

		span {
			font-size: 28rpx;
			color: #909399;
		}

		.examine_title {
			cursor: pointer;
			color: #2979ff;
		}
	}

	.title_index_item {
		color: #909399;
		margin-right: 20rpx;
	}

	.headlinetitle {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 20rpx;
		font-size: 34rpx;
		font-weight: 600;
		border-bottom: 1rpx solid #d7d7d7;
	}

	.card_inner_item {
		display: flex;
		align-items: center;
		padding: 30rpx;
		border-bottom: 1rpx solid #d7d7d7;
	}
</style>