<template>
	<view class="wenjuan-duo u-flex u-col-top">
		<view class="bianhao">
			{{index}}、
		</view>
		<view>
			<view class="timu-text">
				<text>多选</text>
				<text>{{item.quesName}}</text>
			</view>
			<view class="radio-box">
				<u-checkbox-group @change="checkboxGroupChange" :wrap="true">
					<view v-for="(val, key) in checklist" :key="key" v-if="item[val.name]">
						<u-checkbox v-model="val.check" :name="key">
							<text class="item-text">{{item[val.name]}}</text>
						</u-checkbox>
					</view>
				</u-checkbox-group>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			index: {
				type: [Number, String],
				default: 0
			},
			item: {
				type: Object,
				default () {
					return {}
				}
			}
		},
		data() {
			return {
				value: '',
				checked: false,
				checklist: [{
					name: 'answerA',
					check: false
				}, {
					name: 'answerB',
					check: false
				}, {
					name: 'answerC',
					check: false
				}, {
					name: 'answerD',
					check: false
				}, {
					name: 'answerE',
					check: false
				}, {
					name: 'answerF',
					check: false
				}, {
					name: 'answerG',
					check: false
				}]
			}
		},
		onLoad() {

		},
		methods: {
			checkboxGroupChange(e) {
				var arr = []
				e.forEach(val => {
					arr.push(this.item[this.checklist[val].name])
				})
				this.$emit('changecheck',arr)
			}
		}
	}
</script>

<style lang="scss">
	.wenjuan-duo {
		.radio-box {
			margin-top: 20rpx;

			.item-text {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.88);
			}
		}

		.bianhao {
			font-size: 28rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #222222;
			line-height: 44rpx;
		}

		.timu-text {
			text:first-child {
				display: inline-block;
				width: 88rpx;
				line-height: 44rpx;
				background: #167FFF;
				border-radius: 6rpx;
				text-align: center;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
				margin-right: 12rpx;
			}

			text:last-child {
				line-height: 44rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #222222;
			}
		}
	}
</style>