<template>
	<view>
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true" :isRingt="true">
			<block slot="backText">返回</block>
			<block slot="content">排查项列表</block>
		</cu-custom>
		<scroll-view scroll-y>
			<view class="spot-list">
				<view class="spot-item" v-for="(item,index) in list" :key="item.CHECKTYPE_ID" @click="$noMultipleClicks(goToList,{
					'CHECKTYPE_ID':item.CHECKTYPE_ID,
					'CHECKTYPE_NAME':item.CHECKTYPE_NAME,
					'WAYBILLREGISTRATION_ID':WAYBILLREGISTRATION_ID,index})">
					<view class="spot-img">
						<image v-if="item.CHECKTYPE_NAME == '出车前'" src="../../../static/driving_before.png"  class="cu-tag " mode=""></image>
						<image v-else-if="item.CHECKTYPE_NAME == '行车中'" src="../../../static/driving.png" mode=""></image>
						<image v-else src="../../../static/driving_affter.png" mode=""></image>
					</view>
					<view class="spot-cont">
						<view class="text f30">
							{{item.CHECKTYPE_NAME}}

						</view>
					</view>
				</view>

			</view>
			<view class="cu-tabbar-height"></view>
		</scroll-view>

	</view>
</template>

<script>
	import {
		basePath,
		loginUser,
	} from '@/common/tool.js';
	import ykAuthpup from "@/components/yk-authpup/yk-authpup"
	export default {
		components: {
			ykAuthpup
		},
		data() {
			return {
				permissionID: '',
				noClick: true,
				initflag: false,
				listId: '',
				status: '',
				pd:[],
				list: [],
				dataFlag: 'noData',
				CHECKRECORD_ID: '',
			}
		},
		onLoad(e) {
			this.WAYBILLREGISTRATION_ID = e.listId;
			this.status = e.status;
			this.getData();
		},
		onShow(e) {
			var _this = this;
			if (_this.initflag) {
				_this.initflag = false;
				_this.list = [];
			}
			this.getData()
		},
		methods: {
			getData() {
				var _this = this;
				uni.showLoading({
					title: '请稍候'
				})
				uni.request({
					url: basePath + '/app/drivingitem/getDrivingItem',
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						USER_NAME: loginUser.NAME,
						CORPINFO_ID: loginUser.CORPINFO_ID,
						USER_ID: loginUser.USER_ID,
						WAYBILLREGISTRATION_ID: _this.WAYBILLREGISTRATION_ID,
					},
					success: (res) => {
						if ("success" == res.data.result) {
							uni.hideLoading();
							_this.list = res.data.varList;
							_this.pd = res.data.pd;

						} else {
							uni.showToast({
								icon: 'none',
								title: '系统异常',
								duration: 2000
							});
						}
					}
				});
			},

			//跳转事件
			goToList(e) {
				const index = e.index
				if((this.pd.WAYBILLSTATUS === '1' || this.pd.WAYBILLSTATUS === '2' || this.pd.IsExist != '0') && index === 0){
					uni.showModal({
						title: '提示',
						cancelText: '确认',
						confirmText: '取消',
						content:'您已经完成出车前检查，无需再次检查',
					});
					return;
				}else if((this.pd.WAYBILLSTATUS === '2' || this.pd.IsExist == '1' || this.pd.IsExist == '0') && index === 1){
					return
				}else if((this.pd.WAYBILLSTATUS === '2' || this.pd.IsExist == '2' || this.pd.IsExist == '0') && index === 2){
					uni.showModal({
						title: '提示',
						cancelText: '确认',
						confirmText: '取消',
						content:'您未进行行车中检查，请按顺序检查',
					});
					return;
				}
				uni.navigateTo({
					url: '/pages/application/driving-inspections/driving-item-check-list?CHECKTYPE_ID=' +
							e.CHECKTYPE_ID + '&CHECKTYPE_NAME=' + e.CHECKTYPE_NAME + '&WAYBILLREGISTRATION_ID=' + e.WAYBILLREGISTRATION_ID
				});
			},


		}
	}
</script>

<style>
	.spot-list {}

	.spot-cont {
		margin-left: 20upx;
		flex: 1;
	}

	.spot-cont .text {
		line-height: 1.4;
	}

	.spot-img {
		width: 100upx;
		height: 100upx;
	}

	.spot-img image {
		width: 100%;
		height: 100%;
	}

	.spot-list .spot-item {
		display: flex;
		align-items: center;
		background-color: #fff;
		border-radius: 10upx;
		margin: 20upx;
		padding: 20upx;
	}
</style>
