<template>
	<view class="screen">
		<form @submit="formSubmit" @reset="formReset" v-if="memberList.length>0">
			<view class="cu-form-group margin-top">
				<view class="title">筛查对象</view>
				<picker @change="updatePickerVal($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>
		<view class="bg-white padding-xl text-center" style="height: 100vh;" v-else>
			<view class="noneInfo">
				<view class="noneInfoImg">
				</view>
				<view class="margin-top-sm">
					暂无相关信息
				</view>
			</view>
		</view>

		<uni-collapse @change="change">
			<uni-collapse-item v-for="(item,index) in collapseList" :title="item.title" :tips="item.tips" :key="index" class="margin-top">
				<template v-for="(obj,objIndex) in item.list" v-if="flag">
					<view class="basic-info-item" v-if=" obj.childTitle" :key="obj.label">{{obj.childTitle}}：</view>
					<!--  -->
					<view class="basic-info-item" v-if=" obj.type == 'mode1' " :key="obj.label">
						<view class="basic-info-left">
							<view class="info-title">{{obj.label}}</view>
						</view>
						<view class="basic-info-right">
							<view class="info-text">
								<!-- <span> {{data[`obj.value`]}} {{obj.value}}  </span> -->
								<span v-html="obj.value"></span>
							</view>
						</view>
					</view>
					<!--  -->
					<view class="flex flex-wrap basic-info-item" v-else-if="obj.type=='mode2' && !obj.hidden" :key="obj.label">
						<view class="basis-df">
							<div class="info-title">{{obj.labelOne}}</div>
							<div class="margin-top-sm info-text">
								<span v-html="obj.valueOne"></span>
							</div>
						</view>
						<view class="basis-df">
							<div class="info-title">{{obj.labelTwo}}</div>
							<div class="margin-top-sm info-text">
								<span v-html="obj.valueTwo"></span>
							</div>
						</view>
					</view>
					<!--  -->
					<view class="stock-info-item" v-else-if="obj.type=='mode3'" :key="obj.label">
						<div class="info-title"  style="margin-left:12upx">{{obj.label}}</div>
						<div class="margin-top-sm info-text text-right" style="margin-right:10upx">
							<span v-html="obj.value"></span>
							<!-- <span v-html=" obj.formatterValue? obj.value : formatterBasicVal(data[obj.value]) "></span> -->
						</div>
					</view>

					<view class="stock-info-item" v-else-if="obj.type=='img'" :key="obj.label">
						<div class="info-title" style="margin-left:12upx">{{obj.label}}</div>
						<div class="margin-top-sm info-text text-right">
							<view class="cu-list grid" v-if="obj.list.length>0">
							
									<!--  #ifdef MP-WEIXIN  -->
									<view class="cu-item quick-item" style="width:30%;margin-top: 20upx;margin-left:3.3%;height: 200upx;" v-for="(itemImg,indexImg) in obj.list"
										 :key="indexImg" hover-class="cell-hover" :hover-stay-time="50"
										 >
										<img :src="itemImg" mode="widthFix"  @click="previewImage(obj.list,indexImg)">
									</view>
									<!-- #endif -->
									<!-- #ifdef H5  -->
										<view class="cu-item quick-item" style="width:30%;margin-left:3.3%;height: 200upx;" v-for="(itemImg,indexImg) in obj.list"
											 :key="indexImg" hover-class="cell-hover" :hover-stay-time="50"
											 >
											<img :src="itemImg" mode="widthFix" height="100upx"  @click="previewImage(obj.list,indexImg)">
										</view>
									<!-- #endif -->
									<!-- height: 100px; -->
								
							</view>
					<view v-else class="text-right">
						暂无图片
					</view>
					</div>
			</view>
		</template>
	</uni-collapse-item>
</uni-collapse>

<view class="cu-modal" :class="modalName=='Image'?'show':''" @tap="modalName=''">
	<view class="cu-dialog">
		<view class="bg-img">
			<view class="cu-bar justify-end text-black">
				<view class="action" @tap="modalName = ''">
					<text class="cuIcon-close"></text>
				</view>
			</view>
		</view>
		<image :src="bigImg" mode="widthFix"></image>
		<view class="cu-bar bg-white">
			<view class="action margin-0 flex-sub  solid-left text-right" @tap="modalName = ''"></view>
		</view>
	</view>
