<template>
	<view>
		<view class="container">
			<u-form :model="form" ref="uForm" label-width="200rpx">
				<!-- 基本信息 -->
				<view class="card">
					<view class="section-header">
						<view class="section-title">基本信息</view>
						<view v-if="showHelp && form.id" class="history-link" @click="viewHistory('help',form.id)">
							查看历史帮扶信息</view>
					</view>
					<!-- 删除原有镇、村输入框，新增级联选择器 -->
					<!-- <u-form-item label="镇（街）" prop="town" >
					<u-input v-model="form.town" placeholder="请输入镇（街）" />
				</u-form-item>
				<u-form-item label="村（居）" prop="village" >
					<u-input v-model="form.village" placeholder="请输入村（居）" />
				</u-form-item> -->
					<u-form-item label="所属区域" required prop="areaObj">
						<hg-select :disabled="showArea" title="选择所属区域" v-model="form.areaObj" :range="townVillageGroup"
							rangeKey="label" rangeKeyChildren="children" :isGanged="true"></hg-select>
					</u-form-item>
					<u-form-item label="门牌号" required prop="doorNumber">
						<uni-easyinput :disabled="form.submitStatus == 1" v-model="form.doorNumber" type="textarea"
							placeholder="请输入门牌号" />
					</u-form-item>
					<!-- 家庭属性（多选） -->
					<u-form-item label="家庭属性" required prop="householdType">
						<view class="custom-checkbox-group">
							<view v-for="item in householdTypeOptions" :key="item.value" class="custom-checkbox-item">
								<view class="checkbox-icon" @click="toggleHouseholdType(item)">
									<view v-if="form.householdType && form.householdType.includes(item.value)"
										class="checkbox-checked">✓</view>
								</view>
								<view class="checkbox-label" @click="toggleHouseholdType(item)">
									{{ item.label }}
								</view>
							</view>
						</view>
					</u-form-item>
					<!-- 帮扶信息（当家庭属性为监测户或脱贫户时显示） -->


					<!-- 居住属性（单选，checkbox-group+单选逻辑） -->
					<u-form-item label="居住属性" required prop="hukouType">
						<u-radio-group v-model="form.hukouType">
							<view class="option-list-col">
								<u-radio labelSize="26" size="36" shape="square" v-for="item in hukouTypeOptions"
									:key="item.value" :name="item.value" :label="item.label" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item v-if="showRiskMitigation" label="是否消除风险" required prop="riskMitigation">
						<u-radio-group v-model="form.riskMitigation">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>


					<u-form-item v-if="showHelp" label="帮扶单位" prop="helpUnit">
						<zxz-uni-data-select filterable v-model="form.helpUnit" :localdata="helpUnitOptions" clearable
							@change="changeHelpUnit" placeholder="请选择帮扶单位"></zxz-uni-data-select>
					</u-form-item>
					<u-form-item v-if="showHelp" label="帮扶人" required prop="helperName">
						<u-input v-model="form.helperName" placeholder="请输入帮扶人姓名" />
					</u-form-item>
					<u-form-item v-if="showHelp" label="联系方式" required prop="helperPhone">
						<u-input v-model="form.helperPhone" placeholder="请输入帮扶人联系电话" />
					</u-form-item>
					<u-form-item v-if="showHelp" label="记录时间" required prop="helpRecordTime">
						<uni-datetime-picker placeholder="请选择记录时间" type="datetime" v-model="form.helpRecordTime" />
					</u-form-item>
					<u-form-item v-if="showHelp" label="帮扶手册" required>
						<cc-imgPreDelUpload :count="6" :imageList="helpFiles"></cc-imgPreDelUpload>
					</u-form-item>

				</view>
				<!-- 户信息基本情况 -->
				<view class="card">
					<view class="section-title">户信息</view>
					<u-form-item label="户主姓名" required prop="householderName">
						<u-input v-model="form.householderName" placeholder="请输入户主姓名" />
					</u-form-item>
					<u-form-item label="身份证号" required prop="householderIdNumber">
						<u-input v-model="form.householderIdNumber" placeholder="请输入身份证号"
							@blur="validateId(form.householderIdNumber, -1)" />
					</u-form-item>
					<u-form-item label="户籍人数" required prop="householdNum">
						<u-input v-model="form.householdNum" type="number" placeholder="请输入户籍人数，若无填0" />
					</u-form-item>
					<u-form-item label="常住人数" required prop="residentNum">
						<u-input v-model="form.residentNum" type="number" placeholder="请输入常住人数，若无填0" />
					</u-form-item>
					<u-form-item label="联系电话" required prop="householderPhone">
						<u-input v-model="form.householderPhone" placeholder="请输入联系电话"
							@blur="validatePhone(form.householderPhone, -1)" />
					</u-form-item>
					<u-form-item label="劳动力人数" required prop="laborNum">
						<u-input v-model="form.laborNum" type="number" placeholder="请输入劳动力人数，若无填0" />
					</u-form-item>
					<u-form-item label="务工人数" required prop="workNum">
						<u-input v-model="form.workNum" type="number" placeholder="请输入务工人数，若无填0" />
					</u-form-item>
					<u-form-item label="丧失或无劳动力人数" required prop="noLaborNum">
						<u-input v-model="form.noLaborNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
				</view>
				<!-- 家庭成员信息（动态添加） -->
				<view class="card">
					<view class="section-title">家庭成员</view>
					<view>
						<view v-for="(member, idx) in form.members" :key="idx" class="member-block">
							<u-button v-if="member.id" type="success" size="mini"
								@click="viewHistory('member',member.id)">查看该成员历史数据</u-button>

							<u-form-item label="姓名" required :prop="'members.'+idx+'.name'">
								<u-input v-model="member.name" placeholder="请输入姓名" />
							</u-form-item>
							<u-form-item label="与户主关系" required :prop="'members.'+idx+'.relation'">
								<u-input v-model="member.relation" placeholder="请输入与户主关系" />
							</u-form-item>
							<u-form-item label="身份证号" required :prop="'members.'+idx+'.idNumber'">
								<u-input v-model="member.idNumber" placeholder="请输入身份证号"
									@blur="validateId(member.idNumber, idx)" />
							</u-form-item>
							<u-form-item label="联系电话" :prop="'members.'+idx+'.phone'">
								<u-input v-model="member.phone" placeholder="请输入联系电话"
									@blur="validatePhone(member.phone, idx)" />
							</u-form-item>

							<u-form-item label="健康状况" required :prop="'members.'+idx+'.health'">
								<view class="custom-checkbox-group">
									<view v-for="item in healthOptions" :key="item.value" class="custom-checkbox-item">
										<view class="checkbox-icon" @click="toggleHealth(item.value,member)">
											<view v-if="member.health && member.health.includes(item.value)"
												class="checkbox-checked">✓</view>
										</view>
										<view class="checkbox-label" @click="toggleHealth(item.value,member)">
											{{ item.label }}
										</view>
									</view>
								</view>
							</u-form-item>
							<u-form-item v-if="member.showDisability" label="残疾等级" required
								:prop="'members.'+idx+'.disability'">
								<zxz-uni-data-select filterable v-model="member.disability" :localdata="handicapOptions"
									placeholder="请选择残疾等级"></zxz-uni-data-select>

							</u-form-item>
							<u-form-item label="是否就学" required :prop="'members.'+idx+'.isStudy'">
								<u-radio-group v-model="member.isStudy">
									<view class="option-list-row">
										<u-radio labelSize="26" size="36" shape="square" name="是" label="是"
											label-size="36rpx" label-color="#222" class="option-item" />
										<u-radio labelSize="26" size="36" shape="square" name="否" label="否"
											label-size="36rpx" label-color="#222" class="option-item" />
									</view>
								</u-radio-group>
							</u-form-item>
							<u-form-item label="是否就业" required :prop="'members.'+idx+'.isEmploy'">
								<u-radio-group v-model="member.isEmploy">
									<view class="option-list-row">
										<u-radio labelSize="26" size="36" shape="square" name="是" label="是"
											label-size="36rpx" label-color="#222" class="option-item" />
										<u-radio labelSize="26" size="36" shape="square" name="否" label="否"
											label-size="36rpx" label-color="#222" class="option-item" />
									</view>
								</u-radio-group>
							</u-form-item>
							<u-form-item label="就学就业情况" required :prop="'members.'+idx+'.studyEmplouStatus'">
								<uni-easyinput type="textarea" v-model="member.studyEmplouStatus"
									placeholder="请输入就学就业情况，若无填无" />
							</u-form-item>
							<u-form-item label="是否党员" required :prop="'members.'+idx+'.isPartyMember'">
								<u-radio-group v-model="member.isPartyMember">
									<view class="option-list-row">
										<u-radio labelSize="26" size="36" shape="square" name="是" label="是"
											label-size="36rpx" label-color="#222" class="option-item" />
										<u-radio labelSize="26" size="36" shape="square" name="否" label="否"
											label-size="36rpx" label-color="#222" class="option-item" />
									</view>
								</u-radio-group>
							</u-form-item>
							<u-form-item label="是否退役军人" required :prop="'members.'+idx+'isSoldier'">
								<u-radio-group v-model="member.isSoldier">
									<view class="option-list-row">
										<u-radio labelSize="26" size="36" shape="square" name="是" label="是"
											label-size="36rpx" label-color="#222" class="option-item" />
										<u-radio labelSize="26" size="36" shape="square" name="否" label="否"
											label-size="36rpx" label-color="#222" class="option-item" />
									</view>
								</u-radio-group>
							</u-form-item>
							<u-form-item label="养老保险等级" :prop="'members.'+idx+'.pensionInsuranceLevel'">
								<zxz-uni-data-select filterable v-model="member.pensionInsuranceLevel"
									:localdata="insuranceOptions" placeholder="请选择养老保险类型"></zxz-uni-data-select>

							</u-form-item>
							<u-button type="error" size="mini" @click="removeMember(idx)">移除成员</u-button>
						</view>
						<u-button type="primary" size="mini" @click="addMember">添加成员</u-button>
					</view>
				</view>
				<!-- 住房饮水安全保障 -->
				<view class="card">
					<view class="section-title">住房饮水安全保障</view>
					<u-form-item label="住房结构" required prop="houseStructure">
						<u-input :disabled="form.submitStatus == 1" v-model="form.houseStructure"
							placeholder="请输入住房结构，若无填无" />
					</u-form-item>
					<u-form-item label="住房面积(㎡)" required prop="houseArea">
						<u-input :disabled="form.submitStatus == 1" v-model="form.houseArea" type="number"
							placeholder="请输入住房面积，若无填0" />
					</u-form-item>
					<u-form-item label="是否危房" required prop="isDangerousHouse">
						<u-radio-group v-model="form.isDangerousHouse">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="是否有其他安全住房" required prop="hasOtherSafeHouse">
						<u-radio-group v-model="form.hasOtherSafeHouse">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>

					<u-form-item label="饮用水水源" required prop="waterSource">
						<zxz-uni-data-select filterable v-model="form.waterSource" :localdata="waterOptions"
							placeholder="请选择饮用水水源类型"></zxz-uni-data-select>
					</u-form-item>
					<u-form-item label="户厕改造情况" required prop="toiletStatus">
						<zxz-uni-data-select filterable v-model="form.toiletStatus" :localdata="toiletOptions"
							placeholder="请选择户厕改造类型"></zxz-uni-data-select>
					</u-form-item>
				</view>
				<!-- 三保障情况 -->
				<view class="card">
					<view class="section-title">综合保障</view>
					<u-form-item label="医疗保险参保人数" required prop="medicalInsuranceNum">
						<u-input v-model="form.medicalInsuranceNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
					<u-form-item label="养老保险参保人数" required prop="pensionInsuranceNum">
						<u-input v-model="form.pensionInsuranceNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
					<!-- 					<u-form-item label="缴费档次" required prop="insuranceLevel">
						<u-input v-model="form.insuranceLevel" placeholder="请输入缴费档次，若无填无" />
					</u-form-item> -->
					<u-form-item label="享受低保人数" required prop="dibaoNum">
						<u-input v-model="form.dibaoNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
					<u-form-item label="月保障金额" required prop="dibaoAmount">
						<u-input v-model="form.dibaoAmount" type="number" placeholder="请输入金额，若无填0" />
					</u-form-item>
					<u-form-item label="特困供养人数" required prop="tekunNum">
						<u-input v-model="form.tekunNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
					<u-form-item label="月保障金额" required prop="tekunAmount">
						<u-input v-model="form.tekunAmount" type="number" placeholder="请输入金额，若无填0" />
					</u-form-item>
					<u-form-item label="残疾保障人数" required prop="disabledNum">
						<u-input v-model="form.disabledNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
					<u-form-item label="残疾类型" required prop="disabledType">
						<zxz-uni-data-select filterable v-model="form.disabledType" :localdata="handicapAndNoOptions"
							placeholder="请选择残疾类型"></zxz-uni-data-select>
					</u-form-item>
					<u-form-item label="月保障总金额" required prop="disabledAmount">
						<u-input v-model="form.disabledAmount" type="number" placeholder="请输入金额，若无填0" />
					</u-form-item>
					<u-form-item label="领取养老金人数" required prop="pensionNum">
						<u-input v-model="form.pensionNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
					<u-form-item label="月领取总金额" required prop="pensionAmount">
						<u-input v-model="form.pensionAmount" type="number" placeholder="请输入金额，若无填0" />
					</u-form-item>
					<u-form-item label="是否申请临时救助" required prop="hasAppliedForTemporaryAssistance">
						<u-radio-group v-model="form.hasAppliedForTemporaryAssistance">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="家庭医生是否签约" required prop="hasFamilyDoctorContract">
						<u-radio-group v-model="form.hasFamilyDoctorContract">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
				</view>
				<!-- 教育保障 -->
				<view class="card">
					<view class="section-title">教育保障</view>
					<u-form-item label="义务教育学生人数" required prop="eduStudentNum">
						<u-input v-model="form.eduStudentNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
					<u-form-item label="是否需要送教上门" required prop="needsHomeTeaching">
						<u-radio-group v-model="form.needsHomeTeaching">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="大中专学生人数" required prop="collegeStudentNum">
						<u-input v-model="form.collegeStudentNum" type="number" placeholder="请输入人数，若无填0" />
					</u-form-item>
				</view>
				<!-- 生产生活情况 -->
				<view class="card">
					<view class="section-title">生产生活情况</view>
					<!-- 				<u-form-item label="产业发展情况" prop="industryStatus">
