<template>
	<view class="userinform">
		<view class="userItem">
			<u-collapse :value="item.index" accordion v-for="(item, index) in regimeEnumdata" :key="item.index">
				<u-collapse-item :name="item.index" :title="item.name">
					<view class="singleChoice" >
						<u-radio-group  v-model="form[item.key]"  placement="column" @change="(arr)=>addgroup(arr,item.index)">
							<u-radio :customStyle="{marginBottom: '8px'}" v-for="(items, indexs) in item.dataList"
								iconPlacement="left" size="40" labelSize="24" :key="index" :label="items.name" :name="items.value" >
							</u-radio>
						</u-radio-group>
					</view>
				</u-collapse-item>
			</u-collapse>
		</view>
	</view>
</template>

<script>
	import {
		regimeEnum
	} from './enum.js';
	import {
		mapMutations,
		mapGetters
	} from 'vuex';
	export default {
		data() {
			return {
				regimeEnumdata: regimeEnum,
				form: {
					guarderValue: 0,
					guarderScheme: 0,
                    guarderSchemeDetail: undefined,
					buildingValue:0,
					buildingScheme:0,
					buildingSchemeDetail:undefined,
					fireValue:0,
					fireScheme:0,
					fireSchemeDetail:undefined,
					dangerousValue:0,
					dangerousScheme:0,
					dangerousSchemeDetail:undefined,
					conflictValue:0,
					conflictScheme:0,
					conflictSchemeDetail:undefined,
					guarderPMIValue:0,
					guarderPMIScheme:0,
					guarderPMISchemeDetail:undefined,
					
					securityValue:0,
					securityServiceScheme:0,
					securityServiceSchemeDetail:undefined,
					criminalValue:0,
					criminalCase:0,
					criminalCaseDetail:undefined,
									
				},

			};
		},
		created() {
			this.form = this.daily
		},
		computed: {
			// 取数据/
			...mapGetters({
				// 三色预警数据
			   daily: 'daily/getdailyinspection',
			})
		},
		mounted() {},
		methods: {
			// 存vuex数据
			...mapMutations({
				dailyinspectionList: 'daily/dailyinspectionList'
			}),
			addgroup(arr, index) {
				console.log(arr,index);
				let names = '';
				let conuts = 0;
				if (arr && arr!=0) {
					const dataLists = this.regimeEnumdata[index].dataList
					const _list = dataLists.filter(item => arr == item.value)
					names = _list.map(e => e.name).join(',')
					conuts = _list.map(e => e.num).reduce((a, b) => a + b)
				}
				switch (index) {
					case 0:
						this.form.guarderSchemeDetail = names;
						this.form.guarderScheme = conuts;
						break;
					case 1:
						this.form.buildingSchemeDetail = names;
						this.form.buildingScheme = conuts;
						break;
					case 2:
						this.form.fireSchemeDetail = names;
						this.form.fireScheme = conuts;
						break;
					case 3:
						this.form.dangerousSchemeDetail = names;
						this.form.dangerousScheme = conuts;
						break;
					case 4:
						this.form.conflictSchemeDetail = names;
						this.form.conflictScheme = conuts;
						break;
					case 5:
						this.form.guarderPMISchemeDetail = names;
						this.form.guarderPMIScheme = conuts;
						break;
					case 6:
						this.form.securityServiceSchemeDetail = names;
						this.form.securityServiceScheme = conuts;
						break;
					case 7:
						this.form.criminalCaseDetail = names;
						this.form.criminalCase = conuts;
						break;
				}
				this.dailyinspectionList(this.form)
			},
		}
	};
</script>

<style scoped lang="scss">
	.userinform {
		height: 100%;
		width: 100%;
	}

	.userItem {
		color: #7b7b7b;
		font-size: 14px;
		margin-bottom: 8px;

		.textIndex {
			margin-left: 20rpx;
		}
	}

	.text {
		width: 96%;
	}

	.singleChoice {
		width: 90%;
	}

	.label {
		margin: 0 20px;
	}

	/deep/ .u-radio-group--row {
		display: flex;
		flex-direction: row;
		text-align: center;
		align-content: center;
		justify-content: space-evenly;
	}
</style>