</view>

</view>
</template>

<script>
	import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
	import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
	export default {
		components: {
			uniCollapse,
			uniCollapseItem
		},
		data() {
			return {
				id: '',
				data: {},
				flag: true,
				modalName: '',
				bigImg: '',
				addressPicker: [{
						label: '街道1',
						value: '街道1'
					},
					{
						label: '街道2',
						value: '街道2'
					},
					{
						label: '街道3',
						value: '街道3'
					}
				],
				cuIconList: [{
					cuIcon: 'friendadd',
					color: 'blue',
					badge: 0,
					name: '自我报名',
					navUrl: "/personModule/signUp/index?type=self"
				}],
				member: 0,
				memberList: [],
				collapseList: [],
				collapseListCopy: [{
						title: '筛前信息',
						tips: false,
						list: [{
								type: 'mode2',
								childTitle: '基础信息',
								labelOne: "姓名",
								valueOne: "name",
								labelTwo: "调查时间",
								valueTwo: "reportTime"
							},
							{
								type: 'mode2',
								labelOne: "身份证号码",
								valueOne: "IDCard",
								labelTwo: "家庭住址",
								valueTwo: "address"
							},
							{
								type: 'mode2',
								labelOne: "联系电话1",
								valueOne: "cellphone",
								labelTwo: "联系电话2",
								valueTwo: "telephone"
							},
							{
								type: 'mode2',
								childTitle: '入选标准',
								labelOne: "性别",
								valueOne: "sex",
								labelTwo: "年龄",
								valueTwo: "age"
							},
							{
								type: 'mode2',
								labelOne: "知情同意",
								valueOne: "agree",
								formatterValueOne(data) {
									return data['agree'] == 'a' ? '是' : data['agree'] == 'a' ? '否' : '未填报'
								},
								labelTwo: "筛查医院",
								valueTwo: "hospitalName"
							},
							{
								type: 'mode1',
								childTitle: '排除标准',
								label: "距上次胃镜检查间隔时间一年内",
								value: "withinOneYear",
							},
							{
								type: 'mode1',
								label: "胃大部切除术手术史",
								value: "subtotalGastrectomy",
							},
							{
								type: 'mode3',
								label: "两周内服用PPI（埃索美拉唑、泮托拉唑、雷贝拉唑、兰索拉唑等）或H2受体拮抗剂（法莫替丁等）",
								value: "ppi",
							},
							{
								type: 'mode3',
								label: "有以下一种或多种症状（6个月内缺铁性贫血，12个月内消化道出血：黑便、血便等，体重减轻：非减肥原因6月内体重减轻大于等于4.5kg，经常性腹泻，吞咽困难或哽咽感，腹部肿块。）",
								value: "symptom",
								opts: [{
										value: 'a',
										label: '6个月内缺铁性贫血'
									},
									{
										value: 'b',
										label: '12个月内消化道出血（黑便、血便等）'
									},
									{
										value: 'c',
										label: '体重减轻（非减肥原因6个月内体重减轻≥4.5Kg）'
									},
									{
										value: 'd',
										label: '经常性腹泻'
									},
									{
										value: 'e',
										label: '吞咽困难或哽噎感'
									},
									{
										value: 'f',
										label: '腹部肿块'
									},
									{
										value: 'g',
										label: '以上均无'
									}
								]
							},
							{
								type: 'mode3',
								label: "有以下任何一种疾病史（食管癌、胃癌、结直肠肿瘤、炎症性肠病、其他器官恶性肿瘤：乳腺、卵巢、子宫及泌尿系统等）",
								value: "diseasesHistory",
								opts: [{
										value: 'a',
										label: '食管癌'
									},
									{
										value: 'b',
										label: '胃癌'
									},
									{
										value: 'c',
										label: '结直肠肿瘤'
									},
									{
										value: 'd',
										label: '炎症性肠病'
									},
									{
										value: 'e',
										label: '其它器官恶性肿瘤（如乳腺、卵巢等其它器官）'
									},
									{
										value: 'f',
										label: '以上均无'
									}
								]
							},
							{
								type: 'mode1',
								label: "影像、肿瘤标志物等检查高度怀疑罹患肿瘤可能",
								value: "possibilityOfCancer",
							},
							{
								type: 'mode1',
								label: "严重心、肺、肝、肾功能不全，或严重精神疾患",
								value: "seriousIllness",
							},
							// {
							// 	type: 'mode3',
							// 	childTitle: '调查内容',
							// 	formatter: true,
							// 	formatterValue(data) {
							// 		return data['relativesGastric'] == 'a' ? ' 数量：' + (data['relativesGastricCount'] == 'b' ? '多位' : '一位') +
							// 			'，最小年龄：' + data['relativesGastricAge'] : data['relativesGastric'] == 'b' ? '否' : '未填报'
							// 	},
							// 	label: "一级亲属（父母、子女、兄弟姐妹）罹患胃癌情况",
							// 	value: ''
							// },

							// {
							// 	type: 'mode3',
							// 	formatter: true,
							// 	formatterValue(data) {
							// 		return data['relativesCancer'] == 'a' ? ' 数量：' + (data['relativesCancerCount'] == 'b' ? '多位' : '一位') +
							// 			'，肿瘤名称：' + data['relativesCancerName'] : data['relativesCancer'] == 'b' ? '否' : '未填报'
							// 	},
							// 	label: "一级亲属罹患其它恶性肿瘤情况",
							// 	value: ''
							// },

							// {
							// 	type: 'mode2',
							// 	labelOne: "婚姻状况",
							// 	formatterValueOne(data) {
							// 		return data['maritalStatus'] == 'a' ? '未婚' : data['maritalStatus'] == 'b' ? '已婚' : data['maritalStatus'] ==
							// 			'c' ? '离异' : data['maritalStatus'] == 'd' ? '丧偶' : '未填报'
							// 	},
							// 	valueOne: ``,
							// 	labelTwo: "教育程度",
							// 	formatterValueTwo(data) {
							// 		return data['educationDegree'] == 'a' ? '未上过学' : data['educationDegree'] == 'b' ? '小学' : data[
							// 				'educationDegree'] == 'c' ? '初中' : data['educationDegree'] == 'd' ? '高中' : data['educationDegree'] == 'e' ?
							// 			'大专及以上' : '未填报'
							// 	},
							// 	valueTwo: '',
							// },

							// {
							// 	type: 'mode2',
							// 	labelOne: "家庭人口数量",
							// 	valueOne: "familyPopulation",
							// 	labelTwo: "平均年大约收入",
							// 	formatterValueTwo(data) {
							// 		return data['averageYearlyIncome'] == 'a' ? '50万以上' : data['averageYearlyIncome'] == 'b' ? '20万-50万' : data[
							// 			'averageYearlyIncome'] == 'c' ? '15-20万' : data['averageYearlyIncome'] == 'd' ? '10-15万' : data[
							// 			'averageYearlyIncome'] == 'e' ? '10万以下' : '未填报'
							// 	},
							// 	valueTwo: "averageYearlyIncome"
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "身高(cm)",
							// 	valueOne: "height",
							// 	labelTwo: "体重(kg)",
							// 	valueTwo: "weight"
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "血压(mmHg)",
							// 	formatterValueOne(data) {
							// 		return (data['sbp'] ? data['sbp'] : '未填报') + '/' + (data['dbp'] ? data['dbp'] : '未填报')
							// 	},
							// 	valueOne: "",
							// 	labelTwo: "饮水主要来源",
							// 	formatterValueTwo(data) {
							// 		return data['waterSource'] == 'a' ? '地窖水、池塘水、浅井水' : data['waterSource'] == 'b' ? '湖水、河水' : data[
							// 			'waterSource'] == 'c' ? '深井水、泉水' : data['waterSource'] == 'd' ? '自来水（经处理）' : '未填报'
							// 	},
							// 	valueTwo: '',
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "吸烟",
							// 	formatterValueOne(data) {
							// 		return data['smoke'] == 'a' ? ' 频率：' + data['cigaretteFrequency'] + '支（两）/天，<br/>持续年数：' + data['smokeYears'] +
							// 			'年' : data['smoke'] == 'b' ? '否' : '未填报'
							// 	},
							// 	valueOne: "",
							// 	labelTwo: "饮酒",
							// 	formatterValueTwo(data) {
							// 		return data['drink'] == 'a' ? ' 频率：' + data['drinkFrequency'] + '两/天，<br/>持续年数：' + data['drinkYears'] + '年' :
							// 			data['drink'] == 'b' ? '否' : '未填报'
							// 	},
							// 	valueTwo: '',
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "饮茶",
							// 	formatterValueOne(data) {
							// 		return data['teaDrinking'] == 'a' ? ' 频率：' + data['teaFrequency'] + '两/天，<br/>持续年数：' + data['teaYears'] +
							// 			'年' : data['teaDrinking'] == 'b' ? '否' : '未填报'
							// 	},
							// 	valueOne: "",
							// 	labelTwo: "食用新鲜蔬菜",
							// 	formatterValueTwo(data) {
							// 		return data['vegetables'] == 'a' ? '从不' : data['vegetables'] == 'b' ? '很少（&lt;2次/周）' : data['vegetables'] ==
							// 			'c' ? '经常（≥2次/周）' : '未填报'
							// 	},
							// 	valueTwo: '',
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "新鲜水果",
							// 	formatterValueOne(data) {
							// 		return data['fruits'] == 'a' ? '从不' : data['fruits'] == 'b' ? '很少（&lt;2次/周）' : data['fruits'] == 'c' ?
							// 			'经常（≥2次/周）' : '未填报'
							// 	},
							// 	valueOne: "",

							// 	labelTwo: "肉蛋奶类",
							// 	formatterValueTwo(data) {
							// 		return data['meatEggMilk'] == 'a' ? '从不' : data['meatEggMilk'] == 'b' ? '很少（&lt;2次/周）' : data['meatEggMilk'] ==
							// 			'c' ? '经常（≥2次/周）' : '未填报'
							// 	},
							// 	valueTwo: '',
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "豆类食品",
							// 	formatterValueOne(data) {
							// 		return data['beanProduct'] == 'a' ? '从不' : data['beanProduct'] == 'b' ? '很少（&lt;2次/周）' : data['beanProduct'] ==
							// 			'c' ? '经常（≥2次/周）' : '未填报'
							// 	},
							// 	valueOne: "",

							// 	labelTwo: "腌晒食品",
							// 	formatterValueTwo(data) {
							// 		return data['pickledDryFood'] == 'a' ? '从不' : data['pickledDryFood'] == 'b' ? '很少（&lt;2次/周）' : data[
							// 			'pickledDryFood'] == 'c' ? '经常（≥2次/周）' : '未填报'
							// 	},
							// 	valueTwo: ''
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "油炸食品",
							// 	formatterValueOne(data) {
							// 		return data['friedFood'] == 'a' ? '从不' : data['friedFood'] == 'b' ? '很少（&lt;2次/周）' : data['friedFood'] ==
							// 			'c' ? '经常（≥2次/周）' : '未填报'
							// 	},
							// 	valueOne: "",

							// 	labelTwo: "烫热食品",
							// 	formatterValueTwo(data) {
							// 		return data['hotFood'] == 'a' ? '从不' : data['hotFood'] == 'b' ? '很少（&lt;2次/周）' : data['hotFood'] == 'c' ?
							// 			'经常（≥2次/周）' : '未填报'
							// 	},
							// 	valueTwo: '',
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "霉变食品",
							// 	formatterValueOne(data) {
							// 		return data['mildewFood'] == 'a' ? '从不' : data['mildewFood'] == 'b' ? '很少（&lt;2次/周）' : data['mildewFood'] ==
							// 			'c' ? '经常（≥2次/周）' : '未填报'
							// 	},
							// 	valueOne: "",

							// 	labelTwo: "胃肠炎",
							// 	formatterValueTwo(data) {
							// 		return data['enterogastritis'] == 'a' ? ' 胃肠炎诊断时年龄：' + data['enterogastritisAge'] : data['enterogastritis'] ==
							// 			'b' ? '否' : '未填报'
							// 	},

							// 	valueTwo: "",
							// },
							// {
							// 	type: 'mode2',
							// 	labelOne: "胃、十二指肠溃疡",
							// 	formatterValueOne(data) {
							// 		return data['gastricAndDuodenalUlcers'] == 'a' ? ' 胃、十二指肠溃疡诊断时年龄：' + data['gastricAndDuodenalAge'] : data[
							// 			'gastricAndDuodenalUlcers'] == 'b' ? '否' : '未填报'
							// 	},
							// 	valueOne: "",
							// 	labelTwo: "食管炎",
							// 	formatterValueTwo(data) {
							// 		return data['oesophagitis'] == 'a' ? ' 食管炎诊断时年龄：' + data['oesophagitisAge'] : data['oesophagitis'] == 'b' ?
							// 			'否' : '未填报'
							// 	},
							// 	valueTwo: ""
							// },

							// {
							// 	type: 'mode2',
							// 	labelOne: "肝炎",
							// 	formatterValueOne(data) {
							// 		return data['hepatitis'] == 'a' ? ' 肝炎诊断时年龄：' + data['hepatitisAge'] : data['hepatitis'] == 'b' ? '否' :
							// 			'未填报'
							// 	},
							// 	valueOne: "否",

							// 	labelTwo: "是否有其它消化系统疾病史",
							// 	formatterValueTwo(data) {
							// 		return data['otherDiseases'] == 'a' ? '疾病名称:' + data['diseasesName'] + '<br/>诊断时年龄：' + data['diseasesAge'] :
							// 			data['otherDiseases'] == 'b' ? '否' : '未填报'
							// 	},
							// 	valueTwo: ""
							// },
						]
					},
					
					{
						title: '呼气试验结果（最新数据）',
						list: [
							{
								type: 'mode1',
								label: "检查时间",
								value: "reportTime",
							},
							{
								type: 'mode3',
								label: "检查编号",
								value: "reportNum",
							},
							{
								type: 'mode3',
								label: "检查结果",
								value: "result",
							},
						]
					},
					
					
					{
						title: '实验室检查（最新数据）',
						list: [
							{
								type: 'mode1',
								label: "检查时间",
								value: "inspectionsTime",
							},
							{
								type: 'mode2',
								labelOne: "胃泌素-17（G-17）",
								formatterValueOne(data) {
									return data['g17'] ? data['g17'] + ' pmol/L' : '未填报'
								},
								valueOne: "g17",
								labelTwo: "胃蛋白酶原I（PGI）",
								formatterValueTwo(data) {
									return data['pgi'] ? data['pgi'] + ' μg/L' : '未填报'
								},
								valueTwo: "pgi",
							},
							{
								type: 'mode2',
								labelOne: "胃蛋白酶原II（PGII）",
								formatterValueOne(data) {
									return data['pgii'] ? data['pgii'] + ' μg/L' : '未填报'
								},
								valueOne: "pgii",
								labelTwo: "Hp抗体（IgG）检测",
								formatterValueTwo(data) {
									return data['igg'] == 'a' ? '阴性' : data['igg'] == 'b' ? '阳性' : '未填报'
								},
								valueTwo: "igg"
							},
							{
								type: 'mode2',
								hidden: true,
								labelOne: "CagA抗体",
								formatterValueOne(data) {
									return data['caga'] == 'a' ? '阴性' : data['caga'] == 'b' ? '阳性' : '未填报'
								},
								valueOne: "caga",
								labelTwo: "VacA抗体",
								formatterValueTwo(data) {
									return data['vaca'] == 'a' ? '阴性' : data['vaca'] == 'b' ? '阳性' : '未填报'
								},
								valueTwo: "vaca"
							},
							{
								type: 'mode2',
								hidden: true,
								labelOne: "尿霉素A抗体",
								formatterValueOne(data) {
									return data['urea'] == 'a' ? '阴性' : data['urea'] == 'b' ? '阳性' : '未填报'
								},
								valueOne: "urea",
								labelTwo: "尿霉素B抗体",
								formatterValueTwo(data) {
									return data['ureb'] == 'a' ? '阴性' : data['ureb'] == 'b' ? '阳性' : '未填报'
								},
								valueTwo: "ureb"
							},
							{
								type: 'img',
								label: "图片资料",
								value: "inspectionsImgs",
								list: []
							}
						]
					},

					{
						title: '胃癌患病风险评估（最新数据）',
						list: [{
								type: 'mode3',
								label: "根据李氏筛查评估量表，结合您的年龄、性别、G-17、PG I、PG II、PGR等因素，经人工智能分析得出您的早期胃癌风险情况如下：",
								value: 'none',
							},
							{
								type: 'mode2',
								labelOne: "胃癌患病风险评分",
								valueOne: "riskScore",
								formatterValueOne(data) {
									return data['riskScore'] ? data['riskScore'] + '分' : '未填报'
								},
								labelTwo: "胃癌患病风险等级",
								valueTwo: "riskLevel",
								formatterValueTwo(data) {
									return data['riskLevel'] == 'a' ? '高风险(≥17分)' : data['riskLevel'] == 'b' ? '中风险(12～16分)' : data['riskLevel'] ==
										'c' ? '低风险(0～11分)' : '未填报'
								},
							},
							{
								type: 'mode3',
								label: "胃癌筛查策略",
								value: "胃癌筛查策略"
							},
						]
					},
					// 胃癌患病风险等级：高风险
					// 胃癌筛查策略：强烈推荐胃镜精查
					{
						title: '胃镜检查结果（最新数据）',
						list: [
							{
								type: 'mode1',
								label: "检查时间",
								value: "gastricTime",
							},
							// {
							// 	type: 'mode2',
							// 	labelOne: "检查时间",
							// 	valueOne: "gastricTime",
							// 	labelTwo: "胃镜检查方式",
							// 	formatterValueTwo(data) {
							// 		return data['gastricWay'] == 'a' ? '胃镜普通白光检查' : data['gastricWay'] == 'b' ? '胃镜普通白光+LCI检查' : data[
							// 			'gastricWay'] == 'c' ? '磁控胶囊内镜检查' : '未填报'
							// 	},
							// 	valueTwo: "gastricWay"
							// },
							// {
							// 	type: 'mode3',
							// 	label: "胃镜普通白光检查、普通白光+LCI检查、或胶囊内镜检查结果",
							// 	value: "gastricResults",
							// 	formatter: true,
							// 	formatterValue(data) {
							// 		return data['gastricResults'] == 'a' ? '未见异常' : data['gastricResults'] == 'b' ? '异常' : '未填报'
							// 	},
							// },
							// {
							// 	type: 'mode3',
							// 	label: "胃镜精查方式",
							// 	value: "gastroscopeWay",
							// 	opts: [{
							// 			value: 'a',
							// 			label: 'NBI'
							// 		},
							// 		{
							// 			value: 'b',
							// 			label: 'FICE'
							// 		},
							// 		{
							// 			value: 'c',
							// 			label: 'I-SCAN'
							// 		},
							// 		{
							// 			value: 'd',
							// 			label: 'BLI'
							// 		},
							// 		{
							// 			value: 'e',
							// 			label: '放大内镜'
							// 		},
							// 		{
							// 			value: 'f',
							// 			label: '激光共聚焦显微内镜'
							// 		},
							// 		{
							// 			value: 'g',
							// 			label: '荧光内镜'
							// 		},
							// 		{
							// 			value: 'h',
							// 			label: '化学染色'
							// 		},
							// 	]
							// },
							{
								type: 'mode3',
								label: "检查所见",
								value: "diagnoseInfo",
							},
							{
								type: 'mode3',
								label: "诊断",
								value: "diagnoseResult",
							},
							{
								type: 'img',
								label: "图片资料",
								value: "gastricImgs",
								list: []
							},
						]
					},
					{
						title: '病理报告（最新数据）',
						list: [
							{
								type: 'mode1',
								label: "化验时间",
								value: "examTime",
							},
							{
								type: 'mode1',
								label: "临床诊断",
								value: "clinicalDiagnosis",
							},
							{
								type: 'mode3',
								label: "样本名称",
								value: "specimenName",
							},
							{
								type: 'mode3',
								label: "诊断结果",
								value: "examResult",
							},
							{
								type: 'mode3',
								label: "镜下所见",
								value: "examFinding",
							},
							{
								type: 'img',
								label: "病理图片",
								value: "pathologyImage",
								list: []
							},
						]
					}
				]
			}
		},
		onLoad(option) {
			this.getMember()
			this.id = option.id || ''

			if (option.id) {
				this.getInfo(option.id)
			}
		},
		methods: {
			previewImage(list,index) {
				uni.previewImage({
					current:index, //预览图片的下标
					urls: list,
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			deepClone(source) {
				if (!source && typeof source !== 'object') {
					throw new Error('error arguments', 'shallowClone')
				}
				const targetObj = source.constructor === Array ? [] : {}
				Object.keys(source).forEach(keys => {
					if (source[keys] && typeof source[keys] === 'object') {
						targetObj[keys] = source[keys].constructor === Array ? [] : {}
						targetObj[keys] = this.deepClone(source[keys])
					} else {
						targetObj[keys] = source[keys]
					}
				})
				return targetObj
			},
			formatterBasicVal(val, opts, basicVal) {
				if (Array.isArray(val)) {
					let str = ''
					for (let j = 0; j < val.length; j++) {
						for (let i = 0; i < opts.length; i++) {
							if (val[j] == opts[i].value) {
								str = str + opts[i].label + '<br/>'
							}
						}
					}
					return str
				} else {
					if (basicVal == '胃癌筛查策略') {
						return this.data['riskLevel'] == 'a' ? '强烈推荐磁控胶囊内镜或内镜检查' : this.data['riskLevel'] == 'b' ? '推荐磁控胶囊内镜或内镜检查' : this
							.data['riskLevel'] == 'c' ? '推荐定期随访' : '未填报'
					} else {
						if (val || val > 0) {
							val = val + ''
						}
						return val == 'a' ? '是' : val == 'b' ? '否' : val ? val : basicVal != 'none' ? '未填报' : ''
					}
				}
			},
			updatePickerVal(event, props) {
				this.data = {}
				this.member = event.detail.value
				this.getInfo(this.memberList[this.member].id)
			},
			change() {},
			viewImg(obj) {
				console.log(obj)
				// this.bigImg = obj
				// console.log(this.bigImg)
				// this.modalName = 'Image'
			},
			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.id) {
							this.getInfo(this.memberList[0].id)
						} else {
							for (var i = 0; i < this.memberList.length; i++) {
								if (this.id == this.memberList[i].id) {
									this.member = i
								}
							}
						}
					}
				}).catch(err => {
					console.log(err)
				})
			},

			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) {
						let obj = Object.assign({}, d.object.reportContent.data)
						this.data = d.object.reportContent.data
						this.data.reportTime = d.object.reportTime
						this.data.name = d.object.name


						// 处理多条血检,多条胃镜，多条病理情况
						// 血检 examSet
						function compareUp(data, propertyName) { // 降序
						   if ((typeof data[0][propertyName]) != "number") { // 属性值为非数字
								   return function(object1, object2) {
										var value1 = object1[propertyName];
										var value2 = object2[propertyName];
										return value2.localeCompare(value1);
								   }
						   } else {
								return function(object1, object2) { // 属性值为数字
									  var value1 = object1[propertyName];
									  var value2 = object2[propertyName];
									  return value2 - value1;
								}
							}
						}
						function concatJson (obj1, obj2) {
						  for (const key2 in obj2) {
						    for (const key1 in obj1) {
						      if (key2 == key1) {
						        if (obj2[key2]) {
						          console.log(key2);
						          console.log(obj2[key2]);
						          obj1[key1] = obj2[key2]
						        }
						      }
						      if (!obj1[key2]) {
						        obj1[key2] = obj2[key2]
						      }
						    }
						  }
						  return obj1
						}
						
						if (obj.hpBreathSet&&obj.hpBreathSet.length > 0) {
							obj.hpBreathSet = obj.hpBreathSet.sort(compareUp(obj.hpBreathSet, "reportTime"))
							this.data = concatJson(this.data, obj.hpBreathSet[0])
						}
						
						if (obj.examSet&&obj.examSet.length > 0) {
							obj.examSet = obj.examSet.sort(compareUp(obj.examSet, "inspectionsTime"))
							this.data = concatJson(this.data, obj.examSet[0])
						}
						
						if (obj.gastricSet&&obj.gastricSet.length > 0) {
							obj.gastricSet = obj.gastricSet.sort(compareUp(obj.gastricSet, "gastricTime"))
							this.data = concatJson(this.data, obj.gastricSet[0])
						}
						
						if (obj.pathologySet&&obj.pathologySet.length > 0) {
							obj.pathologySet = obj.pathologySet.sort(compareUp(obj.pathologySet, "examTime"))
							this.data = concatJson(this.data, obj.pathologySet[0])
						}
						
						// 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[2].list[3].hidden = this.data['igg'] != 'b'
						this.collapseList[2].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]) {
										let imgArr = []
										if (this.data[this.collapseList[i].list[j].value].length > 0) {
											this.data[this.collapseList[i].list[j].value].forEach((item) => {
												imgArr.push('http://139.9.163.126/gastric/' + item)
											})
										}
										this.collapseList[i].list[j].list = imgArr
									}
								} 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)
										// console.log(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)
				})
			},

			getImgList(imgStr, i, j) {
				console.log(imgStr)
				// http://139.9.163.126/sjsc/
				// let arr = imgStr.split(",")
				//  for (let k = 0; k < arr.length; k++) {
				// 	this.$http.get(`/zuul/gastric-cancer-data/report/downloadImage?id=${arr[k]}`).then(res => {
				// 		if(res.data.code == 1) {
				// 		  let imgType = res.data.object.fileName.split('.')
				// 		  this.collapseList[i].list[j].list.push({ "imgName": res.data.object.base64ImgData, "imgType": imgType[imgType.length - 1] })
				// 		}
				// 	})
				// }
			}
		}
	}
