<template>
	<!-- 页面元信息，用于控制页面滚动（小程序和App） -->
	<page-meta :page-style="pageScrollDisabled ? 'overflow: hidden;' : ''"></page-meta>
	<view class="lx-container">
		<view class="form-card">
			<view class="form-content">
				<form @submit="handleFormSubmit">
					<!-- 活动 -->
					<view class="form-group" v-if="isactivity">
						<text class="form-label">开单活动</text>
						<view class="input-wrapper">
							<view class="custom-select" @tap="removeid?'':openSelectModal('activityId')">
								<text class="select-text">{{ formData.activityId || '请选择开单活动' }}</text>
								<text class="select-arrow">▼</text>
							</view>
						</view>
					</view>
					<!-- 开单会员 -->
					<view class="form-group">
						<text class="form-label">开单会员</text>
						<view class="input-wrapper">
							<view class="custom-select" @tap="removeid?'':iskh?openSelectModal('kdhy'):''">
								<text class="select-text">{{ formData.kdhy || '请选择开单会员' }}</text>
								<text class="select-arrow">▼</text>
							</view>
						</view>
					</view>

					<!-- 开单日期 - 只有新增开单时且为授权用户才显示 -->
					<view class="form-group"  v-if="canEditDate && !removeid">
						<text class="form-label">开单日期</text>
						<view class="input-wrapper">
							<picker :disabled="true" mode="date" :value="formData.kdrq" @change="onDateChange">
								<view class="custom-select">
									<text class="select-text">{{ formData.kdrq || '请选择开单日期' }}</text>
									<text class="select-arrow">▼</text>
								</view>
							</picker>
						</view>
					</view>

					<!-- 整单业绩 -->
					<view class="form-group">
						<text class="form-label">整单业绩</text>
						<view class="input-wrapper">
							<u-input v-model="formData.zdyj" placeholder="请输入整单业绩" type="digit"
								@input="calculateShifuYej" class="select-input" />
						</view>
					</view>

					<!-- 实付业绩 -->
					<view class="form-group">
						<text class="form-label">实付业绩</text>
						<view class="input-wrapper">
							<u-input v-model="formData.sfyj" placeholder="自动计算" type="digit" readonly
								class="select-input" />
						</view>
					</view>

					<!-- 品项明细 -->
					<view class="form-group">
						<text class="form-label">品项明细</text>
						<view class="px-container">
							<view v-for="(px, index) in pxList" :key="index" class="px-row">
								<!-- 第一行：品项选择和总价 -->
								<view class="px-row-first">
									<view class="px-select" @tap="selectPx(index)">
										<text class="select-text"
											style="width: 80%;flex: 0 0 80%;">{{ px.pxmc || '选择品项' }}</text>
										<text class="select-arrow">▼</text>
									</view>
									<u-input :disabled="px.pxmc && px.pxmc.includes('储值')" v-model="px.actualPrice"
										placeholder="总价" type="digit" class="px-amount"
										@input="updatePxActualPrice(index, $event)" />
									<button @click="deletePxRow(index)" class="px-delete">删除</button>
								</view>

								<!-- 第二行：数量、类型和单价 -->
								<view class="px-row-second">
									<u-input v-model="px.projectNumber" placeholder="数量" type="number" class="px-count"
										@input="updatePxProjectNumber(index, $event)" />
									<u-picker v-if="showSourceTypePicker && currentPxIndex === index"
										:show="showSourceTypePicker" :columns="[sourceTypeOptions]" :show-toolbar="true"
										:close-on-click-overlay="true" confirm-color="#43e97b" title="选择类型"
										@confirm="onSourceTypeConfirm" @close="closeSourceTypePicker"
										@cancel="closeSourceTypePicker" class="px-type-picker" />
									<view class="px-type-select" @tap="openSourceTypePicker(index)">
										<text class="select-text">{{ px.sourceType || '选择类型' }}</text>
										<text class="select-arrow">▼</text>
									</view>
									<view class="px-unit-price">
										<!-- <text class="price-label">单价：</text> -->
										<text class="price-value">¥{{ px.pxjg }}</text>
									</view>
								</view>

								<!-- 第三行：选择健康师按钮 -->
								<view class="px-row-third">
									<view class="px-jks-select" @tap="selectJksForPx(index)">
										<text>选择健康师</text>
									</view>
								</view>

								<!-- 第四行：已选择的健康师列表 -->
								<view class="px-row-fourth" v-if="px.lqKdJksyjList && px.lqKdJksyjList.length > 0">
									<view class="px-jks-list">
										<view v-for="(jks, jksIndex) in px.lqKdJksyjList" :key="jksIndex"
											class="px-staff-item">
											<text class="staff-name">{{ jks.jksxm }}</text>
											<u-input v-model="jks.jksyj" placeholder="业绩" type="digit"
												class="staff-amount"
												@input="updateJksAmount(index, jksIndex, $event)" />
											<text class="remove-btn" @tap="removeJksFromPx(index, jksIndex)">×</text>
										</view>
									</view>
								</view>

								<!-- 第五行：选择科技部老师按钮 -->
								<view class="px-row-fifth" v-if="px.qt2 === '科美' ||  (px.lqKdKjbsyjList && px.lqKdKjbsyjList.length > 0)">
									<view class="px-kjb-select" @tap="selectKjbForPx(index)">
										<text>选择科技部老师</text>
									</view>
								</view>

								<!-- 第六行：已选择的科技部老师列表 -->
								<view class="px-row-sixth" v-if="px.lqKdKjbsyjList && px.lqKdKjbsyjList.length > 0">
									<view class="px-kjb-list">
										<view v-for="(kjb, kjbIndex) in px.lqKdKjbsyjList" :key="kjbIndex"
											class="px-staff-item">
											<text class="staff-name">{{ kjb.kjblsxm }}</text>
											<u-input v-model="kjb.kjblsyj" placeholder="业绩" type="digit"
												class="staff-amount"
												@input="updateKjbAmount(index, kjbIndex, $event)" />
											<text class="remove-btn" @tap="removeKjbFromPx(index, kjbIndex)">×</text>
										</view>
									</view>
								</view>

								<!-- 第七行：备注 -->
								<view class="px-row-seventh">
									<view class="px-remark-wrapper">
										<text class="px-remark-label">备注：</text>
										<textarea v-model="px.remark" placeholder="请输入备注" :maxlength="200" :count="true"
											class="px-remark-input" />
									</view>
								</view>
							</view>
						</view>
						<button type="primary" size="normal" @click="addPxRow" class="btn-add-px">
							添加品项
						</button>
					</view>

					<!-- 欠款 -->
					<view class="form-group">
						<text class="form-label">欠款</text>
						<view class="input-wrapper">
							<u-input v-model="formData.qk" readonly placeholder="请输入欠款" type="number"
								class="select-input" />
						</view>
					</view>

					<!-- 是否储扣 -->
					<view class="form-group">
						<text class="form-label">是否储扣</text>
						<view class="input-wrapper">
							<u-picker v-if="showSfckPicker" :show="showSfckPicker" :columns="[sfckOptions]"
								:show-toolbar="true" :close-on-click-overlay="true" confirm-color="#43e97b"
								title="选择是否储扣" @confirm="onSfckConfirm" @close="closeSfckPicker"
								@cancel="closeSfckPicker" class="select-input" />
							<view class="custom-select" @tap="openSfckPicker">
								<text class="select-text">{{ formData.sfck || '请选择是否储扣' }}</text>
								<text class="select-arrow">▼</text>
							</view>
						</view>
					</view>

					<!-- 储扣明细 -->
					<view class="form-group" v-if="formData.sfck === '是'" id="ckfsGroup">
						<text class="form-label">储扣明细</text>
						<view class="deduct-container">
							<view v-for="(deduct, index) in deductList" :key="index" class="deduct-row">
								<view class="deduct-info" v-if="deduct.itemName">
									<view class="deduct-info-item">
										<text class="info-label">类型：</text>
										<text class="info-value">{{ deduct.deductType || '-' }}</text>
									</view>
									<view class="deduct-info-item" v-if="deduct.RemainingCount">
										<text class="info-label">剩余：</text>
										<text class="info-value">{{ deduct.RemainingCount }}</text>
									</view>
								</view>
								<!-- 第一行：品项选择和总价 -->
								<view class="deduct-row-first">
									<view class="deduct-select" @tap="selectDeductPx(index)">
										<text class="select-text"
											style="width: 80%;flex: 0 0 80%;">{{ deduct.itemName || '选择品项' }}</text>
										<text class="select-arrow">▼</text>
									</view>
									<u-input v-model="deduct.amount" placeholder="总价" type="number" readonly
										class="deduct-amount" />
									<button @click="deleteDeductRow(index)" class="deduct-delete">删除</button>
								</view>

								<!-- 第二行：数量和单价 -->
								<view class="deduct-row-second">
									<u-input :disabled="!deduct.RemainingCount?true:false" v-model="deduct.projectNumber" placeholder="数量" type="number"
										:max="deduct.RemainingCount" class="deduct-count"
										@input="updateDeductProjectNumber(index, $event)" />
									<view class="deduct-unit-price">
										<text class="price-value">¥{{ deduct.unitPrice }}</text>
									</view>
								</view>
							</view>
						</view>
						<button type="primary" size="normal" @click="addDeductRow" class="btn-add-deduct">
							添加储扣品项
						</button>
					</view>


					<!-- 付款方式 -->
					<view class="form-group">
						<text class="form-label">付款方式</text>
						<view class="input-wrapper">
							<u-picker v-if="showFkfsPicker" :show="showFkfsPicker" :columns="[fkfsOptions]"
								:show-toolbar="true" :close-on-click-overlay="true" confirm-color="#43e97b"
								title="选择付款方式" @confirm="onFkfsConfirm" @close="closeFkfsPicker"
								@cancel="closeFkfsPicker" class="select-input" />
							<view class="custom-select" @tap="openFkfsPicker">
								<text class="select-text">{{ formData.fkfs || '请选择付款方式' }}</text>
								<text class="select-arrow">▼</text>
							</view>
						</view>
					</view>

					<!-- 合作机构 -->
					<view class="form-group" v-if="formData.fkfs === '合作'" id="hgjgGroup">
						<text class="form-label">合作机构</text>
						<view class="input-wrapper">
							<view class="custom-select" @tap="openSelectModal('hgjg')">
								<text class="select-text">{{ formData.hgjg || '请选择合作机构' }}</text>
								<text class="select-arrow">▼</text>
							</view>
						</view>
					</view>

					<!-- 结算机构 -->
					<view class="form-group" v-else id="fkyyGroup">
						<text class="form-label">结算机构</text>
						<view class="input-wrapper">
							<view class="custom-select" @tap="openSelectModal('fkyy')">
								<text class="select-text">{{ formData.fkyy || '请选择结算机构' }}</text>
								<text class="select-arrow">▼</text>
							</view>
						</view>
					</view>
					<!-- 会员签字 -->
					<view class="form-group" v-if="!removeid">
						<text class="form-label">会员签字</text>
						<view class="input-wrapper">
							<view v-if="!memberSignature" class="signature-placeholder">
								<button @click="openSignatureModal" class="btn-signature-placeholder">
									<text class="signature-placeholder-text">点击进行签字</text>
								</button>
							</view>
							<view v-if="memberSignature" class="signature-preview">
								<text class="preview-label">签字预览：</text>
								<image @tap="previewSignature(memberSignature)" :src="memberSignature"
									class="signature-image" mode="aspectFit" />
								<view class="signature-actions">
									<button @click="openSignatureModal" class="btn-re-signature">重新签字</button>
									<button @click="clearMemberSignature" class="btn-clear-signature">清除签字</button>
								</view>
							</view>
						</view>
					</view>
					<view class="form-group" v-else-if="memberSignature&&removeid">
						<text class="form-label">会员签字</text>
						<view class="input-wrapper">
							<view class="signature-preview">
								<image @tap="previewSignature(baseUrl+memberSignature)" :src="baseUrl+memberSignature"
									class="signature-image" mode="aspectFit" />
							</view>
						</view>
					</view>
					<!-- 是否首开订单 -->
					<view class="form-group">
						<text class="form-label">是否首开订单</text>
						<view class="input-wrapper">
							<u-picker v-if="showSfskddPicker" :show="showSfskddPicker" :columns="[sfskddOptions]"
								:show-toolbar="true" :close-on-click-overlay="true" confirm-color="#43e97b"
								title="选择是否首开订单" @confirm="onSfskddConfirm" @close="closeSfskddPicker"
								@cancel="closeSfskddPicker" class="select-input" />
							<!--  @tap="openSfskddPicker" -->
							<view class="custom-select">
								<text class="select-text">{{ formData.sfskdd || '请选择是否首开订单' }}</text>
								<text class="select-arrow">▼</text>
							</view>
						</view>
					</view>

					<!-- 简介 -->
					<view class="form-group">
						<text class="form-label">简介</text>
						<view class="input-wrapper">
							<textarea v-model="formData.jj" placeholder="请输入简介" :maxlength="500" :count="true"
								class="textarea-input" />
						</view>
					</view>

					<!-- 上传收据文件 -->
					<view class="form-group">
						<text class="form-label">上传收据文件</text>
						<view class="input-wrapper">
							<view class="file-upload-area" @tap.stop="chooseFile('receipt')">
								<view class="file-upload-text">
									<text class="file-upload-icon">📁</text>
									<text>点击选择文件</text>
								</view>
								<view class="file-list">
									<view v-for="(file, index) in scwj" :key="file.id || index" class="file-item">
										<view class="file-info">
											<text class="file-icon">{{ getFileIcon(file.type) }}</text>
											<text class="file-name">{{ file.name }}</text>
											<!-- <text class="file-size">{{ formatFileSize(file.size) }}</text> -->
										</view>
										<view class="file-actions" v-if="file.status">
											<view v-if="file.status === 'uploading'"
												class="file-status uploading">上传中...</view>
											<view v-else-if="file.status === 'success'" class="file-status success">✓
												已上传</view>
											<view v-else-if="file.status === 'error'" class="file-status error">✗
												上传失败</view>
											<button v-if="file.status === 'success'" class="btn-error"
												@click.stop="removeFile('receipt', index)">
												删除
											</button>
										</view>
										<view class="file-actions" v-else>
											<view  class="file-status success">✓
												已上传</view>
											<button class="btn-error"
												@click.stop="removeFile('receipt', index)">
												删除
											</button>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>

					<!-- 上传方案其他文件 -->
					<view class="form-group">
						<text class="form-label">上传方案其他文件</text>
						<view class="input-wrapper">
							<view class="file-upload-area" @tap.stop="chooseFile('other')">
								<view class="file-upload-text">
									<text class="file-upload-icon">📁</text>
									<text>点击选择文件</text>
								</view>
								<view class="file-list">
									<view v-for="(file, index) in f_FileUrl" :key="file.id || index" class="file-item">
										<view class="file-info">
											<text class="file-icon">{{ getFileIcon(file.type) }}</text>
											<text class="file-name">{{ file.name }}</text>
											<!-- <text class="file-size">{{ formatFileSize(file.size) }}</text> -->
										</view>
										<view class="file-actions">
											<view v-if="file.status === 'uploading'"
												class="file-status uploading">上传中...</view>
											<view v-else-if="file.status === 'success'" class="file-status success">✓
												已上传</view>
											<view v-else-if="file.status === 'error'" class="file-status error">✗
												上传失败</view>
											<button v-if="file.status === 'success'" class="btn-error"
												@click.stop="removeFile('other', index)">
												删除
											</button>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>

					<!-- 备注 -->
					<view class="form-group">
						<text class="form-label">备注</text>
						<view class="input-wrapper">
							<textarea v-model="formData.bz" placeholder="请输入备注" :maxlength="500" :count="true"
								class="textarea-input" />
						</view>
					</view>



					<!-- <u-button type="primary" size="normal" @click="submitOrder" class="submit-btn">
						开单
					</u-button> -->
					<view class="btn-group">
						<button type="submit" class="btn btn-primary" :style="{opacity: issubmitOrder?1:0.5}" @tap="issubmitOrder?submitOrder():null">{{ issubmitOrder?'开单':'提交中...' }}</button>
					</view>
				</form>
			</view>
		</view>

		<!-- 选择弹窗 -->
		<SearchSelectModal :show="showModal" :title="modalTitle" :options="currentOptions" :loading="modalLoading"
			:has-more="hasMoreData" :search-param="searchParam" 
			:show-cross-store="currentSelectField === 'kdhy'"
			:is-cross-store="isCrossStore"
			@confirm="handleModalConfirm" @close="closeModal"
			@load-more="handleLoadMore" @refresh="handleRefresh" @search="handleSearch"
			@cross-store-change="onCrossStoreChange" />

		<!-- 全屏签字弹窗 -->
		<view v-if="showSignatureModal" class="signature-modal-overlay" @tap="closeSignatureModal">
			<view class="signature-modal" @tap.stop>
				<view class="signature-modal-header">
					<text class="signature-modal-title"></text>
					<button @click="closeSignatureModal" class="btn-close-modal">×</button>
				</view>
				<view class="signature-modal-content">
					<SignaturePad :width="800" :height="500" :line-width="4"
						stroke-color="#2e7d32" 
						:px-info="signaturePxInfo" signature-type="order"
						@confirm="handleSignatureConfirm" @clear="handleSignatureClear"
						ref="signaturePadModal" />
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import SearchSelectModal from '@/components/SearchSelectModal.vue'
	import SignaturePad from '@/components/SignaturePad.vue'
	import memberApi from '@/apis/modules/member.js'
	import lxApi from '@/apis/modules/lx.js'
	import projectApi from '@/apis/modules/project.js'
	import appointmentApi from '@/apis/modules/appointment.js'
	import config from '@/common/config.js'
	export default {
		components: {
			SearchSelectModal,
			SignaturePad
		},
		data() {
			return {
				iskh:true,
				issubmitOrder:true,
				baseUrl: config.getImgBaseUrl(),
				// 表单数据
				formData: {
					kdhy: '',
					gjlx: '',
					kdhysjh: '',
					kdhyc: '',
					kdrq: '', // 开单日期
					zdyj: '',
					sfyj: '',
					qk: '',
					sfck: '否',
					ckfs: '',
					ckmx: '',
					fkfs: '',
					hgjg: '',
					fkyy: '',
					sfskdd: '',
					jj: '',
					bz: ''
				},

				// 品项列表
				pxList: [],

				// 储扣明细列表
				deductList: [],

				// 文件列表
				scwj: [],
				f_FileUrl: [],

				// 会员签字
				memberSignature: '',
				showSignatureModal: false,
				scrollTop: 0,
				signaturePxInfo: null, // 签字时显示的品项信息

				// 弹窗相关
				showModal: false,
				modalTitle: '',
				currentSelectField: '',
				currentOptions: [],
				modalLoading: false,
				hasMoreData: true,
				currentPage: 1,
				pageSize: 20,
				searchKeyword: '',
				searchParam: '',

				// 用户信息
				userInfo: null,

				// 跨店相关
				isCrossStore: false,

				// 选中的值
				selectedValues: {
					kdhy: null,
					hgjg: null,
					fkyy: null
				},

				// 选择器选项
				sfckOptions: [{
						text: '是',
						value: '是'
					},
					{
						text: '否',
						value: '否'
					}
				],
				ckfsOptions: [{
						text: '储值卡',
						value: '储值卡'
					},
					{
						text: '扣项',
						value: '扣项'
					},
					{
						text: '套餐',
						value: '套餐'
					}
				],
				fkfsOptions: [{
						text: '现金',
						value: '现金'
					},
					{
						text: '微信',
						value: '微信'
					},
					{
						text: '支付宝',
						value: '支付宝'
					},
					{
						text: '银行卡',
						value: '银行卡'
					},
					{
						text: '合作',
						value: '合作'
					},
					// {
					// 	text: '医院',
					// 	value: '医院'
					// },
					{
						text: '直播收款',
						value: '直播收款'
					},
				],
				sfskddOptions: [{
						text: '是',
						value: '是'
					},
					{
						text: '否',
						value: '否'
					}
				],
				memberSourceOptions: [{
						text: '嘉宾',
						value: '嘉宾'
					},
					{
						text: '自然到店',
						value: '自然到店'
					}
				],
				sourceTypeOptions: [{
						text: '购买',
						value: '购买'
					},
					{
						text: '体验',
						value: '体验'
					},
					{
						text: '赠送',
						value: '赠送'
					}
				],

				// 选择器显示状态
				showSfckPicker: false,
				showCkfsPicker: false,
				showFkfsPicker: false,
				showSfskddPicker: false,
				showSourceTypePicker: false,

				// 当前操作的品项索引
				currentPxIndex: -1,

				// 当前操作的储扣明细索引
				currentDeductIndex: -1,
				removeinfo: {},
				removeid: '',
				supplementBillingId: '',
				kdhy:'',
				qk:0,
				isactivity:false,
				// 页面滚动禁止状态（用于小程序和App）
				pageScrollDisabled: false,
				// 滚动位置（用于H5）
				scrollTop: 0
			}
		},
		computed: {
			// 检查当前用户是否可以修改开单日期
			canEditDate() {
				// && this.userInfo.userId === '18628973287';
				return this.userInfo 
			},
		},
		onLoad(options) {
			this.initializePage(options);
		},

		onUnload() {
			// 页面卸载时恢复页面滚动
			this.enablePageScroll();
		},
		methods: {
			// 处理日期变化
			onDateChange(e) {
				this.formData.kdrq = e.detail.value;
			},
			
			// 跨店开关变化
			onCrossStoreChange(value) {
				this.isCrossStore = value;
				// 如果弹窗已打开且正在选择会员，重新加载数据
				if (this.showModal && this.currentSelectField === 'kdhy') {
					this.currentPage = 1;
					this.hasMoreData = true;
					this.loadOptionsData('kdhy', 1, this.searchKeyword);
				}
			},
			
			async newUploadBase64Image() {
				let info = null;
				await lxApi.UploadBase64Image({
					"base64Data": this.memberSignature,
					"imageType": "png",
					"fileName": "memberSignature.png"
				}).then(res => {
					console.log('UploadBase64Image', res);
					if (res.code == 200) {
						info = res.data;
					}
				})
				return info
			},
			previewSignature(e) {
				console.log('previewSignature', e);
				uni.previewImage({
					urls: [e]
				});
			},
			// 初始化页面
			async initializePage(options) {
				try {
					// 获取用户信息
					this.userInfo = uni.getStorageSync('userInfo');
					if (!this.userInfo || Object.keys(this.userInfo).length === 0) {
						uni.showToast({
							title: '请先登录',
							icon: 'none'
						});
						setTimeout(() => {
							uni.reLaunch({
								url: '/pages/login/login'
							});
						}, 1500);
						return;
					}
					if (options.type) {
						this.isactivity =true
					}
					if (options.id) {
						this.removeid = options.id;
						this.API.getLxDetail(options.id).then(res => {
							console.log({
								...res.data
							})
							this.removeinfo = res.data;
							this.formData.kdhy = res.data.kdhyc;
							this.selectedValues.kdhy = res.data.kdhy;
							this.formData.zdyj = res.data.zdyj;
							this.formData.sfyj = res.data.sfyj;
							this.formData.qk = res.data.qk;

							this.formData.fkfs = res.data.fkfs;
							this.formData.hgjg = res.data.hgjg;
							this.formData.fkyy = res.data.fkyy;
							this.formData.sfskdd = res.data.sfskdd;
							this.formData.jj = res.data.jj;
							this.formData.bz = res.data.bz;
							// this.pxList = res.data.lqKdPxmxList;
							this.getpxqtlist(res.data.lqKdPxmxList)
							this.deductList = res.data.lqKdDeductList
							this.formData.sfck = this.deductList.length>0?'是':'否'
							this.scwj = res.data.scwj;
							this.f_FileUrl = res.data.fileUrl ? JSON.parse(res.data.fileUrl) : [];
							this.memberSignature = res.data.hyqz && res.data.hyqz.length > 0 ? res.data.hyqz[0].url : '';
							if(res.data.activityId){
								this.isactivity =true
								this.selectedValues.activityId = res.data.activityId;
								this.formData.activityId = res.data.activityName;
							}
						});
					}else if(options.supplementBillingId){
						this.supplementBillingId = options.supplementBillingId;
						this.kdhy = options.kdhy
						this.qk =  options.qk || 0
						// 设置默认日期为当前日期
						this.formData.kdrq = this.utils.gettime().substring(0, 10);
						// 添加默认的品项行
						this.addPxRow();
					}else if(options.appointmentId){
						this.iskh = false
						this.appointmentId = options.appointmentId;
						const response = await this.API.getMemberDetail(options.gk);
						if(response.code === 200 && response.data){
							this.formData.kdhy = response.data.khmc;
							this.selectedValues.kdhy = response.data.id;
							this.formData.kdhysjh = response.data.sjh;
							this.formData.gjlx = response.data.khlx;
							this.formData.kdhyc = response.data.khmc;
						}
						// 设置默认日期为当前日期
						this.formData.kdrq = this.utils.gettime().substring(0, 10);
						// 添加默认的品项行
						this.addPxRow();
					} else {
						// 设置默认日期为当前日期
						this.formData.kdrq = this.utils.gettime().substring(0, 10);
						// 添加默认的品项行
						this.addPxRow();
					}
					if(options.time){
						this.formData.kdrq = options.time
					}
				} catch (error) {
					console.error('页面初始化失败:', error);
					uni.showToast({
						title: '页面初始化失败',
						icon: 'none'
					});
				}
			},
			async getpxqtlist(list){
				for(let i = 0; i < list.length; i++){
					let px = list[i].px;
					const detailResult = await lxApi.getPxDetail(px);
					list[i].qt2 = detailResult.data.qt2 || "";
					
				}
				this.pxList = list;
				console.log(this.pxList);
				this.$forceUpdate();
			},
			// 计算实付业绩
			calculateShifuYej() {
				// 计算所有品项的总价
				let totalPxPrice = 0;
				this.pxList.forEach(px => {
					const actualPrice = parseFloat(px.actualPrice) || 0;
					totalPxPrice += actualPrice;
				});

				// 计算所有储扣明细的总价
				let totalDeductAmount = 0;
				if (this.deductList && this.deductList.length > 0) {
					this.deductList.forEach(deduct => {
						if (deduct.itemName) {
							const amount = parseFloat(deduct.amount) || 0;
							totalDeductAmount += amount;
						}
					});
				}

				// 实付业绩 = 品项总价 - 储扣明细总价
				this.formData.sfyj = (totalPxPrice - totalDeductAmount).toFixed(2);
				this.calculateQiankuan();
			},

			// 计算欠款
			calculateQiankuan() {
				const zdyj = parseFloat(this.formData.zdyj) || 0;
				const sfyj = parseFloat(this.formData.sfyj) || 0;

				// 计算所有储扣明细的总价
				let totalDeductAmount = 0;
				if (this.deductList && this.deductList.length > 0) {
					this.deductList.forEach(deduct => {
						if (deduct.itemName) {
							const amount = parseFloat(deduct.amount) || 0;
							totalDeductAmount += amount;
						}
					});
				}
				console.error(zdyj ,sfyj ,totalDeductAmount)
				// 欠款 = 整单业绩 - 实付业绩 - 储扣明细总计
				this.formData.qk = (zdyj - sfyj - totalDeductAmount).toFixed(2);
			},

			// 添加品项行
			addPxRow() {
				this.pxList.push({
					px: '', // 品项id
					pxmc: '', // 品项名称
					pxjg: 0, // 单价通过总价除以数量自动计算
					actualPrice: null, // 总价
					projectNumber: 1, // 数量
					sourceType: '购买', // 类型选择（购买，体验，赠送）
					qt2: '', // 品项类型
					remark: '', // 备注
					lqKdJksyjList: [], // 健康师业绩列表
					lqKdKjbsyjList: [] // 科技部业绩列表
				});
				// 重新计算实付业绩
				this.calculateShifuYej();
			},

			// 删除品项行
			deletePxRow(index) {
				if (this.pxList.length > 1) {
					this.pxList.splice(index, 1);
					// 重新计算实付业绩
					this.calculateShifuYej();
				} else {
					uni.showToast({
						title: '至少需要保留一个品项',
						icon: 'none'
					});
				}
			},

			// 选择品项
			selectPx(index) {
				this.currentPxIndex = index;
				this.openSelectModal('px');
			},

			// 更新品项总价
			updatePxActualPrice(index, value) {
				this.pxList[index].actualPrice = parseFloat(value) || 0;

				// 检查是否为储值品项
				if (this.pxList[index].pxmc && this.pxList[index].pxmc.includes('储值')) {
					// 储值品项：单价固定为1，不重新计算单价
					// 只重新计算实付业绩
					this.calculateShifuYej();
				} else {
					// 普通品项：自动计算单价
					this.calculatePxUnitPrice(index);
					// 重新计算实付业绩
					this.calculateShifuYej();
				}
			},

			// 更新品项数量
			updatePxProjectNumber(index, value) {
				const count = parseInt(value) || 1;
				this.pxList[index].projectNumber = count < 1 ? 1 : count;

				// 检查是否为储值品项
				if (this.pxList[index].pxmc && this.pxList[index].pxmc.includes('储值')) {
					// 储值品项：根据数量自动计算总价
					this.calculatePxTotalPrice(index);
				} else {
					// 普通品项：自动计算单价
					this.calculatePxUnitPrice(index);
				}

				// 重新计算实付业绩
				this.calculateShifuYej();
			},

			// 计算品项单价（总价除以数量）
			calculatePxUnitPrice(index) {
				const actualPrice = parseFloat(this.pxList[index].actualPrice) || 0;
				const projectNumber = parseInt(this.pxList[index].projectNumber) || 1;
				this.pxList[index].pxjg = projectNumber > 0 ? (actualPrice / projectNumber).toFixed(2) : 0;
			},

			// 计算品项总价（单价乘以数量）
			calculatePxTotalPrice(index) {
				const pxjg = parseFloat(this.pxList[index].pxjg) || 0;
				const projectNumber = parseInt(this.pxList[index].projectNumber) || 1;
				this.pxList[index].actualPrice = (pxjg * projectNumber).toFixed(2);
			},

			// 选择健康师
			selectJksForPx(index) {
				this.currentPxIndex = index;
				this.openSelectModal('jks');
			},

			// 选择科技部人员
			selectKjbForPx(index) {
				this.currentPxIndex = index;
				this.openSelectModal('kjb');
			},

			// 更新健康师业绩
			updateJksAmount(pxIndex, jksIndex, value) {
				this.pxList[pxIndex].lqKdJksyjList[jksIndex].jksyj = value;
			},

			// 更新科技部人员业绩
			updateKjbAmount(pxIndex, kjbIndex, value) {
				this.pxList[pxIndex].lqKdKjbsyjList[kjbIndex].kjblsyj = value;
			},

			// 从品项中移除健康师
			removeJksFromPx(pxIndex, jksIndex) {
				this.pxList[pxIndex].lqKdJksyjList.splice(jksIndex, 1);
			},

			// 从品项中移除科技部人员
			removeKjbFromPx(pxIndex, kjbIndex) {
				this.pxList[pxIndex].lqKdKjbsyjList.splice(kjbIndex, 1);
			},

			// 储扣明细相关方法
			// 添加储扣明细行
			addDeductRow() {
				this.deductList.push({
					deductType: '品项',
					deductId: '',
					billingId: '',
					amount: 0,
					unitPrice: 0,
					itemName: '',
					itemId: '',
					projectNumber: 1
				});
			},

			// 删除储扣明细行
			deleteDeductRow(index) {
				this.deductList.splice(index, 1);
				// 重新计算实付业绩
				this.calculateShifuYej();
			},

			// 选择储扣品项
			selectDeductPx(index) {
				this.currentDeductIndex = index;
				this.openSelectModal('deductPx');
			},

			// 更新储扣品项数量
			updateDeductProjectNumber(index, value) {
				const count = parseInt(value) || 1;
				this.deductList[index].projectNumber = count < 1 ? 1 : count;
				// 自动计算总价
				this.calculateDeductAmount(index);
			},

			// 计算储扣品项总价
			calculateDeductAmount(index) {
				const unitPrice = parseFloat(this.deductList[index].unitPrice) || 0;
				const projectNumber = parseInt(this.deductList[index].projectNumber) || 1;
				this.deductList[index].amount = (unitPrice * projectNumber).toFixed(2);
				// 重新计算实付业绩
				this.calculateShifuYej();
			},

			// 获取金三角信息
			async getJsjInfo(userId, pxIndex, jksIndex) {
				// const date = new Date();
				// const formattedDate = this.formatDate(date, 'yyyy-MM-dd HH:mm:ss');
				
				const formattedDate = this.formData.kdrq
				console.error(formattedDate)
				try {
					const result = await memberApi.getJsjInfo(userId, formattedDate);
					if (result.code === 200 && result.data) {
						console.log('金三角信息:', result.data);
						// 更新健康师的金三角信息
						this.pxList[pxIndex].lqKdJksyjList[jksIndex].jsj_id = result.data.jsjId;
						// 保存金三角名称
						this.pxList[pxIndex].lqKdJksyjList[jksIndex].jsjName = result.data.jsjName;
					}
				} catch (error) {
					console.error('获取金三角信息失败:', error);
				}
			},
			// 格式化日期方法
			formatDate(date, format) {
				if (!date) return '';
				const d = new Date(date);
				const year = d.getFullYear();
				const month = String(d.getMonth() + 1).padStart(2, '0');
				const day = String(d.getDate()).padStart(2, '0');
				const hours = String(d.getHours()).padStart(2, '0');
				const minutes = String(d.getMinutes()).padStart(2, '0');
				const seconds = String(d.getSeconds()).padStart(2, '0');

				return format
					.replace('yyyy', year)
					.replace('MM', month)
					.replace('dd', day)
					.replace('HH', hours)
					.replace('mm', minutes)
					.replace('ss', seconds);
			},

			// 获取会员订单类型（是否首开订单）
			async getMemberOrderType(memberId) {
				try {
					const result = await memberApi.getMemberOrderType(memberId);
					if (result.code === 200) {
						if (result.data.HasOrderRecord) {
							this.formData.sfskdd = '否';
						} else {
							this.formData.sfskdd = '是';
						}
					}
				} catch (error) {
					console.error('获取会员订单类型失败:', error);
				}
			},

			// 提取金三角名称
			extractJsjNames() {
				const allJksNames = [];
				this.pxList.forEach(px => {
					if (px.lqKdJksyjList && px.lqKdJksyjList.length > 0) {
						px.lqKdJksyjList.forEach(jks => {
							if (jks.jsjName && jks.jsjName.trim() !== '') {
								allJksNames.push(jks.jsjName);
							}
						});
					}
				});
				const uniqueNames = [...new Set(allJksNames)];
				return uniqueNames.length > 0 ? uniqueNames.join(',') : '暂无';
			},

			// 打开选择弹窗
			async openSelectModal(fieldId) {
				this.currentSelectField = fieldId;
				this.showModal = true;
				this.modalTitle = '加载中...';
				this.modalLoading = true;
				this.currentPage = 1;
				this.hasMoreData = true;
				this.searchKeyword = '';
				this.currentOptions = [];

				try {
					// 设置搜索参数
					switch (fieldId) {
						case 'kdhy':
							this.searchParam = 'khmc';
							this.modalTitle = '选择开单会员';
							break;
						case 'hgjg':
						case 'fkyy':
							this.searchParam = 'name';
							this.modalTitle = fieldId === 'hgjg' ? '选择合作机构' : '选择结算机构';
							break;
						case 'px':
							this.searchParam = 'pxmc';
							this.modalTitle = '选择品项';
							break;
						case 'deductPx':
							this.searchParam = 'itemName';
							this.modalTitle = '选择储扣品项';
							break;
						case 'jks':
							this.searchParam = 'jksxm';
							this.modalTitle = '选择健康师';
							break;
						case 'kjb':
							this.searchParam = 'kjblsxm';
							this.modalTitle = '选择科技部人员';
							break;
						case 'activityId':
							this.searchParam = 'activityName';
							this.modalTitle = '选择开单活动';
							break;
					}

					await this.loadOptionsData(fieldId, 1);
				} catch (error) {
					console.error('获取选项数据失败:', error);
					this.modalTitle = '加载失败';
					this.currentOptions = [];
					uni.showToast({
						title: '数据加载失败，请检查网络连接',
						icon: 'none'
					});
				} finally {
					this.modalLoading = false;
				}
			},

			// 关闭弹窗
			closeModal() {
				this.showModal = false;
				this.currentSelectField = '';
				this.currentOptions = [];
				this.modalLoading = false;
				this.hasMoreData = true;
				this.currentPage = 1;
				this.searchKeyword = '';
			},

			// 加载选项数据
			async loadOptionsData(fieldId, page = 1, searchKeyword = '') {
				let options = [];

				switch (fieldId) {
					case 'kdhy':
						options = await this.getMemberOptions(page, searchKeyword);
						break;
					case 'hgjg':
					case 'fkyy':
						options = await this.getHgjgOptions(page, searchKeyword);
						break;
					case 'px':
						if(this.isactivity){
							this.hasMoreData = false;
							options = await this.getActivityItemOptions();
						}else{
							options = await this.getPxOptions(page, searchKeyword);
						}
						break;
					case 'deductPx':
						this.hasMoreData = false;
						options = await this.getDeductPxOptions(page, searchKeyword);
						break;
					case 'jks':
						options = await this.getJksOptions(page, searchKeyword);
						break;
					case 'kjb':
						options = await this.getKjbOptions(page, searchKeyword);
						break;
					case 'activityId':
						this.hasMoreData = false;
						options = await this.getActivityOptions(page, searchKeyword);
						break;
				}

				// 为每个选项添加全局唯一的 key
				options = options.map((option, index) => ({
					...option,
					uniqueKey: `${fieldId}_${page}_${index}_${Date.now()}`
				}));

				if (page === 1) {
					this.currentOptions = options;
				} else {
					this.currentOptions = [...this.currentOptions, ...options];
				}

				// 检查是否还有更多数据
				if (options.length < this.pageSize) {
					this.hasMoreData = false;
				}
			},

			// 处理弹窗确认
			async handleModalConfirm(selectedOption) {
				if (this.currentSelectField && selectedOption) {
					console.log('selectedOption', selectedOption);
					switch (this.currentSelectField) {
						case 'kdhy':
							if(this.supplementBillingId && this.kdhy != selectedOption.value){
								uni.showToast({
									title: '不能选择不同的会员',
									icon: 'none'
								});
								return;
							}
							this.formData.kdhy = selectedOption.label;
							this.formData.gjlx = selectedOption.khlx;
							this.formData.kdhysjh = selectedOption.sjh;
							this.formData.kdhyc = selectedOption.label;
							this.selectedValues.kdhy = selectedOption.value;
							// 自动获取会员订单类型
							this.getMemberOrderType(selectedOption.value);
							break;
						case 'hgjg':
							this.formData.hgjg = selectedOption.label;
							this.selectedValues.hgjg = selectedOption.value;
							break;
						case 'fkyy':
							this.formData.fkyy = selectedOption.label;
							this.selectedValues.fkyy = selectedOption.value;
							break;
						case 'px':

							if (this.currentPxIndex >= 0) {
								this.pxList[this.currentPxIndex].px = selectedOption.value;
								this.pxList[this.currentPxIndex].pxmc = selectedOption.label;
								this.pxList[this.currentPxIndex].qt2 = selectedOption.qt2;
								this.pxList[this.currentPxIndex].remark = selectedOption.remark;
								// 清空健康师和科技部老师列表
								this.pxList[this.currentPxIndex].lqKdJksyjList = [];
								this.pxList[this.currentPxIndex].lqKdKjbsyjList = [];

								// 检查是否为储值品项
								if (selectedOption.label && selectedOption.label.includes('储值')) {
									// 储值品项：单价默认为1，总价根据数量自动计算
									this.pxList[this.currentPxIndex].pxjg = 1;
									this.calculatePxTotalPrice(this.currentPxIndex);
								} else {
									// 普通品项：使用API返回的单价
									this.pxList[this.currentPxIndex].pxjg = selectedOption.pxjg || 0;
									// 自动计算总价
									this.calculatePxTotalPrice(this.currentPxIndex);
								}

								// 重新计算实付业绩
								this.calculateShifuYej();
							}
							break;
						case 'jks':
							if (this.currentPxIndex >= 0) {
								// 先添加健康师到列表
								const jksIndex = this.pxList[this.currentPxIndex].lqKdJksyjList.length;
								this.pxList[this.currentPxIndex].lqKdJksyjList.push({
									jks: selectedOption.label,
									jksxm: selectedOption.label,
									jkszh: selectedOption.value,
									jksyj: "",
									jsj_id: "",
									jsjName: ""
								});
								// 获取金三角信息
								this.getJsjInfo(selectedOption.value, this.currentPxIndex, jksIndex);
							}
							break;
						case 'kjb':
							if (this.currentPxIndex >= 0) {
								this.pxList[this.currentPxIndex].lqKdKjbsyjList.push({
									kjbls: selectedOption.value,
									kjblsxm: selectedOption.label,
									kjblszh: "",
									kjblsyj: ""
								});
							}
							break;
					case 'deductPx':
						if (this.currentDeductIndex >= 0) {
							console.log('selectedOption', selectedOption);
							// 先校验已经选择的品项有没有这个
							const existingIndex = this.deductList.findIndex((item, index) => 
								index !== this.currentDeductIndex && item.deductId === selectedOption.BillingItemId
							);
							if (existingIndex !== -1) {
								uni.showToast({
									title: '该品项已存在，请勿重复添加',
									icon: 'none',
									duration: 2000
								});
								this.closeModal();
								return;
							}
						
							const detailResult = await lxApi.getPxDetail(selectedOption.px);
								let deductType = '品项'; // 默认品项
								if (detailResult.code === 200 && detailResult.data) {
									let ondetailResult = detailResult.data
									// if(ondetailResult.fl === '套餐') {
									// 	deductType = '套餐';
									// } else{
									// 	if(ondetailResult.qt1 == '储值') {
									// 		deductType = '储值卡';
									// 	}
									// }
									if (ondetailResult.qt1 == '储值') {
										deductType = '储值卡';
									}
								}

								this.deductList[this.currentDeductIndex].RemainingCount = selectedOption
								.RemainingCount;
								this.deductList[this.currentDeductIndex].deductType = deductType;
								this.deductList[this.currentDeductIndex].itemId = selectedOption.px;
								this.deductList[this.currentDeductIndex].itemName = selectedOption.label;
								this.deductList[this.currentDeductIndex].unitPrice = selectedOption.pxjg || 0;
								this.deductList[this.currentDeductIndex].deductId = selectedOption.BillingItemId || '';
								// 自动计算总价
								this.calculateDeductAmount(this.currentDeductIndex);
							}
							break;
						case 'activityId':
							this.formData.activityId = selectedOption.label;
							this.selectedValues.activityId = selectedOption.value;
							break;
					}
				}
			},

			// 处理加载更多
			async handleLoadMore(page) {
				if (this.currentSelectField && this.hasMoreData && !this.modalLoading) {
					this.modalLoading = true;
					try {
						await this.loadOptionsData(this.currentSelectField, page, this.searchKeyword);
					} catch (error) {
						console.error('加载更多数据失败:', error);
						uni.showToast({
							title: '加载失败',
							icon: 'none'
						});
					} finally {
						this.modalLoading = false;
					}
				}
			},

			// 处理刷新
			async handleRefresh() {
				if (this.currentSelectField) {
					this.currentPage = 1;
					this.hasMoreData = true;
					this.searchKeyword = '';
					await this.loadOptionsData(this.currentSelectField, 1);
				}
			},

			// 处理搜索
			async handleSearch(searchKeyword) {
				if (this.currentSelectField) {
					this.searchKeyword = searchKeyword;
					this.currentPage = 1;
					this.hasMoreData = true;
					this.modalLoading = true;

					try {
						await this.loadOptionsData(this.currentSelectField, 1, searchKeyword);
					} catch (error) {
						console.error('搜索失败:', error);
						uni.showToast({
							title: '搜索失败',
							icon: 'none'
						});
					} finally {
						this.modalLoading = false;
					}
				}
			},

			// 获取会员选项
			async getMemberOptions(page = 1, searchKeyword = '') {
				try {
					const params = {
						currentPage: page,
						pageSize: this.pageSize
					};

					if (searchKeyword) {
						params.keyword = searchKeyword;
					}

					// 添加跨店参数
					if (!this.isCrossStore) {
						if(this.userInfo && this.userInfo.mdid) {
							params.gsmd = this.userInfo.mdid;
						} else{
							params.gsmd = '暂无';
						}
					}

					const result = await memberApi.getMemberList(params);
					if (result.code === 200 && result.data) {
						return result.data.list.map((item, index) => ({
							value: item.id,
							label: item.khmc,
							sjh: item.sjh,
							khlxName: item.khlxName,
							khlx: item.khlx,
							subtitle: '客户类型：' + (item.khlxName || '无') + '；手机号：' + (item.sjh || '无') +
								'；健康师：' + (item.mrsName || '无') + '；门店：' + (item.gsmdName || '无') + '；',
						}));
					}
					return [];
				} catch (error) {
					console.error('获取会员列表出错:', error);
					return [];
				}
			},

			// 获取合作机构选项
			async getHgjgOptions(page = 1, searchKeyword = '') {
				try {
					const params = {
						page: page,
						pageSize: 20,
						fullName: searchKeyword
					};
					const result = await lxApi.getHgjgList(params);
					if (result.code === 200 && result.data) {
						return result.data.map(item => ({
							value: item.id,
							label: item.fullName,
						}));
					}
					return [];
				} catch (error) {
					console.error('获取合作机构列表出错:', error);
					return [];
				}
			},
			// 获取活动项目选项
			async getActivityItemOptions() {
				try {
					if(!this.selectedValues.activityId){
						uni.showToast({
							title: '请先选择活动',
							icon: 'none'
						});
						return [];
					}
					const result = await lxApi.GetPackageItemDetailByActivityIdAsync(this.selectedValues.activityId);
					if (result.code === 200 && result.data) {
						return result.data.list.map((item, index) => ({
							value: item.id,
							label: item.xmmc,
							px: item.id,
							pxmc: item.xmmc,
							pxjg: item.pxjg || 0, // 品项价格
							qt2: item.qt2,
							// 可以根据需要添加更多字段
							description: item.description || '',
							status: item.status || 1
						}));
					}
					return [];
				} catch (error) {
					console.error('获取活动项目列表出错:', error);
					return [];
				}
			},
			// 获取品项选项
			async getPxOptions(page = 1, searchKeyword = '') {
				try {
					const params = {
						currentPage: page,
						pageSize: this.pageSize,
						isEffective:1
					};

					if (searchKeyword) {
						params.xmmc = searchKeyword;
					}

					const result = await projectApi.getProjectOptions(params);
					return result;
				} catch (error) {
					console.error('获取品项列表出错:', error);
					return [];
				}
			},

			// 获取健康师选项
			async getJksOptions(page = 1, searchKeyword = '') {
				try {
					const params = {
						currentPage: page,
						pageSize: this.pageSize,
						gw: '健康师',
						mdid: this.userInfo.mdid
					};

					if (searchKeyword) {
						params.jksxm = searchKeyword;
					}

					const result = await appointmentApi.getHealthWorkerList(params);
					if (result.code === 200 && result.data) {
						return result.data.list.map((item, index) => ({
							value: item.id,
							label: item.realName || `健康师${index + 1}`,
							jkszh: item.id,
							jksxm: item.realName || `健康师${index + 1}`,
							subtitle: item.department || item.role || ''
						}));
					}
					return [];
				} catch (error) {
					console.error('获取健康师列表出错:', error);
					return [];
				}
			},

			// 获取储扣品项选项（会员剩余品项）
			async getDeductPxOptions(page = 1, searchKeyword = '') {
				try {
					// 需要先选择会员才能获取剩余品项
					if (!this.selectedValues.kdhy) {
						uni.showToast({
							title: '请先选择开单会员',
							icon: 'none'
						});
						return [];
					}

					const params = {
						memberId: this.selectedValues.kdhy,
						currentPage: page,
						pageSize: this.pageSize
					};

					if (searchKeyword) {
						params.itemName = searchKeyword;
					}

					const result = await lxApi.getMemberRemainingItems(params);
					if (result.code === 200 && result.data) {
						return result.data.RemainingItems
							// .filter(item => (item.ItemPrice || 0) > 0) // 只返回ItemPrice大于0的品项
							.map((item, index) => ({
								unitPrice: item.ItemPrice || 0,
								billingId: item.BillingItemId || '',
								value: item.BillingItemId,
								label: item.ItemName,
								px: item.ItemId,
								pxmc: item.ItemName,
								pxjg: item.ItemPrice || 0,
								qt2: item.qt2 || "",
								RemainingCount: item.RemainingCount || 0,
								ItemPrice: item.ItemPrice || 0,
								sgf: 0,
								sourceType: item.SourceType || "购买",
								TotalPurchased: item.TotalPurchased || 0,
								ConsumedCount: item.ConsumedCount || 0,
								BillingItemId: item.BillingItemId,
								subtitle: '剩余: ' + (item.RemainingCount || 0) + '；类型：' + item.SourceType +
									';单价：' + item.ItemPrice +';备注：' + (item.Remark || '无')+ ';'
							}));
					}
					return [];
				} catch (error) {
					console.error('获取会员剩余品项出错:', error);
					return [];
				}
			},

			// 获取科技部人员选项
			async getKjbOptions(page = 1, searchKeyword = '') {
				try {
					const params = {
						currentPage: page,
						pageSize: this.pageSize,
						gw: '科技老师' // 可以根据实际API调整筛选条件
					};

					if (searchKeyword) {
						params.kjblsxm = searchKeyword;
					}

					const result = await appointmentApi.getHealthWorkerList(params);
					if (result.code === 200 && result.data) {
						return result.data.list.map((item, index) => ({
							value: item.id,
							label: item.realName || `科技部人员${index + 1}`,
							kjblszh: item.id,
							kjblsxm: item.realName || `科技部人员${index + 1}`,
							subtitle: item.department || item.role || ''
						}));
					}
					return [];
				} catch (error) {
					console.error('获取科技部人员列表出错:', error);
					return [];
				}
			},
			// 获取活动数据
			async getActivityOptions(page = 1, searchKeyword = '') {
				try {
					const params = {
						currentPage: page,
						pageSize: this.pageSize
					};
					const result = await lxApi.GetCurrentTimeEffectiveActivityAsync(params);
					if (result.code === 200 && result.data) {
						return result.data.map((item, index) => ({
							value: item.id,
							label: item.activityName,
							subtitle: item.activityDesc
						}));
					}
					return [];
				} catch (error) {
					console.error('获取活动列表出错:', error);
					return [];
				}
			},
			// 选择器相关方法
			openSfckPicker() {
				this.showSfckPicker = true;
			},
			closeSfckPicker() {
				this.showSfckPicker = false;
			},
			onSfckConfirm(e) {
				if (e.value && e.value[0]) {
					this.formData.sfck = e.value[0].text;
				}
				this.showSfckPicker = false;
				this.deductList = []
				this.calculateShifuYej();
			},

			openCkfsPicker() {
				this.showCkfsPicker = true;
			},
			closeCkfsPicker() {
				this.showCkfsPicker = false;
			},
			onCkfsConfirm(e) {
				if (e.value && e.value[0]) {
					this.formData.ckfs = e.value[0].text;
				}
				this.showCkfsPicker = false;
			},

			openFkfsPicker() {
				this.showFkfsPicker = true;
			},
			closeFkfsPicker() {
				this.showFkfsPicker = false;
			},
			onFkfsConfirm(e) {
				if (e.value && e.value[0]) {
					this.formData.fkfs = e.value[0].text;
				}
				this.showFkfsPicker = false;
			},

			openSfskddPicker() {
				this.showSfskddPicker = true;
			},
			closeSfskddPicker() {
				this.showSfskddPicker = false;
			},
			onSfskddConfirm(e) {
				if (e.value && e.value[0]) {
					this.formData.sfskdd = e.value[0].text;
				}
				this.showSfskddPicker = false;
			},

			// 类型选择器相关方法
			openSourceTypePicker(index) {
				this.currentPxIndex = index;
				this.showSourceTypePicker = true;
			},
			closeSourceTypePicker() {
				this.showSourceTypePicker = false;
			},
			onSourceTypeConfirm(e) {
				if (e.value && e.value[0] && this.currentPxIndex >= 0) {
					this.pxList[this.currentPxIndex].sourceType = e.value[0].text;
				}
				this.showSourceTypePicker = false;
			},


			// 文件上传相关
			chooseFile(type) {
				uni.chooseImage({
					count: 9,
					type: 'file',
					success: (res) => {
						this.handleFileSelect(res.tempFiles, type);
					}
				});
			},

			// 处理文件选择
			async handleFileSelect(files, type) {
				console.error(files)
				for (let i = 0; i < files.length; i++) {
					const file = files[i];

					// 验证文件类型
					// if (!this.validateFileType(file)) {
					// 	uni.showToast({
					// 		title: `文件 ${file.name} 类型不支持`,
					// 		icon: 'none'
					// 	});
					// 	continue;
					// }

					// 验证文件大小 (限制为10MB)
					if (file.size > 10 * 1024 * 1024) {
						uni.showToast({
							title: `文件 ${file.name} 大小超过10MB限制`,
							icon: 'none'
						});
						continue;
					}

					// 上传文件
					await this.uploadSingleFile(file, type);
				}
			},

			// 验证文件类型
			validateFileType(file) {
				const allowedTypes = [
					'image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp',
					'application/pdf',
					'application/msword',
					'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
				];
				return allowedTypes.includes(file.type);
			},

			// 上传单个文件
			async uploadSingleFile(file, type) {
				const fileId = `file_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;

				// 添加到文件列表显示
				this.addFileToList(file, fileId, 'uploading', type);

				try {
					const result = await lxApi.uploadFile(file);

					if (result.code === 200 && result.data) {
						// 更新文件状态为成功
						this.updateFileStatus(fileId, 'success', type, result.data);

						uni.showToast({
							title: '文件上传成功',
							icon: 'success'
						});
					} else {
						throw new Error(result.msg || '上传失败');
					}
				} catch (error) {
					console.error('文件上传失败:', error);
					this.updateFileStatus(fileId, 'error', type);
					uni.showToast({
						title: `文件 ${file.name} 上传失败`,
						icon: 'none'
					});
				}
			},

			// 添加文件到列表显示
			addFileToList(file, fileId, status, type) {
				const fileItem = {
					id: fileId,
					name: file.name,
					size: file.size,
					type: file.type,
					status: status,
					url: '',
					fileId: ''
				};

				if (type === 'receipt') {
					this.scwj.push(fileItem);
				} else {
					this.f_FileUrl.push(fileItem);
				}
			},

			// 更新文件状态
			updateFileStatus(fileId, status, type, uploadData = null) {
				const fileList = type === 'receipt' ? this.scwj : this.f_FileUrl;
				const fileIndex = fileList.findIndex(file => file.id === fileId);

				if (fileIndex !== -1) {
					fileList[fileIndex].status = status;
					if (uploadData) {
						fileList[fileIndex].url = uploadData.url;
						fileList[fileIndex].fileId = uploadData.name;
						fileList[fileIndex].name = uploadData.name;
					}
				}
			},

			// 获取文件图标
			getFileIcon(fileType) {
				return '🖼️';
				// if (fileType.startsWith('image/')) {
				// 	return '🖼️';
				// } else if (fileType === 'application/pdf') {
				// 	return '📄';
				// } else if (fileType.includes('word')) {
				// 	return '📝';
				// } else {
				// 	return '📁';
				// }
			},

			removeFile(type, index) {
				if (type === 'receipt') {
					this.scwj.splice(index, 1);
				} else {
					this.f_FileUrl.splice(index, 1);
				}
			},

			formatFileSize(size) {
				if (size < 1024) return size + 'B';
				if (size < 1024 * 1024) return (size / 1024).toFixed(1) + 'KB';
				return (size / (1024 * 1024)).toFixed(1) + 'MB';
			},

			// 签字相关方法
			handleSignatureConfirm(signatureData) {
				this.memberSignature = signatureData.dataUrl;
				// 延迟关闭，让用户看到提示信息
				// setTimeout(() => {
				// 	this.showSignatureModal = false;
				// 	// 恢复页面滚动
				// 	this.enablePageScroll();
				// 	uni.showToast({
				// 		title: '签字确认成功',
				// 		icon: 'success'
				// 	});
				// }, 2000);
			},

			handleSignatureClear() {
				this.memberSignature = '';
			},

			clearMemberSignature() {
				this.memberSignature = '';
				if (this.$refs.signaturePad) {
					this.$refs.signaturePad.clearSignature();
				}
				uni.showToast({
					title: '签字已清除',
					icon: 'success'
				});
			},

		// 全屏签字相关方法
		openSignatureModal() {
			// 隐藏键盘，防止点击签字时弹出键盘
			uni.hideKeyboard();
			// 计算品项信息
			this.calculateSignaturePxInfo();
			this.showSignatureModal = true;
			// 禁止页面滚动
			this.disablePageScroll();
		},
			
			// 计算签字时显示的品项信息
			calculateSignaturePxInfo() {
				if (!this.pxList || this.pxList.length === 0) {
					this.signaturePxInfo = {
						items: [],
						actualPrice: '0.00'
					};
					return;
				}
				
				// 收集所有品项信息，每条包含品项名、类型和数量
				const items = [];
				
				this.pxList.forEach(px => {
					if (px.pxmc) {
						items.push({
							name: px.pxmc,
							count: parseInt(px.projectNumber) || 0,
							type: px.sourceType || '购买'
						});
					}
				});
				
				// 实付金额
				const actualPrice = parseFloat(this.formData.sfyj) || 0;
				
				this.signaturePxInfo = {
					items: items,
					actualPrice: actualPrice.toFixed(2)
				};
			},

			closeSignatureModal() {
				this.showSignatureModal = false;
				// 恢复页面滚动
				this.enablePageScroll();
			},

		// 禁止页面滚动
		disablePageScroll() {
			// #ifdef H5
			// 获取当前滚动位置
			this.scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
			// 设置页面不可滚动
			document.body.style.overflow = 'hidden';
			document.body.style.position = 'fixed';
			document.body.style.width = '100%';
			document.body.style.top = `-${this.scrollTop}px`;
			// #endif
			// #ifdef APP-PLUS || MP
			// App 和小程序中，通过 page-meta 组件禁止页面滚动
			this.pageScrollDisabled = true;
			// #endif
		},

		// 恢复页面滚动
		enablePageScroll() {
			// #ifdef H5
			// 恢复页面滚动
			document.body.style.overflow = '';
			document.body.style.position = '';
			document.body.style.width = '';
			document.body.style.top = '';
			// 恢复滚动位置
			if (this.scrollTop !== undefined) {
				window.scrollTo(0, this.scrollTop);
			}
			// #endif
			// #ifdef APP-PLUS || MP
			// App 和小程序中，恢复页面滚动
			this.pageScrollDisabled = false;
			// #endif
		},

			clearSignatureModal() {
				if (this.$refs.signaturePadModal) {
					this.$refs.signaturePadModal.clearSignature();
				}
			},

			confirmSignatureModal() {
				if (this.$refs.signaturePadModal) {
					this.$refs.signaturePadModal.confirmSignature();
				}
			},


			// 表单提交
			handleFormSubmit(event) {
				event.preventDefault();
				this.submitOrder();
			},
			validatePxList() {
				const pxList = this.pxList;

				// 1. 验证是否有品项
				if (!pxList || pxList.length === 0) {
					uni.showToast({
						title: '请至少添加一个品项',
						icon: 'none'
					});
					return false;
				}

				// 2. 验证每个品项的基本信息
				for (let i = 0; i < pxList.length; i++) {
					const px = pxList[i];

					// 验证品项是否选择
					if (!px.px) {
						uni.showToast({
							title: `第${i + 1}个品项请选择品项`,
							icon: 'none'
						});
						return false;
					}

					// 验证品项总价（赠送和体验类型可以为0）
					if (px.actualPrice === undefined || px.actualPrice === null || px.actualPrice === '' || parseFloat(px
							.actualPrice) < 0) {
						uni.showToast({
							title: `第${i + 1}个品项总价不能为负数`,
							icon: 'none'
						});
						return false;
					}

					// 购买类型的品项总价必须大于0
					if (px.sourceType === '购买' && parseFloat(px.actualPrice) <= 0) {
						uni.showToast({
							title: `第${i + 1}个品项是购买类型，总价必须大于0`,
							icon: 'none'
						});
						return false;
					}

					// 验证品项数量
					if (!px.projectNumber || parseInt(px.projectNumber) <= 0) {
						uni.showToast({
							title: `第${i + 1}个品项数量必须大于0`,
							icon: 'none'
						});
						return false;
					}

					// 验证健康师业绩
					if (!px.lqKdJksyjList || px.lqKdJksyjList.length === 0) {
						uni.showToast({
							title: `第${i + 1}个品项请至少添加一个健康师业绩`,
							icon: 'none'
						});
						return false;
					}

					// 验证每个健康师是否选择
					for (let j = 0; j < px.lqKdJksyjList.length; j++) {
						const jks = px.lqKdJksyjList[j];
						if (!jks.jks || !jks.jksxm) {
							uni.showToast({
								title: `第${i + 1}个品项的第${j + 1}个健康师必须选择`,
								icon: 'none'
							});
							return false;
						}
						if (jks.jksyj === undefined || jks.jksyj === null || jks.jksyj === '' || jks.jksyj.trim() === "") {
							uni.showToast({
								title: `第${i + 1}个品项的第${j + 1}个健康师业绩必须填写`,
								icon: 'none'
							});
							return false;
						}
						const yj = parseFloat(jks.jksyj);
						if (isNaN(yj) || yj < 0) {
							uni.showToast({
								title: `第${i + 1}个品项的第${j + 1}个健康师业绩必须为有效数字`,
								icon: 'none'
							});
							return false;
						}
					}

					// 如果是科美品项，验证科技部老师
					if (px.qt2 === '科美') {
						if (!px.lqKdKjbsyjList || px.lqKdKjbsyjList.length === 0) {
							uni.showToast({
								title: `第${i + 1}个品项是科美品项，必须至少选择一个科技部老师`,
								icon: 'none'
							});
							return false;
						}

						// 验证每个科技部老师是否选择
						for (let k = 0; k < px.lqKdKjbsyjList.length; k++) {
							const kjb = px.lqKdKjbsyjList[k];
							if (!kjb.kjbls || !kjb.kjblsxm) {
								uni.showToast({
									title: `第${i + 1}个品项的第${k + 1}个科技部老师必须选择`,
									icon: 'none'
								});
								return false;
							}
							if (kjb.kjblsyj === undefined || kjb.kjblsyj === null || kjb.kjblsyj === '' || kjb.kjblsyj
								.trim() === "") {
								uni.showToast({
									title: `第${i + 1}个品项的第${k + 1}个科技部老师业绩必须填写`,
									icon: 'none'
								});
								return false;
							}
							const yj = parseFloat(kjb.kjblsyj);
							if (isNaN(yj) || yj < 0) {
								uni.showToast({
									title: `第${i + 1}个品项的第${k + 1}个科技部老师业绩必须为有效数字`,
									icon: 'none'
								});
								return false;
							}
						}
					}
				}
				if (this.formData.sfck == '是' && this.deductList.length == 0) {
					uni.showToast({
						title: `请添加储扣明细`,
						icon: 'none'
					});
					return false;
				}


				// 3. 验证每个品项总价等于该品项健康师业绩之和
				if (this.deductList && this.deductList.length > 0) {
					// 验证储扣明细
					for (let i = 0; i < this.deductList.length; i++) {
						const deduct = this.deductList[i];

						// 验证储扣品项是否选择
						if (!deduct.itemName) {
							uni.showToast({
								title: `第${i + 1}个储扣明细请选择品项`,
								icon: 'none'
							});
							return false;
						}

						// 验证储扣数量
						if (!deduct.projectNumber || parseInt(deduct.projectNumber) <= 0) {
							uni.showToast({
								title: `第${i + 1}个储扣明细数量必须大于0`,
								icon: 'none'
							});
							return false;
						}

						// 验证储扣总价
						// if (!deduct.amount || parseFloat(deduct.amount) <= 0) {
						// 	uni.showToast({
						// 		title: `第${i + 1}个储扣明细总价必须大于0`,
						// 		icon: 'none'
						// 	});
						// 	return false;
						// }

						// 验证储扣数量不超过剩余数量
						if (deduct.RemainingCount && parseInt(deduct.projectNumber) > parseInt(deduct.RemainingCount)) {
							uni.showToast({
								title: `第${i + 1}个储扣明细数量(${deduct.projectNumber})不能超过剩余数量(${deduct.RemainingCount})`,
								icon: 'none'
							});
							return false;
						}
					}
					let jksAmount = 0;
					let kjbAmount = 0;
					let isKjb = false;
					for (let i = 0; i < pxList.length; i++) {
						const px = pxList[i];
						if (px.lqKdJksyjList) {
							jksAmount += px.lqKdJksyjList.reduce((sum, jks) => sum + (parseFloat(jks.jksyj) || 0), 0);
						}
						if (px.qt2 === '科美' && px.sourceType == '购买') {
							isKjb = true;
							if (px.lqKdKjbsyjList) {
								kjbAmount += px.lqKdKjbsyjList.reduce((sum, kjb) => sum + (parseFloat(kjb.kjblsyj) || 0),
									0);
							}
						}
					}
					console.error('总健康师业绩', jksAmount);
					console.error('总科技部业绩', kjbAmount);

					// 获取实付业绩
					const sfyj = parseFloat(this.formData.sfyj) || 0;
					console.error('实付业绩', sfyj);

					// 验证总健康师业绩等于实付业绩
					if (Math.abs(jksAmount - sfyj) > 0.01) {
						uni.showToast({
							title: `总健康师业绩(${jksAmount.toFixed(2)})必须等于实付业绩(${sfyj.toFixed(2)})`,
							icon: 'none'
						});
						return false;
					}

					// 如果有科美品项，验证总科技部业绩等于实付业绩
					if (isKjb && Math.abs(kjbAmount - sfyj) > 0.01) {
						uni.showToast({
							title: `总科技部业绩(${kjbAmount.toFixed(2)})必须等于实付业绩(${sfyj.toFixed(2)})`,
							icon: 'none'
						});
						return false;
					}

				} else {
					for (let i = 0; i < pxList.length; i++) {
						const px = pxList[i];
						const pxAmount = parseFloat(px.actualPrice) || 0;

						// 计算当前品项的健康师业绩之和
						let jksAmount = 0;
						if (px.lqKdJksyjList) {
							jksAmount = px.lqKdJksyjList.reduce((sum, jks) => sum + (parseFloat(jks.jksyj) || 0), 0);
						}

						// 验证当前品项总价等于健康师业绩之和（赠送和体验类型总价可以为0）
						if (Math.abs(pxAmount - jksAmount) > 0.01) {
							uni.showToast({
								title: `第${i + 1}个品项总价(${pxAmount.toFixed(2)})必须等于该品项健康师业绩之和(${jksAmount.toFixed(2)})`,
								icon: 'none'
							});
							return false;
						}

						// 如果是科美品项，验证科美品项总价等于科技部业绩之和
						if (px.qt2 === '科美') {
							let kjbAmount = 0;
							if (px.lqKdKjbsyjList) {
								kjbAmount = px.lqKdKjbsyjList.reduce((sum, kjb) => sum + (parseFloat(kjb.kjblsyj) || 0),
								0);
							}

							if (Math.abs(pxAmount - kjbAmount) > 0.01) {
								uni.showToast({
									title: `第${i + 1}个科美品项总价(${pxAmount.toFixed(2)})必须等于该品项科技部业绩之和(${kjbAmount.toFixed(2)})`,
									icon: 'none'
								});
								return false;
							}
						}
					}
				}


				return true;
			},
			// 提交开单
			async submitOrder() {
				
				try {
					if (this.removeid) {
						console.log({...this.formData})
						console.log({...this.removeinfo})
						if (!(toString(this.formData.zdyj))) {
							uni.showToast({
								title: '请输入整单业绩',
								icon: 'none'
							});
							return;
						}
						// return
						// 验证品项列表
						if (!this.validatePxList()) {
							return;
						}
						// 整单业绩要大于等于品项之和的总价
						let totalPxPrice = 0;
						for (let i = 0; i < this.pxList.length; i++) {
							const px = this.pxList[i];
							totalPxPrice += parseFloat(px.actualPrice) || 0;
						}
						console.error(totalPxPrice ,this.formData.zdyj)
						if (Number(this.formData.zdyj) < totalPxPrice) {
							uni.showToast({
								title: '整单业绩要大于等于品项之和的总价',
								icon: 'none'
							});
							return;
						}
						if (!this.formData.fkfs) {
							uni.showToast({
								title: '请选择付款方式',
								icon: 'none'
							});
							return;
						}
						const orderData = {
							...this.removeinfo,
							zdyj:this.formData.zdyj,
							sfyj:this.formData.sfyj,
							qk:this.formData.qk,
							sfck:this.formData.sfck,
							fkfs:this.formData.fkfs,
							hgjg:this.selectedValues.hgjg,
							fkyy:this.selectedValues.fkyy,
							jj:this.formData.jj,
							bz:this.formData.bz,
							lqKdPxmxList:this.pxList,
							scwj:this.scwj,
							f_FileUrl:JSON.stringify(this.f_FileUrl),
							lqKdKdjlbDeductList:this.deductList,
						}
						if(this.removeinfo && this.removeinfo.supplementBillingId){
							let syamount = 0;
							console.error(this.removeinfo)
							let supplementinfo = await lxApi.GetBillingDebtInfo(this.removeinfo.supplementBillingId)
							console.error(supplementinfo)
							if(supplementinfo.code == 200){
								syamount = supplementinfo.data.qk - supplementinfo.data.PaidDebt + Number(this.removeinfo.supplementAmount)
							}
							orderData.supplementAmount = (Number(this.formData.sfyj) > Number(syamount)?syamount:this.formData.sfyj)
							console.error(orderData.supplementAmount)
						}
						
						// return
						console.error({...orderData})
						this.issubmitOrder = false;
						uni.showLoading({
							title: '正在提交...'
						});
						const result = await lxApi.UpdateForNoDelete(orderData);
						uni.hideLoading();
						if (result.code == 200) {
							uni.showToast({
								title: '修改成功！',
								icon: 'success'
							});
							this.clearForm();
							// 返回上一页
							setTimeout(() => {
								uni.navigateBack({
									delta: 1
								});
							}, 1500);
						}else{
							uni.showToast({
								title: result.msg || '修改失败！',
								icon: 'none'
							});
						}
						this.issubmitOrder = true;
					} else {
						// 提取金三角名称
						const jsj = this.extractJsjNames();
						// 验证表单
						if(this.isactivity){
							if(!this.selectedValues.activityId){
								uni.showToast({
									title: '请选择活动',
									icon: 'none'
								});
								return;
							}
						}
						if (!this.selectedValues.kdhy) {
							uni.showToast({
								title: '请选择开单会员',
								icon: 'none'
							});
							return;
						}
						if (!(toString(this.formData.zdyj))) {
							uni.showToast({
								title: '请输入整单业绩',
								icon: 'none'
							});
							return;
						}
						// 验证品项列表
						if (!this.validatePxList()) {
							return;
						}
						// 整单业绩要大于等于品项之和的总价
						let totalPxPrice = 0;
						for (let i = 0; i < this.pxList.length; i++) {
							const px = this.pxList[i];
							totalPxPrice += parseFloat(px.actualPrice) || 0;
						}
						if (Number(this.formData.zdyj) < totalPxPrice) {
							uni.showToast({
								title: '整单业绩要大于等于品项之和的总价',
								icon: 'none'
							});
							return;
						}
						if (!this.formData.fkfs) {
							uni.showToast({
								title: '请选择付款方式',
								icon: 'none'
							});
							return;
						}
						// 验证会员签字
						// if (!this.memberSignature) {
						// 	uni.showToast({
						// 		title: '请进行会员签字',
						// 		icon: 'none'
						// 	});
						// 	return false;
						// }
						let hyqz = []
						if(this.memberSignature) {
							let memberinfo = await this.newUploadBase64Image()
							console.error(memberinfo)
							if (memberinfo) {
								hyqz.push({
									name: memberinfo.name,
									fileId: memberinfo.name,
									url: memberinfo.url
								});
							}
						}
						
						// 收集表单数据
						// 处理开单日期：如果用户设置了日期则使用设置的日期，否则使用当前时间
						let kdrqValue = this.utils.gettime();
						if (this.formData.kdrq) {
							// 如果设置了日期，则添加时分秒
							kdrqValue = this.formData.kdrq + ' ' + new Date().toTimeString().substring(0, 8);
						}
						
						const orderData = {
							activityId: this.selectedValues.activityId?this.selectedValues.activityId:'',
							djmd: this.userInfo.mdid,
							jsj: jsj,
							kdrq: kdrqValue,

							gjlx: this.formData.gjlx,
							kdhysjh: this.formData.kdhysjh,
							kdhyc: this.formData.kdhyc,
							kdhy: this.selectedValues.kdhy,

							zdyj: this.formData.zdyj,
							sfyj: this.formData.sfyj,
							qk: this.formData.qk,
							sfck: this.formData.sfck,
							ckfs: this.formData.ckfs,
							ckmx: this.formData.ckmx,
							fkfs: this.formData.fkfs,
							hgjg: this.selectedValues.hgjg,
							fkyy: this.selectedValues.fkyy,
							sfskdd: Number(this.formData.sfyj) > 0 ? this.formData.sfskdd : '否',
							jj: this.formData.jj,
							bz: this.formData.bz,
							lqKdPxmxList: this.pxList,
							scwj: this.scwj,
							f_FileUrl: JSON.stringify(this.f_FileUrl),
							lqKdKdjlbDeductList: this.deductList,
							hyqz: hyqz,
							supplementBillingId: this.supplementBillingId?this.supplementBillingId:'',
							supplementAmount:this.supplementBillingId?(Number(this.formData.sfyj) > Number(this.qk)?this.qk:this.formData.sfyj):0
						};
						if(this.appointmentId){
							orderData.appointmentId = this.appointmentId;
						}
						console.log('orderData', {
							...orderData
						});
						console.log([...this.pxList])
						// return
						this.issubmitOrder = false;
						
						uni.showLoading({
							title: '正在提交...'
						});

						// 这里需要根据实际API调整
						const result = await lxApi.submitLqKdKdjlb(orderData);
						uni.hideLoading();
						if (result.code == 200) {
							// 模拟成功
							uni.showToast({
								title: '开单成功！',
								icon: 'success'
							});
							// 清空表单
							this.clearForm();
						} else {
							uni.showToast({
								title: result.msg || '开单失败！',
								icon: 'none'
							});
						}	
						this.issubmitOrder = true;
					}

				} catch (error) {
					uni.hideLoading();
					console.error('提交失败:', error);
					uni.showToast({
						title: '网络错误，请稍后重试',
						icon: 'none'
					});
					this.issubmitOrder = true;
				}
			},
			// 清空表单
			clearForm() {
				this.formData = {
					kdhy: '',
					gjlx: '',
					kdhysjh: '',
					kdhyc: '',
					kdrq: this.utils.gettime().substring(0, 10),

					zdyj: '',
					sfyj: '',
					qk: '',
					sfck: '否',
					ckfs: '',
					ckmx: '',
					fkfs: '',
					hgjg: '',
					fkyy: '',
					sfskdd: '',
					jj: '',
					bz: ''
				};

				this.selectedValues = {
					kdhy: null,
					hgjg: null,
					fkyy: null,
					activityId: null
				};

				this.pxList = [];
				this.deductList = [];
				this.scwj = [];
				this.f_FileUrl = [];
				this.memberSignature = '';
				if (this.$refs.signaturePad) {
					this.$refs.signaturePad.clearSignature();
				}

				// 重新添加默认品项
				this.addPxRow();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.lx-container {
		min-height: 100vh;
		background: linear-gradient(135deg, #e8f5e9 0%, #b2dfdb 100%);
		padding: 20rpx;
	}

	.header {
		background: linear-gradient(120deg, #43e97b 0%, #38f9d7 100%);
		border-radius: 36rpx;
		padding: 48rpx;
		text-align: center;
		margin-bottom: 48rpx;
		box-shadow: 0 8rpx 48rpx 0 rgba(76, 175, 80, 0.10);
	}

	.header-title {
		color: #fff;
		font-size: 36rpx;
		font-weight: bold;
		letter-spacing: 4rpx;
	}

	.form-card {
		background: #fff;
		border-radius: 36rpx;
		box-shadow: 0 8rpx 48rpx 0 rgba(76, 175, 80, 0.10);
		border: 3rpx solid #c8e6c9;
		overflow: hidden;
	}

	.form-content {
		padding: 48rpx;
	}

	.form-group {
		margin-bottom: 40rpx;
	}

	.form-group:last-child {
		margin-bottom: 0;
	}

	.form-label {
		display: block;
		margin-bottom: 16rpx;
		font-weight: bold;
		color: #388e3c;
		letter-spacing: 2rpx;
		font-size: 28rpx;
	}

	.input-wrapper {
		position: relative;
	}

	.custom-select {
		position: relative;
		background: #f9fff9;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		padding: 24rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		cursor: pointer;
		z-index: 10;
		min-height: 80rpx;
		box-sizing: border-box;
	}

	.select-text {
		font-size: 28rpx;
		color: #2e7d32;
		flex: 1;
	}

	.select-arrow {
		position: absolute;
		right: 24rpx;
		top: 50%;
		transform: translateY(-50%);
		color: #6a9c6a;
		font-size: 24rpx;
		pointer-events: none;
	}

	.select-input {
		background: #f9fff9;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		padding: 24rpx;
		font-size: 28rpx;
		color: #2e7d32;
	}

	::v-deep .u-input {
		background: #f9fff9;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx !important;
		padding: 24rpx !important;
		font-size: 28rpx;
		color: #2e7d32;
		overflow: hidden;
	}

	::v-deep .input-placeholder {
		font-size: 28rpx !important;
		color: #2e7d32 !important;
	}

	.readonly-input {
		background: #f5f5f5;
		border: 3rpx solid #ddd;
		border-radius: 20rpx;
		padding: 24rpx;
		font-size: 28rpx;
		color: #666;
	}

	.textarea-input {
		background: #f9fff9;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		padding: 24rpx;
		font-size: 28rpx;
		color: #2e7d32;
		min-height: 200rpx;
		box-sizing: border-box;
		width: 100%;
		box-sizing: border-box;
	}

	::v-deep .u-textarea {
		background: #f9fff9;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		padding: 24rpx;
		font-size: 28rpx;
		color: #2e7d32;
		min-height: 200rpx;
	}

	.submit-btn {
		width: 100%;
		padding: 32rpx 40rpx;
		border-radius: 24rpx;
		font-size: 32rpx;
		font-weight: 600;
		letter-spacing: 2rpx;
		background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
		color: #fff;
		box-shadow: 0 8rpx 32rpx rgba(67, 233, 123, 0.3);
		margin-top: 64rpx;
		border-color: #43e97b;
	}

	/* 品项相关样式 */
	.px-container {
		margin-bottom: 32rpx;
	}

	.px-row {
		display: flex;
		flex-direction: column;
		gap: 24rpx;
		margin-bottom: 32rpx;
		padding: 32rpx;
		border: 2rpx solid #e0e0e0;
		border-radius: 20rpx;
		background: #fafafa;
	}

	.px-row-first {
		display: flex;
		gap: 24rpx;
		align-items: center;
	}

	.px-row-second {
		display: flex;
		gap: 16rpx;
		align-items: center;
		width: 100%;
	}

	.px-row-third {
		display: flex;
		gap: 24rpx;
		align-items: center;
		margin-top: 24rpx;
	}

	.px-row-fourth {
		display: flex;
		gap: 24rpx;
		align-items: center;
		margin-top: 24rpx;
	}

	.px-row-fifth {
		display: flex;
		gap: 24rpx;
		align-items: flex-start;
		margin-top: 24rpx;
		flex-wrap: wrap;
	}

	.px-row-sixth {
		display: flex;
		gap: 24rpx;
		align-items: flex-start;
		margin-top: 24rpx;
		flex-wrap: wrap;
	}

	.px-row-seventh {
		display: flex;
		gap: 24rpx;
		align-items: flex-start;
		margin-top: 24rpx;
		flex-wrap: wrap;
	}

	.px-remark-wrapper {
		width: 100%;
		display: flex;
		flex-direction: column;
		gap: 12rpx;
	}

	.px-remark-label {
		font-size: 26rpx;
		color: #2e7d32;
		font-weight: bold;
	}

	.px-remark-input {
		background: #f9fff9;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		padding: 24rpx;
		font-size: 28rpx;
		color: #2e7d32;
		height: 120rpx;
		box-sizing: border-box;
		width: 100%;
	}

	.px-select {
		width: 40%;
		padding: 24rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		font-size: 28rpx;
		background: #f9fff9;
		color: #2e7d32;
		cursor: pointer;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.px-amount {
		// flex: 1;
		width: 40%;
		padding: 24rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		font-size: 28rpx;
		background: #f9fff9;
		color: #2e7d32;
	}

	.px-count {
		min-width: 80rpx;
		padding: 20rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		font-size: 26rpx;
		background: #f9fff9;
		color: #2e7d32;
		text-align: center;
	}

	.px-type-select {
		width: 30%;
		padding: 20rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		font-size: 26rpx;
		background: #f9fff9;
		color: #2e7d32;
		cursor: pointer;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.px-unit-price {
		display: flex;
		align-items: center;
		gap: 8rpx;
		padding: 16rpx 20rpx;
		background: #e8f5e9;
		border-radius: 12rpx;
		border: 2rpx solid #c8e6c9;
		width: 20%;
		justify-content: center;
	}

	.price-label {
		font-size: 22rpx;
		color: #2e7d32;
		font-weight: 500;
	}

	.price-value {
		font-size: 24rpx;
		color: #1b5e20;
		font-weight: bold;
	}

	.px-delete {
		width: 20%;
		padding: 16rpx 0;
		// border: 3rpx solid #ddd;
		border-radius: 20rpx;
		background: #f5f5f5;
		color: #666;
		font-size: 22rpx;
	}

	.btn-add-px {
		width: 100%;
		padding: 10rpx 40rpx;
		border: 3rpx solid #43a047;
		border-radius: 20rpx;
		background: #e8f5e9;
		color: #2e7d32;
		font-size: 28rpx;
		font-weight: bold;
	}

	/* 储扣明细相关样式 */
	.deduct-container {
		margin-bottom: 32rpx;
	}

	.deduct-row {
		display: flex;
		flex-direction: column;
		gap: 24rpx;
		margin-bottom: 32rpx;
		padding: 32rpx;
		border: 2rpx solid #e0e0e0;
		border-radius: 20rpx;
		background: #fafafa;
	}

	.deduct-info {
		background: #e8f5e9;
		border: 2rpx solid #c8e6c9;
		border-radius: 16rpx;
		padding: 24rpx;
		margin-bottom: 16rpx;
	}

	.deduct-info-item {
		display: flex;
		align-items: center;
		margin-bottom: 12rpx;
	}

	.deduct-info-item:last-child {
		margin-bottom: 0;
	}

	.info-label {
		font-size: 26rpx;
		color: #2e7d32;
		font-weight: bold;
		margin-right: 16rpx;
		min-width: 120rpx;
	}

	.info-value {
		font-size: 26rpx;
		color: #1b5e20;
		flex: 1;
	}

	.deduct-row-first {
		display: flex;
		gap: 24rpx;
		align-items: center;
	}

	.deduct-row-second {
		display: flex;
		gap: 16rpx;
		align-items: center;
		width: 100%;
	}

	.deduct-select {
		width: 40%;
		padding: 24rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		font-size: 28rpx;
		background: #f9fff9;
		color: #2e7d32;
		cursor: pointer;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.deduct-amount {
		width: 40%;
		padding: 24rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		font-size: 28rpx;
		background: #f9fff9;
		color: #2e7d32;
	}

	.deduct-count {
		min-width: 80rpx;
		padding: 20rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		font-size: 26rpx;
		background: #f9fff9;
		color: #2e7d32;
		text-align: center;
	}

	.deduct-unit-price {
		display: flex;
		align-items: center;
		gap: 8rpx;
		padding: 16rpx 20rpx;
		background: #e8f5e9;
		border-radius: 12rpx;
		border: 2rpx solid #c8e6c9;
		width: 20%;
		justify-content: center;
	}

	.deduct-delete {
		width: 20%;
		padding: 16rpx 0;
		border-radius: 20rpx;
		background: #f5f5f5;
		color: #666;
		font-size: 22rpx;
	}

	.btn-add-deduct {
		width: 100%;
		padding: 10rpx 40rpx;
		border: 3rpx solid #43a047;
		border-radius: 20rpx;
		background: #e8f5e9;
		color: #2e7d32;
		font-size: 28rpx;
		font-weight: bold;
	}

	.px-jks-select,
	.px-kjb-select {
		flex: 1;
		padding: 24rpx 40rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		font-size: 28rpx;
		font-weight: bold;
		background: #e8f5e9;
		color: #2e7d32;
		cursor: pointer;
		text-align: center;
		box-shadow: 0 4rpx 8rpx rgba(76, 175, 80, 0.1);
	}

	.px-jks-list,
	.px-kjb-list {
		flex: 1;
		min-height: 100rpx;
		padding: 24rpx;
		border: 3rpx solid #c8e6c9;
		border-radius: 20rpx;
		background: #f9fff9;
		font-size: 18rpx;
		gap: 24rpx;
		line-height: 3.6;
		// margin: 20rpx 0;
	}

	.px-staff-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: #e8f5e9;
		color: #2e7d32;
		padding: 20rpx 24rpx;
		margin: 0;
		border-radius: 12rpx;
		font-size: 28rpx;
		border: 2rpx solid #c8e6c9;
		line-height: 3.2;
		margin-bottom: 16rpx;
	}

	.staff-name {
		margin-right: 24rpx;
		font-weight: 500;
		color: #2e7d32;
		line-height: 3.2;
	}

	.staff-amount {
		border: 2rpx solid #a5d6a7;
		border-radius: 8rpx;
		padding: 8rpx 16rpx;
		font-size: 28rpx;
		width: 120rpx;
		text-align: center;
		background: #fff;
		color: #2e7d32;
		margin-right: 16rpx;
		line-height: 3;
	}

	.remove-btn {
		cursor: pointer;
		color: #f44336;
		font-weight: bold;
		font-size: 36rpx;
		width: 50rpx;
		height: 50rpx;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		background: rgba(244, 67, 54, 0.1);
	}

	/* 文件上传样式 */
	.file-upload-area {
		border: 4rpx dashed #c8e6c9;
		border-radius: 24rpx;
		padding: 48rpx;
		text-align: center;
		background: linear-gradient(135deg, #f9fff9 0%, #e8f5e9 100%);
		cursor: pointer;
		min-height: 240rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		position: relative;
		overflow: hidden;
	}

	.file-upload-text {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 24rpx;
		color: #6a9c6a;
		font-size: 19rpx;
		position: relative;
		z-index: 1;
	}

	.file-upload-icon {
		font-size: 50rpx;
		opacity: 0.8;
	}

	.file-list {
		margin-top: 32rpx;
		text-align: left;
		max-height: 400rpx;
		overflow-y: auto;
	}

	.file-item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 24rpx;
		background: #fff;
		border: 1rpx solid #e8f5e9;
		border-radius: 12rpx;
		margin-bottom: 12rpx;
		font-size: 26rpx;
		box-shadow: 0 2rpx 8rpx rgba(67, 233, 123, 0.08);
		transition: all 0.3s ease;
	}

	.file-info {
		display: flex;
		align-items: center;
		gap: 20rpx;
		// flex: 1;
		// min-width: 0;
		overflow: hidden;
		width: 40%;
	}

	.file-icon {
		font-size: 32rpx;
		width: 56rpx;
		height: 56rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: linear-gradient(135deg, #f9fff9 0%, #e8f5e9 100%);
		border-radius: 10rpx;
		flex-shrink: 0;
		border: 1rpx solid #c8e6c9;
	}

	.file-name {
		// flex: 1;
		font-size: 28rpx;
		color: #333;
		font-weight: 500;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		// min-width: 0;
		line-height: 1.4;
	}

	.file-size {
		font-size: 22rpx;
		color: #666;
		background: #f8f9fa;
		padding: 6rpx 12rpx;
		border-radius: 6rpx;
		flex-shrink: 0;
		border: 1rpx solid #e9ecef;
	}

	.file-actions {
		display: flex;
		align-items: center;
		gap: 12rpx;
		flex-shrink: 0;
		width: 50%;
	}

	.file-status {
		font-size: 22rpx;
		padding: 6rpx 12rpx;
		border-radius: 6rpx;
		font-weight: 500;
		white-space: nowrap;
	}

	.file-status.success {
		color: #2e7d32;
		background: #e8f5e9;
		border: 1rpx solid #c8e6c9;
	}

	.file-status.error {
		color: #c62828;
		background: #ffebee;
		border: 1rpx solid #ffcdd2;
	}

	.file-status.uploading {
		color: #ef6c00;
		background: #fff3e0;
		border: 1rpx solid #ffe0b2;
	}
	.btn-error {
		background: #f44336;
		color: #fff;
		border: none;
		// padding: 6rpx 12rpx;
		border-radius: 6rpx;
		font-size: 20rpx;
	}
	.btn-error:hover {
		background: #c62828;
	}

	// @media (max-width: 750rpx) {
	// 	.form-content {
	// 		padding: 40rpx;
	// 	}

	// 	.px-row-second {
	// 		gap: 16rpx;
	// 	}

	// 	.px-row-third {
	// 		gap: 16rpx;
	// 	}

	// 	.px-row-fourth {
	// 		gap: 16rpx;
	// 	}

	// 	.px-jks-select,
	// 	.px-kjb-select {
	// 		width: 100%;
	// 	}

	// 	.px-jks-list,
	// 	.px-kjb-list {
	// 		width: 100%;
	// 	}

	// 	.px-staff-item {
	// 		display: flex;
	// 		justify-content: space-between;
	// 		align-items: center;
	// 		// width: 100%;
	// 	}

	// 	.staff-amount {
	// 		flex: 1;
	// 		margin: 0;
	// 		margin-right: 20rpx;
	// 	}
	// }

	.btn-group {
		display: flex;
		gap: 24rpx;
		margin-top: 48rpx;
		// position: fixed;
		// bottom: 0;
		// width: 100%;
	}

	.btn {
		flex: 1;
		padding: 10rpx 40rpx;
		border: none;
		border-radius: 20rpx;
		font-size: 28rpx;
		font-weight: bold;
		cursor: pointer;
		transition: all 0.2s ease;
		letter-spacing: 2rpx;
	}

	.btn-primary {
		background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
		color: #fff;
		box-shadow: 0 4rpx 16rpx rgba(67, 233, 123, 0.3);
	}

	.btn-primary:hover {
		box-shadow: 0 8rpx 32rpx rgba(67, 233, 123, 0.4);
		transform: translateY(-2rpx);
	}

	/* 签字相关样式 */
	.signature-preview {
		margin-top: 24rpx;
		padding: 24rpx;
		background: #f9fff9;
		border: 2rpx solid #c8e6c9;
		border-radius: 16rpx;
	}

	.preview-label {
		display: block;
		font-size: 26rpx;
		color: #2e7d32;
		font-weight: bold;
		margin-bottom: 16rpx;
	}

	.signature-image {
		width: 100%;
		max-width: 300rpx;
		height: 120rpx;
		border: 2rpx solid #e0e0e0;
		border-radius: 12rpx;
		background: #fff;
		margin-bottom: 16rpx;
	}

	.btn-clear-signature {
		padding: 12rpx 24rpx;
		background: #f5f5f5;
		color: #666;
		border: 2rpx solid #ddd;
		border-radius: 12rpx;
		font-size: 24rpx;
		font-weight: 500;
		cursor: pointer;
		transition: all 0.2s ease;
	}

	.btn-clear-signature:hover {
		background: #e0e0e0;
	}

	/* 全屏签字弹窗样式 */
	.signature-modal-overlay {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.7);
		z-index: 9999;
		display: flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
	}

	.signature-modal {
		width: 100%;
		// max-width: 800rpx;
		background: #fff;
		// border-radius: 20rpx;
		overflow: hidden;
		// box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.signature-modal-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx 40rpx;
		background: #f8f9fa;
		border-bottom: 2rpx solid #e9ecef;

	}

	.signature-modal-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #2e7d32;
	}

	.btn-close-modal {
		width: 60rpx;
		height: 60rpx;
		background: #f5f5f5;
		border: none;
		border-radius: 50%;
		font-size: 36rpx;
		color: #666;
		display: flex;
		align-items: center;
		justify-content: center;
		cursor: pointer;
		transition: all 0.2s ease;
		margin: 0;
	}

	.btn-close-modal:hover {
		background: #e0e0e0;
		color: #333;
	}

	.signature-modal-content {
		// padding: 40rpx;
		// display: flex;
		// justify-content: center;
		background: #fff;
		flex: 1;
		width: 100%;
	}

	/* 全屏模式下SignaturePad组件样式调整 */
	.signature-modal-content .signature-container {
		height: 100%;
		border: none;
		border-radius: 0;
		box-shadow: none;
	}

	.signature-modal-content .signature-header {
		padding: 20rpx 30rpx;
		background: #f8f9fa;
		border-bottom: 2rpx solid #e9ecef;
	}

	.signature-modal-content .signature-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #2e7d32;
	}

	.signature-modal-content .btn-clear,
	.signature-modal-content .btn-confirm {
		padding: 16rpx 32rpx;
		font-size: 28rpx;
		font-weight: 500;
		border-radius: 12rpx;
	}

	.signature-modal-content .btn-clear {
		background: #f5f5f5;
		color: #666;
		border: 2rpx solid #ddd;
	}

	.signature-modal-content .btn-clear:hover {
		background: #e0e0e0;
		color: #333;
	}

	.signature-modal-content .btn-confirm {
		background: #2e7d32;
		color: #fff;
		border: none;
	}

	.signature-modal-content .btn-confirm:hover {
		background: #1b5e20;
		transform: translateY(-2rpx);
	}

	.signature-modal-content .signature-pad {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 20rpx;
	}

	.signature-modal-content .signature-tips {
		padding: 20rpx;
		text-align: center;
		background: #f8f9fa;
		border-top: 2rpx solid #e9ecef;
	}

	.signature-modal-content .tips-text {
		font-size: 24rpx;
		color: #666;
	}

	.signature-modal-footer {
		display: flex;
		justify-content: space-between;
		padding: 30rpx 40rpx;
		background: #f8f9fa;
		border-top: 2rpx solid #e9ecef;
		gap: 20rpx;
	}

	.btn-clear-modal {
		flex: 1;
		padding: 20rpx;
		background: #f5f5f5;
		color: #666;
		border: 2rpx solid #ddd;
		border-radius: 12rpx;
		font-size: 28rpx;
		font-weight: 500;
		cursor: pointer;
		transition: all 0.2s ease;
	}

	.btn-clear-modal:hover {
		background: #e0e0e0;
		color: #333;
	}

	.btn-confirm-modal {
		flex: 1;
		padding: 20rpx;
		background: #2e7d32;
		color: #fff;
		border: none;
		border-radius: 12rpx;
		font-size: 28rpx;
		font-weight: 500;
		cursor: pointer;
		transition: all 0.2s ease;
	}

	.btn-confirm-modal:hover {
		background: #1b5e20;
		transform: translateY(-2rpx);
	}

	/* 签字占位符样式 */
	.signature-placeholder {
		display: flex;
		justify-content: center;
		align-items: center;
		min-height: 200rpx;
		border: 2rpx dashed #c8e6c9;
		border-radius: 16rpx;
		background: #f9fff9;
	}

	.btn-signature-placeholder {
		// padding: 30rpx 60rpx;
		background: #2e7d32;
		color: #fff;
		border: none;
		border-radius: 16rpx;
		font-size: 28rpx;
		font-weight: 500;
		cursor: pointer;
		transition: all 0.2s ease;
		box-shadow: 0 4rpx 16rpx rgba(46, 125, 50, 0.3);
	}

	.btn-signature-placeholder:hover {
		background: #1b5e20;
		transform: translateY(-2rpx);
		box-shadow: 0 8rpx 32rpx rgba(46, 125, 50, 0.4);
	}

	.signature-placeholder-text {
		color: #fff;
	}

	/* 签字操作按钮样式 */
	.signature-actions {
		display: flex;
		gap: 16rpx;
		margin-top: 16rpx;
	}

	.btn-re-signature {
		flex: 1;
		padding: 12rpx 24rpx;
		background: #2e7d32;
		color: #fff;
		border: none;
		border-radius: 12rpx;
		font-size: 24rpx;
		font-weight: 500;
		cursor: pointer;
		transition: all 0.2s ease;
	}

	.btn-re-signature:hover {
		background: #1b5e20;
	}

	// @media (max-width: 750rpx) {
	// 	.signature-preview {
	// 		padding: 20rpx;
	// 	}

	// 	.preview-label {
	// 		font-size: 24rpx;
	// 	}

	// 	.signature-image {
	// 		max-width: 250rpx;
	// 		height: 100rpx;
	// 	}

	// 	.btn-clear-signature {
	// 		padding: 10rpx 20rpx;
	// 		font-size: 22rpx;
	// 	}

	// }
</style>