<template>
	<view class="container">
		<tui-list-cell :hover="false" v-for="(item, index) in dataList">
			<view class="fs-flex__between">
				<view>{{item.planNo}}（{{item.currentPlanNum}}）</view>
				<view>完成比例 <tui-text :text="item.totalFinishPercent" type="danger"></tui-text>%</view>
			</view>
			<view class="fs-mt20 fs-align__right">
				<tui-tag v-if="item.totalFinishPercent < 100" type="primary" padding="12rpx 30rpx" shape="circle" plain @click="toAdd(item.planNo, item.currentPlanNum, item.totalFinishPercent)">添加记录</tui-tag>
				<tui-tag type="primary" padding="12rpx 30rpx" margin="0 0 0 20rpx" shape="circle" plain @click="toRecord(item.planNo, item.currentPlanNum)">提交记录</tui-tag>
			</view>
		</tui-list-cell>
	</view>
</template>

<script>
import { apiMaintainSubList, apiInspectionDetail } from '@/api/work'
export default {
	data() {
		return {
			info: {},
			dataList: []
		}
	},
	onLoad(options) {
		this.getList(options.planNo)
		this.getInspectionInfo(options.planNo)
	},
	methods: {
		// 获取次数列表
		getList(planNo) {
			apiMaintainSubList({data:{plan_no:planNo}}).then(res => {
				this.dataList = res.data
			})
		},
		// 获取养护详情
		getInspectionInfo(planNo) {
			apiInspectionDetail({data:{plan_no:planNo}}).then(res => {
				this.info = res.data
			})
		},
		// 跳转记录添加
		toAdd(planNo, currentPlanNum, totalFinishPercent) {
			let path = 'water'
			// switch (this.info.maintainTypeId) {
			// 	case 2:
			// 		path = 'water'
			// 		break
			// 	case 3:
			// 		path = 'trim'
			// 		break
			// 	case 4:
			// 		path = 'prevention'
			// 		break
			// 	case 5:
			// 		path = 'weed'
			// 		break
			// 	case 10:
			// 		path = 'manure'
			// 		break
			// }
			uni.$tui.href(`/pages/work/daily/maintain/${path}?plan_no=${planNo}&current_plan_num=${currentPlanNum}&total_finish_percent=${totalFinishPercent}`)
		},
		// 跳转记录
		toRecord(planNo, currentPlanNum) {
			uni.$tui.href(`/pages/work/daily/maintain/record?plan_no=${planNo}&maintainTypeId=${this.info.maintainTypeId}&current_plan_num=${currentPlanNum}`)
		}
	}
}
</script>

<style lang="scss" scoped>
	
</style>
