<!--
 * @Date: 2024-10-08 14:29:36
 * @LastEditors: lip
 * @LastEditTime: 2025-05-06 16:55:10
-->
<template>
	<view class="container" style="background-color: #f7f7f7;">
		<scroll-view scroll-y="true" :style="{height: edit?'calc(90vh - 150px)':'calc(100vh - 144px)'}">
			<view class="inner">
				<view class="part-title" style="display: flex;justify-content: space-between;">求职需求信息
					<view v-if="!edit&&formData.id&&formData.currentStatus!=3" class="btn"
						style="font-weight: normal;display: flex;" @click="edit=true">编辑<view class="icon-right">✏️</view></view>
				</view>
				<view class="inner-part">
					<view class="self-form">
						<view class="form-item">
							<view class="form-label">姓名 <text class="required">*</text></view>
							<view v-if="name" style="width: 100%;"
								class="disabledLine">
								{{ formData.personName || '请选择' }}
							</view>
							<view v-else style="width: 100%;" @click="openPersonChooser"
								:class="{disabledLine: !edit||!canChoosePerson, noValue: !formData.personName}">
								{{ formData.personName || '请选择' }}
							</view>
							<view class="icon-right">✏️</view>
						</view>
                        <!-- <u-form-item label="姓名" prop="personName" required>
							<u--input :disabled="!edit" v-model="formData.name" border="none"
								placeholder="请输入"></u--input>
							<view class="icon-right" style="width: 40rpx; height: 40rpx;">✏️</view>
						</u-form-item> -->
						<!-- <u-form-item label="求职工种" prop="jobWorkType" required>
							<view style="width: 100%;" @click="showPicker('jobWorkType')"
								:class="{disabledLine: !edit, noValue: !formData.jobWorkTypeName}">
								{{ formData.jobWorkTypeName ||'请选择' }}
							</view>
							<u-icon slot="right" name="arrow-down" color="#A6A6A6"></u-icon>
						</u-form-item> -->
						<!-- 新增工种选择 -->
                        <view class="form-item">
							<view class="form-label">求职工种</view>
							<picker
								mode="multiSelector"
								:range="workTypeColumns"
								range-key="workTypeName"
								:value="workTypeIndexes"
								@change="onWorkTypePickerChange"
								@columnchange="onWorkTypeColumnChange"
								v-if="workTypeColumns[0] && workTypeColumns[0].length"
							>
								<view class="picker-view">
									<view class="picker-view-text">{{ formData.jobWorkTypeName || '请选择工种' }}</view>
									<view class="icon-right">▼</view>
								</view>
							</picker>
							<view v-else class="picker-view">
								<view class="picker-view-text">工种数据加载中...</view>
							</view>
						</view>
                        <!-- <u-form-item label="工种选择" prop="selectedWorkType">
							<uni-data-picker
								v-model="selectedWorkType"
								:localdata="workTypeTreeList"
								:popup-title="'请选择工种'"
								:clear-icon="false"
								:map="{text:'label', value:'id', children:'children'}"
								@change="onWorkTypeChange"
								:placeholder="'请选择工种'"
								:step-searh="false"
								:popup="true"
								:multiple="false"
								:self-field="false"
							/>
						</u-form-item> -->
						<!-- 	<u-form-item label="希望解决日期" prop="hopeSolveDate" required>
							<view style="width: 100%;" @click="showPicker('hopeSolveDate')"
								:class="{disabledLine: !edit, noValue: !formData.hopeSolveDate}">
								{{ formData.hopeSolveDate||'请选择' }}
							</view>
							<u-icon slot="right" name="arrow-down" color="#A6A6A6"></u-icon>
						</u-form-item> -->
						<!-- <u-form-item label="从业年数" prop="emplymentYear" required>
							<view style="width: 100%;" @click="showPicker('emplymentYear')"
								:class="{disabledLine: !edit, noValue: getDictLabel(formData.emplymentYear, dict.emplymentYear)=='请选择'}">
								{{ getDictLabel(formData.emplymentYear, dict.emplymentYear) }}
							</view>
							<u-icon slot="right" name="arrow-down" color="#A6A6A6"></u-icon>
						</u-form-item>
						<u-form-item label="工资类型" prop="salaryType" required>
							<view style="width: 100%;" @click="showPicker('salaryType')"
								:class="{disabledLine: !edit, noValue: getDictLabel(formData.salaryType, dict.salaryType)=='请选择'}">
								{{ getDictLabel(formData.salaryType, dict.salaryType) }}
							</view>
							<u-icon slot="right" name="arrow-down" color="#A6A6A6"></u-icon>
						</u-form-item> -->
						<view class="form-item">
							<view class="form-label">最低薪酬 <text class="required">*</text></view>
							<input type="number" :disabled="!edit" v-model="formData.minRecruitmentSalary" placeholder="请输入" :class="['form-input', { 'form-input-disabled': !edit }]"/>
							<view class="icon-right" style="width: 40rpx; height: 40rpx;">✏️</view>
					</view>
						<view class="form-item">
							<view class="form-label">最高薪酬 <text class="required">*</text></view>
							<input type="number" :disabled="!edit" v-model="formData.highRecruitmentSalary" placeholder="请输入" :class="['form-input', { 'form-input-disabled': !edit }]"/>
							<view class="icon-right" style="width: 40rpx; height: 40rpx;">✏️</view>
					</view>
						<!-- 	<u-form-item label="单位性质" prop="unitNature" required>
							<view style="width: 100%;" @click="showPicker('unitNature')"
								:class="{disabledLine: !edit, noValue: getDictLabel(formData.unitNature, dict.unitNature)=='请选择'}">
								{{ getDictLabel(formData.unitNature, dict.unitNature) }}
							</view>
							<u-icon slot="right" name="arrow-down" color="#A6A6A6"></u-icon>
						</u-form-item> -->
						<!-- 	<u-form-item label="用工形式" prop="employmentType" required>
							<view style="width: 100%;" @click="showPicker('employmentType')"
								:class="{disabledLine: !edit, noValue: getDictLabel(formData.employmentType, dict.employmentType)=='请选择'}">
								{{ getDictLabel(formData.employmentType, dict.employmentType) }}
							</view>
							<u-icon slot="right" name="arrow-down" color="#A6A6A6"></u-icon>
						</u-form-item> -->
						<view class="form-item">
							<view class="form-label">希望工作地点</view>
							<input type="text" placeholder="请输入" v-model="formData.addressDesc" class="form-input ellipsis_1" @focus="$refs.placePicker.openDialog()"/>
			</view>
			<view class="form-item">
							<view class="form-label">求职说明 <text class="required">*</text></view>
							<textarea :disabled="!edit" v-model="formData.jobDescription" placeholder="请输入" :class="['form-textarea', { 'form-textarea-disabled': !edit }]"></textarea>
						</view>
						<!-- 		<u-form-item label="就业意愿" prop="employmentWillingness">
							<view style="width: 100%;" @click="showPicker('employmentWillingness')"
								:class="{disabledLine: !edit, noValue: getDictLabel(formData.employmentWillingness, dict.employmentWillingness)=='请选择'}">
								{{ getDictLabel(formData.employmentWillingness, dict.employmentWillingness) }}
							</view>
							<u-icon slot="right" name="arrow-down" color="#A6A6A6"></u-icon>
						</u-form-item> -->
				</view>
				</view>
			</view>


			<!-- 办理完成后 需求说明 -->
			<req-comp :form="{
				actualSolveDate: formData.actualSolveDate,
				actualSolvePeople: formData.actualSolvePeople,
				solveDesc: formData.solveDesc,
				fileUrl: formData.fileUrl
			}" />

			<!-- 	<view class="inner">
				<view class="part-title" style="margin-top: 32rpx;">附件信息</view>
				<view class="inner-part">
					<u--form labelPosition="left" class="self-form" labelWidth="110">
						<u-form-item label="附件" prop="fileUrl">
							<ImageUpload :fileList="fileList" @update="changeFile" :maxCount="6" />
						</u-form-item>
					</u--form>
				</view>
			</view>
		</scroll-view>
		<!-- 使用原生picker组件代替uView的选择器 -->
		<!-- 工种选择器弹窗 -->
	

		<view class="button-area" v-if="edit">
			<view class="btn" @click="cancelPage">取消</view>
			<view class="btn reset" @click="getDetail(formData.id)">重置</view>
			<view class="btn save" @click="saveInfo">保存</view>
		</view>
		
		</scroll-view>
	</view>
