<template>
	<view class="ncc-wrap ncc-wrap-form">
		<!-- :rules="rules" -->
		<u-form :model="dataForm" ref="dataForm" :errorType="['toast']" label-position="top" label-width="120"
			label-align="left" class="ncc-form">

			<template v-if="step == 0">
				<u-form-item style="position: relative;" label="患者姓名" prop="name" required>
					<u-input v-model="dataForm.name" @blur="ClearPatient" @input="SelectPatient"
						placeholder="请输入"></u-input>
					<view class="patientInfo_box" v-show="patientInfo.length > 0">
						<view class="patientInfo_item" @click="ClickPatient(item)" v-for="(item,index) in patientInfo"
							:key="index">{{item.value}}
						</view>
					</view>
				</u-form-item>
				<u-form-item label="身份证号" prop="sfzhm">
					<u-input v-model="dataForm.sfzhm" placeholder="请输入"></u-input>
				</u-form-item>
				<u-form-item label="周期" prop="zq">
					<u-input v-model="dataForm.zq" placeholder="请输入"></u-input>
				</u-form-item>
				<u-form-item label="患教" prop="daibiao" required>
					<u-input v-model="dataForm.daibiao" placeholder="请输入"></u-input>
				</u-form-item>
				<u-form-item label="手机号" prop="sjh" required>
					<u-input v-model="dataForm.sjh" placeholder="请输入"></u-input>
				</u-form-item>
				<u-form-item label="地址" prop="dz" required>
					<u-input v-model="dataForm.dz" placeholder="请输入"></u-input>
				</u-form-item>
				<u-form-item label="发放门店" prop="ffmd" required @click="selectYaoBin">
					<ncc-select v-model="dataForm.ffmd" :options="ffmdOptions" :props="ffmdProps"
						placeholder="请选择"></ncc-select>
				</u-form-item>

				<u-form-item label="领药时间" prop="lysj1" required>
					<ncc-date-time type='date' v-model="dataForm.lysj1" placeholder="请选择"></ncc-date-time>
				</u-form-item>

				<u-form-item label="预约下次时间" required>
					<ncc-date-time type='date' v-model="dataForm.yyxcsj1" placeholder="请选择"></ncc-date-time>
				</u-form-item>

				<u-form-item label="赠药规则" prop="zygz">
					<u-input v-model="dataForm.zygz" placeholder="点击选择" @click="opencoupon()"></u-input>
				</u-form-item>


				<u-form-item label="赠药商品" prop="zysp" required>
					<ncc-select v-model="dataForm.zysp" :options="zyspOptions" :props="zyspProps"
						placeholder="请选择"></ncc-select>
				</u-form-item>
				<u-form-item label="规格" prop="gg1" required>
					<u-input v-model="dataForm.gg1" placeholder="请输入"></u-input>
				</u-form-item>
				<u-form-item label="数量" prop="sl1" required>
					<u-number-box v-model="dataForm.sl1" :input-width="120" :input-height="60" :step="1"></u-number-box>
				</u-form-item>



				<u-form-item label="市区/县域" prop="sqxy1">
					<ncc-select v-model="dataForm.sqxy1" :options="sqxy1Options" :props="sqxy1Props"
						placeholder="请选择"></ncc-select>
				</u-form-item>
				<u-form-item label="新患/老患" prop="xlhz1">
					<ncc-select v-model="dataForm.xlhz1" :options="xlhz1Options" :props="xlhz1Props"
						placeholder="请选择"></ncc-select>
				</u-form-item>

				<u-form-item label="邮寄/现场" prop="yjxc7">
					<ncc-select v-model="dataForm.yjxc7" :options="yjxc7Options" :props="yjxc7Props"
						placeholder="请选择"></ncc-select>
				</u-form-item>
				<u-form-item label="新系统/老系统" prop="xlxt2">
					<ncc-select v-model="dataForm.xlxt2" :options="xlxt2Options" :props="xlxt2Props"
						placeholder="请选择"></ncc-select>
				</u-form-item>
				<!-- v-show="item == 'yzez12'?true:false" -->
				<u-form-item label="一赠/二赠" prop="yzez12">
					<ncc-select v-model="dataForm.yzez12" :options="yzez12Options" :props="yzez12Props"
						placeholder="请选择"></ncc-select>
				</u-form-item>
				<!-- v-show="item == 'arthajt8'?true:false" -->
				<u-form-item label="艾瑞妥/A+T" prop="arthajt8">
					<ncc-select v-model="dataForm.arthajt8" :options="arthajt8Options" :props="arthajt8Props"
						placeholder="请选择"></ncc-select>
				</u-form-item>

				


			</template>

			<template v-else>
				<view v-for="(item,index) in yp_from" :key="index">

					<u-form-item v-show="item == 'sfzzfm1'?true:false" label="身份证正反面" prop="sfzzfm1">
						<ncc-upload v-model="dataForm.sfzzfm1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'bqzd1'?true:false" label="病情诊断" prop="bqzd1">
						<ncc-upload v-model="dataForm.bqzd1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'fp1'?true:false" label="发票" prop="fp1">
						<ncc-upload v-model="dataForm.fp1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'cf1'?true:false" label="处方" prop="cf1">
						<ncc-upload v-model="dataForm.cf1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'xmzq1'?true:false" label="项目知情" prop="xmzq1">
						<ncc-upload v-model="dataForm.xmzq1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'jjpgb1'?true:false" label="经济评估表" prop="jjpgb1">
						<ncc-upload v-model="dataForm.jjpgb1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'yzypqsd1'?true:false" label="援助药品签收单" prop="yzypqsd1">
						<ncc-upload v-model="dataForm.yzypqsd1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'tfxx1'?true:false" label="统方信息" prop="tfxx1">
						<ncc-upload v-model="dataForm.tfxx1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'lqd2'?true:false" label="领取单" prop="lqd2">
						<ncc-upload v-model="dataForm.lqd2"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'lyd1'?true:false" label="领药单" prop="lyd1">
						<ncc-upload v-model="dataForm.lyd1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'zqtys1'?true:false" label="知情同意书" prop="zqtys1">
						<ncc-upload v-model="dataForm.zqtys1"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'mphfppz4'?true:false" label="卖品和发票拍照" prop="mphfppz4">
						<ncc-upload v-model="dataForm.mphfppz4"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'zphhcfpz4'?true:false" label="赠品盒和处方拍照" prop="zphhcfpz4">
						<ncc-upload v-model="dataForm.zphhcfpz4"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'zybydjhcfpz4'?true:false" label="赠药板药对剪和处方拍照" prop="zybydjhcfpz4">
						<ncc-upload v-model="dataForm.zybydjhcfpz4"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'lyhz6'?true:false" label="领药合照" prop="lyhz6">
						<ncc-upload v-model="dataForm.lyhz6"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'ct7'?true:false" label="CT" prop="ct7">
						<ncc-upload v-model="dataForm.ct7"></ncc-upload>
					</u-form-item>

					<u-form-item v-show="item == 'yjsqs7'?true:false" label="邮寄申请书" prop="yjsqs7">
						<ncc-upload v-model="dataForm.yjsqs7"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'sfzzfm1'?true:false" label="快递单和药品合照" prop="kddhyphz7">
						<ncc-upload v-model="dataForm.kddhyphz7"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'fkhz7'?true:false" label="反馈合照" prop="fkhz7">
						<ncc-upload v-model="dataForm.fkhz7"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'sz7'?true:false" label="输注" prop="sz7">
						<!-- <u-input v-model="dataForm.sz7" type="textarea" placeholder="请输入" /> -->
						<ncc-upload v-model="dataForm.sz7"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'wkzqtys8'?true:false" label="温控知情同意书" prop="wkzqtys8">
						<ncc-upload v-model="dataForm.wkzqtys8"></ncc-upload>
					</u-form-item>
					<u-form-item v-show="item == 'hzhz9'?true:false" label="患者合照" prop="hzhz9">
						<ncc-upload v-model="dataForm.hzhz9"></ncc-upload>
					</u-form-item>



				</view>
			</template>

		</u-form>
		<view class="buttom-actions" v-if="step==0">
			<u-button class="buttom-btn" @click="ncc.goBack()">取 消</u-button>
			<u-button class="buttom-btn" type="primary" @click="nextForm">下一步</u-button>
		</view>
		<view class="buttom-actions" v-if="step==1">
			<u-button class="buttom-btn" type="primary" @click="prevForm">上一步</u-button>
			<u-button class="buttom-btn" @click="ncc.goBack()">取 消</u-button>
			<u-button class="buttom-btn" type="primary" @click="submitForm" :loading="btnLoading">提 交</u-button>

			<!-- <u-button class="buttom-btn" type="primary" @click="submitForm">提 交</u-button> -->
		</view>

		<!-- 出层 -->
		<view class="mask" catchtouchmove="preventTouchMove" v-if="couponshow == true" @tap="hidecoupon"></view>
		<view class="coupon" v-if="couponshow" :style="'bottom:' + (couponshow == true ? '0px':'')">
			<u-input class="searchInput" v-model="search" placeholder="请输入关键字来进行搜索" @input="SearchGz"></u-input>
			<scroll-view class="scrolls" scroll-y style="height:55vh">
				<cc-defineCoupon colors="#fa436a" :couponList="rulelist2.length > 0 ? rulelist2 : rulelist"
					@onReceive="onReceive"></cc-defineCoupon>
			</scroll-view>
		</view>

	</view>
