<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>
		</cu-custom>
		<block>
			<scroll-view class="dy-scroll-nobg" @scrolltolower="scrolltolower" scroll-y
				:style="'top:'+sTop+'px;height:calc(100vh - '+totalHeight+'px)'">
				<view v-if="list.length>0">
					<view class="dy-card" v-for="item in list" :key="item.FIRE_RECORD_ID"
						@click="$noMultipleClicks(goToList,{FIRE_RECORD_ID:item.FIRE_RECORD_ID,
						FIRE_CHECK_ID:item.FIRE_CHECK_ID,FIRE_CHECK_TYPE:item.FIRE_CHECK_TYPE,PHONE_REPEAT:item.PHONE_REPEAT,ISLOG:'1'})">
						<view class="dy-card-title">
							<text><text v-if="item.USER_ID == loginUserId"
									style="margin-right: 10upx;color: #07BB07;">★</text>{{item.FIRE_CHECK_STANDARD_NAME}}</text>
							<text class="cuIcon-right f30 text-gray"></text>
						</view>
						<view class="dy-card-content">
							<view class="dy-sub-stitle">
								<text class="text-grey">负责部门：{{item.DEPARTMENT}}</text>
								<text class="text-grey">负责人：{{item.USERNAME}}</text>
							</view>
							<view class="dy-sub-stitle">
								<text class="text-grey">涉及点位数：{{item.ITEMCOUNT}}</text>
								<text class="text-grey">排查周期：{{item.BIANMA}}</text>
							</view>
							<view class="dy-stitle">
								<text v-if="item.FIRE_CHECK_TYPE !== 'checkPeriod0001' "
									class="text-grey">检查周期：{{item.PERIODSTART.split(" ")[0]}} ~ {{item.PERIODEND.split(" ")[0]}}</text>
								<text v-else class="text-grey">检查周期：{{item.PERIODSTART.split(" ")[0]}}</text>
							</view>
							<view class="dy-stitle">
								<text class="text-grey">检查时间：{{item.CHECK_TIME}}</text>
							</view>
						</view>
					</view>
				</view>
				<view v-else-if="dataFlag=='noData'" class="dy-null">
					<view class="dy-null-img">
						<image :src="background[dataFlag].url" mode=""></image>
					</view>
					<view class="dy-null-title">
						{{background[dataFlag].msg}}
					</view>
				</view>
				<!-- <view class="cu-tabbar-height"></view> -->
			</scroll-view>
		</block>
	</view>
</template>

<script>
	import {
		basePath,
		loginUser,
		loginSession
	} from '@/common/tool.js';
	export default {
		data() {
			return {
				CHECK_NAME: '',
				FIRE_CHECK_ID: '',
				noClick: true,
				initflag: false,
				sTop: 0,
				totalHeight: 0,
				TabCur: 0,
				scrollLeft: 0,
				loading: false,
				list: [],
				totalList: [],
				page: 1,
				rows: 1000,
				totalCount: 0,
				isEnd: false,
				total: 0,
				dataFlag: 'noData',
				isIndex: 0,
				loginUserId: '',
			}
		},
		onLoad: function(e) {
			let that = this;
			that.showCount = 10;
			that.currentPage = 1;
			this.loginUserId = loginUser.USER_ID;
			this.background = require('@/common/background.json');
			this.CHECK_NAME = e.FIRE_CHECK_NAME
			this.FIRE_CHECK_ID = e.FIRE_CHECK_ID
			setTimeout(function() {
				that.loading = true
			}, 500)
			this.getDataList()
		},
		onReady() {

		},
		onShow() {},
		methods: {
			getDataList() {
				var _this = this;
				if (_this.isEnd) {
					return
				}
				uni.showLoading({
					title: '加载中'
				})

				uni.request({
					url: basePath + '/app/fireRecordManger/getCheckRecordListByCheck?showCount=' + _this.showCount + '&currentPage=' + _this
						.currentPage,
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						USER_ID: loginUser.USER_ID,
						FIRE_CHECK_ID: _this.FIRE_CHECK_ID,
					},
					success: (res) => {
						_this.totalPage = res.data.page.totalPage;
						if ("success" == res.data.result) {
							uni.hideLoading();
							if (_this.list.length == 0) {
								_this.list = res.data.varList;
							} else {
								if (res.data.varList != null) {
									_this.list2 = res.data.varList;
									_this.list = _this.list.concat(_this.list2);
								}
							}
							// _this.list = res.data.varList;
							// _this.totalList = res.data.varList;
						} else {
							uni.showToast({
								icon: 'none',
								title: '系统异常',
								duration: 2000
							});
						}
					}
				})
			},
			// 滑动到底方法
			scrolltolower() {
				console.log("到底了")
				var _this = this;
				_this.currentPage = _this.currentPage + 1;
				_this.isEnd = false;
				if (_this.totalPage >= _this.currentPage) {
					_this.getDataList(); //开始分页查询
				}
			},
			goToList({
				FIRE_RECORD_ID,
				FIRE_CHECK_ID,
				FIRE_CHECK_TYPE,
				PHONE_REPEAT,
				ISLOG
			}) {
				uni.navigateTo({
					url: '/pages/application/fire-management/hidden-trouble-app/hidden-trouble-spot?FIRE_RECORD_ID=' +
						FIRE_RECORD_ID +
						'&FIRE_CHECK_ID=' + FIRE_CHECK_ID +
						'&FIRE_CHECK_TYPE=' + FIRE_CHECK_TYPE +
						'&PHONE_REPEAT=' + PHONE_REPEAT +
						'&ISLOG=' + ISLOG
				});
			},
		}

	}
</script>

<style>
	.dy-list {
		background: #fff;
		margin-top: 2upx;
	}

	.dy-card {
		background-color: #fff;
		border-radius: 10upx;
		margin: 30upx
	}

	.dy-stitle {
		margin: 16upx 0;
	}

	.dy-sub-stitle {
		margin: 16upx 0;
		display: flex;
		justify-content: space-between;
	}

	.dy-card-title {
		display: flex;
		justify-content: space-between;
		border-bottom: 1px solid #eee;
		min-height: 80upx;
		line-height: 80upx;
		padding: 0 30upx;
	}

	.dy-card-content {
		padding: 0upx 30upx 30upx;

	}
</style>
