<template>
	<view class="page_publish">
		<commonHeader :title="isEdit ? '编辑任务' : '新建任务'" @back="goBack"></commonHeader>

		<scroll-view scroll-y class="publish_content" :style="{ paddingTop: statusBarHeight + 160 + 'rpx', paddingBottom: safeAreaBottom + 'rpx' }">
			<view class="form_item">
				<view class="form_row form_row_type">
					<text class="form_label">学年学期</text>
					<view class="form_content">
						<picker mode="selector" :range="academicYearOptions" :value="academicYearIndex" @change="handleAcademicYearChange">
							<view class="filter_item">
								<text class="filter_text">{{ academicYearOptions[academicYearIndex] }}</text>
								<uni-icons type="down" size="16" color="#999999"></uni-icons>
							</view>
						</picker>
					</view>
				</view>
			</view>

			<view class="form_item">
				<view class="form_row form_row_type">
					<text class="form_label">归属部门</text>
					<view class="form_content">
						<picker mode="selector" :range="categoryOptions" :value="categoryIndex" @change="handleCategoryChange">
							<view class="filter_item">
								<text class="filter_text">{{ categoryOptions[categoryIndex] }}</text>
								<uni-icons type="down" size="16" color="#999999"></uni-icons>
							</view>
						</picker>
					</view>
				</view>
			</view>

			<view class="form_item">
				<view class="form_row form_row_type">
					<text class="form_label">材料类目</text>
					<view class="form_content">
						<picker mode="selector" :range="materialTypeOptions" :value="materialTypeIndex" @change="handleMaterialTypeChange">
							<view class="filter_item">
								<text class="filter_text">{{ materialTypeOptions[materialTypeIndex] }}</text>
								<uni-icons type="down" size="16" color="#999999"></uni-icons>
							</view>
						</picker>
					</view>
				</view>
			</view>

			<view class="form_item">
				<view class="form_row form_row_type">
					<text class="form_label">任务名称</text>
					<view class="form_content">
						<input type="text" class="form_input" v-model="formData.taskName" placeholder="请输入任务名称" />
					</view>
				</view>
			</view>

			<view class="form_item">
				<view class="form_row">
					<text class="form_label">采集要求</text>
					<view class="form_content">
						<view class="textarea_container">
							<textarea class="form_textarea" v-model="formData.collectRequirement" placeholder="请输入通知内容"
								:maxlength="-1"></textarea>
						</view>
					</view>
				</view>
			</view>

			<view class="form_item">
				<view class="form_row form_row_type">
					<text class="form_label">采集周期</text>
					<view class="form_content date_range">
						<picker mode="date" :value="formData.startTime" @change="onStartDateChange">
							<view class="date_range_item">
								<text class="date_text" :class="{ placeholder: !formData.startTime }">{{ formData.startTime || '开始日期' }}</text>
								<uni-icons type="calendar" size="16" color="#999999"></uni-icons>
							</view>
						</picker>
						<text class="date_separator">—</text>
						<picker mode="date" :value="formData.endTime" @change="onEndDateChange">
							<view class="date_range_item">
								<text class="date_text" :class="{ placeholder: !formData.endTime }">{{ formData.endTime || '结束日期' }}</text>
								<uni-icons type="calendar" size="16" color="#999999"></uni-icons>
							</view>
						</picker>
					</view>
				</view>
			</view>

			<view class="form_item">
				<view class="form_row form_row_type">
					<text class="form_label">审核机制</text>
					<view class="form_content">
						<customRadio v-model="formData.auditMechanism" :options="auditOptions" />
					</view>
				</view>
			</view>

			<view class="form_item" v-if="formData.auditMechanism === 1">
				<view class="form_row form_row_type">
					<text class="form_label">审核人</text>
					<view class="form_content">
						<view class="auditor_row" @click="openAuditorDialog">
							<text class="auditor_name" :class="{ placeholder: !formData.auditorName }">{{ formData.auditorName || '请选择审核人' }}</text>
							<uni-icons type="down" size="16" color="#999999"></uni-icons>
						</view>
					</view>
				</view>
			</view>

			<view class="form_item">
				<view class="form_row">
					<text class="form_label">采集对象</text>
					<view class="form_content">
						<view class="object_row">
							<view class="object_info" @click="goPersonList">
								<text class="object_count">{{ objectTypeLabel || '请选择' }}</text>
								<text class="object_count">已选{{ selectedCount }}人</text>
							</view>
							<view class="object_action" @click="selectObject">
								<text class="action_text">选择采集对象</text>
								<text class="action_arrow">></text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>

		<view class="publish_footer" :style="{ paddingBottom: safeAreaBottom + 24 + 'rpx' }">
			<view class="confirm_btn" @click="handleSave">
				<text class="btn_text">确定</text>
			</view>
		</view>

		<!-- 审核人搜索选择弹窗 -->
		<customPopupDialog ref="auditorDialogRef" title="选择审核人" :showDialogFooter="false" @DialogConfirm="confirmAuditorSelection">
			<view class="auditor_search_wrap">
				<view class="auditor_search_box">
					<uni-icons type="search" size="20" color="#999999"></uni-icons>
					<input type="text" class="auditor_search_input" v-model="auditorSearchKey" placeholder="请输入搜索关键字"
						@confirm="searchAuditors" @input="handleAuditorSearchInput" />
					<text v-if="auditorSearchKey" class="auditor_search_clear" @click="clearAuditorSearch">
						<uni-icons type="clear" size="18" color="#999999"></uni-icons>
					</text>
				</view>
				<scroll-view scroll-y class="auditor_list">
					<view v-if="auditorSearchLoading" class="auditor_loading">
						<text>加载中...</text>
					</view>
					<view v-else-if="auditorListFiltered.length === 0" class="auditor_empty">
						<noData :tipText="'暂无搜索结果'" />
					</view>
					<view v-else class="auditor_list_content">
						<view v-for="(item, idx) in auditorListFiltered" :key="idx"
							class="auditor_list_item"
							:class="{ active: selectedAuditor && selectedAuditor.teacherId === item.teacherId }"
							@click="selectAuditor(item)">
							<view class="auditor_item_info">
								<text class="auditor_item_name">{{ item.teacherName }}</text>
								<text v-if="item.teacherAccount" class="auditor_item_account">账号：{{ item.teacherAccount
									}}</text>
							</view>
							<view v-if="selectedAuditor && selectedAuditor.teacherId === item.teacherId"
								class="auditor_item_check">
								<uni-icons type="checkmarkempty" size="22" color="#2E64FA"></uni-icons>
							</view>
						</view>
					</view>
				</scroll-view>
				<view class="auditor_dialog_footer">
					<view class="auditor_dialog_btn cancel_btn" @click="closeAuditorDialog">
						<text>取消</text>
					</view>
					<view class="auditor_dialog_btn confirm_btn" @click="confirmAuditorSelection">
						<text>确定</text>
					</view>
				</view>
			</view>
		</customPopupDialog>
	</view>
