<template>
	<view class="app-container">
		<!-- 顶部导航栏 -->
		<!-- <view class="nav-bar" @click="goBack">
			<uni-icons type="back" size="20" color="#fff"></uni-icons>
			<text class="nav-title">贫困认定申请</text>
		</view> -->

		<!-- 选项卡容器 -->
		<view class="tabs-container">
			<view class="tabs-header">
				<view class="tab-item" :class="{ active: activeTab === 0 }" @click="switchTab(0)">
					<uni-icons type="contact" size="12" :color="activeTab === 0 ? '#409EFF' : '#666'"></uni-icons>
					<text class="tab-text">基本信息</text>
				</view>
				<view class="tab-item" :class="{ active: activeTab === 1 }" @click="switchTab(1)">
					<uni-icons type="home" size="12" :color="activeTab === 1 ? '#409EFF' : '#666'"></uni-icons>
					<text class="tab-text">家庭情况</text>
				</view>
				<view class="tab-item" :class="{ active: activeTab === 2 }" @click="switchTab(2)">
					<uni-icons type="team" size="12" :color="activeTab === 2 ? '#409EFF' : '#666'"></uni-icons>
					<text class="tab-text">家庭成员</text>
				</view>
				<view class="tab-item" :class="{ active: activeTab === 3 }" @click="switchTab(3)">
					<uni-icons type="stats" size="12" :color="activeTab === 3 ? '#409EFF' : '#666'"></uni-icons>
					<text class="tab-text">经济状况</text>
				</view>
				<view class="tab-item" :class="{ active: activeTab === 4 }" @click="switchTab(4)">
					<uni-icons type="compose" size="12" :color="activeTab === 4 ? '#409EFF' : '#666'"></uni-icons>
					<text class="tab-text">申请理由</text>
				</view>
				<view class="tab-item" :class="{ active: activeTab === 5 }" @click="switchTab(5)">
					<uni-icons type="chat" size="12" :color="activeTab === 5 ? '#409EFF' : '#666'"></uni-icons>
					<text class="tab-text">审核意见</text>
				</view>
			</view>
		</view>

		<!-- 表单内容区域 -->
		<scroll-view scroll-y class="form-scroll" :style="{ height: formScrollHeight }">
			<view class="form-wrapper">
				<!-- 1. 基本信息标签页 -->
				<view v-show="activeTab === 0" class="tab-panel">
					<view class="form-card">
						<view class="card-title">学生基本信息</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>学号</label>
							<input v-model="formData.xh" placeholder="请输入学号" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>姓名</label>
							<input v-model="formData.xm" placeholder="请输入姓名" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>性别</label>
							<picker mode="selector" :range="genderOptions" :range-key="'text'" v-model="formData.xb" @change="handleGenderChange" :disabled="detailMode">
								<view class="picker-input">
									{{ formData.xb ? getGenderText(formData.xb) : '请选择性别' }}
								</view>
							</picker>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>学院</label>
							<input v-model="formData.xy" placeholder="请输入学院" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>年级</label>
							<input v-model="formData.nj" placeholder="请输入年级" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>班级</label>
							<input v-model="formData.bj" placeholder="请输入班级" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>身份证号</label>
							<input v-model="formData.sfzhm" placeholder="请输入身份证号" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>民族</label>
							<picker mode="selector" :range="nationOptions" v-model="formData.mz" @change="handleNationChange" :disabled="detailMode">
								<view class="picker-input">
									{{ formData.mz ? formData.mz : '请选择民族' }}
								</view>
							</picker>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>手机号</label>
							<input v-model="formData.phone" placeholder="请输入手机号" class="form-input" type="number" :disabled="detailMode"></input>
						</view>
					</view>
				</view>

				<!-- 2. 家庭情况标签页 -->
				<view v-show="activeTab === 1" class="tab-panel">
					<view class="form-card">
						<view class="card-title">家庭基本情况</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>家庭人口数</label>
							<input v-model="formData.rkzs" placeholder="请输入家庭人口数" class="form-input" type="number" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>家庭成员在学人数</label>
							<input v-model="formData.jtcyzxrs" placeholder="请输入在学人数" class="form-input" type="number" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>赡养人数</label>
							<input v-model="formData.syrs" placeholder="请输入赡养人数" class="form-input" type="number" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
								<label class="form-label"><span class="red-tip">*</span>家庭成员失业人数</label>
								<input v-model="formData.jtcysyrs" placeholder="请输入失业人数" class="form-input" type="number" :disabled="detailMode"></input>
							</view>
							<view class="form-item">
								<label class="form-label"><span class="red-tip">*</span>全国学生资助系统、广西学生精准系统困难标签</label>
								<input v-model="formData.knlx" placeholder="系统自动获取" class="form-input" disabled></input>
							</view>
							<view class="form-item">
								<label class="form-label"><span class="red-tip">*</span>籍贯</label>
								<input v-model="formData.jg" placeholder="请输入籍贯" class="form-input" :disabled="detailMode"></input>
							</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>户籍所在地</label>
							<input v-model="formData.hjszd" placeholder="请输入户籍所在地" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>家庭居住房产情况</label>
							<picker mode="selector" :range="houseOptions" :range-key="'text'" v-model="formData.jtjzfqk" @change="handleHouseChange" :disabled="detailMode">
								<view class="picker-input">
									{{ formData.jtjzfqk ? getHouseText(formData.jtjzfqk) : '请选择住房情况' }}
								</view>
							</picker>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>家中有汽车情况</label>
							<picker mode="selector" :range="carOptions" :range-key="'text'" v-model="formData.jtqcqk" @change="handleCarChange" :disabled="detailMode">
								<view class="picker-input">
									{{ formData.jtqcqk ? getCarText(formData.jtqcqk) : '请选择汽车情况' }}
								</view>
							</picker>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>家长手机号码</label>
							<input v-model="formData.parentstel" placeholder="请输入家长手机号码" class="form-input" type="number" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>家庭现居住地址</label>
							<input v-model="formData.jtxjzdz" placeholder="请输入现居住地址" class="form-input" :disabled="detailMode"></input>
						</view>
					</view>
				</view>

				<!-- 3. 家庭成员标签页 -->
				<view v-show="activeTab === 2" class="tab-panel">
					<view class="form-card">
						<view class="card-title">家庭成员情况</view>
						<view class="family-list">
							<view v-for="(member, index) in formData.jtcyObj" :key="index" class="family-item">
								<view class="item-header">
								<text class="item-title">家庭成员 {{ index + 1 }}</text>
								<uni-icons type="close" size="20" color="#ff4d4f" @click="deleteFamilyMember(index)" class="delete-btn" v-if="!detailMode"></uni-icons>
							</view>
							<view class="form-item">
								<label class="form-label"><span class="red-tip">*</span>姓名</label>
								<input v-model="member.xm" placeholder="请输入姓名" class="form-input" :disabled="detailMode"></input>
							</view>
							<view class="form-item">
								<label class="form-label"><span class="red-tip">*</span>年龄</label>
								<input v-model="member.nl" placeholder="请输入年龄" class="form-input" type="number" :disabled="detailMode"></input>
							</view>
							<view class="form-item">
								<label class="form-label"><span class="red-tip">*</span>与学生关系</label>
								<input v-model="member.gx" placeholder="请输入与学生关系" class="form-input" :disabled="detailMode"></input>
							</view>
							<view class="form-item">
								<label class="form-label">工作(学习)单位</label>
								<input v-model="member.dw" placeholder="请输入工作单位" class="form-input" :disabled="detailMode"></input>
							</view>
							<view class="form-item">
								<label class="form-label">联系电话</label>
								<input v-model="member.tel" placeholder="请输入联系电话" class="form-input" type="number" :disabled="detailMode"></input>
							</view>
							<view class="form-item">
								<label class="form-label">职业</label>
								<input v-model="member.zy" placeholder="请输入职业" class="form-input" :disabled="detailMode"></input>
							</view>
							<view class="form-item">
								<label class="form-label">年收入(元)</label>
								<input v-model="member.nsr" placeholder="请输入年收入" class="form-input" type="number" :disabled="detailMode"></input>
							</view>
							<view class="form-item">
								<label class="form-label">健康状况</label>
								<input v-model="member.jkzk" placeholder="请输入健康状况" class="form-input" :disabled="detailMode"></input>
							</view>
							</view>
						</view>
						<view class="add-family-btn" @click="addFamilyMember" v-if="!detailMode">
							<uni-icons type="plus" size="20" color="#409EFF"></uni-icons>
							<text>新增家庭成员</text>
						</view>
						<view class="form-item" style="margin-top: 20px;">
							<label class="form-label"><span class="red-tip">*</span>家庭总收入(元)</label>
							<view class="income-display">
								<text>{{ formData.jtnsr || 0 }}</text>
							</view>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>家庭人均年收入(元)</label>
							<view class="income-display">
								<text>{{ formData.rjnsr || 0 }}</text>
							</view>
						</view>
					</view>
				</view>

				<!-- 4. 经济状况标签页 -->
				<view v-show="activeTab === 3" class="tab-panel">
					<view class="form-card">
						<view class="card-title">家庭经济状况</view>
						<view class="form-item">
						<label class="form-label"><span class="red-tip">*</span>家庭经济主要收入来源</label>
						<view class="checkbox-container">
							<view v-for="(option, index) in incomeSourceOptions" :key="index" class="checkbox-item" @click="!detailMode && toggleIncomeSource(option.value)">
								<view class="checkbox-wrapper" :class="{ 'checkbox-disabled': detailMode }">
									<view 
										class="custom-checkbox" 
										:class="{ 'checkbox-checked': formData.jtzysr.includes(option.value) }"
									>
										<text v-if="formData.jtzysr.includes(option.value)" class="check-icon">✓</text>
									</view>
									<text class="checkbox-text">{{ option.text }}</text>
								</view>
							</view>
						</view>
					</view>
						<view class="form-item">
							<label class="form-label">其他收入说明</label>
							<input v-model="formData.jtzysr2" placeholder="请输入其他收入说明" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>学生父母丧失劳动能力或劳动能力弱(人)</label>
							<input v-model="formData.ssldnl" placeholder="请输入人数" class="form-input" type="number" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>需赡养丧失劳动能力的共同生活家庭成员(人)</label>
							<input v-model="formData.zyssldnl" placeholder="请输入人数" class="form-input" type="number" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>患病残疾人(人)</label>
							<input v-model="formData.hbcjr" placeholder="请输入人数" class="form-input" type="number" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
						<label class="form-label"><span class="red-tip">*</span>突发事件</label>
						<view class="checkbox-container">
							<view v-for="(option, index) in emergencyOptions" :key="index" class="checkbox-item" @click="!detailMode && toggleEmergency(option.value)">
								<view class="checkbox-wrapper" :class="{ 'checkbox-disabled': detailMode }">
									<view 
										class="custom-checkbox" 
										:class="{ 'checkbox-checked': formData.tfsj.includes(option.value) }"
									>
										<text v-if="formData.tfsj.includes(option.value)" class="check-icon">✓</text>
									</view>
									<text class="checkbox-text">{{ option.text }}</text>
								</view>
							</view>
						</view>
					</view>
						<view class="form-item">
							<label class="form-label">其他情况</label>
							<input v-model="formData.tfsj3" placeholder="请输入其他情况" class="form-input" :disabled="detailMode"></input>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>具体时间、内容及涉及金额等情况</label>
							<textarea v-model="formData.tfsj2" placeholder="请详细描述具体情况" class="form-textarea" rows="4" :disabled="detailMode"></textarea>
						</view>
					</view>
				</view>

				<!-- 5. 申请理由标签页 -->
				<view v-show="activeTab === 4" class="tab-panel">
					<view class="form-card">
						<view class="card-title">申请理由与承诺</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>申请理由</label>
							<textarea v-model="formData.sqly" placeholder="请详细说明家庭经济困难情况（100-200字）" class="form-textarea" rows="6" maxlength="200" show-word-limit :disabled="detailMode"></textarea>
						</view>
						<view class="form-item">
							<label class="form-label"><span class="red-tip">*</span>个人承诺</label>
							<view class="promise-content">
								<text>本人承诺以上所填资料真实、准确，并同意授权相关部门通过信息核对，对所填资料进行查询、核对。如虚报资料，本人愿意承担相关责任。</text>
							</view>
							<view class="form-item">
								<label class="form-label"><span class="red-tip">*</span>是否同意</label>
								<view class="radio-container">
									<view class="radio-item" @click="!detailMode && setPromise(1)">
										<view class="custom-radio" :class="{ 'radio-checked': formData.sqrcn === '1', 'radio-disabled': detailMode }">
											<text v-if="formData.sqrcn === '1'" class="check-icon">✓</text>
										</view>
										<text class="radio-text">同意</text>
									</view>
									<view class="radio-item" @click="!detailMode && setPromise(0)">
										<view class="custom-radio" :class="{ 'radio-checked': formData.sqrcn === '0', 'radio-disabled': detailMode }">
											<text v-if="formData.sqrcn === '0'" class="check-icon">✓</text>
										</view>
										<text class="radio-text">不同意</text>
									</view>
								</view>
							</view>
							<!-- 手写签字 -->
							<view class="form-item">
								<label class="form-label"><span class="red-tip">*</span>手写签字</label>
								<view class="sign-img" v-if="signImg != ''">
									<image :src="signImg" mode="aspectFit" style="width: 200px; height: 100px;"></image>
									<text @tap="signToggle" class="re-sign-text">重新签名</text>
								</view>
								<view v-else class="sign" @tap="signToggle" :class="{ 'sign-disabled': detailMode }">
									点击签名
								</view>
							</view>
						</view>
						<view class="form-item">
							<label class="form-label">困难佐证材料</label>
							<view class="upload-btn" @click="handleUpload" :class="{ 'upload-disabled': detailMode }">
								<text class="upload-icon">+</text>
								<text>{{ detailMode ? '已上传佐证材料' : '上传文件' }}</text>
							</view>
							<view class="file-list" v-if="affixFiles.length">
								<view class="file-item" v-for="(file, index) in affixFiles" :key="index">
									<text class="file-name" @click="previewImage(uni.getStorageSync('baseUrl') + '/' + file.savePath)">{{ file.attachmentName || file.trueName }}</text>
									<uni-icons type="trash-filled" size="30" @click="deleteFile(index)" v-if="!detailMode" class="delete-btn"></uni-icons>
								</view>
							</view>
							<view class="upload-tip" v-if="!detailMode">支持上传jpg/png/pdf格式文件，单个文件不超过10MB（如病例、住房证明等）</view>
						</view>
					</view>
				</view>

				<!-- 6. 审核意见标签页 -->
				<view v-show="activeTab === 5" class="tab-panel">
					<view class="form-card">
						<view class="card-title">审核意见</view>
						
						<!-- 辅导员审核意见 -->
						<view class="approval-section">
							<view class="section-title">辅导员意见</view>
							<view class="approval-content">
								<view v-if="formData.bjpyyj" class="approval-text">
									<text>经班级评议小组民主评议，认为该生</text>
									<text class="highlight">{{ formData.bjpyyj !== '4' ? '符合' : '不符合' }}</text>
									<text>家庭经济困难学生认定条件，推荐认定困难类型为：</text>
									<text class="difficulty-level">
										{{ formData.bjpyyj === '1' ? '特别困难' : 
										   formData.bjpyyj === '2' ? '比较困难' : 
										   formData.bjpyyj === '3' ? '一般困难' : 
										   formData.bjpyyj === '4' ? '不困难' : '' }}
									</text>
								</view>
								<text v-else class="no-content">暂无审核意见</text>
							</view>
							<view class="approval-info">
								<text v-if="formData.fdymc">审核人：{{ formData.fdymc }}</text>
								<text v-if="formData.fdyqmrq">审核时间：{{ formData.fdyqmrq }}</text>
							</view>
						</view>
						
						<!-- 学院审核意见 -->
						<view class="approval-section">
							<view class="section-title">二级学院认定意见</view>
							<view class="approval-content">
								<view v-if="formData.ejxyldqmyj" class="approval-text">
									<text>经学院认定工作组审查，认为该生</text>
									<text class="highlight">{{ formData.ejxyldqmyj !== '4' ? '符合' : '不符合' }}</text>
									<text>家庭经济困难学生认定条件，认定困难类型为：</text>
									<text class="difficulty-level">
										{{ formData.ejxyldqmyj === '1' ? '特别困难' : 
										   formData.ejxyldqmyj === '2' ? '比较困难' : 
										   formData.ejxyldqmyj === '3' ? '一般困难' : 
										   formData.ejxyldqmyj === '4' ? '不困难' : '' }}
									</text>
								</view>
								<text v-else class="no-content">暂无审核意见</text>
							</view>
							<view class="approval-info">
								<text v-if="formData.ejxyldmc">审核人：{{ formData.ejxyldmc }}</text>
								<text v-if="formData.ejxyldqmrq">审核时间：{{ formData.ejxyldqmrq }}</text>
							</view>
						</view>
						
						<!-- 学校审核意见 -->
						<view class="approval-section">
							<view class="section-title">学校审核意见</view>
							<view class="approval-content">
								<view v-if="formData.xsqmyj" class="approval-text">
									<text>经学校学生资助工作领导小组审查，经5个工作日公示无异议，认定该生</text>
									<text class="highlight">{{ formData.xsqmyj !== '4' ? '符合' : '不符合' }}</text>
									<text>家庭经济困难学生认定条件，同意认定困难类型为：</text>
									<text class="difficulty-level">
										{{ formData.xsqmyj === '1' ? '特别困难' : 
										   formData.xsqmyj === '2' ? '比较困难' : 
										   formData.xsqmyj === '3' ? '一般困难' : 
										   formData.xsqmyj === '4' ? '不困难' : '' }}
									</text>
								</view>
								<text v-else class="no-content">暂无审核意见</text>
							</view>
							<view class="approval-info">
								<text v-if="formData.xsmc">审核人：{{ formData.xsmc }}</text>
								<text v-if="formData.xsqmrq">审核时间：{{ formData.xsqmrq }}</text>
							</view>
						</view>
					</view>
				</view>

				<!-- 提交按钮区域 -->
				<view class="submit-container" v-if="!detailMode">
					<button type="primary" @click="saveForm" class="submit-btn">
						<uni-icons type="folder" size="16"></uni-icons> 保存
					</button>
					<button type="primary" @click="submitForm" class="submit-btn submit-primary">
						<uni-icons type="checkmark" size="16"></uni-icons> 提交申请
					</button>
				</view>
			</view>
		</scroll-view>

		<!-- 上传文件弹窗 -->
				<uni-popup ref="filePopup" type="bottom">
					<view class="popup-content">
						<view class="popup-header">
							<text class="popup-title">上传文件</text>
							<uni-icons type="close" size="20" color="#999" @click="$refs.filePopup.close()" class="close-btn"></uni-icons>
						</view>
						<view class="popup-body">
							<view class="upload-option" @click="chooseImage">
								<uni-icons type="image" size="30" color="#409EFF"></uni-icons>
								<text>拍照上传</text>
							</view>
							<view class="upload-option" @click="chooseFile">
								<uni-icons type="document" size="30" color="#409EFF"></uni-icons>
								<text>选择文件</text>
							</view>
						</view>
					</view>
				</uni-popup>
				<!-- 签名组件 -->
				<jp-signature-popup ref="jpSignature" :required="true" popup @change="uploadSign" />
	</view>
