<template>
	<view class="page">
		<cu-custom bgColor="bg-gradual-blueness">
			<block slot="content">工作</block>
		</cu-custom>
		<view class="top-fixed">
			<scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft">
				<view class="cu-item" :class="index==TabCur?'text-blue cur':''" v-for="(item,index) in tabNav" :key="index" @tap="tabSelect" :data-id="index">
					{{tabNav[index]}}
				</view>
			</scroll-view>
			<view class="line"></view>
		</view>
		<block v-if="TabCur==0">
			<scroll-view class="dy-scroll" @scrolltolower="scrolltolower" scroll-y :style="'top:'+sTop+'px;height:calc(100vh - '+totalHeight+'px)'">
				<view v-if="total>0" class="dy-list">		
					<view v-for="(item,index) of list1" :key="index" :data-id="item.HIDDEN_ID" class="dy-list-item p201 arrow" @click="$noMultipleClicks(gotDetail,item.HIDDEN_ID)">
						<view class="dy-title-flex">
							<text v-if="item.HIDDENDESCR">{{item.HIDDENDESCR.length>15?item.HIDDENDESCR.substr(0,15)+'...':item.HIDDENDESCR}}</text>
							<text v-else>暂无</text>
							<text v-if="item.HIDDENLEVEL=='hiddenLevel0001'" class="cu-tag radius bg-yellow light">{{item.HIDDENLEVELNAME}}</text>
							<text v-else-if="item.HIDDENLEVEL=='hiddenLevel0002'" class="cu-tag radius bg-red light">{{item.HIDDENLEVELNAME}}</text>
						</view>
						<view class="dy-subtitle">
							<text v-if="item.SOURCE=='1'">来源：隐患快报</text>
							<text v-else-if="item.SOURCE=='2'">来源：隐患排查</text>
						</view>
						<view class="dy-subtitle-flex">
							<text>整改人：{{item.RECTIFICATIONORNAME?item.RECTIFICATIONORNAME:'暂无'}}</text>
							<text class="text-gray f20">{{item.RECTIFICATIONTIME}}</text>
						</view>
					</view>
				</view>
				<view v-else-if="dataFlag=='noData'" class="dy-null">
				    <view class="dy-null-img">
						<image src="../../static/null.png" mode=""></image>
				    </view>
				    <view class="dy-null-title">
						暂无数据
				    </view>
				</view>
				<view class="cu-tabbar-height"></view>
			</scroll-view>
		</block>
		<block v-else-if="TabCur==1">
			<scroll-view class="dy-scroll" @scrolltolower="scrolltolower" scroll-y :style="'top:'+sTop+'px;height:calc(100vh - '+totalHeight+'px)'">
				<view v-if="total>0" class="dy-list">		
					<view v-for="(item,index) of list2" :key="index" :data-id="item.HIDDEN_ID" class="dy-list-item p201 arrow" @click="$noMultipleClicks(gotRectify,item.HIDDEN_ID)">
						<view class="dy-title-flex">
							<text v-if="item.HIDDENDESCR">{{item.HIDDENDESCR.length>15?item.HIDDENDESCR.substr(0,15)+'...':item.HIDDENDESCR}}</text>
							<text v-else>暂无</text>
							<text v-if="item.HIDDENLEVEL=='hiddenLevel0001'" class="cu-tag radius bg-yellow light">{{item.HIDDENLEVELNAME}}</text>
							<text v-else-if="item.HIDDENLEVEL=='hiddenLevel0002'" class="cu-tag radius bg-red light">{{item.HIDDENLEVELNAME}}</text>
						</view>
						<view class="dy-subtitle">
							<text v-if="item.SOURCE=='1'">来源：隐患快报</text>
							<text v-else-if="item.SOURCE=='2'">来源：隐患排查</text>
						</view>
						<view class="dy-subtitle-flex">
							<text>整改人：{{item.RECTIFICATIONORNAME?item.RECTIFICATIONORNAME:'暂无'}}</text>
							<text class="text-gray f20">{{item.RECTIFICATIONTIME}}</text>
						</view>
					</view>
				</view>
				<view v-else-if="dataFlag=='noData'" class="dy-null">
				    <view class="dy-null-img">
						<image src="../../static/null.png" mode=""></image>
				    </view>
				    <view class="dy-null-title">
						暂无数据
				    </view>
				</view>
				<view class="cu-tabbar-height"></view>
			</scroll-view>
		</block>
		<block v-else-if="TabCur==2">
			<scroll-view class="dy-scroll" @scrolltolower="scrolltolower" scroll-y :style="'top:'+sTop+'px;height:calc(100vh - '+totalHeight+'px)'">
				<view v-if="total>0" class="dy-list">	
					<view v-for="(item,index) of list3" :key="index" :data-id="item.HIDDEN_ID" class="dy-list-item p201 arrow" @click="$noMultipleClicks(gotReview,item.HIDDEN_ID)">
						<view class="dy-title-flex">
							<text v-if="item.HIDDENDESCR">{{item.HIDDENDESCR.length>15?item.HIDDENDESCR.substr(0,15)+'...':item.HIDDENDESCR}}</text>
							<text v-else>暂无</text>
							<text v-if="item.HIDDENLEVEL=='hiddenLevel0001'" class="cu-tag radius bg-yellow light">{{item.HIDDENLEVELNAME}}</text>
							<text v-else-if="item.HIDDENLEVEL=='hiddenLevel0002'" class="cu-tag radius bg-red light">{{item.HIDDENLEVELNAME}}</text>
						</view>
						<view class="dy-subtitle">
							<text v-if="item.SOURCE=='1'">来源：隐患快报</text>
							<text v-else-if="item.SOURCE=='2'">来源：隐患排查</text>
						</view>
						<view class="dy-subtitle-flex">
							<text>整改人：{{item.RECTIFICATIONORNAME?item.RECTIFICATIONORNAME:'暂无'}}</text>
							<text class="text-gray f20">{{item.RECTIFICATIONTIME}}</text>
						</view>
					</view>
				</view>
				<view v-else-if="dataFlag=='noData'" class="dy-null">
				    <view class="dy-null-img">
						<image src="../../static/null.png" mode=""></image>
				    </view>
				    <view class="dy-null-title">
						暂无数据
				    </view>
				</view>
				<view class="cu-tabbar-height"></view>
			</scroll-view>
		</block>
		<block v-else-if="TabCur==3">
			<scroll-view class="dy-scroll" @scrolltolower="scrolltolower" scroll-y :style="'top:'+sTop+'px;height:calc(100vh - '+totalHeight+'px)'">
				<view v-if="total>0" class="dy-list">	
					<view v-for="(item,index) of list4" :key="index" :data-id="item.HIDDEN_ID" class="dy-list-item p201 arrow" @click="$noMultipleClicks(gotCheck,item.HIDDEN_ID)">
						<view class="dy-title-flex">
							<text v-if="item.HIDDENDESCR">{{item.HIDDENDESCR.length>15?item.HIDDENDESCR.substr(0,15)+'...':item.HIDDENDESCR}}</text>
							<text v-else>暂无</text>
							<text v-if="item.HIDDENLEVEL=='hiddenLevel0001'" class="cu-tag radius bg-yellow light">{{item.HIDDENLEVELNAME}}</text>
							<text v-else-if="item.HIDDENLEVEL=='hiddenLevel0002'" class="cu-tag radius bg-red light">{{item.HIDDENLEVELNAME}}</text>
						</view>
						<view class="dy-subtitle">
							<text v-if="item.SOURCE=='1'">来源：隐患快报</text>
							<text v-else-if="item.SOURCE=='2'">来源：隐患排查</text>
						</view>
						<view class="dy-subtitle-flex">
							<text>整改人：{{item.RECTIFICATIONORNAME?item.RECTIFICATIONORNAME:'暂无'}}</text>
							<text class="text-gray f20">{{item.RECTIFICATIONTIME}}</text>
						</view>
					</view>
				</view>
				<view v-else-if="dataFlag=='noData'" class="dy-null">
				    <view class="dy-null-img">
						<image src="../../static/null.png" mode=""></image>
				    </view>
				    <view class="dy-null-title">
						暂无数据
				    </view>
				</view>
				<view class="cu-tabbar-height"></view>
			</scroll-view>
		</block>
		<block v-else-if="TabCur==4">
			<scroll-view class="dy-scroll" @scrolltolower="scrolltolower" scroll-y :style="'top:'+sTop+'px;height:calc(100vh - '+totalHeight+'px)'">
				<view v-if="total>0" class="dy-list">	
					<view v-for="(item,index) of list5" :key="index" :data-id="item.HIDDEN_ID" class="dy-list-item p201 arrow" @click="$noMultipleClicks(gotDetail,item.HIDDEN_ID)">
						<view class="dy-title-flex">
							<text v-if="item.HIDDENDESCR">{{item.HIDDENDESCR.length>15?item.HIDDENDESCR.substr(0,15)+'...':item.HIDDENDESCR}}</text>
							<text v-else>暂无</text>
							<text v-if="item.HIDDENLEVEL=='hiddenLevel0001'" class="cu-tag radius bg-yellow light">{{item.HIDDENLEVELNAME}}</text>
							<text v-else-if="item.HIDDENLEVEL=='hiddenLevel0002'" class="cu-tag radius bg-red light">{{item.HIDDENLEVELNAME}}</text>
						</view>
						<view class="dy-subtitle">
							<text v-if="item.SOURCE=='1'">来源：隐患快报</text>
							<text v-else-if="item.SOURCE=='2'">来源：隐患排查</text>
						</view>
						<view class="dy-subtitle-flex">
							<text>整改人：{{item.RECTIFICATIONORNAME?item.RECTIFICATIONORNAME:'暂无'}}</text>
							<text class="text-gray f20">{{item.RECTIFICATIONTIME}}</text>
						</view>
					</view>
				</view>
				<view v-else-if="dataFlag=='noData'" class="dy-null">
				    <view class="dy-null-img">
						<image src="../../static/null.png" mode=""></image>
				    </view>
				    <view class="dy-null-title">
						暂无数据
				    </view>
				</view>
				<view class="cu-tabbar-height"></view>
			</scroll-view>
		</block>
		<block v-else-if="TabCur==5">
			<scroll-view class="dy-scroll" @scrolltolower="scrolltolower" scroll-y :style="'top:'+sTop+'px;height:calc(100vh - '+totalHeight+'px)'">
				<view v-if="total>0" class="dy-list">	
					<view v-for="(item,index) of list6" :key="index" :data-id="item.HIDDEN_ID" class="dy-list-item p201 arrow" @click="$noMultipleClicks(gotDetail,item.HIDDEN_ID)">
						<view class="dy-title-flex">
							<text v-if="item.HIDDENDESCR">{{item.HIDDENDESCR.length>15?item.HIDDENDESCR.substr(0,15)+'...':item.HIDDENDESCR}}</text>
							<text v-else>暂无</text>
							<text v-if="item.HIDDENLEVEL=='hiddenLevel0001'" class="cu-tag radius bg-yellow light">{{item.HIDDENLEVELNAME}}</text>
							<text v-else-if="item.HIDDENLEVEL=='hiddenLevel0002'" class="cu-tag radius bg-red light">{{item.HIDDENLEVELNAME}}</text>
						</view>
						<view class="dy-subtitle">
							<text v-if="item.SOURCE=='1'">来源：隐患快报</text>
							<text v-else-if="item.SOURCE=='2'">来源：隐患排查</text>
						</view>
						<view class="dy-subtitle-flex">
							<text>整改人：{{item.RECTIFICATIONORNAME?item.RECTIFICATIONORNAME:'暂无'}}</text>
							<text class="text-gray f20">{{item.RECTIFICATIONTIME}}</text>
						</view>
					</view>
				</view>
				<view v-else-if="dataFlag=='noData'" class="dy-null">
				    <view class="dy-null-img">
						<image src="../../static/null.png" mode=""></image>
				    </view>
				    <view class="dy-null-title">
						暂无数据
				    </view>
				</view>
				<view class="cu-tabbar-height"></view>
			</scroll-view>
		</block>
	</view>