</template>

<script setup>
import { ref, reactive, onMounted, computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
import notification from '@/reqApi/notification.js';
import CustomRadio from '@/components/customRadio.vue';
import CommonHeader from '@/components/commonHeader.vue';
import CustomPopupDialog from '@/components/customPopupDialog.vue';
import NoData from '@/components/noData.vue';
import { useSafeArea } from '@/common/safeArea';

const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();

const isEdit = ref(false);
const editId = ref('');

const academicYearIndex = ref(0);
const academicYearOptions = ref(['']);
const academicYearIds = ref(['']);
const academicYearCodes = ref(['']);

const categoryIndex = ref(0);
const categoryOptions = ref(['全部分类']);
const categoryData = ref([]);

const materialTypeIndex = ref(0);
const materialTypeOptions = ref(['全部类目']);

// 审核人弹窗相关
const auditorDialogRef = ref(null);
const auditorSearchKey = ref('');
const auditorSearchLoading = ref(false);
const auditorListFull = ref([]);
const selectedAuditor = ref(null);
let auditorSearchTimer = null;

const auditorListFiltered = computed(() => {
	return auditorListFull.value;
});

const auditOptions = [
	{ label: '需审核', value: 1 },
	{ label: '无审核', value: 0 }
];

const formData = reactive({
	schoolYearName: '',
	schoolYearId: '',
	schoolYearCode: '',
	departmentName: '',
	departmentId: '',
	materialCategoryName: '',
	materialCategoryId: '',
	taskName: '',
	collectRequirement: '',
	startTime: '',
	endTime: '',
	auditMechanism: 0,
	auditorName: '',
	auditorId: ''
});

const selectedCount = ref(0);
const selectedUsers = ref([]);
const objectTypeLabel = ref('');
const originalNoticeType = ref(0);

const fetchAcademicYearList = async () => {
	try {
		const res = await notification.getSchoolYearList();
		if (res.data && Array.isArray(res.data)) {
			const names = res.data.map(item => item.schoolYearName);
			const ids = res.data.map(item => item.id);
			const codes = res.data.map(item => item.schoolYearCode);
			academicYearOptions.value = names;
			academicYearIds.value = ids;
			academicYearCodes.value = codes;
			if (res.data.length > 0) {
				academicYearIndex.value = 0;
				formData.schoolYearName = res.data[0].schoolYearName;
				formData.schoolYearId = res.data[0].id;
				formData.schoolYearCode = res.data[0].schoolYearCode;
			}
		}
	} catch (error) {
		console.error('获取学年学期列表失败:', error);
	}
};

const fetchCategoryList = async () => {
	try {
		const res = await notification.getCategoryList();
		if (res.data && Array.isArray(res.data)) {
			categoryData.value = res.data;
			const categoryNames = res.data.map(item => item.categoryName || item.name);
			categoryOptions.value = ['全部分类', ...categoryNames];
			categoryIndex.value = 0;
			materialTypeOptions.value = ['全部类目'];
			formData.departmentName = '';
			formData.departmentId = '';
			formData.materialCategoryName = '';
			formData.materialCategoryId = '';
		}
	} catch (error) {
		console.error('获取归属部门列表失败:', error);
	}
};

const searchAuditors = async () => {
	auditorSearchLoading.value = true;
	try {
		const res = await notification.getAuditorList(auditorSearchKey.value || '');
		if (res.data && Array.isArray(res.data)) {
			auditorListFull.value = res.data.map(item => ({
				teacherId: item.teacherId || item.id,
				teacherName: item.teacherName || item.name,
				teacherAccount: item.teacherAccount || item.accountName || item.userAccount || ''
			}));
		} else {
			auditorListFull.value = [];
		}
	} catch (error) {
		console.error('搜索审核人失败:', error);
		auditorListFull.value = [];
	} finally {
		auditorSearchLoading.value = false;
	}
};

const handleAuditorSearchInput = () => {
	if (auditorSearchTimer) {
		clearTimeout(auditorSearchTimer);
	}
	auditorSearchTimer = setTimeout(() => {
		searchAuditors();
	}, 500);
};

const clearAuditorSearch = () => {
	auditorSearchKey.value = '';
	searchAuditors();
};

const openAuditorDialog = () => {
	auditorDialogRef.value.OpenDialog('bottom');
	// 初始化选中状态
	if (formData.auditorId) {
		selectedAuditor.value = {
			teacherId: formData.auditorId,
			teacherName: formData.auditorName
		};
	} else {
		selectedAuditor.value = null;
	}
	auditorSearchKey.value = '';
	auditorListFull.value = [];
	searchAuditors();
};

const closeAuditorDialog = () => {
	auditorDialogRef.value.CloseDialog();
};

const selectAuditor = (item) => {
	selectedAuditor.value = item;
};

const confirmAuditorSelection = () => {
	if (!selectedAuditor.value) {
		uni.showToast({ title: '请选择审核人', icon: 'none' });
		return;
	}
	formData.auditorName = selectedAuditor.value.teacherName;
	formData.auditorId = selectedAuditor.value.teacherId;
	closeAuditorDialog();
};

onMounted(() => {
	initSafeArea();
});

onLoad(async (options) => {
	await Promise.all([
		fetchAcademicYearList(),
		fetchCategoryList()
	]);

	if (options && options.id) {
		isEdit.value = true;
		editId.value = options.id;
		fetchTaskDetail(options.id);
	}
});

const fetchTaskDetail = async (id) => {
	try {
		const res = await notification.find_collection_task_target_list({ id });
		if (res.data) {
			const data = res.data;
			formData.taskName = data.taskName || '';
			const content = data.noticeContent || data.content || '';
			formData.collectRequirement = content.replace(/<[^>]+>/g, '');
			formData.startTime = data.startTime || '';
			formData.endTime = data.endTime || '';
			formData.auditMechanism = data.auditMechanism ? 1 : 0;
			formData.auditorId = data.auditorId || '';
			formData.auditorName = data.auditorName || '';
			formData.departmentName = data.departmentName || '';
			formData.materialCategoryName = data.materialCategoryName || '';
			formData.schoolYearName = data.schoolYearName || '';

			if (data.departmentId) {
				formData.departmentId = data.departmentId;
				const idx = categoryData.value.findIndex(item => item.id === data.departmentId);
				if (idx >= 0) {
					categoryIndex.value = idx + 1;
					const selectedCategory = categoryData.value[idx];
					const childList = selectedCategory?.childList || [];
					materialTypeOptions.value = ['全部类目', ...childList.map(child => child.categoryName || child.name)];
				}
			}

			if (data.materialCategory) {
				formData.materialCategoryId = data.materialCategory;
				if (categoryIndex.value > 0) {
					const selectedCategory = categoryData.value[categoryIndex.value - 1];
					const childList = selectedCategory?.childList || [];
					const materialIdx = childList.findIndex(item => item.id === data.materialCategory);
					if (materialIdx >= 0) {
						materialTypeIndex.value = materialIdx + 1;
						formData.materialCategoryName = childList[materialIdx].categoryName || childList[materialIdx].name || '';
					}
				}
			}

			if (data.noticeType) {
				const typeMap = {
					1: '按部门',
					2: '按学科',
					3: '按年级',
					4: '按权限',
					5: '按学生'
				};
				objectTypeLabel.value = typeMap[data.noticeType] || '';
				originalNoticeType.value = data.noticeType;
			}

			if (data.userList && Array.isArray(data.userList)) {
				selectedUsers.value = data.userList.map(user => ({
					id: user.userId || user.id,
					name: user.thirdName || user.name,
					userId: user.userId,
					thirdCode: user.thirdCode || user.userAccount || '',
					userAccount: user.userAccount || user.thirdCode,
					departmentName: user.departmentName || '',
					groupName: user.groupName || '',
					subjectName: user.subjectName || '',
					gradeName: user.gradeName || '',
					classTypeName: user.classTypeName || '',
					className: user.className || '',
					roleName: user.roleName || ''
				}));
				selectedCount.value = selectedUsers.value.length;
			}
		}
	} catch (error) {
		console.error('获取任务详情失败:', error);
	}
};

onShow(() => {
	const result = uni.getStorageSync('selectObjectResult');
	if (result) {
		try {
			const data = JSON.parse(result);
			if (data) {
				objectTypeLabel.value = data.tab;
				selectedCount.value = data.count;
				selectedUsers.value = data.users;
			}
		} catch (e) {
			console.error('解析选择结果失败:', e);
		}
		uni.removeStorageSync('selectObjectResult');
	}

	const personResult = uni.getStorageSync('personListResult');
	if (personResult) {
		try {
			const data = JSON.parse(personResult);
			if (data && data.users) {
				selectedUsers.value = data.users;
				selectedCount.value = data.users.length;
			}
		} catch (e) {
			console.error('解析人员列表结果失败:', e);
		}
		uni.removeStorageSync('personListResult');
	}
});

const handleAcademicYearChange = (e) => {
	const idx = e.detail.value;
	academicYearIndex.value = idx;
	formData.schoolYearName = academicYearOptions.value[idx];
	formData.schoolYearId = academicYearIds.value[idx];
	formData.schoolYearCode = academicYearCodes.value[idx];
};

const handleCategoryChange = (e) => {
	categoryIndex.value = e.detail.value;
	materialTypeIndex.value = 0;
	if (categoryIndex.value === 0) {
		materialTypeOptions.value = ['全部类目'];
		formData.departmentName = '';
		formData.departmentId = '';
		formData.materialCategoryName = '';
		formData.materialCategoryId = '';
	} else {
		const selectedCategory = categoryData.value[categoryIndex.value - 1];
		const categoryName = selectedCategory?.categoryName || selectedCategory?.name || '';
		formData.departmentName = categoryName;
		formData.departmentId = selectedCategory?.id || '';
		const childList = selectedCategory?.childList || [];
		materialTypeOptions.value = ['全部类目', ...childList.map(child => child.categoryName || child.name)];
		formData.materialCategoryName = '';
		formData.materialCategoryId = '';
	}
};

const handleMaterialTypeChange = (e) => {
	materialTypeIndex.value = e.detail.value;
	if (categoryIndex.value === 0) {
		formData.materialCategoryName = '';
		formData.materialCategoryId = '';
	} else {
		const selectedCategory = categoryData.value[categoryIndex.value - 1];
		const childList = selectedCategory?.childList || [];
		if (materialTypeIndex.value === 0) {
			formData.materialCategoryName = '';
			formData.materialCategoryId = '';
		} else {
			const selectedChild = childList[materialTypeIndex.value - 1];
			formData.materialCategoryName = selectedChild?.categoryName || selectedChild?.name || '';
			formData.materialCategoryId = selectedChild?.id || '';
		}
	}
};

const onStartDateChange = (e) => {
	formData.startTime = e.detail.value;
};

const onEndDateChange = (e) => {
	formData.endTime = e.detail.value;
};

const goBack = () => {
	uni.navigateBack();
};

const selectObject = () => {
	const lastSelection = {
		tab: objectTypeLabel.value,
		users: selectedUsers.value,
		noticeType: originalNoticeType.value || getNoticeTypeValue(objectTypeLabel.value),
		isEdit: isEdit.value
	};
	uni.setStorageSync('selectObjectLastSelection', JSON.stringify(lastSelection));
	uni.navigateTo({ url: '/pages/materialCollection/taskOverview/components/selectObjectNoDedup' });
};

const goPersonList = () => {
	if (selectedUsers.value.length === 0) {
		return;
	}
	const data = {
		tab: objectTypeLabel.value,
		users: selectedUsers.value
	};
	uni.setStorageSync('personListData', JSON.stringify(data));
	uni.navigateTo({ url: '/pages/materialCollection/taskOverview/components/personList' });
};

const getNoticeTypeValue = (tab) => {
	const map = {
		'按部门': 1,
		'按学科': 2,
		'按年级': 3,
		'按权限': 4,
		'按学生': 5
	};
	return map[tab] || 1;
};

const handleSave = async () => {
	if (!formData.schoolYearId) {
		uni.showToast({ title: '请选择学年学期', icon: 'none' });
		return;
	}
	if (!formData.departmentId) {
		uni.showToast({ title: '请选择归属部门', icon: 'none' });
		return;
	}
	if (!formData.materialCategoryId) {
		uni.showToast({ title: '请选择材料类目', icon: 'none' });
		return;
	}
	if (!formData.taskName) {
		uni.showToast({ title: '请输入任务名称', icon: 'none' });
		return;
	}
	if (!formData.collectRequirement) {
		uni.showToast({ title: '请输入采集要求', icon: 'none' });
		return;
	}
	if (!formData.startTime || !formData.endTime) {
		uni.showToast({ title: '请选择采集周期', icon: 'none' });
		return;
	}
	if (formData.auditMechanism === 1 && !formData.auditorId) {
		uni.showToast({ title: '请选择审核人', icon: 'none' });
		return;
	}
	if (!objectTypeLabel.value) {
		uni.showToast({ title: '请选择采集对象', icon: 'none' });
		return;
	}
	if (selectedUsers.value.length === 0) {
		uni.showToast({ title: '请选择采集人员', icon: 'none' });
		return;
	}

	uni.showLoading({ title: '保存中...' });

	try {
		const objectType = getNoticeTypeValue(objectTypeLabel.value);
		const params = {
			schoolYearCode: formData.schoolYearCode,
			schoolYearId: formData.schoolYearId,
			departmentId: formData.departmentId,
			materialCategory: formData.materialCategoryId,
			taskName: formData.taskName,
			noticeContent: btoa(unescape(encodeURIComponent(formData.collectRequirement))),
			startTime: formData.startTime,
			endTime: formData.endTime,
			auditMechanism: formData.auditMechanism,
			auditorId: formData.auditorId,
			auditorName: formData.auditorName,
			noticeType: objectType,
			fileList: []
		};

		if (isEdit.value && editId.value) {
			params.id = editId.value;
		}

		const userList = selectedUsers.value.map(user => {
			return {
				userType: objectType === 5 ? 2 : 1,
				userId: user.userId || user.id,
				thirdName: user.name,
				thirdCode: user.thirdCode || '',
				gradeName: user.gradeName || '',
				classTypeName: user.classTypeName || '',
				className: user.className || '',
				departmentName: user.departmentName || '',
				groupName: user.groupName || '',
				subjectName: user.subjectName || '',
				roleName: user.roleName || ''
			};
		});

		if (userList.length > 0) {
			params.userList = userList;
		}

		const res = await notification.save_collection_task(params);
		if (res.code === 200) {
			uni.showToast({ title: '保存成功', icon: 'success' });
			setTimeout(() => {
				uni.navigateBack();
			}, 1500);
		} else {
			uni.showToast({ title: res.message || '保存失败', icon: 'none' });
		}
	} catch (error) {
		console.error('保存失败:', error);
		uni.showToast({ title: '保存失败', icon: 'none' });
	} finally {
		uni.hideLoading();
	}
};
</script>

<style lang="scss" scoped>
.page_publish {
	min-height: 100vh;
	background-color: #FFFFFF;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
}

.publish_content {
	flex: 1;
	box-sizing: border-box;
	padding-top: 36rpx;
	padding-left: 24rpx;
	padding-right: 24rpx;
}

.form_item {
	background-color: #FFFFFF;
	border-radius: 8rpx;
	padding-bottom: 24rpx;
	margin-bottom: 24rpx;
	border-bottom: 2rpx solid #F3F3F3;
	&:last-child {
		border-bottom: none;
	}
	.form_label {
		font-size: 28rpx;
		color: #666666;
		font-weight: 400;
		white-space: nowrap;
		flex-shrink: 0;
		margin-right: 16rpx;

		&::after {
			content: ':';
			margin-left: 8rpx;
		}
	}

	.form_row {
		display: flex;
		align-items: flex-start;

		.form_content {
			flex: 1;
		}
	}

	.form_row_type {
		align-items: center;

		.filter_item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 16rpx;
			height: 72rpx;
			line-height: 72rpx;
			background-color: #FFFFFF;
			border-radius: 8rpx;
			width: 320rpx;
			border: 2rpx solid #DCDFE6;

			.filter_text {
				font-size: 28rpx;
				color: #333333;
				margin-right: 8rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				&.placeholder {
					color: #909399;
				}
			}
		}
	}

	.form_input {
		font-size: 28rpx;
		color: #333333;
		padding: 0 24rpx;
		background-color: #FFFFFF;
		border-radius: 8rpx;
		width: 100%;
		height: 72rpx;
		box-sizing: border-box;
		border: 2rpx solid #E9E9E9;
	}

	.textarea_container {
		position: relative;

		.form_textarea {
			width: 100%;
			height: 240rpx;
			font-size: 28rpx;
			color: #333333;
			line-height: 1.6;
			padding: 14rpx 24rpx;
			background-color: #FFFFFF;
			border-radius: 8rpx;
			box-sizing: border-box;
			border: 2rpx solid #E9E9E9;
		}
	}

	.date_range {
		display: flex;
		align-items: center;
		gap: 16rpx;

		.date_range_item {
			display: flex;
			align-items: center;
			gap: 8rpx;
			padding: 0 16rpx;
			height: 72rpx;
			background-color: #FFFFFF;
			border-radius: 8rpx;
			border: 2rpx solid #DCDFE6;

			.date_text {
				font-size: 28rpx;
				color: #333333;
				&.placeholder {
					color: #909399;
				}
			}
		}

		.date_separator {
			font-size: 28rpx;
			color: #999999;
		}
	}

	.object_row {
		display: flex;
		align-items: center;
		justify-content: space-between;

		.object_info {
			display: flex;
			align-items: center;
			gap: 12rpx;

			.object_count {
				font-size: 28rpx;
				color: #2E64FA;
			}
		}

		.object_action {
			display: flex;
			align-items: center;
			gap: 8rpx;

			.action_text {
				font-size: 28rpx;
				color: #2E64FA;
			}

			.action_arrow {
				font-size: 28rpx;
				color: #2E64FA;
			}
		}
	}

	.auditor_row {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 16rpx;
		height: 72rpx;
		background-color: #FFFFFF;
		border-radius: 8rpx;
		border: 2rpx solid #E9E9E9;
		box-sizing: border-box;

		.auditor_name {
			font-size: 28rpx;
			color: #333333;
			flex: 1;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			&.placeholder {
				color: #909399;
			}
		}
	}
}

