<template>
	<view>
		<!-- 选择类巡检操作 -->
		<u-checkbox-group size="40" wrap="true" width="690">
			<u-checkbox icon-size="28" label-size="28" shape="circle" active-color="orange" @change="checkboxChange"
				v-model="item.checked" v-for="(item, index) in list" :key="index" :name="item.id">{{item.name}}
			</u-checkbox>
		</u-checkbox-group>
		<!-- <u-toast ref="sacast" /> -->
	</view>
</template>

<script>
	export default {

		props: {
			// 巡检项规则
			options: {
				type: Array
			},
			//拍照选项项目巡检id
			scan_id: {
				type: Number
			},
			
		},
		data() {
			return {
				list: [],
				value: ''
			}
		},
		created() {
			// console.log("option", this.options)
			this.setData()
		},
		methods: {
			//处理选项数据
			setData() {
				this.options.forEach(j => {
					let obj = {}
					obj.name = j.optionName
					obj.id = j.id
					obj.checked = j.defaultSelect
					this.list.push(obj)
				})
			},
			//选中某个复选框时，由checkbox时触发
			checkboxChange(e) {
			},
			//巡检数据处理
			submit() {
			let item = {
				id: this.scan_id,
				value: null
			} //提交数据
			let newarr = JSON.parse(JSON.stringify(this.list))
			newarr.forEach(i => {
				if(i.checked === true) {
					if(item.value) {
						item.value =item.value + "," + `${i.id}`
					} else {
						item.value = `${i.id}`
					}
				}
			})
				this.$store.state.user.items.push(item)
		},
		//重置表单
		reset() {
			this.list = []
		}
	}
	}
</script>

<style>
</style>