</script>

<style lang="scss" scoped>
	.screen {}

	.cu-form-group {
		padding: 0.5px 24upx;
	}

	.uni-collapse-cell:last-child {
		margin-bottom: 30upx;
	}

	.noneInfo {
		margin-top: 150upx;

		.noneInfoImg {
			background-image: url('../../static/noneInfo.png');
			height: 128upx;
			background-position: center;
			background-repeat: no-repeat;
		}
	}

	.basic-info-item {
		overflow: hidden;
		position: relative;
		padding: 20upx 34upx;
		display: flex;
		display: -webkit-flex;
		flex-direction: row;
		-webkit-flex-direction: row;
		justify-content: space-between;
		-webkit-justify-content: space-between;

		.basic-info-left {
			flex-grow: 1;
			-webkit-flex-grow: 1;

			.info-title {
				font-size: 28upx;
				color: #333;
				line-height: 40upx;
			}
		}

		.basic-info-right {
			flex-shrink: 0;
			-webkit-flex-shrink: 0;

			.info-text {
				font-size: 26upx;
				line-height: 40upx;
				color: #999;
			}
		}
	}

	.info-text {
		font-size: 26upx;
		line-height: 40upx;
		color: #999;
	}

	.basic-info-item:after,
	.stock-info-item:after {
		content: "";
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		border-bottom: 1px solid #ddd;
		-webkit-transform: scaleY(.5);
		-webkit-transform-origin: 0 100%;
	}

	.stock-info-item {
		overflow: hidden;
		position: relative;
		padding: 20upx 24upx;
	}
</style>