</template>

<script>
	import {
		basePath,deptId,loginUserId
	} from '@/common/tool.js';
	export default {
		data() {
			return {
				sTop:0,
				totalHeight:0,
				TabCur: 0,
				scrollLeft: 0,
				tabNav: ['未提交', '待整改', '待复查', '已复查', '已验收', '已超期'],
				page: 1,
				rows: 10,
				totalCount:0,
				isEnd: false,
				total:0,
				varList:[],
				noClick:true,
				dataFlag:'noData',
				list1:[],
				list2:[],
				list3:[],
				list4:[],
				list5:[],
				list6:[],
				initflag:false
			}
		},		
		mounted(){
			this.getData();
			console.info(1)
			let that=this;
			let CustomBar = this.CustomBar;
			uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
				success(res) { //成功回调函数
					let titleH=uni.createSelectorQuery().select(".top-fixed"); //想要获取高度的元素名（class/id）
					titleH.boundingClientRect(data=>{
						console.info(data.height)
						that._data.sTop=data.height  //计算高度：元素高度=窗口高度-元素距离顶部的距离（data.top）
						that.totalHeight = data.height+CustomBar
					}).exec()
				}
			})
		},
		onReady() {
			
		},
		filters: {
			formatDate(time) {
				time = time * 1
				let date = new Date(time)
				return formatDate(date, 'yyyy-MM-dd')
			},
			formatFileSize(size) {
				return formatFileSize(size);
			}
		},
		methods: {
			getData() {
				var _this = this;
				
					if (_this.isEnd) {
						return
					}
					uni.showLoading({
						title: '请稍候'
					});
					let DISPOSESTATE = 0;
					if(_this.TabCur == 1){
						DISPOSESTATE = 2;
					} else if(_this.TabCur == 2){
						DISPOSESTATE = 1;
					} else if(_this.TabCur == 3){
						DISPOSESTATE = 3;
					}
					uni.request({
						url: basePath + '/app/hidden/list',
						method: 'POST',
						dataType: 'json',
						header:{
							'Content-type':'application/x-www-form-urlencoded'
						},
						data: {
							tm:new Date().getTime(),
							STATE:_this.TabCur,
							showCount:_this.rows,
							currentPage:_this.page,
							totalResult:_this.total,
							DISPOSESTATE:DISPOSESTATE,
							USERDEPT:deptId,
							SELFUSERID:loginUserId
						},
						success: (res) => {
							// console.info(res.data);
							if (res.data.result == 'success') {
								console.info(res.data);
								uni.hideLoading();
								_this.total = res.data.page.totalResult;
								if (_this.totalCount < res.data.page.totalResult) {
									var content = res.data.varList;
									if(_this.TabCur==0){
										_this.list1 = _this.list1.concat(content);
									} else if(_this.TabCur==1){
										_this.list2 = _this.list2.concat(content);
									} else if(_this.TabCur==2){
										_this.list3 = _this.list3.concat(content);
									} else if(_this.TabCur==3){
										_this.list4 = _this.list4.concat(content);
									} else if(_this.TabCur==4){
										_this.list5 = _this.list5.concat(content);
									} else if(_this.TabCur==5){
										_this.list6 = _this.list6.concat(content);
									}
									_this.page++;
									_this.totalCount += content.length;
								} else {
									_this.isEnd = true
								}
								
							} else {
								uni.showToast({
									title: res.data.message,
									duration: 2000
								});
							}
						}
					});
				
			},			
			getQuery(){
				var _this = this;
				_this.page = 1;
				_this.isEnd = false;
				_this.totalCount = 0;
				_this.total =0;
				if(_this.TabCur==0) {
					_this.list1 = [];
					_this.getData()
				}else if(_this.TabCur==1){
					_this.list2 = [];
					_this.getData()
				} else if(_this.TabCur==2){
					_this.list3 = [];
					_this.getData()
				} else if(_this.TabCur==3){
					_this.list4 = [];
					_this.getData()
				} else if(_this.TabCur==4){
					_this.list5 = [];
					_this.getData()
				} else if(_this.TabCur==5){
					_this.list6 = [];
					_this.getData()
				}
			},
			getlist() {
				var _this = this;
					_this.page = 1;
					_this.isEnd = false;
					_this.totalCount = 0;
					_this.total =0;
					console.info(_this.TabCur);
					if(_this.TabCur==0) {
						_this.list1 = [];
						_this.getData()
					}else if(_this.TabCur==1){
						_this.list2 = [];
						_this.getData()
					} else if(_this.TabCur==2){
						_this.list3 = [];
						_this.getData()
					} else if(_this.TabCur==3){
						_this.list4 = [];
						_this.getData()
					} else if(_this.TabCur==4){
						_this.list5 = [];
						_this.getData()
					} else if(_this.TabCur==5){
						_this.list6 = [];
						_this.getData()
					}
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
				this.getQuery();
			},
			//跳转事件
			gotRectify(e) {
				uni.navigateTo({
					url: '/pages/works/hidden-danger/hidden-danger-rectify?id='+e,
				});
			},
			//跳转事件
			gotReview(e) {
				uni.navigateTo({
					url: '/pages/works/hidden-danger/hidden-danger-review?id='+e,
				});
			},
			//跳转事件
			gotCheck(e) {
				uni.navigateTo({
					url: '/pages/works/hidden-danger/hidden-danger-check?id='+e,
				});
			},
			//跳转事件
			gotDetail(e) {
				uni.navigateTo({
					url: '/pages/works/hidden-danger/hidden-danger-details?id='+e,
				});
			},
			scrolltolower(){
				this.getData();
			}	
		}
	}
</script>

<style>
</style>
