<template>
	<view>
		<uni-list >
			<!-- 垂直排列，无略缩图，主标题+副标题显示 -->
			<view @click="check(item)" v-for="(item, index) in dataList" :key="item.checklistId">
				<uni-list-item direction="column">
					<template v-slot:header>
						<view class="uni-title">{{item.checklistTitle}}</view>
					</template>
				</uni-list-item>
			</view>
		</uni-list>
	</view>
</template>

<script>
	import { getCheckList, getCheckTaskView } from '@/api/entRiskPoint.js'
	import { createCheckTask } from '@/api/checkRecord.js'
	export default {
		data() {
			return {
				dataList: [],
				queryConditions: {
					page: 1,
					limit: 10,
					total: 0,
					keywords: '',
					riskPointId: ''
				},
				formData: {
					taskId: '',
					taskTitle: '扫码巡检任务',
					riskPointId: '',
					taskCatId: '',
					taskPriority: 2,
					taskTypeId: 3, // 扫码巡检任务
					taskDesc: '扫码巡检任务',
					checklistId: ''
				}
			}
		},
		onLoad(options) {
			this.queryConditions.riskPointId = options.id
			this.getData();
		},
		methods: {
			getData() {
				getCheckList(this.queryConditions).then((resp) => {
					const { code, data, count } = resp
					if (code === 0) {
						this.queryConditions.total = count
						this.dataList = data
					}
				}).catch((error) => {
					console.log(error)
				})
			},
			check(item) {
				this.formData.riskPointId = item.riskPointId
				this.formData.checklistId = item.checklistId
				this.formData.checklistTypeId = item.checklistTypeId
				// //插入Task 表
				createCheckTask(this.formData).then((resp) => {
					console.log("创建新任务记录")
					const { code, msg, data } = resp
					if (code === 0) {
						let riskPointId=item.riskPointId;
						let taskId=data.taskId;
						console.log({
							"跳转到检查表":[{taskId,riskPointId}]
						})
						//跳转到检查表--
						uni.reLaunch({
							url: `/views/entRiskPointCheck/table?taskId=${taskId}&riskPointId=${riskPointId}`
						});
					}
				}).catch((error) => {
					console.log(error)
				})

			},

		}

	}
</script>

<style>

</style>