</template>

<script>
	import { addApply, updateApply, getApply, infoCheck, getStuByXh, getxh, extraInfo, stuInfoView, getOwnFamily, getCurrentYear, queryByStuNo, getKnrdYear } from '@/api/finance/poverty'
import uploadFile from "@/plugins/upload.js"
import { queryAffixs, getAffixItems, deleteAffix } from '@/api/affix'
import config from '@/config'
	export default {
		data() {
			return {
				activeTab: 0,
				formScrollHeight: '600px',
				detailMode: false, // 新增：是否为查看详情模式
				applyId: null, // 新增：申请ID
				formData: {
					step: 1,
					xh: '',
					xm: '',
					xb: '',
					nj: '',
					bj: '',
					phone: '',
					sfzhm: '',
					mz: '',
					csny: '',
					rkzs: '',
					jtcyzxrs: '',
					syrs: '',
					jtcysyrs: '',
					jg: '',
					hjszd: '',
					jtjzfqk: '',
					jtqcqk: '',
					parentstel: '',
					jtxjzdz: '',
					knlx: '',
					jtcyObj: [
						{
							xm: '',
							nl: '',
							gx: '',
							dw: '',
							tel: '',
							zy: '',
							nsr: '',
							jkzk: ''
						}
					],
					jtnsr: 0,
					rjnsr: 0,
					jtzysr: [],
					jtzysrStr: '',
					jtzysr2: '',
					ssldnl: '',
									zyssldnl: '',
									hbcjr: '',
									tfsj: [],
									tfsjStr: '',
									tfsj2: '',
									tfsj3: '',
									sqly: '',
									sqrcn: '',
									sqrqm: '',
									affixId: null
				},
				genderOptions: [
					{ value: '男', text: '男' },
					{ value: '女', text: '女' }
				],
				nationOptions: ['汉族', '蒙古族', '回族', '藏族', '维吾尔族', '苗族', '彝族', '壮族', '布依族', '朝鲜族', '满族', '侗族', '瑶族', '白族', '土家族', '哈尼族', '哈萨克族', '傣族', '黎族', '傈僳族', '佤族', '畲族', '高山族', '拉祜族', '水族', '东乡族', '纳西族', '景颇族', '柯尔克孜族', '土族', '达斡尔族', '仫佬族', '羌族', '布朗族', '撒拉族', '毛南族', '仡佬族', '锡伯族', '阿昌族', '普米族', '塔吉克族', '怒族', '乌孜别克族', '俄罗斯族', '鄂温克族', '德昂族', '保安族', '裕固族', '京族', '塔塔尔族', '独龙族', '鄂伦春族', '赫哲族', '门巴族', '珞巴族', '基诺族'],
				houseOptions: [
					{ value: '商品房', text: '商品房' },
					{ value: '单位福利住房', text: '单位福利住房' },
					{ value: '自建房', text: '自建房' },
					{ value: '租房、无房', text: '租房、无房' },
					{ value: '其他', text: '其他' }
				],
				carOptions: [
					{ value: '自用', text: '自用' },
					{ value: '经营用', text: '经营用' },
					{ value: '无汽车', text: '无汽车' }
				],
				incomeSourceOptions: [
					{ value: '机关事业单位公职人员', text: '机关事业单位公职人员' },
					{ value: '单位公司合同制职工', text: '单位公司合同制职工' },
					{ value: '私营业主', text: '私营业主' },
					{ value: '个体工商户', text: '个体工商户' },
					{ value: '务工', text: '务工' },
					{ value: '务农', text: '务农' },
					{ value: '无固定收入', text: '无固定收入' },
					{ value: '无收入', text: '无收入' },
					{ value: '其他', text: '其他' }
				],
				emergencyOptions: [
					{ value: '家庭遭受疫情', text: '家庭遭受疫情' },
					{ value: '家庭遭受自然灾害', text: '家庭遭受自然灾害' },
					{ value: '家庭遭受突发意外事件', text: '家庭遭受突发意外事件' },
					{ value: '家庭欠债', text: '家庭欠债' },
					{ value: '其它情况', text: '其它情况' },
					{ value: '无', text: '无' }
				],
				affixFiles: [],
							loading: false,
							signImg: '',
			baseUrl: config.baseUrl || ''
			}
		},
		onLoad(option) {
			// 接收从主页面传递过来的学年信息
			if (option && option.stuYearId) {
				this.formData.stuYearId = option.stuYearId;
				this.formData.applyYear = option.yearName;
			}
			// 接收从主页面传递过来的申请ID和类型
			if (option && option.id) {
				this.applyId = option.id;
				if (option.type === 'detail') {
					this.detailMode = true;
				}
			}
			this.calculateFormHeight()
			this.initData()
		},
		onShow() {
			this.calculateFormHeight()
		},
		methods: {
			// 计算表单滚动区域高度
			calculateFormHeight() {
				const systemInfo = uni.getSystemInfoSync()
				const navHeight = 44 // 导航栏高度
				const tabsHeight = 50 // 选项卡高度
				const submitBtnHeight = 60 // 提交按钮高度
				const padding = 20 // 页面内边距
				this.formScrollHeight = (systemInfo.windowHeight - navHeight - tabsHeight - submitBtnHeight - padding) + 'px'
			},
			// 初始化数据
			initData() {
				if (this.applyId) {
					// 无论是否为详情模式，只要有applyId，就获取申请详情
					this.getApplyDetail()
				} else {
					// 如果没有applyId，可能是新建申请的情况
					// 编辑模式，检查基础信息是否完善
					infoCheck().then(res => {
						if (res.code === 0) {
							if (res.data.code === 0) {
								uni.showModal({
									title: '提示',
									content: '基础信息未完善!(备注:白底照片也需要上传)',
									confirmText: '前往完善',
									cancelText: '取消',
									success: (res) => {
										if (res.confirm) {
											// 跳转到基础信息完善页面
											uni.navigateTo({
												url: '/pages/user/infoEdit'
											})
										}
									}
								})
							} else {
								this.init()
							}
						} else {
							this.init()
						}
					})
				}
			},
			// 初始化学生信息
			init() {
				this.loading = true
				// 获取学号等基本信息
				getxh().then(res => {
					if (res.code === 200) {
						this.formData.xh = res.data.stuNo
						this.formData.sfzhm = res.data.idCard
						this.formData.xm = res.data.name
						this.formData.xb = res.data.gender
						this.formData.phone = res.data.phone
						
						// 获取扩展信息
						this.getOwnInfo()
						// 获取家庭成员信息
						this.getFamily()
						// 获取当前学年
						this.getCurrentYear()
					}
					this.loading = false
				}).catch(err => {
					console.error('获取学号失败:', err)
					this.loading = false
				})
			},
			// 获取申请详情
			getApplyDetail() {
				if (!this.applyId) return
				
				this.loading = true
				getApply(this.applyId).then(res => {
					if (res.code === 200) {
						const data = res.data
						// 将字符串类型的数组字段转换为数组
						if (data.jtzysr) {
							data.jtzysr = data.jtzysr.split(',')
							data.jtzysrStr = data.jtzysr.join(',')
						}
						if (data.tfsj) {
							data.tfsj = data.tfsj.split(',')
							data.tfsjStr = data.tfsj.join(',')
						}
						if (data.jtcy) {
							try {
								data.jtcyObj = JSON.parse(data.jtcy)
							} catch (e) {
								console.error('解析家庭成员信息失败:', e)
								data.jtcyObj = []
							}
						}
						// 设置表单数据
						this.formData = data
						
						// 处理个人承诺的"是否同意"字段，确保是字符串格式
						if (this.formData.sqrcn !== undefined && this.formData.sqrcn !== null) {
							this.formData.sqrcn = this.formData.sqrcn.toString()
						}
						
						// 处理手写签字（支持sqrqm和applySign字段）
						const signPath = this.formData.sqrqm || this.formData.applySign;
						if (signPath) {
							// 构造完整的图片URL
							this.signImg = this.baseUrl + signPath;
						} else {
							this.signImg = '';
						}
						
						// 处理困难佐证材料
						if (this.formData.affixId) {
							// 使用affixId调用API获取附件列表
							queryAffixs(this.formData.affixId).then(affixRes => {
								if (affixRes && affixRes.code === 200 && Array.isArray(affixRes.data)) {
									this.affixFiles = affixRes.data.map(item => {
										return {
											attachmentName: item.attachmentName || item.trueName || '未命名文件',
											attachmentUrl: item.attachmentUrl || item.savePath || '',
											serverUrl: item.serverUrl || item.savePath || '',
											fileId: item.id || '',
											fileSize: item.fileSize || 0,
											fileSuffix: item.fileSuffix || (item.attachmentName ? item.attachmentName.split('.').pop().toLowerCase() : ''),
											savePath: item.savePath || item.attachmentUrl || ''
										}
									})
								} else {
									console.error('获取附件列表失败:', affixRes)
									this.affixFiles = []
								}
							}).catch(affixErr => {
								console.error('获取附件列表失败:', affixErr)
								this.affixFiles = []
							})
						} else {
							this.affixFiles = []
						}
					} else {
						uni.showToast({
							title: '获取申请详情失败',
							icon: 'none'
						})
					}
					this.loading = false
				}).catch(err => {
					console.error('获取申请详情失败:', err)
					uni.showToast({
						title: '获取申请详情失败',
						icon: 'none'
					})
					this.loading = false
				})
			},
			// 获取学生扩展信息
			getOwnInfo() {
				extraInfo().then(res => {
					if (res.code === 200) {
						this.formData.jg = res.data.jg
						this.formData.mz = res.data.mz
						this.formData.hjszd = res.data.hksz1 + res.data.hksz2 + res.data.hksz3
						this.formData.jtxjzdz = res.data.xxlxdz
					}
				}).catch(err => {
					console.error('获取扩展信息失败:', err)
				})
				
				stuInfoView().then(res => {
					if (res.code === 200) {
						this.formData.xy = res.data.deptName
						this.formData.bj = res.data.className
						this.formData.nj = res.data.gradeName
						// 将birthday直接赋值给csny（YYYY-MM-DD格式）
						if (res.data.birthday) {
							this.formData.csny = res.data.birthday // YYYY-MM-DD格式
						}
					}
				}).catch(err => {
					console.error('获取学生信息失败:', err)
				})
			},
			// 获取家庭成员信息
			getFamily() {
				getOwnFamily().then(res => {
					if (res.code === 200) {
						const arr = res.data
						if (arr.length > 0) {
							this.formData.jtcyObj = []
							for (let i = 0; i < arr.length; i++) {
								const obj = {}
								obj.xm = arr[i].familyName
								obj.nl = arr[i].age
								obj.gx = arr[i].familyRelation
								// 如果是父母关系，设置家长电话
								if (arr[i].familyRelation.indexOf('父子') !== -1 || arr[i].familyRelation.indexOf('母子') !== -1 ||
									arr[i].familyRelation.indexOf('父女') !== -1 || arr[i].familyRelation.indexOf('母女') !== -1) {
									this.formData.parentstel = arr[i].phone
								}
								obj.tel = arr[i].phone
								obj.nsr = arr[i].yearMoney
								obj.dw = arr[i].workPlace
								obj.zy = arr[i].job
								obj.jkzk = arr[i].health
								this.formData.jtcyObj.push(obj)
							}
							// 设置家庭人口数
							this.formData.rkzs = arr.length + 1
							// 计算家庭收入
							this.calculateIncome()
						}
					}
				}).catch(err => {
					console.error('获取家庭成员信息失败:', err)
				})
			},
			// 获取当前学年
			getCurrentYear() {
				// 使用与列表页面一致的接口获取学年信息
				getKnrdYear('KNRD').then(res => {
					if (res.code === 200 && res.data && res.data.length > 0) {
						// 默认使用第一个学年
						this.formData.applyYear = res.data[0].stuYearName
						this.formData.stuYearId = res.data[0].id
						// 查询困难类别
						this.getKnlx()
					}
				}).catch(err => {
					console.error('获取当前学年失败:', err)
				})
			},
			// 获取困难类别
			getKnlx() {
				queryByStuNo({
					stuNo: this.formData.xh,
					stuYearId: this.formData.stuYearId
				}).then(res => {
					if (res.code === 200) {
						this.formData.knlx = res.data ? res.data.knrdType : '无'
					}
				}).catch(err => {
					console.error('获取困难类别失败:', err)
				})
			},
			// 切换选项卡
			switchTab(tabIndex) {
				this.activeTab = tabIndex
			},
			// 返回上一页
			goBack() {
				uni.navigateBack()
			},
			// 性别选择
			handleGenderChange(e) {
				this.formData.xb = this.genderOptions[e.detail.value].value
			},
			getGenderText(value) {
				const option = this.genderOptions.find(item => item.value === value)
				return option ? option.text : ''
			},
			// 住房情况选择
			handleHouseChange(e) {
				this.formData.jtjzfqk = this.houseOptions[e.detail.value].value
			},
			getHouseText(value) {
				const option = this.houseOptions.find(item => item.value === value)
				return option ? option.text : ''
			},
			// 汽车情况选择
			handleCarChange(e) {
				this.formData.jtqcqk = this.carOptions[e.detail.value].value
			},
			getCarText(value) {
				const option = this.carOptions.find(item => item.value === value)
				return option ? option.text : ''
			},
			// 民族选择
			handleNationChange(e) {
				this.formData.mz = this.nationOptions[e.detail.value]
			},
			// 收入来源选择
			toggleIncomeSource(value) {
				// 切换选中状态
				const index = this.formData.jtzysr.indexOf(value);
				if (index > -1) {
					// 如果已选中，则取消选中
					this.formData.jtzysr.splice(index, 1);
				} else {
					// 如果未选中，则添加到选中列表
					this.formData.jtzysr.push(value);
				}
				// 更新字符串
				this.formData.jtzysrStr = this.formData.jtzysr.join(',');
			},
			// 个人承诺设置
						setPromise(value) {
							// 设置承诺值（1-同意，0-不同意）
							this.formData.sqrcn = value.toString();
						},
						// 签名切换
						signToggle() {
							// 打开签名组件
							this.$refs.jpSignature.toPop();
						},
						// 上传签名
						uploadSign(e) {
							uploadFile('/common/upload', e).then((res) => {
								const data = JSON.parse(res);
								this.formData.sqrqm = data.fileName;
								this.signImg = data.url || (this.baseUrl + data.fileName);
							})
						},
			// 突发事件选择
			toggleEmergency(value) {
				// 切换选中状态
				const index = this.formData.tfsj.indexOf(value);
				if (index > -1) {
					// 如果已选中，则取消选中
					this.formData.tfsj.splice(index, 1);
				} else {
					// 如果未选中，则添加到选中列表
					this.formData.tfsj.push(value);
				}
				// 更新字符串
				this.formData.tfsjStr = this.formData.tfsj.join(',');
			},
			// 新增家庭成员
			addFamilyMember() {
				this.formData.jtcyObj.push({
					xm: '',
					nl: '',
					gx: '',
					dw: '',
					tel: '',
					zy: '',
					nsr: '',
					jkzk: ''
				})
				this.calculateIncome()
			},
			// 删除家庭成员
			deleteFamilyMember(index) {
				if (this.formData.jtcyObj.length <= 1) {
					uni.showToast({
						title: '至少保留一个家庭成员',
						icon: 'none'
					})
					return
				}
				this.formData.jtcyObj.splice(index, 1)
				this.calculateIncome()
			},
			// 计算家庭收入
			calculateIncome() {
				// 计算家庭总收入
				let totalIncome = 0
				this.formData.jtcyObj.forEach(member => {
					if (member.nsr) {
						totalIncome += Number(member.nsr)
					}
				})
				this.formData.jtnsr = totalIncome
				
				// 计算人均年收入
				if (this.formData.rkzs && Number(this.formData.rkzs) > 0) {
					this.formData.rjnsr = parseFloat(totalIncome / Number(this.formData.rkzs)).toFixed(2)
				} else {
					this.formData.rjnsr = 0
				}
			},
			// 上传文件
			handleUpload() {
				// 如果是详情模式，不执行上传操作
				if (this.detailMode) {
					return;
				}

				console.log('handleUpload方法被调用');
				

				// 1. 定义affixId生成工具函数（确保uuid唯一性）
				const generateUUID = () => {
					return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
						const r = Math.random() * 16 | 0;
						const v = c === 'x' ? r : (r & 0x3 | 0x8);
						return v.toString(16);
					});
				};

				uni.chooseFile({
					count: 10, // 最多选择10个文件
					extension: ['.jpg', '.png', '.pdf'], // 限制文件类型
					success: async (chooseRes) => {
						// 2. 初始化affixId（如果为空则生成唯一ID）
						if (!this.formData.affixId) {
							this.formData.affixId = generateUUID();
						}

						// 3. 遍历选择的文件，逐个上传（支持多文件）
						for (const file of chooseRes.tempFiles) {
							try {
								// 4. 构造上传参数（放在循环内，确保每个文件参数正确）
								const formDataObj = {
									affixId: this.formData.affixId,
									fileName: file.name,
									fileSize: file.size
								};

								// 5. 上传文件（await确保上传完成后再处理下一步）
								const uploadRes = await uploadFile('/affix/upload', file.path, formDataObj);
								const result = typeof uploadRes === 'string' ? JSON.parse(uploadRes) : uploadRes;

								// 6. 上传结果校验
								if (result && result.code === 200) {
									// 7. 构造文件信息对象（去重逻辑优化）
									const fileInfo = {
										attachmentName: file.name,
										attachmentUrl: result.savePath,
										serverUrl: result.savePath || '',
										fileId: result.id || '',
										fileSize: file.size,
										fileSuffix: file.name.split('.').pop().toLowerCase(),
										savePath: result.savePath
									};

									// 8. 去重逻辑（优化：通过文件名+大小双重校验，避免路径重复问题）
									const isDuplicate = this.affixFiles.some(item =>
										item.attachmentName === file.name && item.fileSize === file.size
									);

									if (!isDuplicate) {
										this.affixFiles.push(fileInfo);
									}

									uni.showToast({
										title: `文件 ${file.name} 上传成功`,
										icon: 'success',
										duration: 1500
									});
								} else {
									// 上传失败处理
									uni.showToast({
										title: `文件 ${file.name} 上传失败：${result.message || '未知错误'}`,
										icon: 'none',
										duration: 2000
									});
								}
							} catch (error) {
								// 9. 异常捕获（网络错误/上传接口异常）
								console.error(`文件 ${file.name} 上传异常：`, error);
								uni.showToast({
									title: `文件 ${file.name} 上传异常，请重试`,
									icon: 'none',
									duration: 2000
								});
							}
						}
					},
					// 10. 取消选择文件的处理
					fail: (err) => {
						console.error('选择文件失败：', err);
						uni.showToast({
							title: '选择文件失败，请重试',
							icon: 'none'
						});
					}
				});
			},
			// 删除文件
			async deleteFile(index) {
				const deletedFile = this.affixFiles[index];
				if (!deletedFile) return;
				
				try {
					// 调用后端删除接口
					if (deletedFile.fileId) {
						await deleteAffix(deletedFile.fileId);
					}
					
					// 从数组中删除文件
					this.affixFiles.splice(index, 1);
					
					// 如果没有文件了，清空affixId
					if (this.affixFiles.length === 0) {
						this.formData.affixId = null;
					}
					
					uni.showToast({
						title: '删除成功',
						icon: 'success'
					});
				} catch (error) {
					console.error('删除文件失败：', error);
					uni.showToast({
						title: '删除失败，请重试',
						icon: 'none'
					});
				}
			},
			// 预览文件
			previewImage(url) {
				uni.previewImage({
					urls: [url]
				});
			},
			// 保存表单
			saveForm() {
				this.submitForm(false)
			},
			// 提交表单
			submitForm(submit = true) {
				// 表单验证
				if (!this.validateForm()) {
					return
				}
				
				// 计算家庭收入
				this.calculateIncome()
				
				// 设置操作类型
				if (submit) {
					this.formData.step = 1
				}
				
				this.loading = true
				// 准备提交数据，确保字符串字段已更新
					const data = {
						...this.formData,
						// 将数组类型的字段转换为字符串类型
						jtzysr: this.formData.jtzysr.join(','),
						tfsj: this.formData.tfsj.join(','),
						// 将家庭成员数组转换为JSON字符串
						jtcy: JSON.stringify(this.formData.jtcyObj),
						// 确保字符串字段是最新的
						jtzysrStr: this.formData.jtzysr.join(','),
						tfsjStr: this.formData.tfsj.join(','),
						// 优先使用从接口获取的出生年月，如果没有则从身份证号提取
						csny: this.formData.csny || this.extractBirthDate(this.formData.sfzhm)
					}
				
				// 无论新增还是修改，都调用addApply接口（与PC端保持一致）
				addApply(data).then(res => {
					this.handleSubmitResult(res)
				})
			},
			// 表单验证
			validateForm() {
				// 基本信息验证
				if (!this.formData.xh) {
					uni.showToast({
						title: '请输入学号',
						icon: 'none'
					})
					return false
				}
				if (!this.formData.xm) {
					uni.showToast({
						title: '请输入姓名',
						icon: 'none'
					})
					return false
				}
				if (!this.formData.xb) {
					uni.showToast({
						title: '请选择性别',
						icon: 'none'
					})
					return false
				}
				if (!this.formData.rkzs) {
					uni.showToast({
						title: '请输入家庭人口数',
						icon: 'none'
					})
					return false
				}
				if (!this.formData.jtjzfqk) {
					uni.showToast({
						title: '请选择住房情况',
						icon: 'none'
					})
					return false
				}
				if (!this.formData.jtqcqk) {
					uni.showToast({
						title: '请选择汽车情况',
						icon: 'none'
					})
					return false
				}
				if (!this.formData.parentstel) {
					uni.showToast({
						title: '请输入家长手机号码',
						icon: 'none'
					})
					return false
				}
				// 家庭成员验证
				for (let i = 0; i < this.formData.jtcyObj.length; i++) {
					const member = this.formData.jtcyObj[i]
					if (!member.xm) {
						uni.showToast({
							title: '请输入第' + (i + 1) + '个家庭成员的姓名',
							icon: 'none'
						})
						return false
					}
					if (!member.gx) {
						uni.showToast({
							title: '请输入第' + (i + 1) + '个家庭成员与学生的关系',
							icon: 'none'
						})
						return false
					}
				}
				// 收入来源验证
				if (this.formData.jtzysr.length === 0) {
					uni.showToast({
						title: '请选择家庭经济主要收入来源',
						icon: 'none'
					})
					return false
				}
				// 突发事件验证
				if (this.formData.tfsj.length === 0) {
					uni.showToast({
						title: '请选择突发事件情况',
						icon: 'none'
					})
					return false
				}
				// 申请理由验证
				if (!this.formData.sqly) {
					uni.showToast({
						title: '请输入申请理由',
						icon: 'none'
					})
					return false
				}
				if (this.formData.sqly.length < 100) {
					uni.showToast({
						title: '申请理由不少于100字',
						icon: 'none'
					})
					return false
				}
				// 个人承诺验证
				if (this.formData.sqrcn === '') {
					uni.showToast({
						title: '请选择是否同意个人承诺',
						icon: 'none'
					})
					return false
				}
				if (this.formData.sqrcn === '0') {
					uni.showToast({
						title: '必须同意个人承诺才能提交申请',
						icon: 'none'
					})
					return false
				}
				// 佐证材料验证（已改为非必填）
				// if (!this.formData.affixId) {
				// 	uni.showToast({
				// 		title: '请上传困难佐证材料',
				// 		icon: 'none'
				// 	})
				// 	return false
				// }
				return true
			},
			// 从身份证号中提取出生年月
			extractBirthDate(sfzhm) {
				if (!sfzhm || sfzhm.length !== 18) return ''
				// 身份证号第7-14位是出生年月日，格式：YYYYMMDD
				const birthDateStr = sfzhm.substring(6, 14)
				// 转换为YYYY-MM-DD格式
				return birthDateStr.substring(0, 4) + '-' + birthDateStr.substring(4, 6) + '-' + birthDateStr.substring(6, 8)
			},
			// 处理提交结果
			handleSubmitResult(res) {
				this.loading = false
				if (res.code === 200) {
					uni.showToast({
						title: res.msg || '操作成功'
					})
					// 跳转到贫困申请列表页面
					setTimeout(() => {
						uni.redirectTo({
							url: '/pages/finance/poverty/index'
						})
					}, 1500)
				} else {
					uni.showToast({
						title: res.msg || '操作失败',
						icon: 'none'
					})
				}
			}
	},
	}
