<template>
	<view class="vac-form">
		<!-- 展示内容 -->
			<uni-forms :modelValue="formData" label-width="110">
				<!-- 基本信息 -->
				<uni-group title="基本信息" top="0">
					<uni-forms-item required label="身份证号">
						<view class="form_zhan" :class="formData.idCard?'':'nodata'">{{formData.idCard||'暂无信息'}}</view>
					</uni-forms-item>
					<uni-forms-item required label="姓名">
						<view class="form_zhan" :class="formData.userName?'':'nodata'">{{formData.userName||'暂无信息'}}
						</view>
					</uni-forms-item>

					<uni-forms-item label="年龄">
						<view class="form_zhan" :class="formData.age?'':'nodata'">{{formData.age||'暂无信息'}}</view>
					</uni-forms-item>

					<uni-forms-item label="性别">
						<view class="form_zhan" :class="formData.gender?'':'nodata'">{{formData.gender||'暂无信息'}}</view>
					</uni-forms-item>
					<uni-forms-item label="联系号码">
						<view class="form_zhan" :class="formData.phoneNum?'':'nodata'">{{formData.phoneNum||'暂无信息'}}
						</view>
					</uni-forms-item>
					<uni-forms-item label="人员分类">
						<view class="form_zhan" :class="keyIndustries?'':'nodata'">{{keyIndustries||'暂无信息'}}</view>
					</uni-forms-item>
				</uni-group>
				<!-- 户籍信息 -->
				<view>
					<view class="addtit">户籍信息</view>
					<view class="npd15">
						<uni-forms-item required label="户籍地址">
							<view class="form_zhan" :class="birAddress?'':'nodata'">{{birAddress||'暂无信息'}}</view>
						</uni-forms-item>
						<uni-forms-item label="详细地址" label-position="top">
							<view class="form_zhan form_right" :class="formData.nowIn?'':'nodata'">{{formData.nowIn||'暂无信息'}}
							</view>
						</uni-forms-item>
					</view>
					<!-- 居住地 -->
					<view>
						<!-- 新增的 -->
						<!-- 多个现居地 -->
						<view v-for="(item,idx) in formData.czrkJzdzList" style="padding: 10rpx 0;">
							<view class="npd15">
							<uni-forms-item label="现居地">
								<view class="form_zhan" :class="!item.province&&!item.city&&!item.region&&!item.town&&!item.village?'nodata':''">
									{{!item.province&&!item.city&&!item.region&&!item.town&&!item.village?'暂无信息':item.province + item.city + item.region+ item.town + item.village}}</view>
							</uni-forms-item>
							<uni-forms-item label="详细地址" label-position="top">
								<view class="form_zhan form_right" :class="item.nowIn?'':'nodata'">{{item.nowIn||'暂无信息'}}</view>
							</uni-forms-item>
							</view>
						</view>
					</view>
				
				
					<view class="npd15">
						<uni-forms-item label="户主">
							<view class="form_zhan" :class="formData.houseType?'':'nodata'">{{formData.houseType||'暂无信息'}}
							</view>
						</uni-forms-item>
						<uni-forms-item label="户编号">
							<view class="form_zhan" :class="formData.code?'':'nodata'">{{formData.code||'暂无信息'}}</view>
						</uni-forms-item>
						
				
						<uni-forms-item label="与户主关系">
							<view class="form_zhan" :class="formData.yhzgx?'':'nodata'">{{formData.yhzgx||'暂无信息'}}
							</view>
						</uni-forms-item>
						<!-- 网格 -->
						<uni-forms-item label="网格">
							<view class="form_zhan" :class="formData.gridName?'':'nodata'">{{formData.gridName||'暂无信息'}}</view>
						</uni-forms-item>
						<!-- <uni-forms-item label="工作单位">
							<view class="form_zhan" :class="formData.workUnit?'':'nodata'">{{formData.workUnit||'暂无信息'}}
							</view>
						</uni-forms-item> -->
				
						<uni-forms-item label="备注" label-position="top">
							<view class="form_zhan form_right" :class="formData.remark?'':'nodata'">{{formData.remark||'暂无信息'}}</view>
						</uni-forms-item>
				
					</view>
				</view>
				
				<!-- 操作信息 -->
				<uni-group title="操作信息">
					<uni-forms-item label="操作人员">
						<view class="form_zhan" :class="formData.updateBy?'':'nodata'">{{formData.updateBy||'暂无信息'}}
						</view>
					</uni-forms-item>
					<uni-forms-item label="操作日期" v-if="formData.updateTime">
						<view class="form_zhan" :class="formData.updateTime?'':'nodata'">{{rTime('YYYY-mm-dd',formData.updateTime)||'暂无信息'}}</view>
					</uni-forms-item>
					<uni-forms-item label="操作日期" v-else>
						<view class="form_zhan" :class="formData.createTime?'':'nodata'">{{rTime('YYYY-mm-dd',formData.createTime)||'暂无信息'}}</view>
					</uni-forms-item>
				</uni-group>
			</uni-forms>
	</view>
