<template>
	<!-- 顶部导航栏 -->
	<custom-nav-bar :left="true" leftText="" @leftClick="" title="轮灌详情"></custom-nav-bar>
	<view class="card">
		<uni-collapse>
			<uni-collapse-item title-border="none" :border="false" :show-arrow="false" :open="true"
				v-for="group in groups">
				<template v-slot:title>
					<view class="cards-title">
						<view>
							<view class="text">{{group.groupName}}</view>
						</view>
						<view class="title-r">
							<uni-tag type="default" :circle="true" text="未轮灌" v-if="group.status == 0" />
							<uni-tag type="primary" :circle="true" text="轮灌中" v-else-if="group.status == 1" />
							<uni-tag type="success" :circle="true" text="已完成" v-else-if="group.status == 2" />
							<uni-tag type="warning" :circle="true" text="未知" v-else />
						</view>
					</view>
				</template>
				<view class="content">
					<view class="cards-content">
						<view class="txt-list" @click="rotationrecord">
							<view class="list1">
								<view><text>应浇灌时长：</text>{{group.irrigateDurationPredict}}h</view>
								<view><text>实际浇灌时长：</text>{{group.irrigateDurationActual}}h</view>
								<view><text>开阀时间：</text>{{group.startTime}}</view>
								<view><text>关阀时间：</text>{{group.endTime}}</view>
							</view>
							<view class="right">
								<view class="iconfont icon-you" />
							</view>
						</view>
						<view class="card-font">
							<view>异常设备：1</view>
						</view>
					</view>
				</view>
			</uni-collapse-item>
		</uni-collapse>
	</view>
</template>

<script>
	import * as taskApi from '@/api/irrigate/task.js'

	export default {
		data() {
			return {
				groups: [],
			};
		},
		onLoad(par) {
			uni.showLoading()
			taskApi.getGroupList(par.id).then(res => {
				console.error(res)
				this.groups = res.data;
				uni.hideLoading()
			});
		},
		methods: {
			// 页面跳转
			rotationrecord() {
				uni.navigateTo({
					url: '/pages/irrigation/task/record'
				});
			}
		},

	};
</script>

<style lang="scss" scoped>
	.txt-list .left text:first-child {
		width: 100px;
	}

	.card-font {
		color: #e60012;
	}
</style>