</script>

<style scoped>
	.app-container {
		height: 100vh;
		background-color: #f5f7fa;
	}
	.nav-bar {
		height: 44px;
		background-color: #409EFF;
		display: flex;
		align-items: center;
		padding: 0 15px;
		color: #fff;
		position: relative;
		z-index: 100;
	}
	.nav-title {
		font-size: 18px;
		font-weight: bold;
		margin-left: 15px;
	}
	.tabs-container {
		background-color: #fff;
		border-bottom: 1px solid #e4e7ed;
	}
	.tabs-header {
	display: flex;
	height: 45px;
	align-items: center;
	padding: 0 0;
	width: 100%;
	justify-content: space-around;
	overflow-x: auto;
	white-space: nowrap;
}
	.tab-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 0 5px;
	height: 100%;
	justify-content: center;
	cursor: pointer;
	position: relative;
	flex-shrink: 1;
	min-width: 60px;
	z-index: 1;
}
	.tab-item.active {
		color: #409EFF;
	}
	.tab-item.active::after {
		content: '';
		position: absolute;
		bottom: 0;
		left: 10px;
		right: 10px;
		height: 2px;
		background-color: #409EFF;
	}
	.tab-text {
		font-size: 9px;
		margin-top: 1px;
	}
	.form-scroll {
		padding: 10px;
	}
	.form-wrapper {
		background-color: #fff;
		border-radius: 8px;
		padding: 10px;
		margin-bottom: 10px;
	}
	.tab-panel {
		padding: 5px 0;
	}
	.form-card {
		background-color: #fff;
		border-radius: 8px;
		padding: 15px;
		margin-bottom: 15px;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
	}
	.card-title {
		font-size: 16px;
		font-weight: bold;
		margin-bottom: 15px;
		color: #303133;
		border-bottom: 1px solid #e4e7ed;
		padding-bottom: 10px;
	}
	.form-item {
		margin-bottom: 15px;
		display: flex;
		flex-direction: column;
	}
	.form-label {
		font-size: 14px;
		color: #606266;
		margin-bottom: 5px;
		font-weight: 500;
	}
	.red-tip {
		color: #f56c6c;
		margin-right: 2px;
	}
	.form-input {
		height: 40px;
		border: 1px solid #dcdfe6;
		border-radius: 4px;
		padding: 0 10px;
		font-size: 14px;
		color: #606266;
	}
	.picker-input {
		height: 40px;
		border: 1px solid #dcdfe6;
		border-radius: 4px;
		padding: 0 10px;
		font-size: 14px;
		color: #606266;
		display: flex;
		align-items: center;
		background-color: #fff;
	}
	.form-textarea {
		min-height: 80px;
		border: 1px solid #dcdfe6;
		border-radius: 4px;
		padding: 10px;
		font-size: 14px;
		color: #606266;
		resize: none;
	}
	.checkbox-group {
		display: flex;
		flex-wrap: wrap;
		gap: 10px;
	}
	.checkbox-item {
		display: flex;
		align-items: center;
		margin-bottom: 5px;
	}
	.checkbox-disabled {
		opacity: 0.6;
		cursor: not-allowed;
	}
	.upload-disabled {
		opacity: 0.6;
		cursor: not-allowed;
	}
	.radio-item {
		display: flex;
		align-items: center;
		margin-right: 20px;
	}
	/* 自定义radio样式 */
	.radio-container {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 20px;
	}
	.custom-radio {
		width: 20px;
		height: 20px;
		border-radius: 50%;
		border: 2px solid #ccc;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 8px;
		background-color: #fff;
		transition: all 0.3s ease;
		cursor: pointer;
	}
	.custom-radio.radio-checked {
		border-color: #409eff;
		background-color: #409eff;
		color: #fff;
	}
	.custom-radio.radio-disabled {
		border-color: #dcdfe6;
		background-color: #f5f7fa;
		cursor: not-allowed;
		opacity: 0.6;
	}
	.check-icon {
		color: #fff;
		font-size: 14px;
		font-weight: bold;
	}
	.family-list {
		margin-bottom: 15px;
	}
	.family-item {
		background-color: #f9f9f9;
		border-radius: 8px;
		padding: 15px;
		margin-bottom: 15px;
	}
	.item-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 15px;
		padding-bottom: 10px;
		border-bottom: 1px solid #e4e7ed;
	}
	.item-title {
		font-size: 14px;
		font-weight: bold;
		color: #303133;
	}
	.delete-btn {
		cursor: pointer;
	}
	.add-family-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		color: #409EFF;
		padding: 10px;
		border: 1px dashed #409EFF;
		border-radius: 4px;
		cursor: pointer;
		margin-bottom: 15px;
	}
	.income-display {
		height: 40px;
		border: 1px solid #dcdfe6;
		border-radius: 4px;
		padding: 0 10px;
		display: flex;
		align-items: center;
		background-color: #f5f7fa;
		font-size: 14px;
		color: #606266;
	}
	.promise-content {
							background-color: #f5f7fa;
							border-radius: 4px;
							padding: 15px;
							margin-bottom: 15px;
							font-size: 14px;
							color: #606266;
							line-height: 1.5;
						}
						
						.sign-img {
							margin-top: 10px;
							position: relative;
							margin-bottom: 15px;
						}
						
						.sign-img image {
							width: 200px;
							height: 100px;
							border: 1px solid #ddd;
							border-radius: 4px;
						}
						
						.re-sign-text {
							color: #409EFF;
							font-size: 12px;
							margin-left: 20rpx;
							text-decoration: underline;
						}
						
						.sign {
							margin-top: 10px;
							border: 1px dashed #ddd;
							padding: 40rpx;
							color: #999;
							text-align: center;
							border-radius: 4px;
							width: 200px;
						}
						
						.sign-disabled {
							opacity: 0.5;
							pointer-events: none;
						}
				.approval-content {
					background-color: #f5f7fa;
					border-radius: 4px;
					padding: 15px;
					margin-bottom: 10px;
					font-size: 14px;
					color: #606266;
					line-height: 1.5;
					min-height: 80px;
				}
				.no-content {
					color: #909399;
					font-style: italic;
				}
				.approval-info {
					display: flex;
					justify-content: space-between;
					font-size: 12px;
					color: #909399;
					padding: 0 5px;
				}

				.approval-section {
					margin-bottom: 20px;
					padding: 15px;
					background-color: #fafafa;
					border-radius: 8px;
					border: 1px solid #e8e8e8;
				}

				.section-title {
					font-size: 16px;
					font-weight: bold;
					color: #333;
					margin-bottom: 10px;
					padding-bottom: 5px;
					border-bottom: 2px solid #1989fa;
				}

				.approval-text {
					line-height: 1.8;
					color: #333;
				}

				.highlight {
					color: #e64340;
					font-weight: bold;
					margin: 0 4px;
				}

				.difficulty-level {
					color: #1989fa;
					font-weight: bold;
				}
	.upload-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 10rpx;
		width: 200px;
		height: 40px;
		border: 1px solid #dbeafe;
		border-radius: 8px;
		background-color: #f0f9ff;
		color: #409EFF;
		font-size: 14px;
		cursor: pointer;
		margin-bottom: 20px;
	}
	.upload-icon {
		font-size: 20px;
		font-weight: bold;
	}
	.file-list {
		margin-top: 15px;
	}
	.file-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10px;
		background-color: #f5f7fa;
		border-radius: 4px;
		margin-bottom: 10px;
	}
	.file-name {
		font-size: 14px;
		color: #606266;
		flex: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		margin-right: 10px;
	}
	.delete-file-btn {
		color: #f56c6c;
		cursor: pointer;
	}
	.submit-container {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		justify-content: space-around;
		padding: 10px;
		background-color: #fff;
		border-top: 1px solid #e4e7ed;
		z-index: 100;
	}
	.submit-btn {
		width: 45%;
		height: 40px;
		border-radius: 20px;
		font-size: 14px;
		border: none;
		background-color: #409EFF;
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 5px;
	}
	.submit-primary {
		background-color: #67c23a;
	}
	.popup-content {
		background-color: #fff;
		border-radius: 10px 10px 0 0;
		padding: 20px;
	}
	.popup-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20px;
	}
	.popup-title {
		font-size: 16px;
		font-weight: bold;
	}
	.close-btn {
		cursor: pointer;
	}
	.popup-body {
		display: flex;
		justify-content: space-around;
	}
	.upload-option {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 20px;
			cursor: pointer;
		}
	.checkbox-container {
		padding: 20rpx 0;
	}
	.checkbox-wrapper {
		display: flex;
		align-items: center;
	}
	.custom-checkbox {
		width: 40rpx;
		height: 40rpx;
		border: 2rpx solid #ccc;
		border-radius: 6rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
		margin-right: 15rpx;
	}
	.checkbox-checked {
		border-color: #007aff;
		background-color: #007aff;
	}
	.check-icon {
		color: #fff;
		font-size: 24rpx;
		line-height: 1;
	}
</style>