// 审核人搜索弹窗样式
.auditor_search_wrap {
	padding: 24rpx;
	box-sizing: border-box;

	.auditor_search_box {
		display: flex;
		align-items: center;
		height: 72rpx;
		background: #F5F7FA;
		border-radius: 36rpx;
		padding: 0 24rpx;
		margin-bottom: 24rpx;
		gap: 16rpx;

		.auditor_search_input {
			flex: 1;
			font-size: 28rpx;
			color: #333333;
			background: transparent;
			height: 72rpx;
			line-height: 72rpx;
		}

		.auditor_search_clear {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 40rpx;
			height: 40rpx;
		}
	}

	.auditor_list {
		height: 600rpx;

		.auditor_loading {
			text-align: center;
			padding: 60rpx 0;
			font-size: 28rpx;
			color: #999999;
		}

		.auditor_empty {
			padding: 60rpx 0;
		}

		.auditor_list_content {
			.auditor_list_item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 24rpx 16rpx;
				border-bottom: 2rpx solid #F3F3F3;
				&:last-child {
					border-bottom: none;
				}
				&.active {
					background-color: rgba(46, 100, 250, 0.05);
				}

				.auditor_item_info {
					flex: 1;
					display: flex;
					flex-direction: column;
					gap: 8rpx;

					.auditor_item_name {
						font-size: 30rpx;
						color: #333333;
						font-weight: 500;
					}

					.auditor_item_account {
						font-size: 24rpx;
						color: #999999;
					}
				}

				.auditor_item_check {
					width: 44rpx;
					height: 44rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}
		}
	}

	.auditor_dialog_footer {
		display: flex;
		gap: 24rpx;
		padding-top: 24rpx;
		margin-top: 12rpx;
		border-top: 2rpx solid #F3F3F3;

		.auditor_dialog_btn {
			flex: 1;
			height: 88rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			border-radius: 12rpx;
			font-size: 30rpx;
			font-weight: 500;
		}

		.cancel_btn {
			background: #F0F2F9;
			color: #606266;
		}

		.confirm_btn {
			background: #2E64FA;
			color: #FFFFFF;
		}
	}
}

.publish_footer {
	padding: 24rpx;
	background-color: #FFFFFF;

	.confirm_btn {
		width: 702rpx;
		height: 90rpx;
		background: #2E64FA;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		text-align: center;
		line-height: 90rpx;
		.btn_text {
			font-size: 32rpx;
			font-weight: 500;
			color: #FFFFFF;
		}
	}
}
</style>