</template>

<script>
	// import senSetPicker from '../../_components/picker/dateTimePicker.vue'
	// import hUploadImage from '../../_components/hUploadImage.vue'
	// import selectMuPicker from '../../_components/picker/selectMutilPicker.vue'
	// import selectPicker from '../../_components/picker/selectPicker.vue'
	// import hModal from '../../_components/hModal.vue'
	// import dataTimePicke from '../../_components/picker/dataTimePicke.vue'
	// import areaP from '../../_components/picker/areaP.vue'
	// import pickRegions from '@/components/pick-regions/pick-regions.vue'
	// import uniPopup from '@/components/uni-popup/uni-popup.vue'
	// import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	import hostUrl from "@/util/url";
	let {
		host,
		imgDomain
	} = hostUrl

	export default {
		components: {
			// uniPopup,
			// uniPopupDialog,
			// pickRegions,
			// senSetPicker,
			// hUploadImage,
			// selectPicker,
			// hModal,
			// selectMuPicker,
			// dataTimePicke,
			// areaP
		},
		data() {
			return {
				delimg: require("@/static/image/del.png"),
				delfalg: false,
				birAddress: '',
				jiciOption: [], // 剂次选项
				curItem: {},
				curIndex: 0,
				noClick: true, // $noMultipleClicks变量
				defaultRegion: ['安徽省', '安庆市', '潜山市'], // 初始值必须为空，否则更换默认值时不能生效
				searchRegion: [],
				formData: {
					"id": '',
					'villageTowns': '',
					'village': '',
					'birthday': '',
					'age': '',
					'code': '',
					'villagerGroup': '',
					'houseTypeValue': 1,
					'houseType': '',
					'domicile': '',
					'province': '',
					'city': '',
					'region': '',
					'userName': '',
					'genderIndex': 0,
					'idCard': '',
					'phoneNum': '',
					'keyIndustries': '',
					"isVaccinationValue": 0,
					"isVaccination": "是",
					// "vaccinationPlace": null,
					// "contraindication": null,
					// "suspend": "",
					"death": "",
					"lostInMissing": "",
					"shouldBe": "",
					"other": "",
					// "nowIn": "安徽省安庆市潜山市现居地",
					'nowIn': '',
					"remark": "",
					"status": "",
					"createBy": null,
					"createTime": null,
					"updateBy": null,
					"updateTime": null,
					"isDel": null,
					// "urlArr":[], // 禁忌症文件上传地址
					// 'url': [],//提交的数据
					// "suspendUrlArr": [], // 暂缓接种附件
					// 'suspendUrl': [],// 提交的数据
					// "otherUrlArr": [], // 其他附件
					// 'otherUrl': [],// 提交的数据
					// "vaccineInfoUserList": [{
					// 	"vaccineName": "",
					// 	"vaccinationTime": "",
					// 	"vaccinationPlace": "",
					// 	"jici": "",
					// 	'progressValue': 1,
					// 	"progress": "未完成",
					// 	'urlArr': [],// 附件
					// 	'isDel': 'N'
					// }],
					// "code": "123",
					// "crowd_classification": "人群分类"
				},
				areaList: [],
				inputValue: '',
				shixian: false,
				imageValue: {},
				sexRange: [{
					"value": 0,
					"text": "男"
				}, {
					"value": 1,
					"text": "女"
				}], // 性别
				isUPN: [{
					"value": 0,
					"text": "是"
				}, {
					"value": 1,
					"text": "否"
				}], // 是否户主
				vaccination: [{
					"value": 0,
					"text": "是"
				}, {
					"value": 1,
					"text": "否"
				}], // 是否接种
				vacPro: [{
					"value": 0,
					"text": "已完成"
				}, {
					"value": 1,
					"text": "未完成"
				}], // 接种进度
				vacTitle: [], // 疫苗名称
				birthplace: [], // 户籍地
				trades: [], // 重点行业
				contraindication: [], // 禁忌症
				othersOption: [], // 其他原因
				moratorium: [], // 暂缓接种
				vacTimes: [], // 接种疫苗剂次
				vacArea: [], // 疫苗接种地点
				modalContent: '',
				delvalue: '', //删除原因



				peopleclass: [], //人员分类，
				keyIndustries: '',
				deletelist: [], //删除字典
				edidflag: true,
				codefalg:false, //
			}
		},
		methods: {
			getClose() {
				this.delfalg = false
			},
			rTime(format,date) {
				date=new Date(date);
				const dataItem = {
				    'Y+': date.getFullYear().toString(),
				    'm+': (date.getMonth() + 1).toString(),
				    'd+': date.getDate().toString(),
				    'H+': date.getHours().toString(),
				    'M+': date.getMinutes().toString(),
				    'S+': date.getSeconds().toString(),
				  };
				  Object.keys(dataItem).forEach((item) => {
				    const ret = new RegExp(`(${item})`).exec(format);
				    if (ret) {
				      format = format.replace(ret[1], ret[1].length === 1 ? dataItem[item] : dataItem[item].padStart(ret[1].length, '0'));
				    }
				  });
				  return format;
			},
			takePhoto() {
				console.log('---------')
				var that = this
				uni.chooseImage({
					count: 1,
					sourceType: 'camera',
					success(res) {
						var file = res.tempFilePaths[0]
						that.ocrParse(file)
					}
				})
			},
			ocrParse(filePath) {
				var url = host + '/boman-file/ocrIdCard'
				var token = uni.getStorageSync('token')
				// var token = "df057579-73c8-4bdd-8312-f64db8efd699"
				uni.showLoading()
				uni.uploadFile({
					url: url,
					filePath: filePath,
					name: 'file',
					header: {
						// 'Content-type': 'multipart/form-data',
						'Authorization': token
					},
					success: res => {
						uni.hideLoading()
						console.log(JSON.stringify(res))
						var data = JSON.parse(res.data)
						this.formData.idCard = data.data.id
						this.formData.userName = data.data.name
						this.formData.age = this.getAge(data.data.birth)
						this.formData.gender = data.data.gender
						if (this.formData.gender == '男') {
							this.formData.genderIndex = 0
						} else {
							this.formData.genderIndex = 1
						}
					},
					fail: err => {
						uni.hideLoading();
						console.log(JSON.stringify(err))
						uni.showToast({
							title: err.errMsg,
							icon: "none"
						})
					}
				})
			},
			isVaccinationChange(e) {
				console.log('isVaccinationChange ' + JSON.stringify(e))
				console.log(this.formData.isVaccinationValue)
			},
			vacTimeChange(e) {
				var curItem = this.formData.vaccineInfoUserList[this.curIndex]
				this.$set(curItem, 'vaccinationTime', e)
			},
			submit() {
				if (!this.formData.idCard) {
					uni.showToast({
						title: '请输入身份证号码',
						icon: "none"
					})
					return
				}
				if (!this.formData.userName) {
					uni.showToast({
						title: '请输入姓名',
						icon: "none"
					})
					return
				}
				// if(!this.formData.code){
				// 	uni.showToast({
				// 		title: '请输入户编号',
				// 		icon: "none"
				// 	})
				// 	return
				// }
				if (!this.birAddress) {
					uni.showToast({
						title: '请选择户籍地址',
						icon: "none"
					})
					return
				}
				if (this.formData.houseTypeValue == 0) {
					this.formData.houseType = '是'
					//户主
				} else {
					this.formData.houseType = '否'
				}
				if (this.formData.genderIndex == 0) {
					this.formData.gender = '男'
				} else {
					this.formData.gender = '女'
				}

				var tempArr = []
				// console.log(JSON.stringify(this.formData))
				if (this.formData.id) {
					this.$http.post('boman-web-core/core/ryrl/editRlry', this.formData).then(res => {
						if (res.code == 200) {
							uni.navigateTo({
								url: '/add/pages/addvacfrom/submit'
							})
						} else {
							uni.showToast({
								title: res.msg,
								icon: "none"
							})
						}
					})
				} else {
					this.$http.post('boman-web-core/core/ryrl/addRlry', this.formData).then(res => {
						if (res.code == 200) {
							uni.navigateTo({
								url: '/add/pages/addvacfrom/submit'
							})
							// uni.showToast({
							// 	title: '提交成功',
							// 	icon: "none"
							// })
							// setTimeout(function() {
							// 	uni.navigateBack()
							// }, 1000)
						} else {
							uni.showToast({
								title: res.msg,
								icon: "none"
							})
						}
					})
				}
			},
			// 修改
			getUpdateFn() {
				this.edidflag = false
			},
			//删除
			getDeletFn() {
				this.delfalg = true;
			},
			deletSure() {
				var that = this;
				var params = {
					id: this.formData.id,
					deleteReason: this.delvalue
				}
				this.$http.get('boman-web-core/core/czrk/deleteCzrk', params).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: '删除成功',
							icon: "none"
						})
						setTimeout(function() {
							uni.navigateBack()
						}, 1000)
					} else {
						this.delfalg = false;
						uni.showToast({
							title: res.msg,
							icon: "none"
						})
					}
				})
			},
			delete() {
				// this.$http.post('boman-web-core/core/ryrl/editRlry', this.formData).then(res=>{
				// 	if(res.code == 200 ) {
				// 		uni.showToast({
				// 			title: '提交成功',
				// 			icon: "none"
				// 		})
				// 		setTimeout(function() {
				// 			uni.navigateBack()
				// 		}, 1000)
				// 	}
				// })
			},
			regionPickerChange(region) {
				this.searchRegion = region
				console.log(this.searchRegion, 'searchRegion')
				var codeArray = this.searchRegion.map(item => item ? item.code : undefined)
				var nameArray = this.searchRegion.map(item => item ? item.name : undefined)
				this.formData.province = nameArray[0]
				this.formData.city = nameArray[1]
				this.formData.region = nameArray[2]
			},
			uploadFile(filePath, type) {
				var that = this
				uni.showLoading()
				var url = host + '/boman-file/upload'
				var token = uni.getStorageSync('token')
				// var token = "df057579-73c8-4bdd-8312-f64db8efd699"
				uni.uploadFile({
					url: url,
					filePath: filePath,
					name: 'file',
					header: {
						// 'Content-type': 'multipart/form-data',
						'Authorization': token
					},
					success: res => {
						uni.hideLoading()
						console.log(JSON.stringify(res))
						var data = JSON.parse(res.data)
						var imgUrl = data.data.url
						console.log('imgUrl ' + imgUrl)
						// var regexp = new RegExp("((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*/?", "g");
						// imgUrl = imgUrl.replace(regexp, imgDomain + '/');
						console.log('imgUrl ' + imgUrl)
						if (type == 'url') { // 禁忌症附件
							that.formData.urlArr.push(imgUrl)
						} else if (type == 'suspendUrl') { // 暂缓接种附件
							that.formData.suspendUrlArr.push(imgUrl)
						} else if (type == 'otherUrl') { // 其他附件
							that.formData.otherUrlArr.push(imgUrl)
						} else if (type == 'vacUrl') { // 接种信息每行的附件
							var curItem = that.formData.vaccineInfoUserList[that.curIndex]
							console.log('--------curItem ' + JSON.stringify(curItem))
							curItem.urlArr.push(imgUrl)
							that.$set(curItem, 'urlArr', curItem.urlArr)
						}
						console.log('=========' + JSON.stringify(that.formData))
					},
					fail: err => {
						uni.hideLoading();
						console.log(JSON.stringify(err))
						uni.showToast({
							title: err.errMsg,
							icon: "none"
						})
					}
				})
			},
			chooseImg(type, index) {
				console.log('type ' + type + ' index ' + index)
				var that = this
				if (index) {
					that.curIndex = index
					console.log('curIndex ' + that.curIndex)
				}
				var count = 1
				// if (type == 'company') {
				// 	count = 9
				// }
				uni.chooseImage({
					count: count,
					sizeType: ['original', 'compressed'],
					sourceType: ['album', 'camera'],
					success: function(res) {
						console.log("res.tempFilePaths", res.tempFilePaths)
						for (let i = 0; i < res.tempFilePaths.length; i++) {
							let imgSrc = res.tempFilePaths[i]
							that.uploadFile(imgSrc, type)
						}
					}
				})
			},
			removeImg(index, type) {
				if (type == 'url') { // 禁忌症附件
					this.formData.urlArr.splice(index, 1)
				} else if (type == 'suspendUrl') { // 暂缓接种附件
					this.formData.suspendUrlArr.splice(index, 1)
				} else if (type == 'otherUrl') { // 其他附件
					this.formData.otherUrlArr.splice(index, 1)
				} else if (type == 'vacUrl') { //接种附件
					var curItem = this.formData.vaccineInfoUserList[this.curIndex]
					curItem.urlArr.splice(index, 1)
				}
			},
			getOthersOption() {
				this.$http.get('system/dict/data/type/other_status').then(res => {
					if (res.code == 200) {
						this.othersOption = res.data.map(v => {
							return {
								label: v.dictLabel,
								vlaue: v.dictValue,
								children: v.children
							}
						})
						console.log('othersOption ' + JSON.stringify(this.othersOption))
					}
				})
			},
			/* 获取疫苗名称 */
			getVacTitle() {
				this.$http.get('system/dict/data/type/vaccine_name').then(res => {
					if (res.code == 200) {
						this.vacTitle = res.data.map(v => {
							return {
								label: v.dictLabel,
								vlaue: v.dictValue,
								children: v.children
							}
						})
						// 如果是“编辑”模式，根据每行的疫苗厂商，设置剂次选项
						if (this.formData.id) {
							for (var i = 0; i < this.formData.vaccineInfoUserList.length; i++) {
								var curItem = this.formData.vaccineInfoUserList[i]
								console.log('------curItem ' + JSON.stringify(curItem))
								for (var j = 0; j < this.vacTitle.length; j++) {
									var item = this.vacTitle[j]
									console.log('======item ' + JSON.stringify(item))
									if (item.label == curItem.vaccineName) {
										this.$set(curItem, 'jiciOption', item.children)
									}
								}
							}
						}
						console.log('vacTitle ' + JSON.stringify(this.vacTitle))
					}
				})
			},
			/* 获取户籍地 */
			getBirthplace() {
				this.$http.get('boman-web-core/administrativeInfo/treeSelect').then(res => {
					if (res.code == 200) {
						this.birthplace = res.data
					}
				})
			},
			/* 重点行业 */
			getTrade() {
				this.$http.get('system/dict/data/type/key_trades').then(res => {
					if (res.code == 200) {
						this.trades = res.data.map(v => {
							return {
								label: v.dictLabel,
								vlaue: v.dictValue
							}
						})
					}
				})
			},
			/* 禁忌症 */
			getContraindication() {
				this.$http.get('system/dict/data/type/contraindication').then(res => {
					if (res.code == 200) {
						this.contraindication = res.data.map(v => {
							return {
								label: v.dictLabel,
								vlaue: v.dictValue
							}
						})
					}
				})
			},
			/* 获取暂缓接种 */
			getMonVac() {
				this.$http.get('system/dict/data/type/moratorium_on_vaccination').then(res => {
					if (res.code == 200) {
						this.moratorium = res.data.map(v => {
							return {
								label: v.dictLabel,
								vlaue: v.dictValue
							}
						})
					}
				})
			},
			/* 获取疫苗剂次 */
			getVacDictValue(val) {
				let url = '/system/dict/data/type/' + val
				this.$http.get(url).then(res => {
					if (res.code == 200) {
						this.vacTimes = res.data
					}
				})
			},
			/* 获取接种地点 */
			getVacArea() {
				this.$http.get('/system/dict/data/type/vaccination_site').then(res => {
					console.log(res)
					if (res.code == 200) {
						this.vacArea = res.data.map(v => {
							return {
								label: v.dictLabel,
								vlaue: v.dictValue
							}
						})
					}
				})
			},
			/* 初始化 */
			init() {
				this.getPeopleClass();

				// this.getBirthplace();
				// this.getDelectList();

			},
			// 回显数据字典
			selectDictLabel(datas, value) {
				var actions = [];
				Object.keys(datas).some((key) => {
					if (datas[key].dictValue == ('' + value)) {
						actions.push(datas[key].dictLabel);
						return true;
					}
				})
				return actions.join('');
			},

			getDetail() {
				this.$http.get('boman-web-core/core/ryrl/getById/' + this.formData.id).then(res => {
					if (res.code == 200) {
						this.init()

						this.formData = res.data;
						if (this.formData.houseType == '是') {
							this.formData.houseTypeValue = 0
						} else {
							this.formData.houseTypeValue = 1;
							this.formData.houseType = '否'
						}
						if (this.formData.gender == '男') {
							this.formData.genderIndex = 0
						} else {
							this.formData.genderIndex = 1
						}
						if (this.formData.isVaccination == '是') {
							this.formData.isVaccinationValue = 0
						} else {
							this.formData.isVaccinationValue = 1
						}
						
						this.birAddress = ''
						
						if (this.formData.province) {
							this.birAddress += this.formData.province
						}
						if (this.formData.city) {
							this.birAddress += this.formData.city
						}
						if (this.formData.region) {
							this.birAddress += this.formData.region
						}
						if (this.formData.villageTowns) {
							this.birAddress += this.formData.villageTowns
						}
						if (this.formData.village) {
							this.birAddress += this.formData.village
						}
						if (this.formData.villagerGroup) {
							this.birAddress += this.formData.villagerGroup
						}
					}
				})
			},
			getDelectList() {
				// 删除显示
				var tthat = this;
				this.$http.get('system/dict/data/type/people_status').then(res => {
					if (res.code == 200) {
						this.delvalue = res.data[0].dictValue
						this.deletelist = res.data.map(v => {
							return {
								label: v.dictLabel,
								value: v.dictValue
							}
						})
					}
				})
			},
			getDeltab(e) {
				this.delvalue = e;
			},
			// 人员分类
			getPeopleClass() {
				var that = this;
				this.$http.get('system/dict/data/type/renyuanfenlei').then(res => {
					if (res.code == 200) {
						if (that.formData.keyIndustries) {
							that.keyIndustries = that.selectDictLabel(res.data, that.formData.keyIndustries)
						}
						this.peopleclass = res.data.map(v => {
							return {
								label: v.dictLabel,
								value: v.dictValue
							}
						})
					}
				})
			},
			// 显示人员分类
			showPropleSelect() {
				// if (this.formData.id != undefined && this.formData.id != "") {
				// 	return
				// }
				// this.curIndex = index
				this.$refs.peopleselet.show()
			},
			peopleChange(e) {
				var label = e[0].label;
				this.keyIndustries = e[0].label;
				this.formData.keyIndustries = e[0].value;
			},
			/* 上传后端获取身份证信息 */
			getIdcardInfo(val) {
				if (this.formData == undefined) {
					return
				}
				if (this.formData.idCard == undefined || this.formData.idCard == '') {
					return
				}
				this.$http.post('boman-web-core/core/info/findHjInfo', {
					idCard: this.formData.idCard
				}).then(res => {
					if (res.code == 200) {
						this.formData.userName = res.data.userName
						this.formData.age = res.data.age
						this.formData.gender = res.data.gender
						this.formData.id = res.data.id
						if (this.formData.gender == '男') {
							this.formData.genderIndex = 0
						} else {
							this.formData.genderIndex = 1
						}
					}
				})
			},
			// 疫苗选择组件
			showVacPicker(index) {
				if (this.formData.id != undefined && this.formData.id != "") {
					return
				}
				this.curIndex = index
				this.$refs.vacselet.show()
			},
			/* 成功选择疫苗 */
			vacNameChange(e) {
				console.log(JSON.stringify(e))
				var curItem = this.formData.vaccineInfoUserList[this.curIndex]
				console.log('------' + JSON.stringify(curItem))
				var label = e[0].label
				for (var i = 0; i < this.vacTitle.length; i++) {
					var item = this.vacTitle[i]
					console.log('0000000' + JSON.stringify(item))
					if (label == item.label) {
						this.$set(curItem, 'vaccineName', label)
						this.$set(curItem, 'jiciOption', item.children)
						this.$set(curItem, 'vaccineNum', item.children.length)
					}
				}
				console.log('======' + JSON.stringify(this.formData.vaccineInfoUserList[this.curIndex]))
			},
			// 剂次选择组件
			showJiciPicker(index) {
				if (this.formData.id != undefined && this.formData.id != "") {
					return
				}
				this.curIndex = index
				var curItem = this.formData.vaccineInfoUserList[this.curIndex]
				console.log('curItem ' + JSON.stringify(curItem))
				// this.jiciOption = curItem.jiciOption
				this.jiciOption = curItem.jiciOption.map(v => {
					return {
						label: v.dictLabel,
						vlaue: v.dictValue
					}
				})
				console.log('jiciOption ' + JSON.stringify(this.jiciOption))
				this.$refs.jici_select.show()
			},
			jiciChange(e) {
				console.log(JSON.stringify(e[0]))
				var curItem = this.formData.vaccineInfoUserList[this.curIndex]
				console.log('curItem ' + JSON.stringify(curItem))
				this.$set(curItem, 'jici', e[0].label)
				var selectedIndex
				for (var i = 0; i < curItem.jiciOption.length; i++) {
					var item = curItem.jiciOption[i]
					console.log('item ' + JSON.stringify(item))
					if (item.dictLabel == curItem.jici) {
						selectedIndex = i
					}
				}
				if (selectedIndex == curItem.jiciOption.length - 1) { // 位置为最后一剂次，设置已完成
					this.$set(curItem, 'progressValue', 0)
				} else {
					this.$set(curItem, 'progressValue', 1)
				}

			},
			showOthersPicker(index) {
				this.curIndex = index
				this.$refs.others_selet.show();
			},
			/* 其他 */
			othersChange(e) {
				console.log(JSON.stringify(e[0]))
				this.formData.other = e[0].label
			},
			/* 户籍地选择组件 */
			showbirPicker() {
				this.$refs.birselet.show()
			},
			/* 成功选择户籍 */
			birRegion(e) {
				console.log('---------' + JSON.stringify(e))
				this.formData.villageTowns = e[1].label
				this.formData.village = e[2].label
				this.formData.villagerGroup = e[3].label
				this.birAddress = this.formData.villageTowns + this.formData.village + this.formData.villagerGroup
			},
			/* 出生日期组件 */
			showDatePicker() {
				this.$refs.setpicker.show();

			},
			/* 重点行业选择组件 */
			showTrdesSelect() {
				this.$refs.tredselet.show();
			},
			/* 成功选择行业 */
			trdesChange(e) {
				this.formData.keyIndustries = e[0].label
			},
			/* 接种时间组件 */
			showVacTime(index) {
				if (this.formData.id != undefined && this.formData.id != "") {
					return
				}
				this.curIndex = index
				this.$refs.vacTime.show();
			},
			/* 禁忌症组件 */
			showMonList() {
				this.$refs.con_selet.show();
			},
			/* 成功选择禁忌症 */
			conChange(e) {
				console.log(JSON.stringify(e))
				this.formData.contraindication = e[0].label
			},
			/* 暂缓接种组件 */
			showWaitList() {
				this.$refs.mor_selet.show();
			},
			/* 成功选择暂缓原由 */
			morChange(e) {
				this.formData.suspend = e[0].label
			},
			/* 接种地点组件 */
			showVacArea(index) {
				if (this.formData.id != undefined && this.formData.id != "") {
					return
				}
				this.curIndex = index
				this.$refs.vacareaselet.show();
			},
			/* 成功选择接种地点 */
			vacAreaChange(e) {
				console.log(JSON.stringify(e[0]))
				var curItem = this.formData.vaccineInfoUserList[this.curIndex]
				this.$set(curItem, 'vaccinationPlace', e[0].label)
			},
			/* 省市区组件 */
			showArea() {
				this.$refs.area.show();
			},
			// quxiaobutton() {
			// 	this.shixian = false;
			// },
			// quedingbutton (bangdingyear,bangdingmonth,bangdingday){
			// 	this.shixian = false;
			// 	this.inputValue = bangdingyear + "-" + bangdingmonth + "-" + bangdingday;

			// },
			/* 添加接种信息 */
			addInfo(item) {
				if (this.formData.vaccineInfoUserList.length >= 3) {
					this.modalContent = '最多可添加三次接种信息'
					this.$refs.h_modal.show()
					return false
				}
				let obj = {
					"vaccineName": "",
					"vaccinationTime": "",
					"vaccinationPlace": "",
					"jici": "",
					'progressValue': 1,
					"progress": "未完成",
					'urlArr': [], // 附件
					'isDel': 'N'
				}
				this.formData.vaccineInfoUserList.push(obj)
				console.log(this.formData.vaccineInfoUserList)
			},
			delVacInfoDialog(item, index) {
				this.curItem = item
				this.curIndex = index
				this.$refs.delPopup.open()
			},
			/* 删除接种信息 */
			delConfirm(done) {
				done()
				if (this.formData.vaccineInfoUserList.length <= 1) {
					this.modalContent = '至少需要填写一次接种信息'
					this.$refs.h_modal.show()
					return false
				}
				// this.formData.vaccineInfoUserList.splice(index,1)
				this.$set(this.formData.vaccineInfoUserList[this.curIndex], 'isDel', 'Y')
			},
			getAge(strAge) {
				var birArr = strAge.split("-");
				var birYear = birArr[0];
				var birMonth = birArr[1];
				var birDay = birArr[2];

				d = new Date();
				var nowYear = d.getFullYear();
				var nowMonth = d.getMonth() + 1; //记得加1
				var nowDay = d.getDate();
				var returnAge;

				if (birArr == null) {
					return false
				};
				var d = new Date(birYear, birMonth - 1, birDay);
				if (d.getFullYear() == birYear && (d.getMonth() + 1) == birMonth && d.getDate() == birDay) {
					if (nowYear == birYear) {
						returnAge = 0; // 
					} else {
						var ageDiff = nowYear - birYear; // 
						if (ageDiff > 0) {
							if (nowMonth == birMonth) {
								var dayDiff = nowDay - birDay; // 
								if (dayDiff < 0) {
									returnAge = ageDiff - 1;
								} else {
									returnAge = ageDiff;
								}
							} else {
								var monthDiff = nowMonth - birMonth; // 
								if (monthDiff < 0) {
									returnAge = ageDiff - 1;
								} else {
									returnAge = ageDiff;
								}
							}
						} else {
							return "出生日期晚于今天，数据有误"; //返回-1 表示出生日期输入错误 晚于今天
						}
					}
					return returnAge;
				} else {
					return ("输入的日期格式错误！");
				}
			}
		},
		onLoad(option) {
			if (option.id) {
				this.formData.id = option.id;
				this.getDetail()
			} 
		},
	}
