<template>
	<view class="questionnaire">

		<form @submit="formSubmit" @reset="formReset">
			<view class="cu-form-group margin-top">
				<view class="title">问卷对象</view>
				<picker @change="updatePickerVal2($event,'member','memberList')" range-key="name" :data-id="memberList[member].id"
				 :value="member" :range="memberList">
					<view class="picker">
						{{member>-1?memberList[member].name:'请选择'}}
					</view>
				</picker>
			</view>
		</form>

		<form @submit="formSubmit">
			<template v-for="(item,index) in list">
				<view v-if="show(item, index, item.prop)" :key="index">
					<view v-if="item.type == 'radio'" class="margin-top padding sict-label" :key="item.value">
						<view>
							<span style="color:red;display: inline-block; vertical-align:inherit;margin-right:4upx" v-if="item.required">*</span>
							{{item.label}}
						</view>
						<view class="text-right  sict-value">
							<radio-group>
								<view>
									<view class="label" v-for="(opt, optIndex) in item.opts" :key="opt.label" @click="radioChange(opt.value,item.value)">
										<radio :class="form[item.value]== opt.value ?'checked':''" :checked="form[item.value]== opt.value?true:false"
										 :value="opt.value"></radio>
										<view style="display: inline-block;" class="right">{{opt.label}}</view>
									</view>
								</view>
							</radio-group>
						</view>
					</view>

					<template v-else-if="item.type == 'picker'">
						<view class="cu-form-group margin-top padding-rl" :key="item.value">
							<view :class="item.titleClass"><span style="color:red;display: inline-block; vertical-align:inherit;margin-right:4upx"
								 v-if="item.required">*</span>{{item.label}}</view>
							<picker @change="updatePickerVal($event,item.value)" :value="form[item.value]" :range="item.opts">
								<view class="picker">
									{{form[item.value]>-1?item.opts[form[item.value]]:'请选择'}}
								</view>
							</picker>
						</view>
					</template>

					<template v-else-if="item.type == 'morePicker'">
						<view class="margin-top">
							<uni-collapse>
								<uni-collapse-item :title="item.label" :open="true" :required="item.required">
									<view class="padding-lr">
										<view class="uni-list">
											<checkbox-group>
												<label class="uni-list-cell uni-list-cell-pd" v-for="(itemCheck,indexCheck) in item.opts" :key="itemCheck.value"
												 @click="checkboxChange(indexCheck,item.opts,itemCheck,item.value)">
													<view class="list-item">
														<view class="fl">
															<checkbox :value="itemCheck.value" :checked="itemCheck.checked" />
														</view>
														<view style="padding-left:60upx">{{itemCheck.label}}</view>
													</view>
												</label>
											</checkbox-group>
										</view>
									</view>
								</uni-collapse-item>
							</uni-collapse>
						</view>
					</template>

					<template v-else-if="item.type == 'input'">
						<view class="cu-form-group margin-top padding-rl" :key="item.value">
							<view :class="item.titleClass">
								<span style="color:red;display: inline-block; vertical-align:inherit;margin-right:4upx" v-if="item.required">*</span>
								{{item.label}}</view>
							<input class="text-right" :placeholder="item.placeholder" :type="item.controType" :value="form[item.value]" name="input"
							 @input="updateInputVal($event,item.value)"></input>
						</view>
					</template>
				</view>
			</template>
			<view class="padding">
				<button form-type="submit" class="cu-btn block bg-blue margin-tb-sm lg">提 交</button>
			</view>

		</form>
	</view>
</template>

