<template>
	<view>
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true" :isRingt="true">
			<block slot="backText">返回</block>
			<block slot="content">清单排查列表</block>
			<block slot="right">
				<!-- 清单列表扫码 延期解决 -->
				<!-- <view @click="$noMultipleClicks(scan)">扫描</view> -->
			</block>
			<!--			<block slot="right">-->
			<!--				<view class="cuIcon-scan f36" @click="$noMultipleClicks(goToEdit)"></view>-->
			<!--			</block>-->
		</cu-custom>
		<scroll-view scroll-y>
			<view class="spot-list">
				<view class="spot-item" v-for="item in list" :key="item.EQUIPMENT_POINT_ID" @click="$noMultipleClicks(goToList,{
					'FIRE_CHECK_ID':item.FIRE_CHECK_ID,
					'EQUIPMENT_RECORD_ID':item.EQUIPMENT_RECORD_ID,
					'EQUIPMENT_POINT_ID':item.EQUIPMENT_POINT_ID,
					'FIRE_POINT_ID':item.FIRE_POINT_ID,
					'FIRE_DEVICE_ID':item.FIRE_DEVICE_ID,
					'FIRE_DEVICE_TYPE_ID':item.FIRE_DEVICE_TYPE_ID
					})">
					<view class="spot-img">
						<image v-if="item.ISCHECKED=='0'" src="../../../../static/zt-over.png" mode=""></image>
						<image v-else src="../../../../static/zt-ing.png" mode=""></image>
					</view>
					<view class="spot-cont">
						<view class="dy-sub-stitle">
							<text class="text-grey">器材编码: {{ item.FIRE_DEVICE_CODE }}</text>
						</view>
						<view class="dy-sub-stitle">
							<text class="text-grey">器材类型: {{ item.dicName }}</text>
						</view>
						<view class="dy-sub-stitle">
							<text class="text-grey">消防区域: {{ item.FIRE_REGION_NAME }}</text>
						</view>
						<view class="dy-sub-stitle">
							<text class="text-grey">消防点位: {{ item.FIRE_POINT_NAME }}</text>
						</view>
					</view>
					<!-- <view class="spot-right">
						<image src="../../../../static/infocheck.png" mode=""></image>
					</view> -->
				</view>
			</view>
			<view class="cu-tabbar-height"></view>
		</scroll-view>
		<view class="bottom-fixed" @click="$noMultipleClicks(goNext)">
			<button class="cu-btn bg-green">下一步</button>
		</view>
	</view>
</template>

<script>
	import {
		basePath,
		loginUser,
		loginSession
	} from '@/common/tool.js';
	export default {
		data() {
			return {
				noClick: true,
				initflag: false,
				FIRE_RECORD_ID: '',
				FIRE_CHECK_ID: '',
				FIRE_CHECK_TYPE: '',
				PHONE_REPEAT: '',
				ISLOG: '',
				list: [],
				dataFlag: 'noData',
			}
		},
		onLoad(e) {
			this.FIRE_RECORD_ID = e.FIRE_RECORD_ID;
			this.FIRE_CHECK_ID = e.FIRE_CHECK_ID;
			this.FIRE_CHECK_TYPE = e.FIRE_CHECK_TYPE;
			this.PHONE_REPEAT = e.PHONE_REPEAT;
			this.ISLOG = e.ISLOG
			loginSession();
		},
		onShow(e) {
			this.getData()
			var _this = this;
			if (_this.initflag) {
				_this.initflag = false;
				_this.list = [];
			}
		},
		methods: {
			getData() {
				var _this = this;
				uni.showLoading({
					title: '请稍候'
				})
				var path = ''
				if(this.ISLOG == 1) {
					path = '/app/fireRecordManger/getDeviceRecordByPoint'
				}else{
					path = '/app/fireRecordManger/getRiskByPoint'
				}
				uni.request({
					url: basePath + path,
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						FIRE_RECORD_ID: _this.FIRE_RECORD_ID,
						PHONE_REPEAT: _this.PHONE_REPEAT,
						FIRE_CHECK_TYPE: _this.FIRE_CHECK_TYPE,
						FIRE_CHECK_ID: _this.FIRE_CHECK_ID,
						FIRE_PREPARED_ID: _this.FIRE_PREPARED_ID,
						CORPINFO_ID: loginUser.CORPINFO_ID,
						USER_ID: loginUser.USER_ID,
					},
					success: (res) => {
						if ("success" == res.data.result) {
							uni.hideLoading();
							_this.list = res.data.varList;
							_this.PHONE_REPEAT = '1'
						} else {
							uni.showToast({
								icon: 'none',
								title: '系统异常',
								duration: 2000
							});
						}
					}
				});
			},
			//跳转事件
			goToList(e) {
				uni.navigateTo({
					url: '/pages/application/fire-management/hidden-trouble-app/check-items-list?FIRE_CHECK_ID=' +
						e.FIRE_CHECK_ID 
						+"&FIRE_DEVICE_ID=" + e.FIRE_DEVICE_ID 
						+"&EQUIPMENT_RECORD_ID=" + e.EQUIPMENT_RECORD_ID 
						+'&EQUIPMENT_POINT_ID=' + e.EQUIPMENT_POINT_ID 
						+'&FIRE_POINT_ID=' + e.FIRE_POINT_ID
						+'&FIRE_DEVICE_TYPE_ID=' + e.FIRE_DEVICE_TYPE_ID 
						+'&FIRE_RECORD_ID=' + this.FIRE_RECORD_ID
						+'&ISLOG=' + this.ISLOG
				});
			},
			scan() {
				let _this = this;
				uni.scanCode({
					success: function(res) {
						let flag = false;
						let ideId = res.result;
						for (var i = 0; i < _this.list.length; i++) {
							if (_this.list[i].FIRE_RECORD_ID == ideId) {
								flag = true;
								_this.goToList({
									'FIRE_CHECK_STANDARD_ID': _this.list[i].FIRE_CHECK_STANDARD_ID,
									'FIRE_DEVICE_ID': _this.list[i].FIRE_DEVICE_ID,
									'EQUIPMENT_RECORD_ID': _this.list[i].EQUIPMENT_RECORD_ID,
									'FIRE_PREPARED_ID': _this.list[i].FIRE_PREPARED_ID
								});
								break;
							}
						}
						if (!flag) {
							uni.showToast({
								icon: 'none',
								title: "该清单中不含此部位。",
								duration: 2000
							});
						}
					}
				});
			},
			//跳转事件
			goNext(e) {
				for (let i = 0; i < this.list.length; i++) {
					if (this.list[i].ISCHECKED != 0) {
						uni.showToast({
							icon: 'none',
							title: '清单未全部检查,无法提交',
							duration: 3000
						});
						return;
					}
				}
				uni.navigateTo({
					url: '/pages/application/fire-management/hidden-trouble-app/check-items-next?FIRE_CHECK_ID=' +
						this.FIRE_CHECK_ID 
						+ '&FIRE_RECORD_ID=' + this.FIRE_RECORD_ID
						+ '&ISLOG=' + this.ISLOG
				});
			},
		}
	}
</script>

<style>
	.spot-list {}

	.spot-cont {
		width: 250px;
		margin-left: 20upx;
	}

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

	.spot-right {
		margin-left: 125px;
		width: 100upx;
		height: 100upx;
	}

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

	.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>