</script>

<style>
	.vac-form textarea {
		display: block;
		padding:16rpx 36rpx;
		font-size: 28rpx;
		box-sizing: border-box;
	}
</style>

<style scoped lang="scss">
	// 新修改的
	.npd15{padding:6px 15px;background-color: #FFFFFF;}
	.addtit{/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		padding-left: 15px;
		height: 40px;
		background-color: $uni-bg-color-grey;
		font-weight: normal;
		color: $uni-text-color;}
	.addbox{position: fixed;left: 0;right: 0;bottom: 0;background: #F2F2F2;padding: 20rpx 34rpx;z-index: 1;background: #ffffff;box-shadow: 0 14rpx 40rpx 12rpx rgba(218, 218, 218, 1);}
	.submit_btn {
		width: 100%;
		height: 96rpx;
		background: #00B034;
		border-radius: 6rpx;
		font-size: 34rpx;
	}

	.submit_btns {
		background: #EA2929;
		width: 684rpx;
		height: 98rpx;
		border-radius: 6rpx;
		font-size: 34rpx;
		margin-top: 20rpx;
	}

	.bgbox {
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.2);
		z-index: 3;
	}

	.delbox {
		width: 580rpx;
		background: #FFFFFF;
		border-radius: 14px;
		position: fixed;
		top: 50%;
		left: 80rpx;
		right: 80rpx;
		padding: 48rpx 34rpx 72rpx;
		box-sizing: border-box;
		z-index: 5;
		margin-top: -210rpx;

		.deltit {
			font-size: 28rpx;
			font-weight: bold;
			color: #343434;
			text-align: center;
			line-height: 40rpx;
		}

		.del_img {
			width: 34rpx;
			height: 34rpx;
			position: absolute;
			right: 34rpx;
			top: 44rpx;
		}

		.del_btn {
			width: 100%;
			height: 76rpx;
			background: #00B034;
			border-radius: 6rpx;
			font-size: 28rpx;
			font-weight: bold;
			color: #FFFFFF;
			text-align: center;
			line-height: 76rpx;
		}

		.del_list {
			display: flex;
			padding: 60rpx 0 40rpx;
			flex-wrap: wrap;

			.del_lista {
				width: 132rpx;
				height: 64rpx;
				background: #CACACA;
				border-radius: 32rpx;
				font-size: 26rpx;
				font-weight: 500;
				color: #FFFFFF;
				text-align: center;
				line-height: 64rpx;
				margin: 0 20rpx 20rpx 0;

				&.act {
					background-color: #019FE8;
				}
			}
		}
	}

	.form_zhan {
		flex: 1;
		width: 100%;
		display: flex;
		box-sizing: border-box;
		min-height: 72rpx;
		flex-direction: row;
		align-items: center;
		font-size: 28rpx;
		color: #343434;

		&.nodata {
			color: #999999;
		}
		&.form_right{background-color: rgb(242, 242, 242);height: 120rpx;padding: 10rpx;align-items: flex-start;}
	}





	.pick-line {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding-left: 20rpx;
	}

	.from_image {
		width: 30rpx;
		height: 30rpx;
	}

	.delPop {
		z-index: 2;
		top: -10rpx;
		right: -10rpx;

		.circleRed {
			width: 40rpx;
			height: 40rpx;
			background-color: red;
			border-radius: 50%;

			&::after,
			&::before {
				content: '';
				width: 25rpx;
				height: 5rpx;
				position: absolute;
				background-color: white;
				top: 50%;
				left: 50%;
				// transform-origin:center;
			}

			&::after {
				transform: translate(-50%, -50%) rotate(45deg);
			}

			&::before {
				transform: translate(-50%, -50%) rotate(-45deg);
			}
		}
	}

	.img-add {
		width: 120rpx;
		height: 120rpx;
		margin: 10rpx 3% 10rpx 0;
		border-radius: 10rpx;
		overflow: hidden;
		background-color: #f7f7f7;
		display: flex;
		flex-direction: column;
		justify-content: center;

		.add {
			padding-top: 0rpx;
			display: flex;
			flex-direction: column;
			align-items: center;

			image {}

			.font {
				color: #8a8a8a;
				font-size: 26rpx;
			}
		}

	}
</style>