<script>
	import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
	import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
	import validate from '@/utils/validate.js'
	export default {
		components: {
			uniCollapse,
			uniCollapseItem
		},
		data() {
			return {
				memberList: [],
				member: -1,
				id: '',
				radio: ['食管癌', '胃癌', '结直肠肿瘤', '炎症性肠病', '其它器官恶性肿瘤（如乳腺、卵巢等其它器官）'],
				list: [{
						label: '姓名',
						type: 'input',
						required: true,
						disabled: true,
						value: 'name',
						placeholder: '请输入姓名'
					},
					{
						label: '身份证号',
						type: 'input',
						required: true,
						disabled: true,
						value: 'IDCard',
						placeholder: '请输入身份证号'
					},
					{
						label: '联系电话',
						type: 'input',
						required: true,
						disabled: true,
						value: 'cellphone',
						placeholder: '请输入联系电话'
					},
					{
						label: '身高(cm)',
						titleClass: 'title',
						// required:true,
						placeholder: '请输入身高（单位：cm）',
						type: 'input',
						controType: 'number',
						value: 'height'
					},
					{
						label: '体重(kg)',
						// required:true,
						titleClass: 'title',
						placeholder: '请输入体重（单位：kg）',
						type: 'input',
						controType: 'number',
						value: 'weight'
					},
					{
						type: 'input',
						placeholder: '请输入医保卡号',
						label: '医保卡号',
						value: 'medicalCard',
					},
					{
						type: 'input',
						placeholder: '请输入家庭住址',
						label: '家庭住址',
						value: 'address',
					},
					{
						type: 'radio',
						label: '距上次内镜检查间隔时间一年内',
						value: 'withinOneYear',
						opts: [{
							value: 'a',
							label: '是'
						}, {
							value: 'b',
							label: '否'
						}],
					},
					{
						type: 'radio',
						label: '胃大部切除术手术史',
						value: 'subtotalGastrectomy',
						opts: [{
							value: 'a',
							label: '是'
						}, {
							value: 'b',
							label: '否'
						}],
					},
					{
						type: 'radio',
						label: '两周内服用PPI（埃索美拉唑、泮托拉唑、雷贝拉唑、兰索拉唑等）或H2受体拮抗剂（法莫替丁等)',
						value: 'ppi',
						opts: [{
							value: 'a',
							label: '是'
						}, {
							value: 'b',
							label: '否'
						}],
					},
					{
						label: '有下列一种或多种症状',
						value: 'symptom',
						type: 'morePicker',
						opts: [{
								value: 'a',
								eliminateVal: '05',
								label: '6个月内缺铁性贫血',
							},
							{
								value: 'b',
								eliminateVal: '06',
								label: '12个月内消化道出血（黑便、血便等）',
							},
							{
								value: 'c',
								eliminateVal: '07',
								label: '体重减轻（非减肥原因6个月内体重减轻≥4.5Kg）',
							},
							{
								value: 'd',
								eliminateVal: '08',
								label: '经常性腹泻',
							},
							{
								value: 'e',
								eliminateVal: '09',
								label: '吞咽困难或哽噎感',
							},
							{
								value: 'f',
								eliminateVal: '10',
								label: '腹部肿块',
							},
							{
								value: 'g',
								label: '以上均无',
							},
						],
					},
					{
						label: '有以下任何一种或多种疾病史',
						value: 'diseasesHistory',
						type: 'morePicker',
						opts: [{
								value: 'a',
								eliminateVal: '11',
								label: '食管癌',
							},
							{
								value: 'b',
								eliminateVal: '12',
								label: '胃癌',
							},
							{
								value: 'c',
								eliminateVal: '13',
								label: '结直肠肿瘤',
							},
							{
								value: 'd',
								eliminateVal: '14',
								label: '炎症性肠病',
							},
							{
								value: 'e',
								eliminateVal: '15',
								label: '其它器官恶性肿瘤（如乳腺、卵巢等其它器官）',
							},
							{
								value: 'f',
								label: '以上均无',
							},
						],
					},

					{
						type: 'radio',
						label: '影像、肿瘤标志物等检查高度怀疑罹患肿瘤可能',
						value: 'possibilityOfCancer',
						opts: [{
							value: 'a',
							label: '是'
						}, {
							value: 'b',
							label: '否'
						}],
					},
					{
						type: 'radio',
						label: '严重心、肺、肝、肾功能不全，或严重精神疾患',
						value: 'seriousIllness',
						opts: [{
							value: 'a',
							label: '是'
						}, {
							value: 'b',
							label: '否'
						}],
					},
					{
						label: '一级亲属（父母、子女、兄弟姐妹）有无罹患胃癌情况',
						type: 'radio',
						value: 'relativesGastric',
						opts: [{
								value: 'a',
								label: '是'
							},
							{
								value: 'b',
								label: '否'
							},
						],
					},
					{
						label: '数量',
						show: false,
						value: 'relativesGastricCount',
						titleClass: 'title',
						type: 'radio',
						opts: [{
							value: 'a',
							label: '一位'
						}, {
							value: 'b',
							label: '多位'
						}],
						link: {
							show: [{
								prop: 'relativesGastric',
								value: 'a',
							}],
						}
					},
					{
						label: '诊断时最小年龄',
						show: false,
						// required:true,
						controType: 'number',
						value: 'relativesGastricAge',
						titleClass: 'title',
						placeholder: '请输入年龄',
						type: 'input',
						link: {
							show: [{
								prop: 'relativesGastric',
								value: 'a',
							}],
						}
					},
					{
						label: '一级亲属罹患其它恶性肿瘤情况',
						type: 'radio',
						// required:true,
						value: 'relativesCancer',
						opts: [{
								value: 'a',
								label: '是'
							},
							{
								value: 'b',
								label: '否'
							},
						],
					},
					{
						label: '数量',
						show: false,
						// required:true,
						value: 'relativesCancerCount',
						titleClass: 'title',
						type: 'radio',
						opts: [{
							value: 'a',
							label: '一位'
						}, {
							value: 'b',
							label: '多位'
						}],
						link: {
							show: [{
								prop: 'relativesCancer',
								value: 'a',
							}],
						}
					},
					{
						label: '肿瘤名称',
						show: false,
						value: 'relativesCancerName',
						// required:true,
						titleClass: 'title',
						placeholder: '请输入肿瘤名称',
						type: 'input',
						link: {
							show: [{
								prop: 'relativesCancer',
								value: 'a',
							}],
						}
					},
					{
						label: '是否服用阿司匹林、氯吡格雷、华法林等抗凝药',
						titleClass: 'title',
						type: 'radio',
						value: 'anticoagulant',
						// required:true,
						opts: [{
								value: 'a',
								label: '有'
							},
							{
								value: 'b',
								label: '无'
							}
						]
					},
					{
						label: '饮食咸淡习惯',
						titleClass: 'title',
						type: 'radio',
						value: 'hpInfection',
						opts: [{
								value: 'a',
								label: '清淡'
							},
							{
								value: 'b',
								label: '正常'
							},
							{
								value: 'c',
								label: '较咸'
							},
						],
					},
					{
						label: '腌制食品摄入（如酱菜，咸肉等）',
						titleClass: 'title',
						type: 'radio',
						value: 'pickledFood',
						opts: [{
							value: 'a',
							label: '每周1-2次'
						}, {
							value: 'b',
							label: '每周3-4次'
						}, {
							value: 'c',
							label: '不吃'
						}]
					},
					{
						label: '煎炸、熏制、烧烤食品摄入',
						titleClass: 'title',
						type: 'radio',
						value: 'fryFood',
						opts: [{
							value: 'a',
							label: '每周1-2次'
						}, {
							value: 'b',
							label: '每周3-4次'
						}, {
							value: 'c',
							label: '不吃'
						}]
					},
					{
						label: '隔夜菜摄入',
						titleClass: 'title',
						type: 'radio',
						value: 'leftoverFood',
						opts: [{
							value: 'a',
							label: '每周1-2次'
						}, {
							value: 'b',
							label: '每周3-4次'
						}, {
							value: 'c',
							label: '不吃'
						}]
					},
					{
						label: '猪、羊、牛肉（红肉）任何一种摄入',
						titleClass: 'title',
						type: 'radio',
						value: 'redMeat',
						opts: [{
							value: 'a',
							label: '每周1-2次'
						}, {
							value: 'b',
							label: '每周3-4次'
						}, {
							value: 'c',
							label: '不吃'
						}]
					},
					{
						label: '鸡、鸭、鱼肉（白肉）任何一种摄入',
						titleClass: 'title',
						type: 'radio',
						value: 'whiteFood',
						opts: [{
							value: 'a',
							label: '每周1-2次'
						}, {
							value: 'b',
							label: '每周3-4次'
						}, {
							value: 'c',
							label: '不吃'
						}]
					},
					{
						label: '新鲜蔬菜、水果摄入',
						titleClass: 'title',
						type: 'radio',
						value: 'fruitVegetable',
						opts: [{
							value: 'a',
							label: '每周1-2次'
						}, {
							value: 'b',
							label: '每周3-4次'
						}, {
							value: 'c',
							label: '不吃'
						}]
					},
					{
						label: '茶叶摄入',
						// required:true,
						titleClass: 'title',
						type: 'radio',
						value: 'tea',
						opts: [{
							value: 'a',
							label: '每周1-2次'
						}, {
							value: 'b',
							label: '每周3-4次'
						}, {
							value: 'c',
							label: '不喝'
						}],
					},
					{
						label: '是否吸烟',
						titleClass: 'title',
						// required:true,
						type: 'radio',
						value: 'smoke',
						opts: [{
								value: 'a',
								label: '偶尔'
							},
							{
								value: 'b',
								label: '经常'
							},
							{
								value: 'c',
								label: '不抽'
							},
						]
					},
					{
						type: 'radio',
						label: '吸烟频率',
						opts: [{
							value: 'a',
							label: '每天一包以上'
						}, {
							value: 'b',
							label: '每天一包以下'
						}],
						value: 'smokeFrequency',
						link: {
							type: 'or',
							show: [{
									prop: 'smoke',
									value: 'a',
								},
								{
									prop: 'smoke',
									value: 'b',
								},
							],
						},
					},
					{
						type: 'input',
						placeholder: "请输入吸烟年数",
						label: '吸烟年数',
						value: 'smokeYears',
						link: {
							type: 'or',
							show: [{
									prop: 'smoke',
									value: 'a',
								},
								{
									prop: 'smoke',
									value: 'b',
								},
							],
						}
					},


					{
						type: 'radio',
						titleClass: 'title',
						label: '饮酒史',
						opts: [{
							value: 'a',
							label: '偶尔'
						}, {
							value: 'b',
							label: '经常'
						}, {
							value: 'c',
							label: '不饮'
						}],
						value: 'drink',
					},
					{
						type: 'radio',
						label: '饮酒种类',
						opts: [{
							value: 'a',
							label: '白酒'
						}, {
							value: 'b',
							label: '啤酒'
						}, {
							value: 'c',
							label: '黄酒'
						}, {
							value: 'd',
							label: '红酒'
						}, {
							value: 'e',
							label: '米酒'
						}],
						value: 'drinkType',
						link: {
							type: 'or',
							show: [{
									prop: 'drink',
									value: 'a',
								},
								{
									prop: 'drink',
									value: 'b',
								},
							],
						},
					},
					{
						type: 'input',
						label: '饮酒年数',
						placeholder: "请输入饮酒年数",
						value: 'drinkYears',
						link: {
							type: 'or',
							show: [{
									prop: 'drink',
									value: 'a',
								},
								{
									prop: 'drink',
									value: 'b',
								},
							],
						}
					},
					{
						label: '糖尿病（空腹血糖大于或等于7.0mmol/l或126mg/dl，或已诊断为糖尿病）',
						titleClass: 'title',
						// required:true,
						type: 'radio',
						value: 'diabetes',
						opts: [{
								value: 'a',
								label: '是'
							},
							{
								value: 'b',
								label: '否'
							}
						],

					},
					{
						type: 'input',
						titleClass: 'title',
						label: '糖尿病持续年数',
						placeholder: '请输入糖尿病持续年数',
						value: 'diabetesYears',
						link: {
							show: [{
								prop: 'diabetes',
								value: 'a',
							}, ],
						}
					},

					{
						label: '高血压病史（BP≥140/90mmHg或服用降压药）',
						titleClass: 'title',
						// required:true,
						type: 'radio',
						value: 'hypertension',
						opts: [{
								value: 'a',
								label: '是'
							},
							{
								value: 'b',
								label: '否'
							}
						]
					},

					{
						type: 'input',
						titleClass: 'title',
						label: '高血压持续年数',
						placeholder: '请输入高血压持续年数',
						value: 'hypertensionYears',
						link: {
							show: [{
								prop: 'hypertension',
								value: 'a',
							}]
						}
					},

					{
						label: '高血脂病史（TG≥1.7mmol/l或150mg/dl，或服用降血脂药物）',
						titleClass: 'title',
						// required:true,
						type: 'radio',
						value: 'hyperlipidemia',
						opts: [{
								value: 'a',
								label: '是'
							},
							{
								value: 'b',
								label: '否'
							}
						]
					},
					{
						type: 'input',
						titleClass: 'title',
						label: '高血脂持续年数',
						placeholder: '请输入高血脂持续年数',
						value: 'hyperlipidemiaYears',
						link: {
							show: [{
								prop: 'hyperlipidemia',
								value: 'a',
							}]
						}
					},
					{
						label: '近三个月不适症状（可多选）',
						titleClass: 'title',
						// required:true,
						type: 'morePicker',
						value: 'uncomfortable',
						opts: [{
							value: "a",
							label: "腹胀"
						}, {
							value: "b",
							label: "腹痛"
						}, {
							value: "c",
							label: "反酸"
						}, {
							value: "d",
							label: "嗳气"
						}, {
							value: "e",
							label: "早饱感"
						}, {
							value: "f",
							label: "恶心"
						}, {
							value: "g",
							label: "吞咽困难"
						}, {
							value: "h",
							label: "黑粪"
						}, {
							value: "i",
							label: "餐后不适"
						}, {
							value: "j",
							label: "呕血"
						}, {
							value: "k",
							label: "体重减轻"
						}, {
							value: "l",
							label: "食欲不振"
						}, {
							value: "m",
							label: "烧心"
						}],
					},
				],
				form: {
					"relativesGastric": "",
					"relativesGastricCount": -1,
					"relativesGastricAge": "",
					"relativesCancer": "",
					"relativesCancerCount": -1,
					"relativesCancerName": "",
					"maritalStatus": "",
					"educationDegree": "",
					"familyPopulation": "",
					"averageYearlyIncome": "",
					"diabetes": '',
					"hypertension": '',
					"hyperlipidemia": '',
					"anticoagulant": '',
					"dietHabit": '',
					"pickledFood": '',
					"fryFood": '',
					"leftoverFood": '',
					"redMeat": '',
					"whiteFood": '',
					"fruitVegetable": '',
					"tea": '',
					"smoke": '',
					"smokeFrequency": '',
					"smokeYears": '',
					"drink": '',
					"drinkType": '',
					"drinkYears": '',
					"diabetesYears": '',
					"hypertensionYears": '',
					"hyperlipidemiaYears": '',
					"uncomfortable": '',
					"height": "",
					"weight": "",
					"sbp": "",
					"dbp": "",
					"waterSource": "",
					"smoke": "",
					"cigaretteFrequency": "",
					"tobaccoFrequency": "",
					"smokeYears": "",
					"drink": "",
					"drinkFrequency": "",
					"drinkYears": "",
					"teaDrinking": "",
					"teaFrequency": "",
					"teaYears": "",
					"vegetables": "",
					"fruits": "",
					"meatEggMilk": "",
					"beanProduct": "",
					"pickledDryFood": "",
					"friedFood": "",
					"hotFood": "",
					"mildewFood": "",
					"enterogastritis": "",
					"enterogastritisAge": "",
					"gastricAndDuodenalUlcers": "",
					"gastricAndDuodenalAge": "",
					"oesophagitis": "",
					"oesophagitisAge": "",
					"hepatitis": "",
					"hepatitisAge": "",
					"otherDiseases": "",
					"diseasesName": "",
					"diseasesAge": "",
					uncomfortable: []
				}
			}
		},

		onLoad(option) {
			this.getMember()
		},

		methods: {
			// 更新复选框绑定的表单内容
			checkboxChange(index, checkList, obj, prop) {
				for (var i = 0, lenI = checkList.length; i < lenI; ++i) {
					if (index == i) {
						this.$set(checkList[i], 'checked', !checkList[i].checked)
					}
				}

				// 处理以上均无情况
				if (obj.label == '以上均无') {
					for (var i = 0, lenI = checkList.length; i < lenI; ++i) {
						this.$set(checkList[i], 'checked', false)
					}
					this.$set(checkList[checkList.length - 1], 'checked', true)
				} else {
					this.$set(checkList[checkList.length - 1], 'checked', false)
				}
			},

			show(item, index, basic) {
				if (item.link) {
					const list = item.link.show
					let flag = item.link.type
					if (flag == 'or') {
						return list.some((v) => {
							if (this.form[v.prop] === v.value) return true
							return false
						})
					} else {
						return list.every((v) => {
							if (this.form[v.prop] === v.value) return true
							return false
						})
					}
				}
				return true
			},

			getMember() {
				const data = {
					params: {
						pageNum: 1,
						pageSize: 10000
					}
				}
				this.$http.get(`/gastric-cancer-data/wechat/report/member/page`, data).then(res => {
					const d = res.data
					if (d.code == 1) {
						this.memberList = d.object.list
						if (this.memberList.length > 0) {
							this.member = 0
							this.getInfo(this.memberList[0].id)
							this.id = this.memberList[this.member].id
						}
					}
				}).catch(err => {
					console.log(err)
				})
			},

			updatePickerVal2(event, props) {
				this.member = event.detail.value
				this.getInfo(this.memberList[this.member].id)
				this.id = this.memberList[this.member].id
			},
			// getInfo(id){
			// 	this.collapseList = this.deepClone(this.collapseListCopy)
			// 	this.$http.get(`/gastric-cancer-data/report/selectReportBySampleId?id=${id}`).then(res => {
			// 		const d = res.data
			// 		if(d.code == 1){
			// 			this.data = d.object.reportContent.data
			// 			this.data.reportTime = d.object.reportTime
			// 			this.data.name = d.object.name
			// 			// this.data.address = this.addressPicker[this.data.address].label
			// 			this.data.sex = parseInt(this.data.IDCard.substr(16, 1)) % 2 == 1 ?'男':'女'

			// 			this.data.hospitalName = d.object.hospitalBean ?d.object.hospitalBean.hospitalName:'未填报'

			// 			this.collapseList[1].list[3].hidden = this.data['igg'] != 'b'
			// 			this.collapseList[1].list[4].hidden = this.data['igg'] != 'b'

			// 			for (let i = 0; i < this.collapseList.length; i++) {
			// 				for (let j = 0; j < this.collapseList[i].list.length; j++) {
			// 					if(this.collapseList[i].list[j].type == 'mode2'){
			// 						this.collapseList[i].list[j].valueOne = this.collapseList[i].list[j].formatterValueOne ? this.collapseList[i].list[j].formatterValueOne(this.data):this.formatterBasicVal(this.data[this.collapseList[i].list[j].valueOne],this.collapseList[i].list[j].opts || [],this.collapseList[i].list[j].value)
			// 						this.collapseList[i].list[j].valueTwo = this.collapseList[i].list[j].formatterValueTwo ? this.collapseList[i].list[j].formatterValueTwo(this.data): this.formatterBasicVal(this.data[this.collapseList[i].list[j].valueTwo],this.collapseList[i].list[j].opts || [],this.collapseList[i].list[j].value)
			// 					}else if(this.collapseList[i].list[j].type == 'img'){
			// 						if(this.data[this.collapseList[i].list[j].value]){
			// 							this.getImgList(this.data[this.collapseList[i].list[j].value],i,j)
			// 						}
			// 					}else{
			// 						this.collapseList[i].list[j].value = this.collapseList[i].list[j].formatterValue ? this.collapseList[i].list[j].formatterValue(this.data) :  this.formatterBasicVal(this.data[this.collapseList[i].list[j].value],this.collapseList[i].list[j].opts || [],this.collapseList[i].list[j].value)
			// 					}
			// 				}
			// 			}
			// 		}
			// 	}).catch(err => {
			// 		console.log(err)
			// 	})
			// },

			// 获取信息
			getInfo(id) {
				this.$http.get(`/gastric-cancer-data/report/selectReportBySampleId?id=${id}`).then(res => {
					const d = res.data
					if (d.code == 1) {
						this.form = Object.assign(this.form, d.object.reportContent.data)
						for (let i = 0, lenI = this.list.length; i < lenI; ++i) {
							if(this.list[i].type == 'morePicker'){
								for (let j = 0, lenJ = this.list[i].opts.length; j < lenJ; ++j) {
									if (this.form[this.list[i].value].indexOf(this.list[i].opts[j].value) > -1) {
										this.$set(this.list[i].opts[j], 'checked', true)
									}else{
										this.$set(this.list[i].opts[j], 'checked', false)
									}
								}
							}
						}
					}
				}).catch(err => {
					console.log(err)
				})
			},

			radioChange(val, prop) {
				this.$set(this.form, prop, val)
			},

			radioChange2(index, checkList, val) {
				for (var i = 0, lenI = checkList.length; i < lenI; ++i) {
					if (index == i) {
						this.$set(checkList[i], 'checked', !checkList[i].checked)
					} else {
						this.$set(checkList[i], 'checked', false)
					}
				}
			},

			Switch(e, prop) {
				this.form[prop] = e.detail.value
			},
			// 更新输入框绑定的表单内容
			updateInputVal(event, props) {
				this.form[props] = event.target.value
			},
			// 更新下拉框绑定的表单内容
			updatePickerVal(event, props) {
				this.$set(this.form, props, event.detail.value)
			},

			// 提交信息
			formSubmit() {
				for (let i = 0, lenI = this.list.length; i < lenI; ++i) {
					if(this.list[i].type == 'morePicker'){
						this.form[this.list[i].value] = []
						for (let j = 0, lenJ = this.list[i].opts.length; j < lenJ; ++j) {
							if (this.list[i].opts[j].checked) {
								this.form[this.list[i].value].push(this.list[i].opts[j].value)
							}
						}
					}
				}
				
				let flag = true
				let msg = ''
				if (!flag) {
					return false
				} else {
					let obj2 = Object.assign({}, this.form)

					if (obj2.relativesGastricAge) {
						obj2.relativesGastricAge = parseInt(obj2.relativesGastricAge)
					}

					let obj = {
						"id": this.id,
						"auditStatus": -3,
						"data": {
							"data": obj2,
							"diseaseType": this.$store.getters.userInfo.diseaseType,
							"isPrivate": this.$store.getters.userInfo.isPrivate
						}
					}

					this.$http.post(`/gastric-cancer-data/wechat/report`, obj).then(res => {
						const d = res.data
						if (d.code == 1) {
							uni.showToast({
								icon: 'none',
								title: '感谢您填写问卷调查。'
							})
							// #ifdef MP-WEIXIN
							setTimeout(function() {
								wx.switchTab({
									url: '/pages/person/index',
								});
							}, 1000);
							// #endif
						} else {
							// uni.showToast({
							// 	icon: 'none',
							// 	title: d.message
							// })
							uni.showToast({
								icon: 'none',
								title: '感谢您完成问卷调查。'
							})
							// #ifdef MP-WEIXIN
							setTimeout(function() {
								wx.switchTab({
									url: '/pages/person/index',
								});
							}, 1000);
							// #endif
						}
					}).catch(err => {
						console.log(err)
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.sict-title {
		padding: 20upx 0;
		padding-right: 20upx;
		word-break: break-all;
		text-align: justify
	}

	.sict-label {
		background-color: white;
		font-size: 30upx;
		text-align: justify;
	}

	.sict-value {
		margin-top: 15upx;

		.right {
			margin-left: 10upx;
			vertical-align: bottom;
		}

		.label {
			// display: inline-block;
			text-align: left;
			padding: 20upx 0;
			padding-left: 30upx;
			border-bottom: 2upx solid #d3d3d3;

			&:last-child {
				border-bottom: 0;
			}
		}
	}

	uni-radio-group {
		border: 2upx solid #d3d3d3;
		border-radius: 8upx;
		margin-left: 20upx;
		display: block;
	}

	radio-group {
		border: 2upx solid #d3d3d3;
		border-radius: 8upx;
		margin-left: 20upx;
		display: block;
	}

	.icon-right {
		font-family: cuIcon;
		font-size: 34upx;
		color: #8799a3;
		line-height: 100upx;
		width: 60upx;
		text-align: right;
		margin: auto;
	}

	.uni-list-cell {
		.list-item {
			border-bottom: 2upx solid #d3d3d3;
			padding: 20upx 0;
			padding-left: 30upx;
		}

		&:last-child {
			.list-item {
				border-bottom: 0;
			}
		}
	}

	.uni-list {
		margin-left: 20upx;
		border: 2upx solid #d3d3d3;
		border-radius: 8upx;
	}
</style>

<style>
	.questionnaire .uni-collapse-cell__title:after {
		border-bottom: 0 !important;
	}
</style>
