<template>
	<view>
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">工作安排</block>
		</cu-custom>
		<view>
			<!-- 插入模式 -->
			<uni-calendar class="uni-calendar--hook" :selected="info.selected" :showMonth="false" @change="change" @monthSwitch="monthSwitch" />
		</view>
		<scroll-view scroll-y>
			<view class="cu-bar bg-white solid-bottom margin-top-sm">
				<view class="action">
					本日工作提醒
				</view>
			</view>
			<view class="padding-sm bg-white">
				<view class="cale-item">
					<view class="">
						<text class="cuIcon-title text-blue mr10"></text>
						<text class="text-grey">需进行{{yjcNum}}项隐患排查</text>		
					</view>
					<view class="text-green">
						已完成
					</view>
				</view>
				<view class="cale-item">
					<view class="">
						<text class="cuIcon-title text-blue mr10"></text>
						<text class="text-grey">需进行{{wjcNum}}项隐患排查</text>		
					</view>
					<view class="text-red">
						未完成
					</view>
				</view>
			</view>
			<view class="cu-bar bg-white solid-bottom margin-top-sm">
				<view class="action">
					本日日程安排
				</view>
			</view>
			<view class="padding-sm bg-white">
				<view class="cale-item">
					<view class="">
						<text class="cuIcon-title text-blue mr10"></text>
						<text class="text-grey" v-if="schedule!=null">{{schedule.desc}}</text>	
						<text class="text-grey" v-if="schedule==null">暂无数据</text>
					</view>
				</view>
			</view>
			<view class="margin-top-sm"></view>
		</scroll-view>
	</view>	
</template>

<script>
	import {
		basePath,corpinfoId,loginSession,loginUser
	} from '@/common/tool.js';
	
	export default {
		data() {
			return {
				info: {
					lunar: true,
					range: true,
					insert: false,
					selected: [],
				
				
				},
				rcap:'',
				CDATA:'',
				username:'',
				schedule:[],
				wjcNum:0,
				yjcNum:0
			}
		},
		onLoad(e){
			this.getData(); 
			this.getbrgzData();
			this.username=loginUser.USERNAME;
		},
		methods: {
			change(e) {
				console.log('change 返回:', e)
				// 模拟动态打卡
				// if (this.info.selected.length > 5) return
				// this.info.selected.push({
				// 	date: e.fulldate,
				// 	info: '打卡'
				// })
				this.CDATA= e.fulldate;
				this.getData(); 
			},getData() {
				console.log(this.CDATA)
				var _this = this;
				uni.showLoading({
					title: '请稍候'
				})
				uni.request({
					url: basePath + '/app/schedule/getData',
					method: 'POST',
					dataType: 'json',
					header:{
							'Content-type':'application/x-www-form-urlencoded'
					},
					data: {
						CDATA: this.CDATA,
						USERNAME:loginUser.USERNAME
					},
					success: (res) => {
						console.log('confirm 返回:', res)
						if(res.data.result=="success"){
							if(res.data.varList.length>0){
								_this.schedule=res.data.varList[0];
							}else{
									_this.schedule=null;
							}
							uni.hideLoading();
						}else {
							uni.showToast({
								title: "获取数据失败",
								duration: 2000
							});
						}
					}
				});
			},getbrgzData() {
				var _this = this;
				uni.showLoading({
					title: '请稍候'
				})
				uni.request({
					url: basePath + '/app/listmanager/checkListIndex',
					method: 'POST',
					dataType: 'json',
					header:{
							'Content-type':'application/x-www-form-urlencoded'
					},
					data: {
						tm:new Date().getTime(),
						CORPINFO_ID:loginUser.CORPINFO_ID,
						USER_ID:loginUser.USER_ID,
						DEPARTMENT_ID:loginUser.DEPARTMENT_ID,
					},
					success: (res) => {
						console.log('confirm 返回:', res)
						if(res.data.result=="success"){
							_this.wjcNum=res.data.wjcNum;
							_this.yjcNum=res.data.yjcNum;
							uni.hideLoading();
						}else {
							uni.showToast({
								title: "获取数据失败",
								duration: 2000
							});
						}
					}
				});
			},
			confirm(e) {
				console.log('confirm 返回:', e)
			},
			monthSwitch(e) {
				console.log('monthSwitchs 返回:', e)
			},
			//跳转事件
			goToEdit(e) {
				uni.navigateTo({
					url: '/pages/application/basic-info-manage/basic-information/basic-information-edit'
				});
			},
		}
	}
</script>

<style>
.cu-bar{
	min-height: 86upx;
}
.cale-item{
	display: flex;
	align-items: center;
	justify-content: space-between;
	text-align: left;
	line-height: 2;
}
.cale-item .zt{
	
}
</style>
