<template>
	<view :style="{height:'100vh',overflow:'hidden'}">
		<u-status-bar></u-status-bar>
		<u-navbar title="问题处理" :autoBack="true" :titleStyle="{
				fontSize:'18px'
			}" :height='44' :safeAreaInsetTop=true leftIconSize='20' leftIconColor='rgb(153, 153, 153)'>
		</u-navbar>
		<view class=""
			style="margin-top: 50px;;background-color: #f0f0f0;border-top: 1px solid #f0f0f0;overflow: auto;">
			<view style="padding:0 10px;backgroundColor:#fff">
				<view class="time-ranger">
					<view class="start-time">
						<text>开始时间</text>
						<text @click="showTime=true" style="margin-left:10%;color:#3399ef">{{startTime}}</text>
					</view>
					<view class="end-time">
						<text>结束时间</text>
						<text @click="showTime1=true" style="margin:0 10%;color:#3399ef">{{endTime}}</text>
						<view class="search-btn" @click="searchTm">
							搜索
						</view>
					</view>
				</view>
			</view>
			<view style="height:calc(100vh - 150px);overflow: auto;" v-if='list.length !== 0'>
				<view class="" v-for="(item,index) in list" :key="index" @click="toDetail(item)"
					style="margin:10px;background-color: #fff;padding: 10px;">
					<view class="item">
						<!-- {{item.title}} -->
						<view class="title">
							{{item.taskTitle}}
						</view>
						<view class="titleRight" >
							<view class="border">
								{{item.isHandle==1?'已处理':'待处理'}}
							</view>
							<u-icon name="arrow-right" size="20"></u-icon>
						</view>
					</view>
					<view class="contentItem">
						<view class="itemC">
							<text>巡检项</text>
							<text>{{item.itemDesc}}</text>
						</view>
						<view class="itemC">
							<text>巡查人</text>
							<text>{{item.inspectUserName}}</text>
						</view>
						<view class="itemC">
							<text>巡查时间</text>
							<text>{{item.finishTime}}</text>
						</view>
					</view>
				</view>
			</view>
			<view style="height:calc(100vh - 150px);display: flex;align-items: center;justify-content: center;background-color: #fff;" v-else>
				<image src="../../../../static/empty.png" mode="" ></image>
			</view>

		</view>
		<u-datetime-picker :show="showTime" v-model="stm" mode="datetime" @confirm="showTime=false"
			@cancel="showTime=false"></u-datetime-picker>
		<u-datetime-picker :show="showTime1" v-model="etm" mode="datetime" @confirm="showTime1=false"
			@cancel="showTime1=false"></u-datetime-picker>
	</view>
</template>

<script>
	import moment from 'moment'

	export default {
		data() {
			return {
				show: false,
				showTime: false,
				showTime1: false,
				minDate:moment().startOf('year').valueOf(),
				maxDate:moment().valueOf(),
				start: '请选择开始时间',
				end: '请选择结束时间',
				stm:moment().startOf('year').format('YYYY-MM-DD'),
				etm:moment().format('YYYY-MM-DD'),
				customStyle: {
					background: '#000'
				},
				list: []
			};
		},
		onLoad() {
			this.getList()
		},
		computed: {
			startTime: function () {

				return this.stm ? moment(this.stm).format('YYYY-MM-DD') : this.start
			},
			endTime: function () {
				return this.etm ? moment(this.etm).format('YYYY-MM-DD') : this.end
			}
		},
		methods: {
			searchTm() {
				this.getList()
			},
			getList() {
				console.log(uni.getStorageSync('value'));
				let params = {
					"pageSo": {
						"pageSize": 999,
						"pageNumber": 1
					},
					"dateTimeRangeSo": {
						start:this.stm?moment(this.stm).format('YYYY-MM-DD 00:00:00'):'',
						end:this.etm?moment(this.etm).format('YYYY-MM-DD 23:59:59'):''
					},
					"isHandle": 1,
					"handleUserId": uni.getStorageSync('value').userId
				}
				uni.$http.post('/gunshiApp/hsz/inspect/detail/page', params).then(res => {
					this.list = res.data.data.records
				})
			},
			confirm(e) {
				console.log(e);
				this.model.start = e[0]
				this.model.end = e[1]
				this.show = false
			},
			cancel() {
				this.show = false
			},
			toDetail(item) {
				uni.navigateTo({
					url: '/pages/mypage/compents/wtcl/detail/index?item=' + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.myTitleStyle {
		font-size: 30px;
		background-color: red;
		height: 200px;
	}

	.tabsClass {
		margin-top: 44px;
		height: 44px;
		padding: 0 40px;
		border-top: 1px solid #eee;
		border-bottom: 1px solid #eee;
	}

	.item {
		border-bottom: 1px solid #f0f0f0;
		padding-bottom: 10px;
		display: flex;
		justify-content: space-between;

		.title {
			border-width: 0px;
			font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑', sans-serif;
			font-weight: 700;
			font-style: normal;
			font-size: 15px;
			color: #666666
		}

		.titleRight {
			display: flex;

			.border {
				border-width: 0px;
				background-color: rgba(236, 245, 255, 1);
				box-sizing: border-box;
				border-width: 1px;
				border-style: solid;
				border-color: rgba(187, 220, 255, 1);
				border-radius: 5px;
				box-shadow: none;
				width: 58px;
				height: 25px;
				color: #689FFF;
				text-align: center;
			}
		}

	}

	.contentItem {
		.itemC {
			display: flex;
			justify-content: space-between;
			display: flex;
			color: #666666;
			padding: 10px;
		}
	}
</style>