<template>
	<view class="container">
		<view style="background-color: #fff;">
			<uni-search-bar bgColor="#F6F6F6 " v-model="searchValue" placeholder="请输入保单信息" @confirm="searchChange"
				cancelButton="none" @clear="searchChange">
			</uni-search-bar>
		</view>
		<z-paging ref="paging" v-model="dataList" @query="getList" :fixed="false" :auto-show-back-to-top="true"
			:empty-view-text="'暂无数据'" :hide-empty-view="false" :auto-show-system-loading="true">
			<view class="list">
				<view class="tab-bar-item" v-for="(item, index) in dataList" :key="index" @click="inEdit(item)">
					<view class="list-item">
						<view style="font-weight: 800;">
							{{item.claimNo}}
						</view>
						<view style="color: #B5B4B4;">
							{{item.submitTime}}
						</view>
					</view>
					<view class="list-item">
						<view style="font-weight: 800;color: #03803B;">
							{{item.vehicleNumber||'暂无车牌'}}
						</view>
						<view class="">
							轮胎规格: {{item.tyreSpecs||'-'}}
						</view>
					</view>
					<view class="list-item-end">
						<view class="">
							轮胎:{{item.tireQuantity||0}}条
						</view>
						<view style="display: flex;align-items: center;color: #03803B;">
							<image style="width: 32rpx;height: 32rpx;margin-right: 18rpx;"
								src="@/static/images/home/claim/ap.png" />
							<text v-if="item.auditStatus==0" style="color:#e6a23c">
								待审核
							</text>
							<text v-if="item.auditStatus==1" style="color:#409EFF">
								审核中
							</text>
							<text v-if="item.auditStatus==2" style="color:#67c23a">
								已通过
							</text>
							<text v-if="item.auditStatus==3" style="color:#f56c6c">
								已拒绝
							</text>
						</view>
					</view>
				</view>
			</view>
		</z-paging>

	</view>
</template>

<script>
	import {
		getList
	} from '@/api/home/claim.js'
	export default {
		data() {
			return {
				searchValue:null,
				dataList: [],
			}
		},
		onLoad() {
		},
		onShow() {
			if (uni.getStorageSync('isUpdate')) {
				this.$nextTick(() => {
					if (this.$refs.paging) {
						this.$refs.paging.reload();
					}
				});
				uni.removeStorageSync('isUpdate')
			}
		},
		filters: {
			statusMap(value) {
				const statusList = ['待审核', '审核中', '已通过', '已拒绝']
				return statusList[value] || '未知状态'
			}
		},
		methods: {
			addDetails() {
				uni.navigateTo({
					url: '/pages/home/claim/details'
				});
			},
			inEdit(row) {
				uni.navigateTo({
					url: '/pages/home/claim/details?id=' + row.id,
				});
			},
			searchChange() {
				this.$refs.paging.reload()
			},
			async getList(pageNo, pageSize) {
				try {
					const obj = {
						current: pageNo,
						size: pageSize,
						claimType:2,
						searchCriteria:this.searchValue
					}
					const res = await getList(obj)
					this.$refs.paging.complete(res.data.records)
				} catch (e) {
					this.$refs.paging.complete(false)
					uni.showToast({
						title: '加载失败',
						icon: 'none'
					})
				}
			},
			goBack() {
				uni.navigateBack({
					delta: 1,
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.scroll-view {
		flex: 1;
		height: 100%;
		/* 关键样式：防止内容被裁剪 */
		overflow-anchor: none;
	}

	.container {
		height: 100vh;
		display: flex;
		flex-direction: column;
	}

	.loading,
	.no-more {
		text-align: center;
		padding: 20px;
		color: #999;
	}

	.uni-lastmsg {
		width: 80rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		display: block;
		/* 需明确设置display */
	}

	.uni-lastmsg2 {
		width: 140rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		display: block;
		/* 需明确设置display */
	}

	.nav-right {
		width: 37rpx;
		height: 42rpx;
	}

	.list {
		width: 100%;

		.tab-bar-item {
			background-color: #fff;
			margin-top: 30rpx;
			padding: 0rpx 62rpx;
			font-size: 28rpx;
			line-height: 32rpx;
			color: #5F5F5F;
			font-weight: 400;

			.list-item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 100%;
				height: 100rpx;
				border-bottom: 2px solid #F6F6F6;
			}

			.list-item-end {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 100%;
				height: 100rpx;
			}
		}
	}
</style>