</template>
<script>
	import {
		getPersonBase
	} from "@/packageRc/api/personinfo/index";
	import {
		addPersonDemand,
		updatePersonDemand,
		getPersonDemand
	} from "@/packageRc/api/needs/personDemand";
	import {
		listJobType
	} from "@/packageRc/api/jobType/index";
	import ImageUpload from './ImageUpload'
	import ChoosePerson from './choosePerson';
	import PlacePicker from "@/components/placePicker";

	//import uPopup from 'uview-ui/components/u-popup/u-popup.vue'
	export default {
		components: {
			ChoosePerson,
			ImageUpload,
			PlacePicker,
	//		uPopup
		},
		props: {
			needId: {
				type: String,
				default: ''
			},
			name: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				edit: true,
				personBase: {},
				dates: {},
				currentCommunityId: '',
				showPickerPicker: false,
				canChoosePerson: true,
				canChoosePerson: true,
				formData: {
					demandType:"1",
						personName: '',
					personId:"",
					userId:"",
					jobWorkType: '',
					jobWorkTypeName: '',
					selectedWorkType: '',
					selectedWorkTypeName: '',
					highRecruitmentSalary: '',
					minRecruitmentSalary: '',
					employmentType: '',
					currentCommunity: '',
					addressDesc: '',
					jobDescription: '',
					// fileUrl: []
				},
				rules: {
					personName: [{
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change'],
					}],
					jobWorkType: [{
						required: true,
						message: '请选择求职工种',
						trigger: ['blur', 'change'],
						validator: (rule, value) => {
							return (Array.isArray(value) && value.length > 0) || (!!value);
						}
					}],
					highRecruitmentSalary: [{
						required: true,
						message: '请选择最高薪酬',
						trigger: ['blur', 'change'],
					}, ],
					minRecruitmentSalary: [{
						required: true,
						message: '请选择最低薪酬',
						trigger: ['blur', 'change'],
					}, ],
				   jobDescription: [{
        required: true,
        message: '请填写求职说明',
        trigger: ['blur', 'change'],
    }, ]
					// employmentType: [{
					// 	required: true,
					// 	message: '请选择用工形式',
					// 	trigger: ['blur', 'change'],
					// }, ],
					// addressDesc: [{
					// 	required: true,
					// 	message: '请选择希望工作地点',
					// 	trigger: ['blur', 'change'],
					// }, ],
				},
				dict: {
					emplymentYear: [],
					salaryType: [],
					highRecruitmentSalary: [],
					minRecruitmentSalary: [],
					unitNature: [],
					employmentWillingness: []
				},
				show: {
					hopeSolveDate: false,
					jobWorkType: false,
					emplymentYear: false,
					salaryType: false,
					highRecruitmentSalary: false,
					minRecruitmentSalary: false,
					unitNature: false,
					employmentType: false,
					employmentWillingness: false
				},
				currentCity: '请选择',
				bysj: '',
				loading: false,
				jobTypeList: [],
				route: {},
				canChoosePerson: false,
				fileList: [],
				workTypeList: [],
				workTypeColumns: [[], [], []],
				workTypeIndexes: [0, 0, 0],
			}
		},
		// 移除uView表单验证相关代码
		created() {
			this.setName()
			this.loading = true;
			let arr = [{
					key: 'qcjy_gznx',
					prop: 'emplymentYear'
				},
				{
					key: 'qcjy_gzlx',
					prop: 'salaryType'
				},
				{
					key: 'qcjy_zgzpgz',
					prop: 'highRecruitmentSalary'
				},
				{
					key: 'qcjy_zgzpgz',
					prop: 'minRecruitmentSalary'
				},
				{
					key: 'qcjy_dwxz',
					prop: 'unitNature'
				},
				// {
				// 	key: 'qcjy_ygxs',
				// 	prop: 'employmentType'
				// },
				{
					key: 'qcjt_jyyy',
					prop: 'employmentWillingness'
				},
			]

			// 使用 Promise.all 确保所有字典数据加载完成
			Promise.all(arr.map(ele => this.getDicts(ele.key)))
				.then(responses => {
					responses.forEach((res, index) => {
						this.dict[arr[index].prop] = res.data || [];
					});
					this.loading = false;
				})
				.catch(error => {
					console.error('加载字典数据失败:', error);
					// 设置默认空数组
					arr.forEach(ele => {
						this.dict[ele.prop] = [];
					});
					this.loading = false;
				});

			this.workTypeRemoteMethod('');
		},
		methods: {
			// 获取字典数据
			getDicts(dictType) {
				return new Promise((resolve, reject) => {
					// 这里应该调用实际的API，暂时返回空数组
					// 如果需要真实的API调用，请替换下面的代码
					setTimeout(() => {
						resolve({ data: [] });
					}, 100);
				});
			},

			cancelPage() {
				if (this.formData.id) {
					this.edit = false;
					this.getDetail(this.formData.id)
				} else {
					uni.navigateBack()
				}
			},
			openPersonChooser() {
				if (this.edit && this.canChoosePerson) {
					this.$refs.personChooser.open();
				}
			},
			setName(){
				this.formData.personName = this.name
				this.formData.personId = this.needId
				this.formData.userId = this.needId
			},
			personNameConfirm(event) {
				this.formData.personName = event.name
				this.formData.personId = event.id
				this.formData.userId = event.userId

			},
			changeFile(e) {
				// 清空当前的 fileUrl 数组
				this.formData.fileUrl = [];
				// 如果 e 有长度（即用户选择了文件）
				if (e.length) {
					// 遍历每个文件对象并获取其 url
					for (let data of e) {
						const url = data.data ? data.data.url : data.url;
						this.formData.fileUrl.push(url);
					}
				}
				this.formData.fileUrl = this.$arrayToString(this.formData.fileUrl)
			},
			addOne() {
				this.formData = {}
				this.getPersonInfo()
				if(this.name){
					this.formData.personName = this.name
					this.formData.userId = this.needId
				}
				this.edit = true
			},
			getDetail(id) {
				getPersonDemand(id).then(res => {
					this.formData = res.data;
					// 设置工种索引（需要等工种数据加载完成后）
					if (this.formData.jobWorkType && this.workTypeColumns[0].length) {
						this.setWorkTypeIndexes(this.formData.jobWorkType);
					}
					this.currentCommunityId = +res.data.currentCommunity
					this.formData.currentCommunity = res.data.currentCommunity
					this.edit = false;
					this.fileList = this.$processFileUrl(this.formData.fileUrl)
				}).catch(error => {
					console.error('Error fetching job detail:', error);
				});
			},
			confirmDate(type, e) {
				this.show[type] = false;
				let date = new Date(e.value)
				this.formData[type] =
					`${date.getFullYear()}-${(date.getMonth()+1)>9?(date.getMonth()+1):('0'+(date.getMonth()+1))}-${date.getDate()>9?date.getDate():('0'+date.getDate())}`
			},
			workTypeRemoteMethod(key) {
				listJobType({
					workTypeName: key,
					pageNum: 1,
					pageSize: 50
				}).then(
					(res) => {
						console.log('工种数据加载成功:', res.rows);
						this.jobTypeList = res.rows;
						// 处理树形数据为级联选择器格式
						this.processWorkTypeTree(res.rows);
					}
				).catch(error => {
					console.error('获取工种列表失败:', error);
					this.workTypeList = [];
					this.workTypeColumns = [[], [], []];
				});
			},
			goBack() {
				uni.navigateBack();
			},
			cancelPicker(type) {
				this.show[type] = false
			},
			getCityOptis(data) {
				if (data && data[0] && data[0].children) {
					return [data].concat(this.getCityOptions(data[0].children))
				} else {
					return [data]
				}
			},

			getDictLabel(value, list) {
				if (list && Array.isArray(list)) {
					let arr = list.filter(ele => ele.dictValue == value)
					if (arr.length) {
						return arr[0].dictLabel || '请选择'
					} else {
						return '请选择'
					}
				}
				return '请选择'
			},

			pickerConfirm(type, event) {
				this.show[type] = false
				this.formData[type] = event.value[0].dictValue
			},
			jobTypeConfirm(type, event) {
				this.show[type] = false
				this.formData[type] = event.value[0].id
				this.formData.jobWorkTypeName = event.value[0].workTypeName
			},
			showPicker(type) {
				if (this.edit) {
					if(type === 'workTypeTree') {
						if (!this.workTypeTreeColumns[0] || !this.workTypeTreeColumns[0].length) {
							this.$u.toast('工种数据未加载，请稍后重试');
							return;
						}
						// 弹窗打开时，初始化临时columns和index
						this.tempWorkTypeTreeColumns = JSON.parse(JSON.stringify(this.workTypeTreeColumns));
						this.tempWorkTypeTreeIndex = [...this.workTypeTreeIndex];
					}
					this.show[type] = true;
				}
			},
			getPersonInfo() {
				this.loading = true;
				this.$store.dispatch("GetInfo").then((res) => {
					if (res.data.roles.indexOf('qunzhong') == -1) {
						this.canChoosePerson = true;
					} else {
						this.canChoosePerson = false;
						getPersonBase(res.data.user.userId).then(resp => {
							this.formData.personId = resp.data.id
							this.formData.userId = resp.data.userId
							this.formData.personName = resp.data.name
						})
					}
				})
			},
			async saveInfo() {
				this.setName()
				try {
					console.log("this.formData.personName",this.formData.personName)
					// 先检查求职说明是否为空，如果为空直接提示
					if (!this.formData.jobDescription || this.formData.jobDescription.trim() === '') {
						uni.showToast({ title: '请填写求职说明！', icon: 'none' });
						return;
					}

					// 简单的表单验证
					console.log(this.formData)
					if (!this.formData.personName) {
						uni.showToast({ title: '请填写姓名！', icon: 'none' });
						return;
					}
					if (!this.formData.jobWorkType) {
						uni.showToast({ title: '请选择求职工种！', icon: 'none' });
						return;
					}
					if (!this.formData.minRecruitmentSalary) {
						uni.showToast({ title: '请填写最低薪酬！', icon: 'none' });
						return;
					}
					if (!this.formData.highRecruitmentSalary) {
						uni.showToast({ title: '请填写最高薪酬！', icon: 'none' });
						return;
					}
					// 显示全局加载
					uni.showLoading({ title: '加载中...' });
					this.formData.demandType = 1;
					// this.formData.userId = this.formData.personId
					// 根据 formData 是否有 id 来决定是更新还是新增
					let response;
					let successMessage;
					if (this.formData.id) {
						response = await updatePersonDemand(this.formData);
						successMessage = '修改成功';
					} else {
						response = await addPersonDemand(this.formData);
						successMessage = '保存成功';
					}
					// 检查响应码是否为200
					if (response.code === 200) {
						uni.showToast({ title: successMessage });
						// 如果是编辑模式，关闭编辑状态；否则返回上一页
						if (this.formData.id) {
							this.edit = false;
						} else {
							// 延迟1秒后返回
							setTimeout(() => {
								uni.navigateBack();
							}, 1000);
						}
					}
				} catch (error) {
					if(error && error.length){
						uni.showToast({ title: '请填写完整信息！', icon: 'none' });
					} else {
						uni.showToast({ title: '系统错误,请联系管理员！', icon: 'none' });
					}
				}
				finally {
					// 确保加载页总是会被隐藏
					uni.hideLoading();
				}
			},
			popupclosed() {
				this.showPickerPicker = false
			},

			onChange(e) {
				const arr = e.detail.value
				this.formData.currentCity = arr[0].value || "";
				this.formData.currentArea = arr[1].value || "";
				this.formData.currentStreet = arr[2].value || "";
				this.formData.currentCommunity = arr[3].value + '' || "";
				this.$forceUpdate();
			},

			// 接收地图数据
			handleSelected(marker) {
				this.$set(this.formData, "addressDesc", marker.address);
				this.$set(this.formData, "latitude", marker.location.lat);
				this.$set(this.formData, "longitude", marker.location.lng);
			},









			// 处理树形数据为级联选择器格式
			processWorkTypeTree(treeData) {
				if (!treeData || !Array.isArray(treeData)) {
					this.workTypeColumns = [[], [], []];
					return;
				}

				// 第一级
				const level1 = treeData.filter(item => item.level === "1");
				// 第二级
				const level2 = treeData.filter(item => item.level === "2");
				// 第三级
				const level3 = treeData.filter(item => item.level === "3");

				// 构建级联数据
				const columns = [];
				columns[0] = level1;

				// 根据第一级选择，过滤第二级
				if (level1.length > 0) {
					const firstLevelId = level1[0].id;
					columns[1] = level2.filter(item => item.parentId === firstLevelId);
				} else {
					columns[1] = [];
				}

				// 根据第二级选择，过滤第三级
				if (columns[1].length > 0) {
					const secondLevelId = columns[1][0].id;
					columns[2] = level3.filter(item => item.parentId === secondLevelId);
				} else {
					columns[2] = [];
				}

				this.workTypeColumns = columns;
				console.log('级联数据构建完成:', this.workTypeColumns);
			},

			// 级联选择器列变化事件
			onWorkTypeColumnChange(e) {
				const { column, value } = e.detail;
				const newIndexes = [...this.workTypeIndexes];
				newIndexes[column] = value;

				// 重置后续列的数据
				if (column === 0) {
					// 第一列变化，重置第二、三列
					const selectedLevel1 = this.workTypeColumns[0][value];
					if (selectedLevel1) {
						const level2 = this.jobTypeList.filter(item =>
							item.level === "2" && item.parentId === selectedLevel1.id
						);
						this.workTypeColumns[1] = level2;
						this.workTypeColumns[2] = [];
						newIndexes[1] = 0;
						newIndexes[2] = 0;
					}
				} else if (column === 1) {
					// 第二列变化，重置第三列
					const selectedLevel2 = this.workTypeColumns[1][value];
					if (selectedLevel2) {
						const level3 = this.jobTypeList.filter(item =>
							item.level === "3" && item.parentId === selectedLevel2.id
						);
						this.workTypeColumns[2] = level3;
						newIndexes[2] = 0;
					}
				}

				this.workTypeIndexes = newIndexes;
			},

			// 级联选择器确认事件
			onWorkTypePickerChange(e) {
				const indexes = e.detail.value;
				const selectedLevel1 = this.workTypeColumns[0][indexes[0]];
				const selectedLevel2 = this.workTypeColumns[1][indexes[1]];
				const selectedLevel3 = this.workTypeColumns[2][indexes[2]];

				if (selectedLevel3) {
					// 选择第三级
					this.formData.jobWorkType = selectedLevel3.id;
					this.formData.jobWorkTypeName = `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}/${selectedLevel3.workTypeName}`;
				} else if (selectedLevel2) {
					// 选择第二级
					this.formData.jobWorkType = selectedLevel2.id;
					this.formData.jobWorkTypeName = `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}`;
				} else if (selectedLevel1) {
					// 选择第一级
					this.formData.jobWorkType = selectedLevel1.id;
					this.formData.jobWorkTypeName = selectedLevel1.workTypeName;
				}

				this.workTypeIndexes = indexes;
			},

			// 根据工种ID设置索引
			setWorkTypeIndexes(workTypeId) {
				// 在工种列表中查找对应的工种
				const targetWorkType = this.jobTypeList.find(item => item.id == workTypeId);
				if (!targetWorkType) return;

				// 根据level确定是哪一级
				if (targetWorkType.level === "1") {
					const index = this.workTypeColumns[0].findIndex(item => item.id == workTypeId);
					if (index !== -1) {
						this.workTypeIndexes = [index, 0, 0];
					}
				} else if (targetWorkType.level === "2") {
					// 需要先找到父级
					const parent = this.jobTypeList.find(item => item.id == targetWorkType.parentId);
					if (parent) {
						const parentIndex = this.workTypeColumns[0].findIndex(item => item.id == parent.id);
						const childIndex = this.workTypeColumns[1].findIndex(item => item.id == workTypeId);
						if (parentIndex !== -1 && childIndex !== -1) {
							this.workTypeIndexes = [parentIndex, childIndex, 0];
						}
					}
				} else if (targetWorkType.level === "3") {
					// 需要找到祖父级和父级
					const parent = this.jobTypeList.find(item => item.id == targetWorkType.parentId);
					const grandparent = this.jobTypeList.find(item => item.id == parent.parentId);
					if (parent && grandparent) {
						const grandparentIndex = this.workTypeColumns[0].findIndex(item => item.id == grandparent.id);
						const parentIndex = this.workTypeColumns[1].findIndex(item => item.id == parent.id);
						const childIndex = this.workTypeColumns[2].findIndex(item => item.id == workTypeId);
						if (grandparentIndex !== -1 && parentIndex !== -1 && childIndex !== -1) {
							this.workTypeIndexes = [grandparentIndex, parentIndex, childIndex];
						}
					}
				}
			}
		}
	}