<uni-easyinput type="textarea" v-model="form.industryStatus" placeholder="请输入产业发展情况" />
				</u-form-item> -->
					<u-form-item label="是否有耕地" required prop="hasFarmland">
						<u-radio-group v-model="form.hasFarmland">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="确权面积(亩)" required prop="landArea">
						<u-input v-model="form.landArea" type="number" placeholder="请输入面积，若无填0" />
					</u-form-item>
					<u-form-item label="养殖情况" required prop="breedingStatus">
						<uni-easyinput type="textarea" v-model="form.breedingStatus" placeholder="请输入养殖情况，若无填无" />
					</u-form-item>
					<u-form-item label="个体经营情况" required prop="businessStatus">
						<uni-easyinput type="textarea" v-model="form.businessStatus" placeholder="请输入个体经营情况，若无填无" />
					</u-form-item>
					<u-form-item label="是否需要创业贷款" required prop="needsStartupLoan">
						<u-radio-group v-model="form.needsStartupLoan">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="贷款用途" required prop="loanPurpose">
						<uni-easyinput type="textarea" v-model="form.loanPurpose" placeholder="请输入贷款用途，若无填无" />
					</u-form-item>
					<u-form-item label="惠民政策享受情况" prop="beneficialPolicy">
						<view class="custom-checkbox-group">
							<view v-for="item in beneficialPolicyOptions" :key="item.value"
								class="custom-checkbox-item">
								<view class="checkbox-icon" @click="togglebeneficialPolicy(item.value)">
									<view v-if="form.beneficialPolicy && form.beneficialPolicy.includes(item.value)"
										class="checkbox-checked">✓</view>
								</view>
								<view class="checkbox-label" @click="togglebeneficialPolicy(item.value)">
									{{ item.label }}
								</view>
							</view>
						</view>
					</u-form-item>
					<u-form-item v-if="showOtherBene" label="其他享受政策说明" required prop="otherBene">
						<uni-easyinput type="textarea" v-model="form.otherBene" placeholder="请输入其他享受政策，不得为空或无" />
					</u-form-item>
				</view>
				<!-- 监测对象、综合研判、重点关注对象 -->
				<view class="card">
					<view class="section-title">监测对象、综合研判、重点关注对象</view>
					<u-form-item label="是否知道如何申报监测对象" required prop="knowsHowToReportMonitoring">
						<u-radio-group v-model="form.knowsHowToReportMonitoring">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="是否纳入监测对象（人均纯收入低于9000元，或家庭开支较大、突发重大疾病或事故等）" required
						prop="comprehensiveJudgment">
						<u-radio-group v-model="form.comprehensiveJudgment">
							<view class="option-list-row">
								<u-radio labelSize="26" size="36" shape="square" name="是" label="是" label-size="36rpx"
									label-color="#222" class="option-item" />
								<u-radio labelSize="26" size="36" shape="square" name="否" label="否" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="是否八必访重点关注对象" prop="keyAttention">
						<view class="custom-checkbox-group">
							<view v-for="item in keyAttentionOptions" :key="item.value" class="custom-checkbox-item">
								<view class="checkbox-icon" @click="toggleKeyAttention(item.value)">
									<view v-if="form.keyAttention && form.keyAttention.includes(item.value)"
										class="checkbox-checked">✓</view>
								</view>
								<view class="checkbox-label" @click="toggleKeyAttention(item.value)">
									{{ item.label }}
								</view>
							</view>
						</view>
					</u-form-item>
					<!--        <u-form-item label="综合研判" prop="comprehensiveJudgment">
          <u-input v-model="form.comprehensiveJudgment" type="textarea" placeholder="请输入综合研判内容" />
        </u-form-item> -->
					<!--        <u-form-item label="是否八必访重点关注对象" prop="keyAttention">
          
        </u-form-item> -->
				</view>
				<!-- 培训、就业、诉求、建议 -->
				<view class="card">
					<view class="section-header">
						<view class="section-title">培训、就业、诉求、建议</view>
						<view v-if="form.id" class="history-link" @click="viewHistory('need',form.id)">查看历史信息</view>
					</view>
					<u-form-item label="培训需求" required prop="trainingNeed">
						<uni-easyinput v-model="form.trainingNeed" type="textarea" placeholder="请输入培训需求，若无填无" />
					</u-form-item>
					<u-form-item label="就业需求" required prop="jobNeed">
						<uni-easyinput v-model="form.jobNeed" type="textarea" placeholder="请输入就业需求，若无填无" />
					</u-form-item>
					<u-form-item label="其他诉求" required prop="otherNeed">
						<uni-easyinput v-model="form.otherNeed" type="textarea" placeholder="请输入其他诉求，若无填无" />
					</u-form-item>
					<u-form-item label="意见建议" required prop="suggestion">
						<uni-easyinput v-model="form.suggestion" type="textarea" placeholder="请输入意见建议，若无填无" />
					</u-form-item>
				</view>
				<!-- 满意度 -->
				<view class="card">
					<view class="section-header">
						<view class="section-title">满意度</view>
						<view v-if="form.id" class="history-link" @click="viewHistory('satisfaction',form.id)">查看历史信息
						</view>
					</view>
					<u-form-item label="对村两委满意度" required prop="villageSatisfaction">
						<u-radio-group v-model="form.villageSatisfaction">
							<view class="option-list-col">
								<u-radio labelSize="26" size="36" shape="square" v-for="item in satisfactionOptions"
									:key="item.value" :name="item.value" :label="item.label" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="对驻村工作队满意度" required prop="workTeamSatisfaction">
						<u-radio-group v-model="form.workTeamSatisfaction">
							<view class="option-list-col">
								<u-radio labelSize="26" size="36" shape="square" v-for="item in satisfactionOptions"
									:key="item.value" :name="item.value" :label="item.label" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
				</view>
				<!-- 签字 -->
				<view class="card">
					<view class="section-header">
						<view class="section-title">签字</view>
						<view v-if="form.id" class="history-link" @click="viewHistory('sign',form.id)">查看历史信息</view>
					</view>
					<u-form-item label="入户员签字" required prop="signatureImg">
						<view>
							<image v-if="form.signatureImg" :src="form.signatureImg" @click="viewSignature('staff')"
								style="width: 200rpx; height: 80rpx; border: 1px solid #ddd; border-radius: 4rpx;" />
							<u-button v-if="!form.signatureImg" @click="sign('staff')">点击此处进行签字</u-button>
							<u-button v-else @click="sign('staff')">重新签名</u-button>

						</view>
					</u-form-item>
					<u-form-item label="户主签字" required prop="holderSignatureImg">
						<view>
							<image v-if="form.holderSignatureImg" :src="form.holderSignatureImg"
								@click="viewSignature('holder')"
								style="width: 200rpx; height: 80rpx; border: 1px solid #ddd; border-radius: 4rpx;" />
							<u-button v-if="!form.holderSignatureImg" @click="sign('holder')">点击此处进行签字</u-button>
							<u-button v-else @click="sign('holder')">重新签名</u-button>

						</view>
					</u-form-item>
					<u-form-item label="入户方式" required prop="hukouType">
						<u-radio-group v-model="form.recordMethod">
							<view class="option-list-col">
								<u-radio labelSize="26" size="36" shape="square" v-for="item in recordMethodOptions"
									:key="item.value" :name="item.value" :label="item.label" label-size="36rpx"
									label-color="#222" class="option-item" />
							</view>
						</u-radio-group>
					</u-form-item>
				</view>
				<!-- 提交与导出 -->
				<view class="btn-row">
					<view class="button-row">
						<u-button v-if="editId" type="error" class="btn-main btn-left"
							@click="deleteMsg()">删除</u-button>
						<u-button type="success" class="btn-main btn-left" @click="saveDraft">暂存</u-button>
						<u-button type="primary" class="btn-main btn-right" @click="submitForm">提交</u-button>
					</view>
					<!-- <u-button type="success" class="btn-main" @click="exportExcel">导出Excel</u-button> -->
				</view>
			</u-form>

		</view>

		<FullScreenSignature v-if="showSign" :signatureImg="form.holderSignatureImg" @save="onSignatureSave" />

		<!-- 帮扶信息日期选择器 -->
		<u-calendar v-model="showHelpCalendar" :min-date="helpMinDate" :max-date="helpMaxDate"
			@confirm="onHelpDateConfirm"></u-calendar>
	</view>