</template>
<script>
	import {
		getDictionaryDataSelector,
		login,
		previewDataInterface
	} from '@/api/common'
	import request from '@/utils/request'
	export default {
		data() {
			return {
				btnLoading: false,
				fromTable: false,
				step: 0,
				yp_from: [], //当前选择药品规格参数
				login_mdid:'',//当前登录用户门店ID
				tbFormRuleEntity_id: '', //选择的表单规则ID

				search: '', // 规则搜索输入值

				dataForm: {
					id: '',
					name: undefined,
					daibiao: undefined,
					sjh: undefined,
					zq: undefined,
					dz: undefined,
					sfzhm: undefined,

					zysp: undefined,
					ffmd: undefined,
					gg1: undefined,
					sl1: 1,
					sqxy1: undefined,
					xlhz1: undefined,
					sfzzfm1: [],
					bqzd1: [],
					fp1: [],
					cf1: [],
					xmzq1: [],
					jjpgb1: [],
					yzypqsd1: [],
					tfxx1: [],
					lqd2: [],
					lyd1: [],
					zqtys1: [],
					mphfppz4: [],
					zphhcfpz4: [],
					zybydjhcfpz4: [],
					lyhz6: [],
					ct7: [],
					yjxc7: undefined,
					yjsqs7: [],
					kddhyphz7: [],
					fkhz7: [],
					sz7: [],
					wkzqtys8: [],
					hzhz9: [],
					yzez12: undefined,
					arthajt8: undefined,
					lysj1: undefined,
					yyxcsj1: undefined,
					xlxt2: undefined,
					zygz: '',
					ypgz_id: undefined,
				},
				rules: {
					name: [{
						required: true,
						message: '请输入患者姓名',
						trigger: 'blur'
					}, ],
					daibiao: [{
						required: true,
						message: '请输入患教',
						trigger: 'blur'
					}, ],
					sjh: [{
						required: true,
						message: '请输入手机号',
						trigger: 'blur'
					}, ],
					dz: [{
						required: true,
						message: '请输入地址',
						trigger: 'blur'
					}, ],
					ffmd: [{
						required: true,
						message: '请输入发放门店',
						trigger: 'blur'
					}, ],
					zygz: [{
						required: true,
						message: '请输入赠药规则',
						trigger: 'blur'
					}, ],
					zysp: [{
						required: true,
						message: '请输入赠药商品',
						trigger: 'blur'
					}, ],

					gg1: [{
						required: true,
						message: '请输入规格',
						trigger: 'blur'
					}, ],
					sqxy1: [{
						required: true,
						message: '请输入市区/县域',
						trigger: 'blur'
					}, ],
					xlhz1: [{
						required: true,
						message: '请输入新患/老患',
						trigger: 'blur'
					}, ],

				},



				zyspProps: {
					"label": "name",
					"value": "name"
				},
				zyspOptions: [],
				zygzOptions: {
					"label": "ruleId",
					"value": "ruleId"
				},
				ffmdProps: {
					"label": "fullName",
					"value": "id"
				},
				ffmdOptions: [],
				sqxy1Props: {
					"label": "fullName",
					"value": "id"
				},
				sqxy1Options: [{
					"fullName": "市区",
					"id": "市区"
				}, {
					"fullName": "县域",
					"id": "县域"
				}],
				xlhz1Props: {
					"label": "fullName",
					"value": "id"
				},
				xlhz1Options: [{
					"fullName": "新患",
					"id": "新患"
				}, {
					"fullName": "老患",
					"id": "老患"
				}],

				xlxt2Props: {
					"label": "fullName",
					"value": "id"
				},
				xlxt2Options: [{
					"fullName": "新系统",
					"id": "新系统"
				}, {
					"fullName": "老系统",
					"id": "老系统"
				}],
				yjxc7Props: {
					"label": "fullName",
					"value": "id"
				},
				yjxc7Options: [{
					"fullName": "邮寄",
					"id": "邮寄"
				}, {
					"fullName": "现场",
					"id": "现场"
				}],
				yzez12Props: {
					"label": "fullName",
					"value": "id"
				},
				yzez12Options: [{
					"fullName": "一赠",
					"id": "一赠"
				}, {
					"fullName": "二赠",
					"id": "二赠"
				}],
				arthajt8Props: {
					"label": "fullName",
					"value": "id"
				},
				arthajt8Options: [{
					"fullName": "艾瑞妥",
					"id": "艾瑞妥"
				}, {
					"fullName": "A+T",
					"id": "A+T"
				}],
				rulelist: [],
				rulelist2: [], //用来筛选搜索
				couponshow: false,
				showloading: false,
				timeout: null, //防抖定时器
				patientInfo: [], // 患者信息
			};
		},
		onLoad(option) {
			this.dataForm.id = option.id || ''
			var userInfo = uni.getStorageSync('userInfo')
			this.dataForm.ffmd = userInfo.menDianId
			uni.setNavigationBarTitle({
				title: this.dataForm.id ? '编辑' : '新增'
			})
			this.initData()
			this.getzyspOptions();
			this.getffmdOptions();
			this.forceRule();
		},
		onReady() {
			this.$refs.dataForm.setRules(this.rules);
		},
		watch: {
			'dataForm.zysp': {
				handler: function(a, b) {
					if (!this.showloading) {
						var yp = this.zyspOptions.filter(o => o.name == a);
						if (yp && yp.length) {
							this.dataForm.gg1 = yp[0].ypgg || ''
						}
						console.log('watch:', this.yp_from);
					}
				}
			}
		},

		methods: {
			//
			ClearPatient() {
				setTimeout(()=>{
					this.patientInfo = []
				},100)
			},
			//添加患者信息
			AddPatient() {
				var _this = this
				var data = {
					name: this.dataForm.name,
					huanjiao: this.dataForm.daibiao,
					phone: this.dataForm.sjh,
					address: this.dataForm.dz,
					id_card: this.dataForm.sfzhm,
					zhouqi: this.dataForm.zq,
				}
				request({
					url: `/api/Extend/TbDrugIftForm/AddPatient`,
					method: 'post',
					data: data,
				}).then((res) => {

				})
			},
			//选择患者
			ClickPatient(item) {
				// console.log(item);
				this.dataForm.name = item.name
				this.dataForm.daibiao = item.huanjiao
				this.dataForm.sjh = item.phone
				this.dataForm.dz = item.address
				this.dataForm.zq = item.zhouqi
				this.dataForm.sfzhm = item.id_card
				this.patientInfo = []
			},
			//搜索患者信息
			SelectPatient() {
				var _this = this
				if (this.timeout != null) {
					clearTimeout(this.timeout)
				}
				this.timeout = setTimeout(() => {
					name = this.dataForm.name
					// console.log(name);
					if (name != '') {
						request({
							url: `/api/Extend/TbDrugIftForm/GetPatientInfoByName`,
							method: 'Get',
							data: {
								"name": name
							},
						}).then((res) => {
							this.patientInfo = res.data
							// console.log('AddPatient', res.data);
						})
					} else {
						this.patientInfo = []
					}
				}, 800)
			},
			//搜索药品规则
			SearchGz() {
				var rulelist = this.rulelist

				if (this.search != '' && this.search != undefined) {
					// console.log(this.search);
					this.rulelist2 = []
					for (var i = 0; i < rulelist.length; i++) {
						if (rulelist[i].ruleName.includes(this.search)) {
							this.rulelist2.push(rulelist[i])
						}
					}

				} else {
					this.rulelist2 = []
				}
			},
			//   
			opencoupon() {
				this.couponshow = true
			},
			//   
			hidecoupon() {
				this.couponshow = false
			},
			// 
			onReceive(item, index) {
				var _this = this;
				console.log(item);
				_this.dataForm.zygz = item.ruleId;
				// _this.tbFormRuleEntity_id = item.id
				_this.dataForm.ypgz_id = item.id
				_this.showloading = true;
				setTimeout(() => {
					_this.showloading = false;
				}, 3000);

				_this.setFormSelect(item);

				_this.hidecoupon();
			},
			setFormSelect(item) {
				var _this = this;
				var splst = item.ruleId.split('@');
				// console.log({splst});
				for (var i = 0; i < splst.length; i++) {
					var spi = splst[i];
					// console.log({spi});
					switch (i) {
						case 0: {
							_this.dataForm.zysp = spi;
							var filter = this.zyspOptions.filter(o => o.name.indexOf(spi) != -1);
							if (filter && filter.length) {
								filter = filter[0];
								_this.dataForm.zysp = filter.name;
								_this.dataForm.gg1 = filter.ypgg || '';
							}

						}
						break; //药品
						// case 1:  _this.dataForm.gg1 = spi; break;//规格

						case 1:
							_this.dataForm.sqxy1 = spi;
							break; //市区/县域
						case 2:
							_this.dataForm.xlhz1 = spi;
							break; //新患/老患
						case 3:
							_this.dataForm.yjxc7 = spi;
							break; //邮寄/现场
						case 4:
							_this.dataForm.xlxt2 = spi;
							break; //新系统/老系统
						case 5:
							_this.dataForm.yzez12 = spi;
							break; //一赠/二赠
						case 6:
							_this.dataForm.arthajt8 = spi;
							break; //艾瑞妥/A+T

					}

				}
				_this.$forceUpdate()
			},
			forceRule() {
				request({
					url: '/api/Extend/TbFormRule',
					data: {
						currentPage: 1,
						pageSize: 1000
					},
					method: 'get',
				}).then(res => {
					this.rulelist = res.data.list;
				});
			},
			prevForm() {
				this.step = 0;
			},
			nextForm() {
				var that = this
				var form = this.dataForm;

				var postForm = [];



				if (!form.name) {
					uni.showToast({
						icon: 'none',
						title: '请填写患者姓名'
					})
					return;
				}

				if (!form.daibiao) {
					uni.showToast({
						icon: 'none',
						title: '请填写患教'
					})
					return;
				}

				if (!form.sjh) {
					uni.showToast({
						icon: 'none',
						title: '请填写手机号'
					})
					return;
				}
				if (!form.dz) {
					uni.showToast({
						icon: 'none',
						title: '请填写地址'
					})
					return;
				}

				if (!form.ffmd) {
					uni.showToast({
						icon: 'none',
						title: '请选择发放门店'
					})
					return;
				}
				if (!form.lysj1) {
					uni.showToast({
						icon: 'none',
						title: '请选择领药时间'
					})
					return;
				}
				if (!form.yyxcsj1) {
					uni.showToast({
						icon: 'none',
						title: '请选择预约下次时间'
					})
					return;
				}

				// if (!form.zygz) {
				// 	uni.showToast({
				// 		icon: 'none',
				// 		title: '请选择赠药规则'
				// 	})
				// 	return;
				// }

				if (!form.zysp) {
					uni.showToast({
						icon: 'none',
						title: '请选择赠药商品'
					})
					return;
				}

				if (!form.gg1) {
					uni.showToast({
						icon: 'none',
						title: '请填写规格'
					})
					return;
				}
				if (!form.sl1) {
					uni.showToast({
						icon: 'none',
						title: '请填写数量'
					})
					return;
				}

				// if(!form.sqxy1)
				// {
				// 	uni.showToast({
				// 		icon:'none',
				// 		title:'市区/县域'
				// 	})
				// 	return;
				// }
				// if(!form.xlhz1)
				// {
				// 	uni.showToast({
				// 		icon:'none',
				// 		title:'新患/老患'
				// 	})
				// 	return;
				// }
				var yp = this.zyspOptions.filter(o => o.name == form.zysp);
				if (yp && yp.length) {
					postForm.push(form.zysp.replace(yp[0].nid, ''))
				}
				// postForm.push('规格') //规格
				postForm.push(form.sqxy1) //市区/县域
				postForm.push(form.xlhz1) //新患/老患
				postForm.push(form.yjxc7) //邮寄/现场
				postForm.push(form.xlxt2) //新系统/老系统
				postForm.push(form.yzez12) //一赠/二赠
				postForm.push(form.arthajt8) //艾瑞妥/A+T
				// console.log('postForm', postForm);
				request({
					// url: '/api/Extend/TbFormRule/GetRule?key=' + JSON.stringify(postForm),
					url: '/api/Extend/TbFormRule/GetRule?key=' + that.dataForm.ypgz_id,
					method: 'post',
				}).then(res => {
					if (!res || !res.data) {
						uni.showToast({
							icon: 'none',
							title: '未匹配到对应填写的表单！'
						})
						return;
					}
					this.yp_from = JSON.parse(res.data.fileIds);
					this.step = 1;
					// console.log('this.yp_from',this.yp_from);
					// data = res.data.fileIds.replace('[', '').replace(']', '').split(',')

					// for (var j = 0; j < data.length; j++) {
					// 	data[j] = data[j].replace('"', '').replace('"', '')

					// }
					// console.log(this.rules);
					// this.yp_from = data
				});
			},

			getzyspOptions() {
				previewDataInterface('508633651819316485').then(res => {
					this.zyspOptions = res.data
				});
			},
			getffmdOptions() {
				getDictionaryDataSelector('508628742709445893').then(res => {
					this.ffmdOptions = res.data.list
				});
			},
			initData() {
				if (this.dataForm.id) {
					request({
						url: '/api/Extend/TbDrugIftForm/' + this.dataForm.id,
						method: 'get',
					}).then(res => {
						this.dataForm = res.data;
						// if (!this.dataForm.sfzzfm1) this.dataForm.sfzzfm1 = [];
						// else this.yp_from.push('sfzzfm1');

						if (this.dataForm.sfzzfm1.length > 0) {

						} else {
							this.dataForm.sfzzfm1 = [];
						}
						if (this.dataForm.bqzd1.length > 0) {

						} else {
							this.dataForm.bqzd1 = [];
						}
						if (this.dataForm.fp1.length > 0) {

						} else {
							this.dataForm.fp1 = [];
						}
						if (this.dataForm.cf1.length > 0) {

						} else {
							this.dataForm.cf1 = [];
						}
						if (this.dataForm.xmzq1.length > 0) {

						} else {
							this.dataForm.xmzq1 = [];
						}
						if (this.dataForm.jjpgb1.length > 0) {

						} else {
							this.dataForm.jjpgb1 = [];
						}
						if (this.dataForm.yzypqsd1.length > 0) {

						} else {
							this.dataForm.yzypqsd1 = [];
						}
						if (this.dataForm.tfxx1.length > 0) {

						} else {
							this.dataForm.tfxx1 = [];
						}
						if (this.dataForm.lqd2.length > 0) {

						} else {
							this.dataForm.lqd2 = [];
						}
						if (this.dataForm.lyd1.length > 0) {

						} else {
							this.dataForm.lyd1 = [];
						}
						if (this.dataForm.zqtys1.length > 0) {

						} else {
							this.dataForm.zqtys1 = [];
						}
						if (this.dataForm.mphfppz4.length > 0) {

						} else {
							this.dataForm.mphfppz4 = [];
						}
						if (this.dataForm.zphhcfpz4.length > 0) {

						} else {
							this.dataForm.zphhcfpz4 = [];
						}
						if (this.dataForm.zybydjhcfpz4.length > 0) {

						} else {
							this.dataForm.zybydjhcfpz4 = [];
						}
						if (this.dataForm.lyhz6.length > 0) {

						} else {
							this.dataForm.lyhz6 = [];
						}
						if (this.dataForm.ct7.length > 0) {

						} else {
							this.dataForm.ct7 = [];
						}
						if (this.dataForm.yjsqs7.length > 0) {

						} else {
							this.dataForm.yjsqs7 = [];
						}
						if (this.dataForm.kddhyphz7.length > 0) {

						} else {
							this.dataForm.kddhyphz7 = [];
						}
						if (this.dataForm.fkhz7.length > 0) {

						} else {
							this.dataForm.fkhz7 = [];
						}
						if (this.dataForm.sz7.length > 0) {

						} else {
							this.dataForm.sz7 = [];
						}
						if (this.dataForm.wkzqtys8.length > 0) {

						} else {
							this.dataForm.wkzqtys8 = [];
						}
						if (this.dataForm.hzhz9.length > 0) {

						} else {
							this.dataForm.hzhz9 = [];
						}
						if (this.dataForm.xlxt2 != null) {

						} else {
							this.dataForm.xlxt2 = undefined;
						}
					})
				}
			},

			submitForm() {
				// var fromIsOk = true
				// var ypFrom = this.yp_from
				// for (var i = 0; i < ypFrom.length; i++) {
				// 	if (ypFrom[i] == 'sfzzfm1' && this.dataForm.sfzzfm1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'bqzd1' && this.dataForm.bqzd1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'fp1' && this.dataForm.fp1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'cf1' && this.dataForm.cf1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'xmzq1' && this.dataForm.xmzq1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'jjpgb1' && this.dataForm.jjpgb1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'yzypqsd1' && this.dataForm.yzypqsd1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'tfxx1' && this.dataForm.tfxx1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'lqd2' && this.dataForm.lqd2.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'lyd1' && this.dataForm.lyd1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'zqtys1' && this.dataForm.zqtys1.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'mphfppz4' && this.dataForm.mphfppz4.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'zphhcfpz4' && this.dataForm.zphhcfpz4.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'zybydjhcfpz4' && this.dataForm.zybydjhcfpz4.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'lyhz6' && this.dataForm.lyhz6.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'ct7' && this.dataForm.ct7.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'yjsqs7' && this.dataForm.yjsqs7.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'kddhyphz7' && this.dataForm.kddhyphz7.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'fkhz7' && this.dataForm.fkhz7.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'sz7' && this.dataForm.sz7.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'wkzqtys8' && this.dataForm.wkzqtys8.length <= 0) fromIsOk = false;
				// 	else if (ypFrom[i] == 'hzhz9' && this.dataForm.hzhz9.length <= 0) fromIsOk = false;
				// 	// else if (ypFrom[i] == 'lysj1' && this.dataForm.lysj1.length <= 0) fromIsOk = false;
				// }

				// if (!fromIsOk) {
				// 	uni.showToast({
				// 		icon: 'none',
				// 		title: '请先完成表单填写'
				// 	})
				// 	return;
				// }
				if (this.step == 0) {
					uni.showToast({
						icon: 'none',
						title: '请先完成表单填写！'
					})
					return;
				}

				this.$refs.dataForm.validate(valid => {
					if (!valid) return
					this.btnLoading = true
					console.log(this.dataForm);
					if (this.dataForm.id) {
						request({
							url: '/api/Extend/TbDrugIftForm/' + this.dataForm.id,
							method: 'put',
							data: this.dataForm,
						}).then(res => {
							uni.showToast({
								title: res.msg,
								complete: () => {
									setTimeout(() => {
										this.btnLoading = false
										uni.$emit('refresh')
										uni.navigateBack()
									}, 1500)
								}
							})
						})
					} else {
						// console.log(this.dataForm);
						this.AddPatient()
						request({
							url: '/api/Extend/TbDrugIftForm',
							method: 'post',
							data: this.dataForm
						}).then(res => {
							uni.showToast({
								title: res.msg,
								complete: () => {
									setTimeout(() => {
										this.btnLoading = false
										uni.$emit('refresh')
										uni.navigateBack()
									}, 1500)
								}
							})
						})
					}
				});
			},
		}
	};
</script>


<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;

	}

	.mask {
		width: 100%;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
		background: #000;
		z-index: 900;
		opacity: 0.7;
	}

	/* 优惠券 */
	.coupon {
		background-color: #fff;
		border-radius: 10upx 10upx 0 0;
		position: fixed;
		left: 0;
		bottom: -1000upx;
		z-index: 999;
		transition: all 0.3s;
	}

	.scrolls {
		width: 100vw;
		height: 60vh;
		padding-top: 10upx;
		z-index: 500;
	}

	.searchInput {
		text-indent: 20rpx;
	}

	.patientInfo_box {
		position: absolute;
		// border: 1px solid black;
		// bottom: -70px;
		top: 190rpx;
		z-index: 999;
		background-color: white;

		width: 90%;
		box-shadow: 0px 1px 5px;
		max-height: 320rpx;
		overflow: auto;
	}

	.patientInfo_item {
		border-bottom: 1px solid lightgray;
		padding-left: 20rpx;
	}
</style>