</script>
<style scoped>
.inner {
    padding: 40rpx;
}

.form-item {
    display: flex;
    margin-bottom: 40rpx;
    align-items: center;
    background-color: #fff;
    border-radius: 12rpx;
    padding: 20rpx;
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}

.form-label {
    width: 140rpx;
    font-size: 30rpx;
    color: #333;
    line-height: 1.5;
    font-weight: 500;
    margin-right: 30rpx;
    text-align: right;
    flex-shrink: 0;
}

.form-input {
    flex: 1;
    height: 80rpx;
    padding: 0 25rpx;
    border: 1px solid #e8e8e8;
    border-radius: 8rpx;
    font-size: 30rpx;
    color: #333;
    background-color: #fafafa;
}

.form-input:focus {
    border-color: #1989fa;
    background-color: #fff;
    box-shadow: 0 0 0 3rpx rgba(25, 137, 250, 0.1);
}

.form-input-disabled {
    color: #999;
    background-color: #f5f5f5;
}

.form-textarea {
    flex: 1;
    min-height: 200rpx;
    padding: 25rpx;
    border: 1px solid #e8e8e8;
    border-radius: 8rpx;
    font-size: 30rpx;
    color: #333;
    background-color: #fafafa;
    resize: vertical;
}

.form-textarea:focus {
    border-color: #1989fa;
    background-color: #fff;
    box-shadow: 0 0 0 3rpx rgba(25, 137, 250, 0.1);
}

.form-textarea-disabled {
    color: #999;
    background-color: #f5f5f5;
}

.required {
    color: #FF4D4F;
    margin-left: 4rpx;
}

.picker-view {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80rpx;
    border: 1px solid #e8e8e8;
    border-radius: 8rpx;
    padding: 0 25rpx;
    background-color: #fafafa;
}

.picker-view-text {
    font-size: 30rpx;
    color: #333;
}

.disabledLine {
    background-color: #f5f5f5;
    color: #999;
}

.noValue {
    color: #999;
}

.ellipsis_1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 按钮区域样式 */
.button-area {
    display: flex;
    justify-content: center;
    padding: 40rpx;
    gap: 30rpx;
    background-color: #fff;
    border-top: 1px solid #eee;
    margin-top: 20rpx;
}

.btn {
    flex: 1;
    height: 88rpx;
    line-height: 88rpx;
    text-align: center;
    border-radius: 44rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #333;
    background-color: #f5f5f5;
}

.btn.save {
    color: #fff;
    background-color: #1989fa;
}

.btn.reset {
    color: #666;
    background-color: #f0f0f0;
}

/* 图标样式优化 */
.icon-right {
    margin-left: 20rpx;
    font-size: 36rpx;
    color: #1989fa;
}
</style>