</template>

<script>
	// 建议后续引入 xlsx.js 实现前端导出
	import FullScreenSignature from '../../components/FullScreenSignature.vue';
	
	import {
		householdApi,
		areaApi,
		systemApi,
		memberApi
	} from '../../utils/api';
	import {
		v4 as uuidv4
	} from 'uuid';
	import {
		config
	} from '../../utils/config.js';
	import userUtil from '../../utils/UserUtil';
	export default {
		components: {
			FullScreenSignature
		},
		data() {
			return {
				showRiskMitigation: false,
				showArea: false,
				showHelp: false,
				id: '',
				action: '',
				inputType: 'textarea',
				showSign: false,
				holderShowSign: false,
				showOtherBene: false,
				userInfo: {},
				penColor: 'red',
				showSign: false,
				penSize: 5,
				openSmooth: true,
				isEdit: false,
				editId: null,
				form: {
					id: '',
					householderName: '',
					householderIdNumber: '',
					householdNum: '',
					residentNum: '',
					riskMitigation: '',
					householderPhone: '',
					laborNum: '',
					workNum: '',
					noLaborNum: '',
					town: '',
					village: '',
					groupName: '',
					area: [],
					doorNumber: '',
					householdType: [], // 多选
					hukouType: '', // 单选，实际只保留一个
					// 8个单选字段，直接使用字符串
					isDangerousHouse: '',
					hasOtherSafeHouse: '',
					hasAppliedForTemporaryAssistance: '',
					hasFamilyDoctorContract: '',
					needsHomeTeaching: '',
					hasFarmland: '',
					waterSource: '',
					toiletStatus: '',
					needsStartupLoan: '',
					knowsHowToReportMonitoring: '',
					populationType: [], // 多选
					members: [{
						name: '',
						idNumber: '',
						phone: '',
						relation: '',
						health: '',
						job: ''
					}],
					houseStructure: '',
					houseArea: '',
					signatureImg: '', // 签名图片
					holderSignatureImg: '',
					// 三保障情况
					medicalInsuranceNum: '',
					pensionInsuranceNum: '',
					insuranceLevel: '',
					dibaoNum: '',
					dibaoAmount: '',
					tekunNum: '',
					tekunAmount: '',
					disabledNum: '',
					disabledType: '',
					disabledAmount: '',
					pensionNum: '',
					pensionAmount: '',
					isTempHelp: '',
					hasFamilyDoctor: '',
					// 教育保障
					eduStudentNum: '',
					collegeStudentNum: '',
					// 生产生活情况
					industryStatus: '',
					landArea: '',
					breedingStatus: '',
					businessStatus: '',
					loanPurpose: '',
					beneficialPolicy: [],
					otherBene: '',
					// 监测对象、综合研判、重点关注对象
					comprehensiveJudgment: '',
					keyAttention: [],

					// 培训、就业、诉求、建议
					trainingNeed: '',
					jobNeed: '',
					otherNeed: '',
					suggestion: '',
					// 满意度
					villageSatisfaction: '',
					workTeamSatisfaction: '',
					recordMethod: '',
					// 签字
					signer: '',
					areaObj: [],
					// 帮扶信息
					helpUnit: '',
					helperName: '',
					helperPhone: '',
					helpRecordTime: '',
				},
				helpFiles: [],
				showCalendar: false,
				minDate: '1950-01-01',
				maxDate: '2100-12-31',
				showHelpCalendar: false,
				helpMinDate: '1950-01-01',
				helpMaxDate: '2100-12-31',
				householdTypeOptions: [],
				townVillageGroup: [],
				hukouTypeOptions: [],
				keyAttentionOptions: [],
				satisfactionOptions: [],
				recordMethodOptions: [],
				helpUnitOptions: [],
				waterOptions: [],
				insuranceOptions: [],
				toiletOptions: [],
				healthOptions: [],
				handicapOptions: [],
				handicapAndNoOptions: [],
				beneficialPolicyOptions: [],

				noMultiple: '',
				queryDictTypeDO: {
					dictTypeList: ['biz_household_type', 'biz_hukou_type', 'biz_key_attention', 'biz_record_type',
						'biz_satisfaction', 'biz_help_unit', 'biz_water_type',
						'biz_insurance_type',
						'biz_toilet_type',
						'biz_health_type',
						'biz_handicap_type',
						'beneficial_policy_type'

					].join(','),
				}
			}
		},
		async onLoad(options) {
			await this.initData()
			this.loadUserInfo()
			if (options.id) {
				this.editId = options.id
				this.isEdit = true
				this.loadHouseholdData(options.id)
			} else {
				this.loadDraftData()
			}
		},
		computed: {
			// 控制帮扶信息显示
			showHelpInfo() {
				return this.form.householdType && this.form.householdType.some(type =>
					type === '监测户' || type === '脱贫户'
				);
			}
		},
		methods: {
			changeHelpUnit(e) {
				console.log(e)
			},
			viewHistory(type, item) {
				uni.navigateTo({
					url: `/packageForm/pages/historyMessage?id=${item}&type=${type}`
				})
			},
			async initData() {
				await this.listAreaNode();
				var dictType = await systemApi.getDictType(this.queryDictTypeDO);
				this.handicapAndNoOptions.push({
					text: '无',
					value: '99'
				})
				dictType.forEach(item => {
					if (item.dictType == 'biz_household_type') {
						if (item.isMultiple && item.isMultiple == 1) {
							this.noMultiple = this.noMultiple + item.value + ','
						}
						this.householdTypeOptions.push(item)
					} else if (item.dictType == 'biz_hukou_type') {
						this.hukouTypeOptions.push(item)
					} else if (item.dictType == 'biz_key_attention') {
						this.keyAttentionOptions.push(item)
					} else if (item.dictType == 'biz_satisfaction') {
						this.satisfactionOptions.push(item)
					} else if (item.dictType == 'biz_record_type') {
						this.recordMethodOptions.push(item)
					} else if (item.dictType == 'biz_help_unit') {
						this.helpUnitOptions.push({
							text: item.label,
							value: item.value
						})
					} else if (item.dictType == 'biz_water_type') {
						this.waterOptions.push({
							text: item.label,
							value: item.value
						})
					} else if (item.dictType == 'biz_insurance_type') {
						this.insuranceOptions.push({
							text: item.label,
							value: item.value
						})
					} else if (item.dictType == 'biz_toilet_type') {
						this.toiletOptions.push({
							text: item.label,
							value: item.value
						})
					} else if (item.dictType == 'biz_health_type') {
						this.healthOptions.push(item)
					} else if (item.dictType == 'biz_handicap_type') {
						this.handicapOptions.push({
							text: item.label,
							value: item.value
						})
						this.handicapAndNoOptions.push({
							text: item.label,
							value: item.value
						})
					} else if (item.dictType == 'beneficial_policy_type') {
						this.beneficialPolicyOptions.push(item)
					}

				})

			},

			async listAreaNode() {
				var areaDate = await areaApi.getAreaList();
				this.townVillageGroup = this.transformTree(areaDate);
			},
			transformTree(nodes) {
				return nodes.map(node => {
					// 创建基础对象（只包含label和value）
					const newNode = {
						"label": node.name,
						"value": node.name
					};

					// 如果存在非空children则递归处理
					if (node.children && node.children.length > 0) {
						newNode.children = this.transformTree(node.children);
					}

					return newNode;
				});
			},
			sign(type) {
				if (type == 'staff') {
					uni.navigateTo({
						url: '/packageForm/pages/FullScreenSignature?signatureType=' + type + '&signatureImg=' +
							encodeURIComponent(this.form.signatureImg),
						events: {
							signatureSaved: (data) => {
								if (data.img != 'return') {
									this.form.signatureImg = data.img;
								}
							},
						}
					});
				} else if (type == 'holder') {
					uni.navigateTo({
						url: '/packageForm/pages/FullScreenSignature?signatureType=' + type + '&signatureImg=' +
							encodeURIComponent(this.form.holderSignatureImg),
						events: {
							signatureHoulderSaved: (data) => {
								if (data.img != 'return') {
									this.form.holderSignatureImg = data.img;
								}
							},
						}
					});
				}


			},
			onSignatureSave(img) {
				if (img == 'return') {
					this.showSign = false;
				} else {
					this.form.signatureImg = img;
					this.showSign = false;
				}

			},
			loadUserInfo() {
				const userInfo = uni.getStorageSync('userInfo')
				if (userInfo) {
					this.userInfo = userInfo
				} else {
					uni.reLaunch({
						url: '/packageUser/pages/login'
					})
				}
			},
			async loadHouseholdData(id) {
				try {
					const token = uni.getStorageSync('token')
					var response = await householdApi.getHouseholdDetail(id);

					if (response) {
						this.fillFormData(response)
					}
				} catch (error) {
					uni.showToast({
						title: '加载数据失败',
						icon: 'none'
					})
				}
			},
			async loadDraftData() {
				try {
					var userInfo = userUtil.getLoginInfo();
					const response = await householdApi.getDraft(userInfo.userId);

					if (response) {
						this.fillFormData(response)
						uni.showToast({
							title: '已加载暂存数据',
							icon: 'success'
						})
					} else {
						this.form.members = []
					}
				} catch (error) {
					if (!error.data.data) {
						this.form.members = []
					}
				}
			},
			fillFormData(data) {
				this.form.id = data.id || ''
				// 基本信息
				this.form.householderName = data.householderName || ''
				this.form.householderIdNumber = data.householderIdNumber || ''
				this.form.householdNum = data.householdNum || ''
				this.form.residentNum = data.residentNum || ''
				this.form.householderPhone = data.householderPhone || ''
				this.form.laborNum = data.laborNum || ''
				this.form.doorNumber = data.doorNumber || ''
				this.form.workNum = data.workNum || ''
				this.form.noLaborNum = data.noLaborNum || ''
				this.form.town = data.town || ''
				this.form.waterSource = data.waterSource || ''
				this.form.toiletStatus = data.toiletStatus || ''
				this.form.village = data.village || ''
				this.form.groupName = data.groupName || ''

				if (data.town) {
					this.showArea = true;
					if (data.town) {
						for (var i = 0; i < this.townVillageGroup.length; i++) {
							var t = this.townVillageGroup[i];
							if (t.value == data.town) {
								this.form.areaObj.push(t);
								for (var j = 0; j < t.children.length; j++) {
									var v = t.children[j];
									if (v.value == data.village) {
										this.form.areaObj.push(v)
										var msg = false;
										for (var k = 0; k < v.children.length; k++) {

											var g = v.children[k];
											if (g.value == data.groupName) {
												msg = true;
												this.form.areaObj.push({
													label: g.value,
													value: g.value
												})
												break;
											}
										}
										if (!msg) {
											uni.showToast({
												title: "区域缺失组/网格，请确认！",
												icon: "exception"
											})
										}
									}
								}
							}
						}
					}
				}
				// 户属性
				if (data.householdType) {
					try {
						this.form.householdType = JSON.parse(data.householdType)
						if(this.form.householdType && this.form.householdType.length > 0){
							for(var i = 0 ; i < this.form.householdType.length ; i++){
								
								var item = this.form.householdType[i];
								console.log(item)
								if (item == '监测户' || item == '脱贫户') {
									this.showHelp = true;
								}
								if (item == '监测户') {
									this.showRiskMitigation = true;
								}
							}
						}
					} catch (e) {
						this.form.householdType = []
					}
					
				}
				this.form.hukouType = data.hukouType || ''
				this.form.riskMitigation = data.riskMitigation || ''
				if (this.form.riskMitigation) {
					this.showRiskMitigation = true;
				}
				// 8个单选字段
				this.form.isDangerousHouse = data.isDangerousHouse || ''
				this.form.hasOtherSafeHouse = data.hasOtherSafeHouse || ''
				this.form.hasAppliedForTemporaryAssistance = data.hasAppliedForTemporaryAssistance || ''
				this.form.hasFamilyDoctorContract = data.hasFamilyDoctorContract || ''
				this.form.needsHomeTeaching = data.needsHomeTeaching || ''
				this.form.hasFarmland = data.hasFarmland || ''
				this.form.needsStartupLoan = data.needsStartupLoan || ''
				this.form.knowsHowToReportMonitoring = data.knowsHowToReportMonitoring || ''

				if (data.populationType) {
					try {
						this.form.populationType = JSON.parse(data.populationType)
					} catch (e) {
						this.form.populationType = []
					}
				}

				// 住房情况
				this.form.houseStructure = data.houseStructure || ''
				this.form.houseArea = data.houseArea || ''

				// 三保障情况
				this.form.medicalInsuranceNum = data.medicalInsuranceNum || ''
				this.form.pensionInsuranceNum = data.pensionInsuranceNum || ''
				// this.form.insuranceLevel = data.insuranceLevel || ''
				this.form.dibaoNum = data.dibaoNum || ''
				this.form.dibaoAmount = data.dibaoAmount || ''
				this.form.tekunNum = data.tekunNum || ''
				this.form.tekunAmount = data.tekunAmount || ''
				this.form.disabledNum = data.disabledNum || ''
				this.form.disabledType = data.disabledType || ''
				this.form.disabledAmount = data.disabledAmount || ''
				this.form.pensionNum = data.pensionNum || ''
				this.form.pensionAmount = data.pensionAmount || ''

				// 教育保障
				this.form.eduStudentNum = data.eduStudentNum || ''
				this.form.collegeStudentNum = data.collegeStudentNum || ''

				// 生产生活情况
				this.form.industryStatus = data.industryStatus || ''
				this.form.landArea = data.landArea || ''
				this.form.breedingStatus = data.breedingStatus || ''
				this.form.businessStatus = data.businessStatus || ''
				this.form.loanPurpose = data.loanPurpose || ''

				// 监测对象、综合研判、重点关注对象
				this.form.comprehensiveJudgment = data.comprehensiveJudgment || ''
				if (data.keyAttention) {
					try {
						this.form.keyAttention = JSON.parse(data.keyAttention)
					} catch (e) {
						this.form.keyAttention = []
					}
				} else {
					this.form.keyAttention = []
				}
				if (data.beneficialPolicy) {
					try {
						this.form.beneficialPolicy = JSON.parse(data.beneficialPolicy)
						if (this.form.beneficialPolicy.length > 0) {
							for (var i = 0; i < this.form.beneficialPolicy.length; i++) {
								var item = this.form.beneficialPolicy[i];
								if (item.includes('13丨')) {
									console.log('gg')
									var iii = item.split('丨');
									this.form.otherBene = iii[1];
									this.form.beneficialPolicy[i] = iii[0];
									this.showOtherBene = true;
									break;
								}
							}
						}


					} catch (e) {
						this.form.beneficialPolicy = []
					}
				} else {
					this.form.beneficialPolicy = []
				}
				// 培训、就业、诉求、建议
				this.form.trainingNeed = data.trainingNeed || ''
				this.form.jobNeed = data.jobNeed || ''
				this.form.otherNeed = data.otherNeed || ''
				this.form.suggestion = data.suggestion || ''
				this.form.recordMethod = data.recordMethod !== null && data.recordMethod !==
					undefined ? data.recordMethod + '' : ''
				// 满意度
				this.form.villageSatisfaction = data.villageSatisfaction !== null && data.villageSatisfaction !==
					undefined ? data.villageSatisfaction + '' : ''
				this.form.workTeamSatisfaction = data.workTeamSatisfaction !== null && data.workTeamSatisfaction !==
					undefined ? data.workTeamSatisfaction + '' : ''
				// 签名
				this.form.signatureImg = data.signatureImg || ''
				this.form.holderSignatureImg = data.holderSignatureImg || ''
				this.form.submitStatus = data.submitStatus || '0'

				// 帮扶信息
				this.form.helpUnit = data.helpUnit || ''
				this.form.helperName = data.helperName || ''
				this.form.helperPhone = data.helperPhone || ''
				this.form.helpRecordTime = data.helpRecordTime || ''

				// 家庭成员
				if (data.members) {

					this.form.members = data.members.map(member => ({
						id: member.id || '',
						name: member.name || '',
						idNumber: member.idNumber || '',
						phone: member.phone || '',
						relation: member.relation || '',
						health: member.health.split(',').map(item => item.trim()) || '',
						studyEmplouStatus: member.studyEmplouStatus || '',
						isStudy: member.isStudy || '',
						isEmploy: member.isEmploy || '',
						isPartyMember: member.isPartyMember || '',
						isSoldier: member.isSoldier || '',
						pensionInsuranceLevel: member.pensionInsuranceLevel || '',
						remark: member.remark || '',
						disability: member.disability || '',
						showDisability: member.showDisability || false,

					}))
					//this.form.members = data.members
				} else {
					this.form.members = []
				}
				if (data.helpFiles) {
					this.helpFiles = data.helpFiles.map(helpFiles => ({
						id: helpFiles.id,
						status: data.submitStatus + '' || '0',
						base64: helpFiles.manualPhoto,
						fileName: helpFiles.manualPhotoName,
						deleteFlag: helpFiles.deleteFlag,
						groupId: helpFiles.groupId,
					}))
					this.showHelp = true;
				}
			},
			addMember() {
				this.form.members.push({
					name: '',
					idNumber: '',
					phone: '',
					relation: '',
					health: [],
					studyEmplouStatus: '',
					isStudy: '',
					isEmploy: '',
					isPartyMember: '',
					isSoldier: '',
					pensionInsuranceLevel: '',
					disability: '',
					showDisability: false,
				})
			},
			async removeMember(idx) {
				if (this.form.members[idx].id) {
					await memberApi.deleteMember(this.form.members[idx].id);
				}
				this.form.members.splice(idx, 1)
			},
			validateId(id, idx) {
				const reg = /^(\d{15}|\d{17}[\dXx])$/
				if (id && !reg.test(id)) {
					uni.showToast({
						title: idx === -1 ? '户主身份证号格式有误' : `第${idx+1}位成员身份证号格式有误`,
						icon: 'none',
						duration: 3000,
					})
				}
			},
			validatePhone(phone, idx) {
				const reg = /^1[3-9]\d{9}$/
				if (phone && !reg.test(phone)) {
					uni.showToast({
						title: idx === -1 ? '户主手机号格式有误' : `第${idx+1}位成员手机号格式有误`,
						icon: 'none',
						duration: 3000,
					})
				}
			},
			// 限制checkbox-group为单选（仅用于居住属性）
			onSingleCheckboxChange(field) {
				// 确保单选：只保留当前选中的值
				if (Array.isArray(this.form[field])) {
					// 获取最后选择的那个选项
					const lastSelected = this.form[field][this.form[field].length - 1];
					// 立即清空数组，只保留当前选中的
					this.form[field] = lastSelected ? [lastSelected] : [];

					// 同步到对应的字符串字段用于提交（仅居住属性）
					if (field === 'hukouType') {
						this.form.hukouType = this.form[field][0] || '';
					}
				}
			},
			// 互斥单选：只保留最后一个选项
			onSingleStringCheckboxChange(field) {
				if (Array.isArray(this.form[field])) {
					if (this.form[field].length > 1) {
						this.form[field] = this.form[field][this.form[field].length - 1];
					} else if (this.form[field].length === 1) {
						this.form[field] = this.form[field][0];
					} else {
						this.form[field] = '';
					}
				}
			},
			clearSignature() {
				this.$refs.limeSign.clear();
				this.form.signatureImg = '';
			},
			// lime-signature官方推荐：@confirm事件获取base64
			onSignatureConfirm(e) {

				this.form.signatureImg = e;
				this.showSign = false;
				uni.showToast({
					title: '签名已保存',
					icon: 'success'
				});

			},
			openSignatureDialog(type) {
				if (type === 'staff') {
					this.showSign = true;
					// 如果已有签名，提示用户
					if (this.form.signatureImg) {
						setTimeout(() => {
							uni.showToast({
								title: '已有签名，如需修改请重新签名',
								icon: 'none',
								duration: 2000
							});
						}, 500);
					}
				} else if (type === 'holder') {
					this.holderShowSign = true;
					// 如果已有签名，提示用户
					if (this.form.holderSignatureImg) {
						setTimeout(() => {
							uni.showToast({
								title: '已有签名，如需修改请重新签名',
								icon: 'none',
								duration: 2000
							});
						}, 500);
					}
				}
			},
			viewSignature(type) {
				let signatureImg = '';
				if (type == 'staff') {
					signatureImg = this.form.signatureImg;
				} else {
					signatureImg = this.form.holderSignatureImg;
				}

				this.showSign = false;


				if (signatureImg) {
					// 预览签名图片
					uni.previewImage({
						urls: [signatureImg],
						current: 0
					});
				}
			},
			toggleKeyAttention(value) {
				const index = this.form.keyAttention.indexOf(value);
				if (index > -1) {
					this.form.keyAttention.splice(index, 1);
				} else {
					this.form.keyAttention.push(value);
				}
			},
			toggleHealth(value, member) {
				console.log(member)
				const healthOptions = member.health;
				const isHealth = value === '健康';
				const hasHealth = healthOptions.includes('健康');
				const hasOtherOptions = healthOptions.some(opt => opt !== '健康');
				if (!healthOptions.includes(value)) {
					if (isHealth && hasOtherOptions) {
						uni.showToast({
							title: '健康不允许与其他选项同时选择',
							icon: "none",
						})
						return;
					}
					if (!isHealth && hasHealth) {
						uni.showToast({
							title: '健康不允许与其他选项同时选择',

							icon: "none",
						})
						//    alert('健康不允许与其他选项同时选择');
						return;
					}
				}
				const index = member.health.indexOf(value);
				if (index > -1) {
					if (value == '残疾') {
						member.showDisability = false;
						member.disability = '';
					}
					member.health.splice(index, 1);
				} else {
					if (value == '残疾') {
						member.showDisability = true;
						member.disability = ''
					}
					member.health.push(value);
				}
			},
			togglebeneficialPolicy(value) {
				const index = this.form.beneficialPolicy.indexOf(value);
				if (index > -1) {
					if (value == '13') {
						this.showOtherBene = false;
						this.otherBene = '';
					}
					this.form.beneficialPolicy.splice(index, 1);
				} else {
					if (value == '13') {
						this.showOtherBene = true;
						this.otherBene = '';
					}
					this.form.beneficialPolicy.push(value);
				}
			},
			toggleHouseholdType(item) {
				console.log(this.form.householdType)
				if (!this.form.householdType) {
					if (item.value == '监测户' || item.value == '脱贫户') {
						this.showHelp = true;
					}
					if (item.value == '监测户') {
						this.showRiskMitigation = true;
					}
					this.form.householdType.push(item.value);
				} else {

					const index = this.form.householdType.indexOf(item.value);

					if (index > -1) {
						if (item.value == '监测户' || item.value == '脱贫户') {
							this.showHelp = false;
						}
						if (item.value == '监测户') {
							this.showRiskMitigation = false;
						}
						this.form.householdType.splice(index, 1);
					} else {
						if (item.value == '监测户' || item.value == '脱贫户') {
							this.showHelp = true;
						}
						if (item.value == '监测户') {
							this.showRiskMitigation = true;
						}
						//看有没有不允许多选的，如果有就提示错误
						if (item.isMultiple == 1) {
							var isMultiple = false;
							var isMultiple1 = false;
							console.log(this.form.householdType)
							if (this.noMultiple.includes(item.value)) {
								isMultiple = true;
							}
							for (var i = 0; i < this.form.householdType.length; i++) {
								var item1 = this.form.householdType[i];
								if (item1 != item.value) {
									if (this.noMultiple.includes(item1)) {
										isMultiple1 = true;
										break;
									}
								}
							}
							if (isMultiple && isMultiple1) {
								uni.showToast({
									title: this.noMultiple + "不允许多选！",
									duration: 3000,
									icon: "none",
								})
								return;
							}
						}
						this.form.householdType.push(item.value);
					}
				}

			},
			onClick(type) {
				if (type == 'openSmooth') {
					this.openSmooth = !this.openSmooth
					return
				}
				if (type == 'save') {
					this.$refs.signatureRef.canvasToTempFilePath({
						success: (res) => {
							// 检查是否为空
							if (res.isEmpty) {
								uni.showToast({
									title: "请先签字",
									duration: 3000,
									icon: "none",
								});
								return;
							}

							// 获取图片路径
							const url = res.tempFilePath;
							// 检查是否为base64格式
							if (url && url.startsWith('data:image/')) {
								// 直接使用base64数据
								this.form.signatureImg = url;

							} else {
								// 如果是文件路径，需要转换为base64
								this.convertToBase64(0, url);
								return;
							}

							// 关闭签名弹窗
							this.showSign = false;

							// 显示成功提示
							uni.showToast({
								title: '签名已保存',
								duration: 3000,
								icon: 'success'
							});
						},
						fail: (err) => {

							uni.showToast({
								title: '生成签名图片失败',
								duration: 3000,
								icon: 'none'
							});
						}
					})
					return
				}
				if (this.$refs.signatureRef)
					this.$refs.signatureRef[type]()
			},
			onHolderSignatureSave(img) {
				this.form.holderSignatureImg = img;
				this.holderShowSign = false;
				uni.showToast({
					title: '签名已保存',
					duration: 3000,
					icon: 'success'
				});
			},

			convertToBase64(type, filePath) {
				const fs = uni.getFileSystemManager();
				fs.readFile({
					filePath: filePath,
					encoding: "base64", // 指定编码为base64
					success: (res) => {
						// 构造data URL
						const base64String = `data:image/png;base64,${res.data}`;

						if (type === 0) {
							// 保存到表单
							this.form.signatureImg = base64String;

							// 关闭签名弹窗
							this.showSign = false;
						} else {
							this.form.holderSignatureImg = base64String;
							this.holderShowSign = false;
						}


						// 显示成功提示
						uni.showToast({
							title: '签名已保存',
							icon: 'success',
							duration: 3000,
						});
					},
					fail: (err) => {

						uni.showToast({
							title: '转换签名图片失败',
							duration: 3000,
							icon: 'none'
						});
					},
				});
			},
			onAreaChange(val) {
				this.form.town = val.town || '';
				this.form.village = val.village || '';
				this.form.groupName = val.groupName || '';
			},

			async deleteMsg() {
				try {
					var userInfo = userUtil.getUserInfo();
					const response = await householdApi.deleteHousehold(this.editId, userInfo.username);

					if (response && response.data) {
						var msg = '删除失败';
						if (response.data.msg) {
							msg = response.data.msg;
						}
						console.log(response.data)
						uni.showToast({
							title: msg,
							icon: 'none',
							duration: 2000
						})
						return

					} else if (response == true) {
						uni.showToast({
							title: '删除成功',
							duration: 3000,
							icon: 'success'
						})
						// 返回主页并刷新数据
						setTimeout(() => {
							// 通过事件总线通知主页刷新数据
							uni.$emit('refreshStats')

							// 返回主页
							uni.reLaunch({
								url: '/pages/index/index'
							})
						}, 1500)
					} else {
						uni.showToast({
							title: '删除失败',
							duration: 3000,
							icon: 'success'
						})
					}
				} catch (error) {
					uni.showToast({
						title: error.data.msg,
						duration: 3000,
						icon: 'none'
					})
				}
			},
			async submitForm() {
				// 保证keyAttention为数组
				if (!Array.isArray(this.form.keyAttention)) {
					this.form.keyAttention = [];
				}
				if (!this.showHelp) {
					this.form.helpUnit = '';
					this.form.helperPhone = '';
					this.form.helpRecordTime = '';
					this.form.helpFiles = []
				}
				// 完整的表单验证
				const validationErrors = [];

				// 基本信息验证
				if (!this.form.areaObj || this.form.areaObj.length === 0) {
					validationErrors.push('请选择所属区域');
				} else {
					if (!this.form.areaObj[2]) {
						validationErrors.push('区域缺失组/网格，请确认!');
					}
				}
				if (!this.form.doorNumber) {
					validationErrors.push('请输入门牌号');
				}
				if (!this.form.householdType || this.form.householdType.length === 0) {
					validationErrors.push('请选择家庭属性');

				} else {
					for (var i = 0; i < this.form.householdType.length; i++) {
						if (this.form.householdType[i] == '监测户') {
							if (this.form.riskMitigation == '') {
								validationErrors.push('监测户需填写是否消除风险！');
							}
						}
					}
				}
				if (!this.form.hukouType) {
					validationErrors.push('请选择居住属性');
				}


				if (!this.form.householderName) {
					validationErrors.push('请输入户主姓名');
				}
				if (!this.form.householderIdNumber) {
					validationErrors.push('请输入身份证号');
				} else {
					// 验证户主身份证号格式
					const idReg = /^(\d{15}|\d{17}[\dXx])$/;
					if (!idReg.test(this.form.householderIdNumber)) {
						validationErrors.push('户主身份证号格式不正确');
					}
				}
				if (!this.form.householdNum) {
					validationErrors.push('请输入户籍人数');
				}
				if (!this.form.residentNum) {
					validationErrors.push('请输入常住人数');
				}
				if (!this.form.householderPhone) {
					validationErrors.push('请输入联系电话');
				} else {
					if (this.form.householderPhone == '无') {

					} else {
						// 验证户主手机号格式
						const phoneReg = /^1[3-9]\d{9}$/;
						if (!phoneReg.test(this.form.householderPhone)) {
							validationErrors.push('户主手机号格式不正确');
						}
					}

				}
				if (!this.form.laborNum) {
					validationErrors.push('请输入劳动力人数');
				}
				if (!this.form.workNum) {
					validationErrors.push('请输入务工人数');
				}
				if (!this.form.noLaborNum) {
					validationErrors.push('请输入丧失或无劳动力人数');
				}

				// 家庭成员验证
				if (this.form.members && this.form.members.length > 0) {
					this.form.members.forEach((member, index) => {
						if (!member.name) {
							validationErrors.push(`第${index + 1}位成员姓名不能为空,若无成员请删除移除第一条数据后重新条`);
						}
						if (!member.relation) {
							validationErrors.push(`第${index + 1}位成员与户主关系不能为空,若无成员请删除移除第一条数据后重新条`);
						}
						if (!member.idNumber) {
							validationErrors.push(`第${index + 1}位成员身份证号不能为空,若无成员请删除移除第一条数据后重新条`);
						} else {
							// 验证成员身份证号格式
							const idReg = /^(\d{15}|\d{17}[\dXx])$/;
							if (!idReg.test(member.idNumber)) {
								validationErrors.push(`第${index + 1}位成员身份证号格式不正确,若无成员请删除移除第一条数据后重新条`);
							}
						}
						// if (!member.phone) {
						// 	validationErrors.push(`第${index + 1}位成员联系电话不能为空`);
						// } else {
						// 	// 验证成员手机号格式
						// 	const phoneReg = /^1[3-9]\d{9}$/;
						// 	if (!phoneReg.test(member.phone)) {
						// 		validationErrors.push(`第${index + 1}位成员手机号格式不正确`);
						// 	}
						// }
						if (!member.health) {
							validationErrors.push(`第${index + 1}位成员健康状况不能为空,若无成员请删除移除第一条数据后重新条`);
						} else {
							if (member.health.includes('残疾')) {
								if (member.disability == '') {
									validationErrors.push(`第${index + 1}位成员残疾等级未选择,若无成员请删除移除第一条数据后重新条`);
								}
							}
						}

						if (!member.isStudy) {
							validationErrors.push(`第${index + 1}位成员就学情况不能为空,若无成员请删除移除第一条数据后重新条`);
						}
						if (!member.isEmploy) {
							validationErrors.push(`第${index + 1}位成员就业情况不能为空,若无成员请删除移除第一条数据后重新条`);
						}
						if (!member.studyEmplouStatus) {
							validationErrors.push(`第${index + 1}位成员就学就业情况不能为空,若无成员请删除移除第一条数据后重新条`);
						}
						if (!member.isPartyMember) {
							validationErrors.push(`第${index + 1}位成员是否党员不能为空,若无成员请删除移除第一条数据后重新条`);
						}
						if (!member.isSoldier) {
							validationErrors.push(`第${index + 1}位成员是否退役军人不能为空,若无成员请删除移除第一条数据后重新条`);
						}
					});
				}

				// 住房饮水安全保障验证
				if (!this.form.houseStructure) {
					validationErrors.push('请输入住房结构');
				}
				if (!this.form.houseArea) {
					validationErrors.push('请输入住房面积');
				}
				if (!this.form.isDangerousHouse) {
					validationErrors.push('请选择是否危房');
				}
				if (!this.form.hasOtherSafeHouse) {
					validationErrors.push('请选择是否有其他安全住房');
				}
				if (!this.form.waterSource) {
					validationErrors.push('请输入饮用水水源');
				}
				if (!this.form.toiletStatus) {
					validationErrors.push('请输入户厕改造情况');
				}

				// 综合保障验证
				if (!this.form.medicalInsuranceNum) {
					validationErrors.push('请输入医疗保险参保人数');
				}
				if (!this.form.pensionInsuranceNum) {
					validationErrors.push('请输入养老保险参保人数');
				}
				// if (!this.form.insuranceLevel) {
				// 	validationErrors.push('请输入缴费档次');
				// }
				if (!this.form.dibaoNum) {
					validationErrors.push('请输入享受低保人数');
				}
				if (!this.form.dibaoAmount) {
					validationErrors.push('请输入月保障金额');
				}
				if (!this.form.tekunNum) {
					validationErrors.push('请输入特困供养人数');
				}
				if (!this.form.tekunAmount) {
					validationErrors.push('请输入特困月保障金额');
				}
				if (!this.form.disabledNum) {
					validationErrors.push('请输入残疾保障人数');
				}
				if (!this.form.disabledType) {
					validationErrors.push('请输入残疾类型');
				}
				if (!this.form.disabledAmount) {
					validationErrors.push('请输入残疾月保障金额');
				}
				if (!this.form.pensionNum) {
					validationErrors.push('请输入领取养老金人数');
				}
				if (!this.form.pensionAmount) {
					validationErrors.push('请输入月领取金额');
				}
				if (!this.form.hasAppliedForTemporaryAssistance) {
					validationErrors.push('请选择是否申请临时救助');
				}
				if (!this.form.hasFamilyDoctorContract) {
					validationErrors.push('请选择家庭医生是否签约');
				}

				// 教育保障验证
				if (!this.form.eduStudentNum) {
					validationErrors.push('请输入义务教育学生人数');
				}
				if (!this.form.needsHomeTeaching) {
					validationErrors.push('请选择是否需要送教上门');
				}
				if (!this.form.collegeStudentNum) {
					validationErrors.push('请输入大中专学生人数');
				}

				// 生产生活情况验证
				if (!this.form.hasFarmland) {
					validationErrors.push('请选择是否有耕地');
				}
				if (!this.form.landArea) {
					validationErrors.push('请输入确权面积');
				}
				if (!this.form.breedingStatus) {
					validationErrors.push('请输入养殖情况');
				}
				if (!this.form.businessStatus) {
					validationErrors.push('请输入个体经营情况');
				}
				if (!this.form.needsStartupLoan) {
					validationErrors.push('请选择是否需要创业贷款');
				}
				if (!this.form.loanPurpose) {
					validationErrors.push('请输入贷款用途');
				}

				// 监测对象验证
				if (!this.form.knowsHowToReportMonitoring) {
					validationErrors.push('请选择是否知道如何申报监测对象');
				}
				if (!this.form.comprehensiveJudgment) {
					validationErrors.push('请选择是否纳入监测对象');
				}
				// if (!this.form.keyAttention || this.form.keyAttention.length === 0) {
				// 	validationErrors.push('请选择是否八必访重点关注对象');
				// }

				// 培训就业验证
				if (!this.form.trainingNeed) {
					validationErrors.push('请输入培训需求');
				}
				if (!this.form.jobNeed) {
					validationErrors.push('请输入就业需求');
				}
				if (!this.form.otherNeed) {
					validationErrors.push('请输入其他诉求');
				}
				if (!this.form.suggestion) {
					validationErrors.push('请输入意见建议');
				}

				// 满意度验证
				if (this.form.villageSatisfaction === '') {
					validationErrors.push('请选择对村两委满意度');
				}
				if (this.form.workTeamSatisfaction === '') {
					validationErrors.push('请选择对驻村工作队满意度');
				}

				// 签字验证
				if (!this.form.signatureImg) {
					validationErrors.push('请完成入户员签字');
				}
				// 签字验证
				// if (!this.form.holderSignatureImg) {
				// 	validationErrors.push('请完成户主签字');
				// }
				// 签字验证
				if (!this.form.recordMethod) {
					validationErrors.push('请选择入户方式');
				}

				// 帮扶信息验证（当家庭属性为监测户或脱贫户时）
				if (this.showHelpInfo) {
					// if (!this.form.helpUnit) {
					// 	validationErrors.push('请输入帮扶单位');
					// }
					if (!this.form.helperName) {
						validationErrors.push('请输入帮扶人姓名');
					}
					if (!this.form.helperPhone) {
						validationErrors.push('请输入帮扶人联系方式');
					} else {
						if (this.form.helperPhone == '无') {

						} else {
							// 验证帮扶人手机号格式
							const phoneReg = /^1[3-9]\d{9}$/;
							if (!phoneReg.test(this.form.helperPhone)) {
								validationErrors.push('帮扶人手机号格式不正确');
							}
						}
					}
					if (!this.form.helpRecordTime) {
						validationErrors.push('请选择记录时间');
					}

				}

				try {
					if (this.form.areaObj && this.form.areaObj.length != 0) {
						this.form.town = this.form.areaObj[0].value;
						this.form.village = this.form.areaObj[1].value;
						this.form.groupName = this.form.areaObj[2].value;
					}
					// 准备提交数据，确保members格式正确
					const formData = {
						...this.form
					}
					var userInfo = userUtil.getUserInfo();
					formData.submitterId = userInfo.userId;
					formData.submitterName = userInfo.username;
					if (formData.members && Array.isArray(formData.members)) {
						formData.members = formData.members.map(member => ({
							id: member.id || '',
							name: member.name || '',
							idNumber: member.idNumber || '',
							phone: member.phone || '',
							relation: member.relation || '',
							health: member.health.join(',') || '',
							studyEmplouStatus: member.studyEmplouStatus || '',
							isStudy: member.isStudy || '',
							isEmploy: member.isEmploy || '',
							isPartyMember: member.isPartyMember || '',
							isSoldier: member.isSoldier || '',
							pensionInsuranceLevel: member.pensionInsuranceLevel || '',
							remark: member.remark || '',
							disability: member.disability || '',
							showDisability: member.showDisability || false,
						}))
						var j = 0;
						var k = 0;
						for (var i = 0; i < formData.members.length; i++) {
							var item = formData.members[i];
							if (!item.health) {
								validationErrors.push('第' + i + '位成员，健康状况不能为空！');
								break;
							}
							if (item.pensionInsuranceLevel) {
								k++;
							}
							if (item.health.includes('残疾')) {
								if (!item.disability) {
									validationErrors.push('第' + i + '位成员，残疾类型不能为空！')
									break;
								}

								j++;
							}
							if (!item.isStudy) {
								validationErrors.push('第' + i + '位成员，是否就学必须选择一项！');
								break;
							}
							if (!item.isEmploy) {
								validationErrors.push('第' + i + '位成员，是否就业必须选择一项！');
								break;
							}
							if (!item.studyEmplouStatus) {
								validationErrors.push('第' + i + '位成员，就学就业情况不能为空！');
								break;
							}
							if (!item.isPartyMember) {
								validationErrors.push('第' + i + '位成员，是否党员必须选择！');
								break;
							}
							if (!item.isSoldier) {
								validationErrors.push('第' + i + '位成员，是否退役军人必须选择！');
								break;
							}

						}
						if (this.form.disabledNum) {
							if (this.form.disabledNum > j) {
								uni.showToast({
									title: '残疾保障人数不得大于家庭成员总残疾人数',
									duration: 3000,
									icon: 'none'
								})
								return
							}
						}
						if (this.form.pensionInsuranceNum) {
							if (this.form.pensionInsuranceNum > k) {
								uni.showToast({
									title: '养老保险人数不得大于家庭成员中已填保险信息的总人数',
									duration: 3000,
									icon: 'none'
								})
								return
							}
						}
					}
					if (this.helpFiles.length >= 1) {
						formData.helpFiles = this.helpFiles.map(helpFiles => ({
							id: helpFiles.id || '',
							groupId: helpFiles.groupId || '',
							manualPhoto: helpFiles.base64,
							manualPhotoName: helpFiles.fileName,
						}))
					}

					// 如果有验证错误，显示第一个错误并返回
					if (validationErrors.length > 0) {
						uni.showToast({
							title: validationErrors[0],
							duration: 3000,
							icon: 'none'
						});
						return;
					}

					formData.submitStatus = 1;
					const response = await householdApi.createHousehold(formData);

					if (response) {

						this.id = response.id;
						uni.showToast({
							title: '提交成功',
							duration: 3000,
							icon: 'success'
						})
						// 返回主页并刷新数据
						setTimeout(() => {
							// 通过事件总线通知主页刷新数据
							uni.$emit('refreshStats')

							// 返回主页
							uni.reLaunch({
								url: '/pages/index/index'
							})
						}, 1500)
					} else {
						uni.showToast({
							title: response.data.message || '提交失败',
							duration: 3000,
							icon: 'none'
						})
					}
				} catch (error) {
					formData.members = formData.members.map(member => ({
						id: member.id || '',
						name: member.name || '',
						idNumber: member.idNumber || '',
						phone: member.phone || '',
						relation: member.relation || '',
						health: member.health.split(',').map(item => item.trim()) || '',
						studyEmplouStatus: member.studyEmplouStatus || '',
						isStudy: member.isStudy || '',
						isEmploy: member.isEmploy || '',
						isPartyMember: member.isPartyMember || '',
						isSoldier: member.isSoldier || '',
						pensionInsuranceLevel: member.pensionInsuranceLevel || '',
						remark: member.remark || '',
						disability: member.disability || '',
						showDisability: member.showDisability || false,

					}))
					if (error.data && error.data.msg) {
						uni.showToast({
							title: error.data.msg,
							duration: 3000,
							icon: 'none'
						})
					} else {
						uni.showToast({
							title: '提交失败，请检查网络连接',
							duration: 3000,
							icon: 'none'
						})
					}

				}
			},
			formatTimestamp(timestamp) {
				const date = new Date(timestamp);
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				const hours = String(date.getHours()).padStart(2, '0');
				const minutes = String(date.getMinutes()).padStart(2, '0');
				const seconds = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day}${hours}:${minutes}:${seconds}`;
			},
			async saveDraft() {
				// 保证keyAttention为数组
				if (!this.showHelp) {
					this.form.helpUnit = '';
					this.form.helperPhone = '';
					this.form.helpRecordTime = '';
					this.form.helpFiles = []
				}
				if (!Array.isArray(this.form.keyAttention)) {
					this.form.keyAttention = [];
				}
				if (this.form.areaObj && this.form.areaObj.length != 0) {
					this.form.town = this.form.areaObj[0].value;
					this.form.village = this.form.areaObj[1].value;
					this.form.groupName = this.form.areaObj[2].value;

				}


				// 暂存时只验证身份证号
				if (!this.form.householderIdNumber) {
					uni.showToast({
						title: '身份证号不得为空',
						duration: 3000,
						icon: 'none'
					})
					return
				}

				try {
					const token = uni.getStorageSync('token')
					if (!token) {
						uni.showToast({
							title: '请先登录',
							duration: 3000,
							icon: 'none'
						})
						return
					}
					// 准备暂存数据，确保members格式正确
					const formData = {
						...this.form
					}
					formData.submitStatus = 0 // 标记为暂存

					// 确保members是Map格式
					if (formData.members && Array.isArray(formData.members)) {

						formData.members = formData.members.map(member => ({
							id: member.id || '',
							name: member.name || '',
							idNumber: member.idNumber || '',
							phone: member.phone || '',
							relation: member.relation || '',
							health: member.health.join(',') || '',
							studyEmplouStatus: member.studyEmplouStatus || '',
							isStudy: member.isStudy || '',
							isEmploy: member.isEmploy || '',
							isPartyMember: member.isPartyMember || '',
							isSoldier: member.isSoldier || '',
							pensionInsuranceLevel: member.pensionInsuranceLevel || '',
							remark: member.remark || '',
							disability: member.disability || '',
							showDisability: member.showDisability || false,
						}))
						var i = 0;
						for (var i = 0; i < formData.members.length; i++) {
							var item = formData.members[i];
							if (item.health.includes('残疾')) {
								i++;
							}
						}
						if (this.form.disabledNum) {
							if (this.form.disabledNum > i) {
								uni.showToast({
									title: '残疾保障人数不得大于家庭成员总残疾人数',
									duration: 3000,
									icon: 'none'
								})
								return
							}
						}
					}
					if (this.helpFiles.length >= 1) {
						formData.helpFiles = this.helpFiles.map(helpFiles => ({
							id: helpFiles.id || '',
							groupId: helpFiles.groupId || '',
							manualPhoto: helpFiles.base64,
							manualPhotoName: helpFiles.fileName,
						}))
					}

					var userInfo = userUtil.getUserInfo();
					formData.submitterId = userInfo.userId;
					formData.submitterName = userInfo.username;
					const response = await householdApi.createHousehold(formData)
					if (response) {
						uni.showToast({
							title: '暂存成功',
							duration: 3000,
							icon: 'success'
						})
						// 返回主页并刷新数据
						setTimeout(() => {
							uni.navigateBack({
								success: () => {
									// 通过事件总线通知主页刷新数据
									uni.$emit('refreshStats')
								}
							})
						}, 1500)
					} else {
						uni.showToast({
							title: response.data.message || '暂存失败',
							duration: 3000,
							icon: 'none'
						})
					}
				} catch (error) {
					formData.members = formData.members.map(member => ({
						id: member.id || '',
						name: member.name || '',
						idNumber: member.idNumber || '',
						phone: member.phone || '',
						relation: member.relation || '',
						health: member.health.split(',').map(item => item.trim()) || '',
						studyEmplouStatus: member.studyEmplouStatus || '',
						isStudy: member.isStudy || '',
						isEmploy: member.isEmploy || '',
						isPartyMember: member.isPartyMember || '',
						isSoldier: member.isSoldier || '',
						pensionInsuranceLevel: member.pensionInsuranceLevel || '',
						remark: member.remark || '',
						disability: member.disability || '',
						showDisability: member.showDisability || false,

					}))
					uni.showToast({
						title: error.data.message,
						duration: 3000,
						icon: 'none'
					})
				}
			},
			exportExcel() {
				// TODO: 可用 xlsx.js 前端导出，或调用后端导出接口
				uni.showToast({
					title: '导出功能开发中',
					duration: 3000,
					icon: 'none'
				})
			},
			onHelpDateConfirm(e) {
				this.form.helpRecordTime = e.result;
				this.showHelpCalendar = false;
			}
		},
		mounted() {}
	}
</script>

<style scoped>
	.container {
		padding: 20rpx;
		background-color: #f5f5f5;
		min-height: 100vh;
	}

	.card {
		background-color: #fff;
		border-radius: 16rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
	}

	.section-title {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 30rpx;
		border-left: 8rpx solid #007aff;
		padding-left: 20rpx;
	}

	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 30rpx;
	}

	.history-link {
		font-size: 28rpx;
		color: #007aff;
		text-decoration: underline;
		cursor: pointer;
		padding: 6rpx 16rpx;
		border-radius: 8rpx;
		transition: background-color 0.3s;
	}

	.history-link:hover {
		background-color: rgba(0, 122, 255, 0.1);
	}

	.history-link:active {
		opacity: 0.7;
	}

	.option-list-row {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 20rpx;
	}

	.option-list-col {
		display: flex;
		flex-direction: column;
		gap: 20rpx;
	}

	.option-list-col-compact {
		display: flex;
		flex-direction: column;
		gap: 12rpx;
	}

	.option-item {
		margin-right: 20rpx;
		font-size: 26rpx;
		color: #222;

	}

	/* 复选框包装器样式 */
	.checkbox-item-wrapper {
		display: flex;
		align-items: flex-start;
		margin-bottom: 12rpx;
		padding: 8rpx 0;
	}

	/* 强制复选框文本换行 */
	.checkbox-item-wrapper :deep(.u-checkbox) {
		align-items: flex-start !important;
		width: 100% !important;
		display: flex !important;
	}

	.checkbox-item-wrapper :deep(.u-checkbox__label) {
		white-space: normal !important;
		word-wrap: break-word !important;
		word-break: break-all !important;
		line-height: 1.4 !important;
		flex: 1 !important;
		padding-top: 4rpx;
		max-width: none !important;
		overflow-wrap: break-word !important;
	}

	.checkbox-item-wrapper :deep(.u-checkbox__icon-wrap) {
		flex-shrink: 0 !important;
		margin-top: 4rpx;
		margin-right: 12rpx;
	}

	/* 自定义复选框样式 */
	.custom-checkbox-group {
		display: flex;
		flex-direction: column;
		gap: 12rpx;
	}

	.custom-checkbox-item {
		display: flex;
		align-items: flex-start;
		padding: 8rpx 0;
		cursor: pointer;
	}

	.checkbox-icon {
		width: 32rpx;
		height: 32rpx;
		border: 2rpx solid #ddd;
		border-radius: 4rpx;
		margin-right: 12rpx;
		margin-top: 4rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;
		background-color: #fff;
	}

	.checkbox-checked {
		color: #007aff;
		font-size: 20rpx;
		font-weight: bold;
	}

	.checkbox-label {
		flex: 1;
		font-size: 26rpx;
		color: #222;
		line-height: 1.4;
		white-space: normal;
		word-wrap: break-word;
		word-break: break-all;
		padding-top: 4rpx;
	}

	.btn-row {
		display: flex;
		flex-direction: column;
		gap: 20rpx;
		margin-top: 40rpx;
	}

	.button-row {
		display: flex;
		justify-content: space-between;
		gap: 20rpx;
	}

	.btn-left {
		flex: 1;
	}

	.btn-right {
		flex: 1;
	}

	.btn-main {
		height: 80rpx;
		font-size: 32rpx;
	}

	.member-block {
		border: 2rpx solid #eee;
		border-radius: 12rpx;
		padding: 20rpx;
		margin-bottom: 20rpx;
		background-color: #fafafa;
	}

	.member-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.member-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
	}

	.remove-btn {
		background-color: #ff4757;
		color: white;
		padding: 10rpx 20rpx;
		border-radius: 8rpx;
		font-size: 24rpx;
	}

	.add-btn {
		background-color: #007aff;
		color: white;
		padding: 15rpx 30rpx;
		border-radius: 12rpx;
		font-size: 28rpx;
		margin-top: 20rpx;
		text-align: center;
	}

	/* 帮扶信息样式 */
	.help-info-card {
		background-color: #f8f9fa;
		border: 2rpx solid #e9ecef;
		border-radius: 12rpx;
		padding: 20rpx;
		margin: 20rpx 0;
	}

	.help-info-card .section-title {
		color: #495057;
		font-size: 30rpx;
		font-weight: 600;
		margin-bottom: 20rpx;
		border-bottom: 2rpx solid #dee2e6;
		padding-bottom: 10rpx;
	}

	.preview-list {
		display: flex;
		flex-wrap: wrap;
		margin-top: 20px;
	}

	.preview-image {
		width: 30%;
		margin: 5px;
		border-radius: 4px;
	}
</style>