<template>
	<view>
		<view style="height:30rpx"></view>
		<view class=" bg-white plan-sec text-center" style="margin:0rpx 30rpx 30rpx 30rpx">
			<view class="plan-tit padding-top-lg">任务名称：ui测试</view>
			<chart :bindData="this.getData" v-if=" JSON.stringify(getData) != '{}'"></chart>
		</view>

		<view class="margin bg-white plan-sec">
			<view class="info-tit margin-left-xs">
				<text class="cuIcon-titles margin-right-xs"></text>
				巡检详情
			</view>
			<view class="cu-list menu-avatar">
				<view class="cu-item deviceTypeItem" v-for="(item,index) in planList" :key="index"
					@tap="goDetailPage(item)">
					<view class="content" style="left:0!important;width:80%">
						<view class="title text-cut" style="display:block">{{item.spot_name}}</view>
					</view>
					<view class="nav-right num">
						<view class="text-grey">
							<span class="online" v-if="item.data3==2">已执行</span>
							<span class="error" v-if="item.data3==1">未执行</span>
							<text class="icon iconfont margin-right-xs ">&#xe629;</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>


</template>

<script>
	import chart from './components/chart.vue';
	import json from '../../../data/json.js';
	export default {
		components: {
			chart
		},
		data() {
			return {
				inspectList: json.xunJianPlan,
				getData: {},
				planList: [],
			};
		},
		onLoad: function(option) {
			this.getPlanList({
				'company_code': uni.getStorageSync('selectedCode'),
				"id":option.id
			})
		},

		methods: {
			// 巡检计划列表数据请求
			async getPlanList(params = {}) {
				const res = await this.$myRequest({
					url: 'Inspection/getInspectionDetails',
					data: params,
					showLoading: true
				})
				this.getData = res.data.data[0];
				this.planList = this.getData.point
			},
			goDetailPage(item) {
				if (item.data3 == 2) {
					uni.navigateTo({
						url: "/pages/xunJian/planDetailDone/planDetailDone?id=" + item.id + '&zb_id=' + this
							.getData.id,
					})
				} else {
					uni.navigateTo({
						url: "/pages/xunJian/planDetail/planDetail?id=" + item.id + '&zb_id=' + this.getData.id,
					})
				}
			}
		}

	}
</script>

<style lang="scss">
	page {
		background-color: #F4F5F7;
	}
</style>
