<template>
	<div class="navigation-container">
		<div class="map-stage" ref="mapStage">
				<div class="main-content">
			<!-- 当前操作类型标记 -->
			<div class="hand-ment-mark">
				<el-tag type="danger" effect="dark" size="mini" v-if="nowHandMenu">{{ nowHandMenu }}</el-tag>
			</div>
			
			<!-- 障碍物警告提示 -->
			<div class="obstacle-warning" v-if="obstacleWarning.show" :class="'obstacle-' + obstacleWarning.level">
				<div class="warning-content">
					<div class="warning-icon">
						<i class="el-icon-warning-outline" v-if="obstacleWarning.level === 'warning'"></i>
						<i class="el-icon-error" v-if="obstacleWarning.level === 'danger'"></i>
						<i class="el-icon-info" v-if="obstacleWarning.level === 'info'"></i>
					</div>
					<div class="warning-text">
						<div class="warning-title">障碍物检测</div>
						<div class="warning-message">{{ obstacleWarning.message }}</div>
						<div class="obstacle-distances" v-if="obstacleData.left > 0 || obstacleData.front > 0 || obstacleData.right > 0">
							<span v-if="obstacleData.left > 0" class="distance-item">
								左: {{ obstacleData.left.toFixed(1) }}m
							</span>
							<span v-if="obstacleData.front > 0" class="distance-item">
								前: {{ obstacleData.front.toFixed(1) }}m
							</span>
							<span v-if="obstacleData.right > 0" class="distance-item">
								右: {{ obstacleData.right.toFixed(1) }}m
							</span>
						</div>
					</div>
					<div class="warning-close" @click="closeObstacleWarning">
						<i class="el-icon-close"></i>
					</div>
				</div>
			</div>
			
			<!-- 遇障停车提示（基于run_state） -->
			<div class="obstacle-stop-warning" v-if="obstacleStopState.showWarning">
				<div class="stop-warning-content">
					<div class="countdown-circle">
						<div class="countdown-number">
							{{ obstacleStopState.replanTimeLeft > 999 ? '999+' : obstacleStopState.replanTimeLeft }}
						</div>
						<div class="countdown-label">秒</div>
					</div>
					<div class="stop-warning-text">
						<div class="stop-warning-title">遇障停车</div>
						<div class="stop-warning-message">检测到前方障碍物，系统将自动重规划路径</div>
						<div class="stop-warning-state">当前状态: {{ obstacleStopState.runStateText }}</div>
					</div>
					<div class="stop-warning-actions">
						<el-button 
							type="primary" 
							size="small" 
							@click="handleReplanRequest"
							:disabled="obstacleStopState.isReplanning"
						>
							{{ obstacleStopState.isReplanning ? '重规划中...' : '立即重规划' }}
						</el-button>
					</div>
				</div>
			</div>
			
			<!-- 地图组件 - 完全保持原样 -->
					<OlMap ref="olmap" :width="olWidth + 'px'" :height="olHeight + 'px'" backgroundColor="#F5F5F5" :mapName="mapName"
						:pointSwitch="settingParams.pointId" :baseLayerShow="settingParams.baseMap" :robotPoseData="laserPositionData"
				:pointSelectionEnabled="selectPointMode" :poseInitEnable="initPoseMode" @addNowPoint="addNowPoint"
				:isRobotFollow="settingParams.follow" @initNavigationResult="initNavigationResult"
				:showPointcloud="settingParams.pointCloud"
				:showRoadNetwork="settingParams.showRoadNetwork"
				:showDefaultControls="false"></OlMap>
			
			<!-- 左侧工具条浮层 -->
			<MapToolbar 
				class="nav-toolbar"
				preset="nav"
				:selectedKey="selectedKey"
				:hasRobotPosition="true"
				:isConnected="true"
				:isBusy="false"
				:isFullscreen="isFullscreen"
				@zoom-in="onZoomIn"
				@zoom-out="onZoomOut"
				@center-robot="onCenterRobot"
				@toggle-fullscreen="onToggleFullscreen"
				@confirm-init="handleConfirmInit"
				@confirm-reboot="handleConfirmReboot"
				@confirm-stop="handleConfirmStop"
			/>
			
			<!-- 右侧信息面板浮层 -->
		<RightPanel
			mode="nav"
			panelType="nav"
			:overlay="true"
			:visible.sync="rightVisible"
			:realtime-info="realtimeInfo"
			:waypoint-list="waypoints"
			:task-list="tasks"
			:setting-params="settingParams"
			:emergency-stop-enabled="emergencyStopEnabled"
			:navigation-stack-status="navigationStackStatus"
			:current-navigation-task="currentNavigationTask"
			:navigation-status="navigationStatus"
			:is-navigating="isNavigating"
			@wp-select="onWpSelect"
			@wp-send="onWpSend"
			@wp-create="onWpCreate"
			@wp-edit="onWpEdit"
			@wp-remove="onWpRemove"
			@wp-move-up="onWpMoveUp"
			@wp-move-down="onWpMoveDown"
			@wp-batch-remove="onWpBatchRemove"
			@wp-goto="onWpGoto"
			@wp-goto-single="onWpGotoSingle"
			@wp-create-task="onWpCreateTask"
			@wp-selection-change="onWpSelectionChange"
			@map-select-mode-change="onMapSelectModeChange"
			@task-view="onTaskView"
			@task-edit="onTaskEdit"
			@task-start="onTaskStart"
			@task-pause="onTaskPause"
			@task-resume="onTaskResume"
			@task-stop="onTaskStop"
			@task-remove="onTaskRemove"
			@setting-change="onSettingChange"
			@emergency-stop-release="executeEmergencyStopRelease"
			@navigation-pause="handleNavigationPause"
			@navigation-resume="handleNavigationResume"
			@navigation-stop="handleNavigationStop"
		/>
			
				</div>
		<!-- 目标点编辑对话框 -->
		<el-dialog 
			title="目标点编辑" 
			:visible.sync="pointEditDiaShow" 
			width="480px" 
			@close="clearActionDia"
			class="waypoint-edit-dialog"
			:close-on-click-modal="false"
			center
		>
			<div class="dialog-content">
				<el-form :model="pointEditData" label-width="90px" size="small" class="waypoint-form">
					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-location-outline"></i>
							位置信息
						</h4>
						<!-- 分两行布局，给输入框更多空间 -->
						<el-form-item label="X坐标(m)">
							<el-input v-model="pointEditData.x" placeholder="请输入X坐标值" class="coordinate-input">
							</el-input>
						</el-form-item>
						<el-form-item label="Y坐标(m)">
							<el-input v-model="pointEditData.y" placeholder="请输入Y坐标值" class="coordinate-input">
							</el-input>
						</el-form-item>
					</div>

					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-guide"></i>
							路径配置
						</h4>
						<el-form-item label="规划类型">
							<el-select v-model="pointEditData.type" placeholder="请选择路径类型" style="width: 100%">
				<el-option v-for="item in planOptions" :key="item.value" :label="item.label" :value="item.value">
									<span style="float: left">{{ item.label }}</span>
									<span style="float: right; color: #8492a6; font-size: 13px">{{ item.value === 0 ? '自由规划' : '路网约束' }}</span>
				</el-option>
			</el-select>
						</el-form-item>
					</div>

					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-setting"></i>
							动作配置
							<el-button type="text" size="mini" @click="appendActionMenu" class="add-action-btn">
								<i class="el-icon-plus"></i><span>添加动作</span>
							</el-button>
						</h4>
						<div class="action-list">
							<div v-for="(item, index) in pointEditData.actionMenuList" :key="index" class="action-item">
								<div class="action-header">
									<span class="action-index">{{ index + 1 }}</span>
									<el-select v-model="item.value" placeholder="请选择动作" size="small" @change="changeAction(index)" style="flex: 1;">
										<el-option v-for="option in actionOptions" :key="option.value" :label="option.label" :value="option.value"></el-option>
				</el-select>
									<el-button v-if="index > 0" type="text" size="mini" @click="removeActionMenu(index)" class="remove-btn">
										<i class="el-icon-close"></i>
									</el-button>
								</div>
								<div v-if="'other' in item" class="action-params">
									<el-input v-model="item.other" placeholder="等待时间" size="small" style="width: 120px;">
										<template slot="append">秒</template>
									</el-input>
								</div>
							</div>
						</div>
					</div>
				</el-form>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="pointEditDiaShow = false" size="medium">取 消</el-button>
				<el-button type="primary" @click="submitEditPoint" size="medium">
					<i class="el-icon-check"></i> 保存修改
				</el-button>
			</span>
		</el-dialog>
		<!-- 创建任务对话框 -->
		<el-dialog 
			title="创建任务" 
			:visible.sync="taskGenerateDiaShow" 
			width="480px" 
			@close="closeTaskGenerate"
			class="task-create-dialog"
			:close-on-click-modal="false"
			center
		>
			<div class="dialog-content">
				<el-form :model="generateTaskParam" label-width="90px" size="small" class="task-form">
					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-s-order"></i>
							任务信息
						</h4>
						<el-form-item label="任务名称">
							<el-input v-model="generateTaskParam.taskName" placeholder="请输入任务名称" class="task-input">
							</el-input>
						</el-form-item>
						<el-form-item label="执行次数">
							<el-input-number 
								v-model="generateTaskParam.count"
								controls-position="right" 
								:min="1" 
								:max="100" 
								class="task-input-number"
								style="width: 100%"
							></el-input-number>
						</el-form-item>
					</div>
					
					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-time"></i>
							执行计划
						</h4>
					<el-form-item label="开始时间">
						<el-time-picker 
							v-model="generateTaskParam.time" 
							format="HH:mm"
							value-format="HH:mm:ss"
							:picker-options="{
				selectableRange: '00:00:00 - 23:59:59'
							}" 
							placeholder="选择时间"
							class="task-time-picker"
							style="width: 100%"
						>
			</el-time-picker>
					</el-form-item>
						<el-form-item label="执行日期">
							<el-checkbox-group v-model="generateTaskParam.date" class="task-date-group">
					<el-checkbox label="1">周一</el-checkbox>
					<el-checkbox label="2">周二</el-checkbox>
					<el-checkbox label="3">周三</el-checkbox>
					<el-checkbox label="4">周四</el-checkbox>
					<el-checkbox label="5">周五</el-checkbox>
					<el-checkbox label="6">周六</el-checkbox>
					<el-checkbox label="7">周日</el-checkbox>
				</el-checkbox-group>
						</el-form-item>
					</div>
				</el-form>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="closeTaskGenerate()" size="medium">取 消</el-button>
				<el-button type="primary" @click="submitTaskGenerate" size="medium">
					<i class="el-icon-check"></i> 创建任务
				</el-button>
			</span>
		</el-dialog>
		
		<!-- 任务编辑对话框 -->
		<el-dialog 
			title="编辑任务" 
			:visible.sync="taskEditDiaShow" 
			width="480px" 
			@close="closeTaskEdit"
			class="task-create-dialog"
			:close-on-click-modal="false"
			center
		>
			<div class="dialog-content">
				<el-form :model="editTaskParam" label-width="90px" size="small" class="task-form">
					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-s-order"></i>
							任务信息
						</h4>
						<el-form-item label="任务名称">
							<el-input v-model="editTaskParam.taskName" placeholder="请输入任务名称" class="task-input">
							</el-input>
						</el-form-item>
						<el-form-item label="执行次数">
							<el-input-number 
								v-model="editTaskParam.count"
								controls-position="right" 
								:min="1" 
								:max="100" 
								class="task-input-number"
								style="width: 100%"
							></el-input-number>
						</el-form-item>
					</div>
					
					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-time"></i>
							执行计划
						</h4>
					<el-form-item label="开始时间">
						<el-time-picker 
							v-model="editTaskParam.time" 
							format="HH:mm"
							value-format="HH:mm:ss"
							:picker-options="{
				selectableRange: '00:00:00 - 23:59:59'
							}" 
							placeholder="选择时间"
							class="task-time-picker"
							style="width: 100%"
						>
			</el-time-picker>
					</el-form-item>
						<el-form-item label="执行日期">
							<el-checkbox-group v-model="editTaskParam.date" class="task-date-group">
					<el-checkbox label="1">周一</el-checkbox>
					<el-checkbox label="2">周二</el-checkbox>
					<el-checkbox label="3">周三</el-checkbox>
					<el-checkbox label="4">周四</el-checkbox>
					<el-checkbox label="5">周五</el-checkbox>
					<el-checkbox label="6">周六</el-checkbox>
					<el-checkbox label="7">周日</el-checkbox>
				</el-checkbox-group>
						</el-form-item>
					</div>
				</el-form>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="closeTaskEdit()" size="medium">取 消</el-button>
				<el-button type="primary" @click="submitTaskEdit" size="medium">
					<i class="el-icon-check"></i> 保存修改
				</el-button >
			</span>
		</el-dialog>
		
		<!-- 任务查看对话框 - 已改为直接在地图上回显点位，不再需要弹窗 -->
		<!-- <el-dialog 
			title="任务详情" 
			:visible.sync="taskViewDiaShow" 
			width="480px" 
			class="task-view-dialog"
			:close-on-click-modal="false"
			center
		>
			<div class="dialog-content">
				<el-form :model="taskViewData" label-width="90px" size="small" class="task-view-form">
					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-s-order"></i>
							任务信息
						</h4>
						<el-form-item label="任务名称">
							<span class="form-text">{{ taskViewData.taskName || '--' }}</span>
						</el-form-item>
						<el-form-item label="执行次数">
							<span class="form-text">{{ taskViewData.count || '--' }}次</span>
						</el-form-item>
						<el-form-item label="任务状态">
							<span class="form-text status-text" :class="getTaskStatusClass(taskViewData.status)">
								{{ getTaskStatusText(taskViewData.status) }}
							</span>
						</el-form-item>
					</div>
					
					<div class="form-section">
						<h4 class="section-title">
							<i class="el-icon-time"></i>
							执行计划
						</h4>
						<el-form-item label="开始时间">
							<span class="form-text">{{ formatTime(taskViewData.time) }}</span>
						</el-form-item>
						<el-form-item label="执行日期">
							<span class="form-text">{{ formatDate(taskViewData.date) }}</span>
						</el-form-item>
					</div>

				</el-form>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="taskViewDiaShow = false" size="medium">关 闭</el-button>
			</span>
		</el-dialog> -->
		</div>
		<MqttComp ref="mqtt" :topics="topics" @message-received="onMessage" />
	</div>
</template>

<script>
import OlMap from "@/components/OlMap";
import { MapToolbar, RightPanel } from "./components/shared";
import { FullscreenOperations, RobotPositionUtils } from "@/utils/map-operations";
import { listTask, addTask, delTask, getTask } from "@/api/map/task";

import MqttComp from "@/components/Mqtt/mqttComp.vue";
export default {
	name: "NavigationPage",
	components: {
		OlMap,
		MapToolbar,
		RightPanel,
		MqttComp
	},
	data() {
		return {
			topics:[
				{ topic: this.$mqttPrefix+'/localization/action/init/reply', qos: 2, retain: false },
				{ topic:this.$mqttPrefix + '/localization/pose'},
				{ topic: this.$mqttPrefix + '/sensor/battery'},
				// 路径规划相关主题
				{ topic: this.$mqttPrefix + '/planning/service/plan/response', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/planning/trajectory/2d/compact', qos: 2, retain: true },
				{ topic: this.$mqttPrefix + '/planning/action/replan/reply', qos: 2, retain: false },
				// 任务下发相关主题
				{ topic: this.$mqttPrefix + '/task/target/action/goto/reply', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/task/target/event/arrive', qos: 2, retain: true },
				// 任务管理相关主题
				{ topic: this.$mqttPrefix + '/task/agent/action/exec/reply', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/task/agent/event/complete', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/task/realtime/info', qos: 0, retain: false },
				// 任务控制相关主题
				{ topic: this.$mqttPrefix + '/task/procedure/action/start/reply', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/task/procedure/action/pause/reply', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/task/procedure/action/resume/reply', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/task/procedure/action/cancel/reply', qos: 2, retain: false },
				// 导航控制相关主题
				{ topic: this.$mqttPrefix + '/navigation/stack/action/start/reply', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/navigation/stack/action/stop/reply', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/ability/function/action/exec/reply', qos: 2, retain: false },
				// 急停控制相关主题
				{ topic: this.$mqttPrefix + '/control/vehicle/action/stop/reply', qos: 2, retain: false },
				{ topic: this.$mqttPrefix + '/control/vehicle/property/stop', qos: 2, retain: true },
				// 障碍物感知相关主题
				{ topic: this.$mqttPrefix + '/perception/simple/obstacle', qos: 0, retain: false }
				],
			nowHandMenu: '',
		mapName: this.$route.query.mapName || '',  // 地图名称（从query参数获取）
			// 激光定位数据
			laserPositionData: {
        x: 0,
        y: 0,
        angle: 0
      },
			activeIndex: -1, // 默认为没有激活的项
			settingDrawer: false,
			pointDrawer: false,
			taskDrawer: false,
			pointEditDiaShow: false,
			taskGenerateDiaShow: false,
			taskEditDiaShow: false,
			taskViewDiaShow: false,
			// 是否开启地图选点
			pointSelectionEnabled: false,
			// 是否开启位置初始化功能
			poseInitEnable: false,
			// 功能设置参数
			settingParams: {
				pointCloud: false,
				baseMap: true,
				pointId: false,
				follow: false,
				network: false,
				showRoadNetwork: true // 控制路网线段显示
			},
			// 非单个禁用
			single: true,
			// 非多个禁用
			multiple: true,
			taskDataList: [],
			// 目标点的编辑数据
			pointEditData: {
				id: '',
				x: '',
				y: '',
				type: '',
				// 添加动作菜单列表 (other:追加参数,例如原定等待选项的等待时间)
				actionMenuList: []
			},
			// 生成任务的参数
			generateTaskParam: {
				taskId: '',
				taskName: '',
				count: 1,
				time: '',
				date: []  // 1-7分别指代周一到周末
			},
			
			// 编辑任务的参数
			editTaskParam: {
				originalTaskName: '', // 原始任务名（用于删除旧任务）
				taskId: '',
				taskName: '',
				count: 1,
				time: '',
				date: [],
				selectedWaypoints: []
			},
			
			// 任务查看数据
			taskViewData: {},
			// 点位列表
			pointList: [],
			pointIds: [],
			// 路径类型
			planOptions: [
				{ label: '自由路径', value: 0 },
				{ label: '路网路径', value: 1 }
			],
			// 动作类型
			actionOptions: [
				{ label: '原地等待', value: 0 },
				{ label: '开始录制', value: 1 },
				{ label: '结束录制', value: 2 },
				{ label: '添加建图轨迹', value: 3 },
				{ label: '挂钩挂载', value: 4 },
				{ label: '挂钩卸载', value: 5 }
			],
			olWidth: 0,  // 用于存储宽度的变量
			olHeight: 0,
			nowHandMenu: '',
			
			// 新UI相关状态
			panelVisible: true, // 右侧面板是否可见（旧的，保留兼容）
			rightVisible: true, // 导航页右侧面板是否可见
			activeTab: 'info', // 当前激活的tab
			lastTab: 'info', // 上次激活的tab
			selectPointMode: false, // 选点模式
			initPoseMode: false, // 初始化位姿模式
			// Mock任务数据
			mockTasks: [
				{ id: 1, name: '巡检任务A', nodes: 5, status: 'idle' },
				{ id: 2, name: '运输任务B', nodes: 3, status: 'running' },
				{ id: 3, name: '清扫任务C', nodes: 8, status: 'paused' }
			],
	// 实时信息数据
	realtimeInfo: {
		currentMap: this.$route.query.mapName || 'Unknown',
			currentTask: '',
			speed: '',
			speedCommand: '',
			coordinates: '',
			heading: '',
			totalDistance: '',
			registrationError: '',
			batteryLevel: ''
		},
		
		// 机器人位姿数据（用于OlMap组件）
		robotPoseData: {
			x: 1.813,
			y: -63.931,
			angle: 0.000
		},
			// 连接和状态
			isConnected: true,
			isBusy: false,
			isFullscreen: false,
			
			// 导航和急停状态
			navigationStackStatus: 'unknown', // unknown, started, stopped
			emergencyStopEnabled: false, // 急停状态
			
			// 全屏监听清理函数
			fullscreenCleanup: null,

			// 目标点相关状态
			selectedWaypointIds: [], // 选中的目标点ID列表
			waypointSingle: true, // 是否单个选中
			waypointMultiple: true, // 是否多个选中
			pointEditDiaShow: false, // 目标点编辑对话框显示状态
			
			// 目标点的编辑数据
			pointEditData: {
				id: '',
				x: '',
				y: '',
				type: '',
				// 添加动作菜单列表 (other:追加参数,例如原定等待选项的等待时间)
				actionMenuList: []
			},
			
			// 路径类型选项
			planOptions: [
				{ label: '自由路径', value: 0 },
				{ label: '路网路径', value: 1 }
			],
			
			// 动作类型选项
			actionOptions: [
				{ label: '原地等待', value: 0 },
				{ label: '开始录制', value: 1 },
				{ label: '结束录制', value: 2 },
				{ label: '添加建图轨迹', value: 3 },
				{ label: '挂钩挂载', value: 4 },
				{ label: '挂钩卸载', value: 5 }
			],
			
			// === 导航页专用数据 ===
			waypoints: [],
			// 任务下发状态跟踪
			currentNavigationTask: null, // 当前导航任务
			isNavigating: false, // 是否正在导航
			navigationStatus: 'idle', // idle, planning, navigating, arrived, failed
			lastGotoRequest: null, // 最后一次goto请求，用于匹配响应
			
			// 任务管理系统
			currentExecutingTask: null, // 当前执行的任务
			taskQueue: [], // 任务队列
			isTaskExecuting: false, // 是否正在执行任务
			taskExecutionStatus: 'idle', // idle, executing, paused, completed, failed, cancelled
			currentTaskWaypointIndex: 0, // 当前任务执行到的目标点索引
			taskRealtimeInfo: {
				odom: { total: 0, remain: 0 },
				time: { total: 0, remain: 0, duration: 0 },
				driveMode: 'auto',
				autoReady: true
			}, // 任务实时信息
			lastTaskExecRequest: null, // 最后一次任务执行请求
			tasks: [],
			
			// 任务查看相关
			currentViewTaskWaypointIds: [], // 当前查看任务的点位ID列表
			taskViewAutoCloseTimer: null, // 任务查看自动关闭定时器
			
			// 任务列表定时刷新
			taskListTimer: null, // 任务列表定时查询定时器
			
			// 定时任务调度状态（今日相关）- 基于现有MQTT推断
			scheduledTasksToday: [], // 今日应执行的定时任务列表（从cron计算）
			scheduledTasksExecuted: [], // 今日已执行的定时任务名称列表
			currentScheduledTask: null, // 当前正在执行的定时任务 { name, startTime, status }
			lastTaskStartTime: {}, // 记录每个任务最后一次启动时间，格式：{ taskName: timestamp }
			
			// 定时任务自动执行
			autoExecuteTimer: null, // 自动执行定时器
			autoExecuteEnabled: true, // 是否启用自动执行定时任务
			
			// 障碍物检测相关
			obstacleData: {
				left: 0,    // 左侧障碍物距离(m)
				front: 0,   // 前方障碍物距离(m)  
				right: 0,   // 右侧障碍物距离(m)
				timestamp: 0 // 数据时间戳
			},
			obstacleWarning: {
				show: false,        // 是否显示警告
				level: 'info',      // 警告级别: info, warning, danger
				message: '',        // 警告消息
				direction: '',      // 障碍物方向
				distance: 0,        // 最近障碍物距离
				autoHideTimer: null // 自动隐藏定时器
			},
			obstacleSettings: {
				warningDistance: 3.0,  // 警告距离阈值(m)
				dangerDistance: 1.0,   // 危险距离阈值(m)
				autoHideDelay: 5000,   // 自动隐藏延迟(ms)
				enableWarning: true    // 是否启用障碍物警告
			},
			
			// 遇障停车状态检测（基于run_state）
			obstacleStopState: {
				counter: 0,           // 遇障状态计数器（用于稳定检测）
				replanTimeLeft: 0,    // 重规划剩余时间（秒）
				showWarning: false,   // 是否显示遇障警告
				isReplanning: false,  // 是否正在请求重规划
				runState: 0,          // 机器人运行状态
				runStateText: '未知'  // 运行状态文本
			}
		};
	},
	computed: {
		// 当前选中的工具key
		selectedKey() {
			if (this.initPoseMode) return 'init-pose';
			return '';
		},
		
		// 机器人位置
		robotPosition() {
			// 直接使用robotPoseData，与标定页面保持一致
			if (this.robotPoseData && (this.robotPoseData.x !== 0 || this.robotPoseData.y !== 0)) {
				return [this.robotPoseData.x, this.robotPoseData.y];
			}
			return null;
		},
		
		// 是否有有效的机器人位置
		hasValidRobotPosition() {
			return !!this.robotPosition;
		},
		
		// 地图是否就绪
		isMapReady() {
			return !!this.getMapInstance();
		},
		
		// 导航状态文本
		navigationStatusText() {
			switch(this.navigationStatus) {
				case 'idle': return '空闲';
				case 'planning': return '规划中';
				case 'navigating': return '导航中';
				case 'arrived': return '已到达';
				case 'failed': return '失败';
				default: return '未知';
			}
		},
		
		// 是否可以发送新的导航任务
		canStartNavigation() {
			return !this.isNavigating && this.navigationStatus !== 'planning';
		},
		
		// 当前导航目标描述
		currentNavigationTarget() {
			if (!this.currentNavigationTask) return null;
			const waypoint = this.currentNavigationTask.waypoint;
			return `${waypoint.name || '目标点' + waypoint.id} (${waypoint.x}, ${waypoint.y})`;
		},
		
		// 任务执行状态文本
		taskExecutionStatusText() {
			switch(this.taskExecutionStatus) {
				case 'idle': return '空闲';
				case 'executing': return '执行中';
				case 'paused': return '暂停';
				case 'completed': return '已完成';
				case 'failed': return '失败';
				case 'cancelled': return '已取消';
				default: return '未知';
			}
		},
		
		// 当前执行任务描述
		currentTaskDescription() {
			if (!this.currentExecutingTask) return null;
			const task = this.currentExecutingTask;
			const progress = `${this.currentTaskWaypointIndex}/${task.points?.length || 0}`;
			return `${task.taskName} (${progress})`;
		},
		
		// 是否可以开始新任务
		canStartNewTask() {
			return !this.isTaskExecuting && !this.isNavigating;
		},
		
		// 任务实时进度信息
		taskProgressInfo() {
			if (!this.currentExecutingTask || !this.taskRealtimeInfo) return null;
			
			return {
				taskName: this.currentExecutingTask.taskName,
				waypointProgress: `${this.currentTaskWaypointIndex}/${this.currentExecutingTask.points?.length || 0}`,
				totalDistance: `${(this.taskRealtimeInfo.odom.total / 1000).toFixed(2)}km`,
				remainDistance: `${(this.taskRealtimeInfo.odom.remain / 1000).toFixed(2)}km`,
				totalTime: this.formatSeconds(this.taskRealtimeInfo.time.total),
				remainTime: this.formatSeconds(this.taskRealtimeInfo.time.remain),
				duration: this.formatSeconds(this.taskRealtimeInfo.time.duration),
				driveMode: this.taskRealtimeInfo.driveMode === 'auto' ? '自动' : '手动',
				autoReady: this.taskRealtimeInfo.autoReady
			};
		},
		
		// 今日定时任务统计信息
		todayScheduleInfo() {
			const pendingTasks = this.scheduledTasksToday.filter(
				taskName => !this.scheduledTasksExecuted.includes(taskName) && 
				(!this.currentScheduledTask || this.currentScheduledTask.name !== taskName)
			);
			
			return {
				total: this.scheduledTasksToday.length,
				executed: this.scheduledTasksExecuted.length,
				running: this.currentScheduledTask ? 1 : 0,
				pending: pendingTasks.length,
				currentRunning: this.currentScheduledTask,
				pendingList: pendingTasks
			};
		},
		
		// 是否有定时任务正在执行
		hasScheduleRunning() {
			return this.currentScheduledTask !== null;
		},
		
		// 获取今日待执行的定时任务列表
		scheduledTasksPending() {
			return this.scheduledTasksToday.filter(
				taskName => !this.scheduledTasksExecuted.includes(taskName) && 
				(!this.currentScheduledTask || this.currentScheduledTask.name !== taskName)
			);
		}
	},
watch: {
	// 监听路由变化，更新mapName（从query参数）
	'$route.query.mapName': {
		handler(newMapName, oldMapName) {
			if (newMapName && newMapName !== this.mapName) {
				console.log(`✅ 路由变化，更新mapName: ${oldMapName} -> ${newMapName}`);
				this.mapName = newMapName;
			}
		},
		immediate: false
	}
},
	created() {

	},
	mounted() {
		// const mapId = this.$route.params.mapId;	
		this.updateOlCss();
		window.addEventListener('resize', this.updateOlCss);
		
		// 地图初始化（无需额外操作，直接使用getMapInstance方法获取地图实例）
		
		// 加载任务列表
		this.loadTaskList();
		
		// 启动任务列表定时刷新（每5秒查询一次）
		this.startTaskListTimer();
		
		// 设置全屏状态监听
		this.fullscreenCleanup = FullscreenOperations.addFullscreenListener((isFullscreen) => {
			this.isFullscreen = isFullscreen;
			// 全屏状态改变后，重新计算地图尺寸
			this.$nextTick(() => {
				this.updateOlCss();
				// 触发地图重新计算尺寸
				const map = this.getMapInstance();
				if (map) {
					map.updateSize();
				}
			});
		});
		
		// 每小时重新计算一次今日定时任务（因为日期可能变化）
		setInterval(() => {
			this.calculateTodayScheduledTasks();
		}, 60 * 60 * 1000); // 1小时
		
		// 启动定时任务自动执行功能
		this.startAutoExecuteTimer();
	},
	// Vue keep-alive激活时的钩子
activated() {
	console.log('导航页面被激活');
	
	// 🔧 修复：切换页签后更新mapName（从query参数）
	const newMapName = this.$route.query.mapName || '';
	if (this.mapName !== newMapName) {
		console.log(`✅ 更新mapName: ${this.mapName} -> ${newMapName}`);
		this.mapName = newMapName;
	}
		
		// 使用$nextTick确保DOM完全渲染后再更新地图
		this.$nextTick(() => {
			// 重新计算地图容器尺寸
			this.updateOlCss();
			
			// 更新OpenLayers地图尺寸
			const map = this.getMapInstance();
			if (map) {
				// 延迟一下以确保容器尺寸已更新
				setTimeout(() => {
					map.updateSize();
					console.log('✅ 地图尺寸已更新');
				}, 100);
			}
			
			// 如果地图组件有refresh方法，也调用一下
			if (this.$refs.olmap && this.$refs.olmap.refresh) {
				setTimeout(() => {
					this.$refs.olmap.refresh();
				}, 150);
			}
		});
	},
	
	beforeDestroy() {
		window.removeEventListener('resize', this.updateOlCss);
		
		// 清理全屏监听
		if (this.fullscreenCleanup) {
			this.fullscreenCleanup();
		}
		
		// 清理任务查看定时器
		if (this.taskViewAutoCloseTimer) {
			clearTimeout(this.taskViewAutoCloseTimer);
		}
		
		// 清理任务列表定时刷新定时器
		this.stopTaskListTimer();
		
		// 清理定时任务自动执行定时器
		this.stopAutoExecuteTimer();
		
		// 清理障碍物警告定时器
		if (this.obstacleWarning.autoHideTimer) {
			clearTimeout(this.obstacleWarning.autoHideTimer);
		}
	},
	methods: {
		goto() {
			// if (this.pointIds.length !== 1) {
			// 	this.$message.warning('请选择一个点位进行前往操作');
			// 	return;
			// }
			// const point = this.pointList.find(p => p.id === this.pointIds[0]);
			// if (point) {
			// 	console.log('前往点位:', point);
			// 	this.$refs.mqtt.publish(this.$mqttPrefix + "/task/target/action/goto", {
			// 			"timestamp" : 123456,
			// 			"args"      : [
			// 					{
			// 							"roadmap" : this.mapName,
			// 							"coord"   : [[Number(point.x), Number(point.y)]]
			// 					}
			// 			]
			// 	},2,false);
			// 	this.$refs.olmap.drawPoint()
			// }
			// this.$refs.olmap.drawTrackLine(-15.491 , -57.526,10.209 , -123.223)
		},
		onMessage({ topic, message }) {
        // console.log("收到消息:", topic, message);
				if (topic === this.$mqttPrefix + '/localization/action/init/reply') {
					this.handleInitReply(message);
				} else if (topic === this.$mqttPrefix + '/localization/pose') {
					this.handleLaserPose(message);
				} else if (topic === this.$mqttPrefix + '/sensor/battery') {
					// 处理电池消息
					const data = message.args[0];
					this.realtimeInfo.batteryLevel = (data.capacity * 100).toFixed(2) + '%' || '0%';
				} else if (topic === this.$mqttPrefix + '/planning/service/plan/response') {
					// 处理路径规划响应
					this.handlePlanResponse(message);
				} else if (topic === this.$mqttPrefix + '/planning/trajectory/2d/compact') {
					// 处理当前行驶轨迹
					this.handleTrajectoryData(message);
				} else if (topic === this.$mqttPrefix + '/planning/action/replan/reply') {
					// 处理重规划响应
					this.handleReplanReply(message);
				} else if (topic === this.$mqttPrefix + '/task/target/action/goto/reply') {
					// 处理前往目标点响应
					this.handleGotoReply(message);
				} else if (topic === this.$mqttPrefix + '/task/target/event/arrive') {
					// 处理到达目标点事件
					this.handleArriveEvent(message);
				} else if (topic === this.$mqttPrefix + '/task/agent/action/exec/reply') {
					// 处理任务执行响应
					this.handleTaskExecReply(message);
				} else if (topic === this.$mqttPrefix + '/task/agent/event/complete') {
					// 处理任务完成事件
					this.handleTaskCompleteEvent(message);
				} else if (topic === this.$mqttPrefix + '/task/realtime/info') {
					// 处理任务实时信息
					this.handleTaskRealtimeInfo(message);
				} else if (topic === this.$mqttPrefix + '/task/procedure/action/start/reply') {
					// 处理任务开始响应
					this.handleTaskStartReply(message);
				} else if (topic === this.$mqttPrefix + '/task/procedure/action/pause/reply') {
					// 处理暂停任务响应
					this.handleTaskPauseReply(message);
				} else if (topic === this.$mqttPrefix + '/task/procedure/action/resume/reply') {
					// 处理继续任务响应
					this.handleTaskResumeReply(message);
				} else if (topic === this.$mqttPrefix + '/task/procedure/action/cancel/reply') {
					// 处理取消任务响应
					this.handleTaskCancelReply(message);
				} else if (topic === this.$mqttPrefix + '/navigation/stack/action/start/reply') {
					// 处理导航启动响应
					this.handleNavigationStartReply(message);
				} else if (topic === this.$mqttPrefix + '/navigation/stack/action/stop/reply') {
					// 处理导航停止响应
					this.handleNavigationStopReply(message);
				} else if (topic === this.$mqttPrefix + '/ability/function/action/exec/reply') {
					// 处理导航重启响应
					this.handleNavigationRestartReply(message);
				} else if (topic === this.$mqttPrefix + '/control/vehicle/action/stop/reply') {
					// 处理急停控制响应
					this.handleEmergencyStopReply(message);
				} else if (topic === this.$mqttPrefix + '/control/vehicle/property/stop') {
					// 处理急停状态变化
					this.handleEmergencyStopStatus(message);
				} else if (topic === this.$mqttPrefix + '/perception/simple/obstacle') {
					// 处理障碍物感知数据
					this.handleObstacleData(message);
				}
    },
		handleInitReply(message) {
			// 处理初始化回复消息
			// console.log("初始化回复:", message);
			
		},
		handleLaserPose(message) {			
			try {
        const data = message.args[0];				
        const {xyz, rpy, blh, heading} = data.pose;
        
        // 保存旧的位置数据，用于比较
        const oldX = this.laserPositionData.x;
        const oldY = this.laserPositionData.y;
        
        // 激光定位实时数据
        this.laserPositionData.x = xyz[0];
        this.laserPositionData.y = xyz[1];
        this.laserPositionData.angle = rpy[2];
        // 实时数据
				this.realtimeInfo.coordinates = `(${xyz[0]}, ${xyz[1]}, ${xyz[2]})`;
				this.realtimeInfo.heading = rpy[2] + '°'; // 航向角
				this.realtimeInfo.speed = data.vel.heading+ 'm/s'; // 速度
				this.realtimeInfo.speedCommand = data.vel.enu + 'm/s'; // 速度指令
				this.realtimeInfo.totalDistance = data.odometer + 'm'; // 总里程
				this.realtimeInfo.registrationError = data.score;
				
				// 处理运行状态（run_state）和重规划时间（replan）
				if (data.run_state !== undefined) {
					this.obstacleStopState.runState = data.run_state;
					this.obstacleStopState.runStateText = this.getRunStateText(data.run_state);
					
					// run_state为4表示遇障停车状态
					if (data.run_state === 4) {
						// 增加计数器，最大值25（避免溢出）
						if (this.obstacleStopState.counter < 25) {
							this.obstacleStopState.counter++;
						}
						// 重置重规划按钮状态
						if (this.obstacleStopState.isReplanning) {
							this.obstacleStopState.isReplanning = false;
						}
					} else {
						// 非遇障状态，减少计数器
						if (this.obstacleStopState.counter > 0) {
							this.obstacleStopState.counter--;
						}
					}
				}
				
				// 处理重规划剩余时间
				if (data.replan !== undefined) {
					this.obstacleStopState.replanTimeLeft = data.replan;
				}
				
				// 根据计数器判断是否显示遇障警告（计数器>=20时显示，避免误触发）
				if (this.obstacleStopState.counter >= 20) {
					if (!this.obstacleStopState.showWarning) {
						this.obstacleStopState.showWarning = true;
						console.log('检测到稳定遇障状态，显示警告');
					}
				} else {
					if (this.obstacleStopState.showWarning) {
						this.obstacleStopState.showWarning = false;
						console.log('遇障状态解除，隐藏警告');
					}
				}
				
				// 检查位置是否有变化 - 降低阈值以实现更频繁的轨迹更新
				const positionChanged = Math.abs(xyz[0] - oldX) > 0.005 || Math.abs(xyz[1] - oldY) > 0.005;
				
				// 如果位置发生变化且存在轨迹，更新轨迹进度
				if (positionChanged && this.$refs.olmap && this.$refs.olmap.currentTrajectory) {
					const currentTrajectory = this.$refs.olmap.currentTrajectory;
					
					// 检查是否到达目标点
					const reachedTarget = this.checkIfReachedTarget(currentTrajectory);
					
					// 如果还没到达目标点，实时更新轨迹绘制
					if (!reachedTarget) {
						// 不再基于进度索引，而是直接基于机器人位置重新绘制轨迹
						console.log(`机器人位置更新，重新绘制实时轨迹: (${xyz[0].toFixed(3)}, ${xyz[1].toFixed(3)})`);
						if (this.$refs.olmap.updateRealtimeTrajectory) {
							this.$refs.olmap.updateRealtimeTrajectory([xyz[0], xyz[1]]);
						}
					}
				}
				
				// 更新实时轨迹（机器人实际行走路径）
				// if (this.$refs.olmap && this.$refs.olmap.drawRealTimeTrajectory && (xyz[0] !== 0 || xyz[1] !== 0) && this.settingParams.showRealTimeTrajectory) {
				// 	this.$refs.olmap.drawRealTimeTrajectory([xyz[0], xyz[1]], this.trajectoryStyles.realTime);
				// }
				
        /* this.gnssPositionData.longitude = blh[1]; // 经度
        this.gnssPositionData.latitude = blh[0]; // 纬度
        this.gnssPositionData.angle = heading; // 航向角
        
        this.gnssPositionData.status = data.rtk.star+ '/' + data.rtk.status; // RTK状态 */
        
      } catch (e) {
        console.error("解析失败:", e);
      }
		},
		
	// 处理路径规划响应
	handlePlanResponse(message) {
		console.log("路径规划响应:", message);
		if (message.status === 'ok' && message.args && message.args.length > 0) {
			const planData = message.args[0];
			console.log("规划路径数据:", planData);
			
			// 提取规划路径
			if (planData.path && planData.path.length > 0) {
				// path 可能是压缩格式，需要根据实际数据结构解析
				const plannedPath = planData.path.map(point => {
					// 如果点包含 div 字段，需要除以 div
					if (planData.div) {
						return [point[0] / planData.div, point[1] / planData.div];
					}
					return [point[0], point[1]];
				});
				
				console.log("绘制规划路径，点数:", plannedPath.length);
				
				// 🔧 修复：绘制新路径前先清除之前的轨迹，避免多点规划时出现多条路线
				if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
					this.$refs.olmap.clearTrajectory();
					console.log('✅ 已清除旧轨迹，准备绘制新的规划路径');
				}
				
				// 隐藏路网，显示规划路径
				// this.settingParams.showRoadNetwork = false;
				
				// 绘制规划路径
				if (this.$refs.olmap && this.$refs.olmap.drawTrajectory) {
					this.$refs.olmap.drawTrajectory(plannedPath, {
						totalPoints: plannedPath.length,
						currentProgress: 0, // 规划路径还未开始执行
						robotPosition: [this.laserPositionData.x, this.laserPositionData.y]
					});
				}
				
				this.$message.success(`路径规划成功！规划路径共 ${plannedPath.length} 个点`);
			} else {
				this.$message.success('路径规划成功！');
			}
		} else {
			this.$message.error('路径规划失败');
		}
	},
		
	// 处理轨迹数据
handleTrajectoryData(message) {
	console.log("接收到轨迹数据:", message);
	
	// 🔒 重要：只有在导航状态下才处理轨迹数据
	// 防止页面加载时因 MQTT retain 消息而错误隐藏路网
	if (!this.isNavigating && !this.currentNavigationTask) {
		console.log('⏭️ 非导航状态，忽略轨迹数据（可能是retain消息）');
		return;
	}
	
	try {
		if (message.args && message.args.length > 0) {
			const trajectoryData = message.args[0];
			const { trj, idx, total, div } = trajectoryData;
			
			// 转换轨迹数据：真实坐标 = 坐标值/div
			const realTrajectory = trj.map(point => [
				point[0] / div,
				point[1] / div
			]);
				
		// 计算当前机器人在轨迹中的进度
		const currentProgress = this.calculateCurrentProgress(realTrajectory);
		
		// 只有在真正导航时才隐藏路网（防止页面加载时因retain消息而隐藏路网）
		// if (this.isNavigating || this.currentNavigationTask) {
		// 	this.settingParams.showRoadNetwork = false;
		// 	console.log('导航中，隐藏路网');
		// } else {
		// 	console.log('非导航状态，保持路网显示');
		// }
		
		// 🔧 修复：绘制实时轨迹前也要清除旧轨迹，避免多条轨迹叠加（参考robot_map_editor实现）
		// handleTrajectoryData 和 handlePlanResponse 都会绘制轨迹，需要保持一致的清除逻辑
		if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
			this.$refs.olmap.clearTrajectory();
			console.log('✅ 已清除旧轨迹，准备绘制新的实时轨迹');
		}
		
		// 调用地图组件绘制轨迹（实时轨迹会覆盖规划路径，显示实际行驶路径）
		if (this.$refs.olmap && this.$refs.olmap.drawTrajectory) {
			this.$refs.olmap.drawTrajectory(realTrajectory, {
				totalPoints: total,
				indices: idx,
				currentProgress: currentProgress,
				robotPosition: [this.laserPositionData.x, this.laserPositionData.y]
			});
		}
			
			console.log("轨迹绘制完成，总点数:", total, "轨迹点数:", realTrajectory.length);
			}
		} catch (error) {
			console.error("处理轨迹数据失败:", error);
		}
	},
		
		// 处理重规划响应
		handleReplanReply(message) {
			console.log("重规划响应:", message);
			
			// 重置重规划按钮状态
			this.obstacleStopState.isReplanning = false;
			
			if (message.status === 'ok') {
				this.$message.success('重规划成功');
			} else {
				this.$message.error('重规划失败');
			}
		},
		
		// 处理前往目标点响应
		handleGotoReply(message) {
			console.log("前往目标点响应:", message);
			try {
				if (message.status === 'ok') {
					// 检查是否匹配当前的goto请求
					if (this.lastGotoRequest && message.pub_timestamp === this.lastGotoRequest.timestamp) {
						this.navigationStatus = 'navigating';
						this.isNavigating = true;
						this.$message.success('机器人已接收前往指令，开始导航');
					}
				} else {
					this.navigationStatus = 'failed';
					this.isNavigating = false;
					this.$message.error('前往目标点请求失败');
				}
			} catch (error) {
				console.error("处理goto响应失败:", error);
			}
		},
		
		// 处理到达目标点事件
		handleArriveEvent(message) {
			console.log("到达目标点事件:", message);
			try {
				if (message.args && message.args.length > 0) {
					const arriveData = message.args[0];
					const { status, coord, nid, error } = arriveData;
					
					if (status === 'ok') {
						// 成功到达目标点
						this.navigationStatus = 'arrived';
						this.isNavigating = false;
						
						// 显示成功消息
						const targetInfo = coord && coord.length > 0 ? 
							`(${coord[0][0]}, ${coord[0][1]})` : 
							(nid && nid.length > 0 ? `点位${nid[0]}` : '目标点');
						
						// 检查是否是任务中的目标点到达
						if (this.currentExecutingTask && this.currentNavigationTask?.taskContext) {
							// 处理任务中的目标点到达
							this.handleTaskWaypointArrival();
						} else {
							// 单独目标点到达
							this.$message.success(`已成功到达目标点 ${targetInfo}！`);
							
						// 清除轨迹（2秒后）
						if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
							setTimeout(() => {
								this.$refs.olmap.clearTrajectory();
								// 恢复路网显示
								this.settingParams.showRoadNetwork = true;
								console.log('轨迹已自动清除');
							}, 2000);
						}
						}
						
						// 重置导航任务状态
						this.currentNavigationTask = null;
						this.lastGotoRequest = null;
						
					} else if (status === 'fail') {
						// 到达失败
						this.navigationStatus = 'failed';
						this.isNavigating = false;
						
						// 根据错误代码显示具体错误信息
						let errorMessage = '前往目标点失败';
						if (error) {
							switch (error) {
								case 21:
									errorMessage = '前往目标点失败：规划失败';
									break;
								case 22:
									errorMessage = '前往目标点失败：偏离车道线';
									break;
								case 23:
									errorMessage = '前往目标点失败：任务提前终止';
									break;
								case 24:
									errorMessage = '前往目标点失败：定位异常';
									break;
								default:
									errorMessage = `前往目标点失败：未知错误(${error})`;
							}
						}
						
						this.$message.error(errorMessage);
						console.error("导航失败，错误代码:", error);
						
					// 清除轨迹
					if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
						this.$refs.olmap.clearTrajectory();
						// 恢复路网显示
						this.settingParams.showRoadNetwork = true;
					}
					
					// 重置导航任务状态
						this.currentNavigationTask = null;
						this.lastGotoRequest = null;
					}
				}
			} catch (error) {
				console.error("处理到达事件失败:", error);
			}
		},
		
		// 处理任务执行响应
		handleTaskExecReply(message) {
			console.log("任务执行响应:", message);
			try {
				if (message.status === 'ok') {
					// 检查是否匹配当前的任务执行请求
					if (this.lastTaskExecRequest && message.pub_timestamp === this.lastTaskExecRequest.timestamp) {
						this.taskExecutionStatus = 'executing';
						this.isTaskExecuting = true;
						this.$message.success(`任务 "${this.currentExecutingTask.taskName}" 已开始执行`);
						
						// 开始执行任务的第一个目标点
						this.executeNextWaypoint();
					}
				} else {
					this.taskExecutionStatus = 'failed';
					this.isTaskExecuting = false;
					this.$message.error('任务执行失败');
				}
			} catch (error) {
				console.error("处理任务执行响应失败:", error);
			}
		},
		
		// 处理任务完成事件
		handleTaskCompleteEvent(message) {
			console.log("任务完成事件 - 原始消息:", message);
			try {
				if (message.args && message.args.length > 0) {
					const completeData = message.args[0];
					let { name, status } = completeData;
					
					// 额外的编码处理：如果name包含乱码字符，尝试修复
					const hasEncodingIssue = name && /[\uFFFD\u00C0-\u00FF]{2,}/.test(name);
					if (hasEncodingIssue) {
						console.warn("⚠️ 检测到编码问题，任务名称包含乱码:", name);
					}
					
					console.log("解析后的任务名称:", name, "状态:", status);
					
					let currentTask = null;
					let taskNameToDisplay = name;
					
					if (this.currentExecutingTask) {
						// 方案1：使用当前正在执行的任务引用
						currentTask = this.currentExecutingTask;
						taskNameToDisplay = currentTask.taskName; 
						console.log("✅ 使用 currentExecutingTask 引用匹配任务:", currentTask.taskName);
					} else {
						// 如果没有 currentExecutingTask，尝试通过 name 查找
						currentTask = this.tasks.find(t => t.taskName === name);
						if (!currentTask && hasEncodingIssue) {
							//如果 name 有乱码且找不到任务，查找当前唯一的执行中任务
							const runningTasks = this.tasks.filter(t => t.status === 'running' || t.status === 'paused');
							if (runningTasks.length === 1) {
								currentTask = runningTasks[0];
								taskNameToDisplay = currentTask.taskName;
								console.log("⚠️ 通过运行状态匹配到任务:", currentTask.taskName, "(原name为乱码)");
							} else {
								console.error("❌ 无法匹配任务，name为乱码且存在多个运行中任务或无运行中任务");
							}
						}
					}
					
				if (status === 'ok') {
					// 任务成功完成
					this.taskExecutionStatus = 'completed';
					this.isTaskExecuting = false;
					this.$message.success(`任务 "${taskNameToDisplay}" 已成功完成！`);
					
					// 检查是否是今日定时任务完成
					if (currentTask && this.scheduledTasksToday.includes(currentTask.taskName)) {
						// 记录定时任务已执行
						if (!this.scheduledTasksExecuted.includes(currentTask.taskName)) {
							this.scheduledTasksExecuted.push(currentTask.taskName);
							console.log(`✅ 定时任务完成: ${currentTask.taskName}`);
						}
						
						// 清除当前定时任务状态
						this.currentScheduledTask = null;
					}
					
					// 重置任务执行状态
					this.currentExecutingTask = null;
					this.currentTaskWaypointIndex = 0;
					this.lastTaskExecRequest = null;
						
					// 更新任务列表中的状态
					if (currentTask) {
						//同时更新 currentTask 和 this.tasks 中的任务
						currentTask.status = 'completed';
						currentTask.executionStatus = 'completed';
						currentTask.currentWaypointIndex = 0;
						
						// 同时在 this.tasks 数组中查找并更新（防止被 loadTaskList 覆盖）
						const taskInList = this.tasks.find(t => t.taskName === currentTask.taskName || t.taskId === currentTask.taskId);
						if (taskInList && taskInList !== currentTask) {
							taskInList.status = 'completed';
							taskInList.executionStatus = 'completed';
							taskInList.currentWaypointIndex = 0;
							console.log(`✅ 同步更新 tasks 数组中的任务状态`);
						}
						
						// 保存任务名称用于定时器回调
						const taskNameForReset = currentTask.taskName;
						
						// 5秒后自动恢复为空闲状态
						setTimeout(() => {
							const taskToReset = this.tasks.find(t => t.taskName === taskNameForReset);
							if (taskToReset && taskToReset.status === 'completed') {
								taskToReset.status = 'idle';
								taskToReset.executionStatus = 'idle';
								console.log(`任务 "${taskNameForReset}" 状态已自动恢复为空闲`);
							}
						}, 5000);
						
						console.log(`✅ 任务状态已更新: ${currentTask.taskName} -> completed`);
					} else {
						console.warn("⚠️ 无法找到对应的任务进行状态更新");
					}
						
					// 清除轨迹
					if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
						setTimeout(() => {
							this.$refs.olmap.clearTrajectory();
							// 恢复路网显示
							this.settingParams.showRoadNetwork = true;
							console.log('任务完成，轨迹已清除');
						}, 3000);
					}
						
					} else if (status === 'fail') {
						// 任务失败
						this.taskExecutionStatus = 'failed';
						this.isTaskExecuting = false;
						this.$message.error(`任务 "${taskNameToDisplay}" 执行失败`);
						
						// 重置任务执行状态
						this.currentExecutingTask = null;
						this.currentTaskWaypointIndex = 0;
						this.lastTaskExecRequest = null;
						
					// 更新任务列表中的状态
					if (currentTask) {
						// 同时更新 currentTask 和 this.tasks 中的任务
						currentTask.status = 'error';
						currentTask.executionStatus = 'failed';
						currentTask.currentWaypointIndex = 0;
						
						// 同时在 this.tasks 数组中查找并更新（防止被 loadTaskList 覆盖）
						const taskInList = this.tasks.find(t => t.taskName === currentTask.taskName || t.taskId === currentTask.taskId);
						if (taskInList && taskInList !== currentTask) {
							taskInList.status = 'error';
							taskInList.executionStatus = 'failed';
							taskInList.currentWaypointIndex = 0;
							console.log(`✅ 同步更新 tasks 数组中的任务状态`);
						}
						
						// 保存任务名称用于定时器回调
						const taskNameForReset = currentTask.taskName;
						
						// 5秒后自动恢复为空闲状态
						setTimeout(() => {
							const taskToReset = this.tasks.find(t => t.taskName === taskNameForReset);
							if (taskToReset && taskToReset.status === 'error') {
								taskToReset.status = 'idle';
								taskToReset.executionStatus = 'idle';
								console.log(`任务 "${taskNameForReset}" 状态已自动恢复为空闲`);
							}
						}, 5000);
						
						console.log(`✅ 任务状态已更新: ${currentTask.taskName} -> error`);
					} else {
						console.warn("⚠️ 无法找到对应的任务进行状态更新");
					}
						
					// 清除轨迹
					if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
						this.$refs.olmap.clearTrajectory();
						// 恢复路网显示
						this.settingParams.showRoadNetwork = true;
					}
				}
			}
		} catch (error) {
			console.error("处理任务完成事件失败:", error);
			}
		},
		
		// 处理任务实时信息
		handleTaskRealtimeInfo(message) {
			// console.log("任务实时信息:", message);
			try {
				if (message.args && message.args.length > 0) {
					const realtimeData = message.args[0];
					const { odom, time, drive_mode, auto_ready } = realtimeData;
					
					// 更新任务实时信息
					this.taskRealtimeInfo = {
						odom: {
							total: odom?.tottal || 0,
							remain: odom?.remain || 0
						},
						time: {
							total: time?.total || 0,
							remain: time?.remain || 0,
							duration: time?.duration || 0
						},
						driveMode: drive_mode || 'auto',
						autoReady: auto_ready !== undefined ? auto_ready : true
					};
					
					// 如果有正在执行的任务，更新实时信息到右侧面板
					if (this.currentExecutingTask) {
						this.realtimeInfo.currentTask = this.currentExecutingTask.taskName;
						this.realtimeInfo.totalDistance = `${(odom?.tottal / 1000).toFixed(2)}km` || '';
						// 可以在这里更新其他实时信息显示
					}
				}
			} catch (error) {
				console.error("处理任务实时信息失败:", error);
			}
		},
		
		// 处理任务开始响应
		handleTaskStartReply(message) {
			console.log("任务开始响应:", message);
			try {
				if (message.status === 'ok') {
					this.$message.success('任务已成功开始执行');
					console.log("任务开始执行成功");
					
					// 确保任务状态已更新（虽然在 onTaskStart 中已设置，但这里再确认一次）
					if (this.currentExecutingTask) {
						const taskName = this.currentExecutingTask.taskName;
						this.currentExecutingTask.status = 'running';
						this.currentExecutingTask.executionStatus = 'executing';
						
						// 同时更新任务列表中对应任务的状态
						const taskInList = this.tasks.find(t => t.taskId === this.currentExecutingTask.taskId);
						if (taskInList) {
							taskInList.status = 'running';
							taskInList.executionStatus = 'executing';
						}
						
						// 检查是否是今日定时任务
						if (this.scheduledTasksToday.includes(taskName)) {
							// 记录定时任务开始执行
							this.currentScheduledTask = {
								name: taskName,
								startTime: new Date().getTime(),
								status: 'running'
							};
							this.lastTaskStartTime[taskName] = new Date().getTime();
							console.log(`🕐 定时任务开始: ${taskName}`);
							
							// 更新调度状态
							this.updateTaskListScheduleStatus();
						}
					}
				} else {
					this.taskExecutionStatus = 'failed';
					this.isTaskExecuting = false;
					
					if (this.currentExecutingTask) {
						this.currentExecutingTask.status = 'idle';
						this.currentExecutingTask.executionStatus = 'failed';
						
						// 同时更新任务列表中对应任务的状态
						const taskInList = this.tasks.find(t => t.taskId === this.currentExecutingTask.taskId);
						if (taskInList) {
							taskInList.status = 'idle';
							taskInList.executionStatus = 'failed';
						}
					}
					
					this.$message.error('任务开始失败');
					console.error("任务开始失败:", message);
				}
			} catch (error) {
				console.error("处理任务开始响应失败:", error);
			}
		},
		
		// 处理暂停任务响应
		handleTaskPauseReply(message) {
			console.log("暂停任务响应:", message);
			if (message.status === 'ok') {
				this.taskExecutionStatus = 'paused';
				
				// 更新当前执行任务的状态
				if (this.currentExecutingTask) {
					this.currentExecutingTask.status = 'paused';
					this.currentExecutingTask.executionStatus = 'paused';
					
					// 同时更新任务列表中对应任务的状态
					const taskInList = this.tasks.find(t => t.taskId === this.currentExecutingTask.taskId);
					if (taskInList) {
						taskInList.status = 'paused';
						taskInList.executionStatus = 'paused';
					}
				}
				
				this.$message.success('任务已暂停');
			} else {
				this.$message.error('任务暂停失败');
			}
		},
		
		// 处理继续任务响应
		handleTaskResumeReply(message) {
			console.log("继续任务响应:", message);
			if (message.status === 'ok') {
				this.taskExecutionStatus = 'executing';
				
				// 更新当前执行任务的状态
				if (this.currentExecutingTask) {
					this.currentExecutingTask.status = 'running';
					this.currentExecutingTask.executionStatus = 'executing';
					
					// 同时更新任务列表中对应任务的状态
					const taskInList = this.tasks.find(t => t.taskId === this.currentExecutingTask.taskId);
					if (taskInList) {
						taskInList.status = 'running';
						taskInList.executionStatus = 'executing';
					}
				}
				
				this.$message.success('任务已继续执行');
			} else {
				this.$message.error('任务继续失败');
			}
		},
		
		// 处理取消任务响应
		handleTaskCancelReply(message) {
			console.log("取消任务响应:", message);
			if (message.status === 'ok') {
				this.taskExecutionStatus = 'cancelled';
				this.isTaskExecuting = false;
				
				// 保存当前执行任务的引用（用于找到任务列表中的对应项）
				const cancelledTaskName = this.currentExecutingTask?.taskName;
				
				// 重置任务执行状态
				this.currentExecutingTask = null;
				this.currentTaskWaypointIndex = 0;
				this.lastTaskExecRequest = null;
				
				// 更新任务列表中对应任务的状态
				if (cancelledTaskName) {
					const taskInList = this.tasks.find(t => t.taskName === cancelledTaskName);
					if (taskInList) {
						taskInList.status = 'idle';
						taskInList.executionStatus = 'idle';
						taskInList.currentWaypointIndex = 0;
					}
				}
				
			this.$message.success('任务已取消');
			
			// 清除轨迹
			if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
				this.$refs.olmap.clearTrajectory();
				// 恢复路网显示
				this.settingParams.showRoadNetwork = true;
			}
			} else {
				this.$message.error('任务取消失败');
			}
		},
		
		// === 导航控制相关MQTT处理方法 ===
		
		// 处理导航启动响应
		handleNavigationStartReply(message) {
			console.log("导航启动响应:", message);
			try {
				if (message.status === 'ok') {
					this.navigationStackStatus = 'started';
					this.$message.success('导航系统已启动');
				} else {
					this.$message.error('导航系统启动失败');
					console.error("导航启动失败:", message);
				}
			} catch (error) {
				console.error("处理导航启动响应失败:", error);
			}
		},
		
		// 处理导航停止响应
		handleNavigationStopReply(message) {
			console.log("导航停止响应:", message);
			try {
				if (message.status === 'ok') {
					this.navigationStackStatus = 'stopped';
					// 停止导航时，清除当前的导航任务和轨迹
					this.isNavigating = false;
					this.navigationStatus = 'idle';
					this.currentNavigationTask = null;
				this.lastGotoRequest = null;
				
				// 清除轨迹
				if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
					this.$refs.olmap.clearTrajectory();
					// 恢复路网显示
					this.settingParams.showRoadNetwork = true;
				}
				
				this.$message.success('导航系统已停止');
				} else {
					this.$message.error('导航系统停止失败');
					console.error("导航停止失败:", message);
				}
			} catch (error) {
				console.error("处理导航停止响应失败:", error);
			}
		},
		
		// 处理导航重启响应
		handleNavigationRestartReply(message) {
			console.log("导航重启响应:", message);
			try {
				if (message.status === 'ok') {
					this.navigationStackStatus = 'started';
					// 重启导航时，重置所有导航相关状态
					this.isNavigating = false;
					this.navigationStatus = 'idle';
					this.currentNavigationTask = null;
					this.lastGotoRequest = null;
					
					// 重置任务执行状态
					this.isTaskExecuting = false;
					this.taskExecutionStatus = 'idle';
					this.currentExecutingTask = null;
					this.currentTaskWaypointIndex = 0;
					
					// 清除轨迹
					// if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
					// 	this.$refs.olmap.clearTrajectory();
					// }
					
					this.$message.success('导航系统已重启');
					this.isBusy = false;
				} else {
					this.$message.error('导航系统重启失败');
					this.isBusy = false;
					console.error("导航重启失败:", message);
				}
			} catch (error) {
				console.error("处理导航重启响应失败:", error);
				this.isBusy = false;
			}
		},
		
		// 处理急停控制响应
		handleEmergencyStopReply(message) {
			console.log("急停控制响应:", message);
			try {
				if (message.status === 'ok') {
					this.$message.success('急停指令已执行');
				} else {
					this.$message.error('急停指令执行失败');
					console.error("急停控制失败:", message);
				}
			} catch (error) {
				console.error("处理急停控制响应失败:", error);
			}
		},
		
		// 处理急停状态变化
		handleEmergencyStopStatus(message) {
			// console.log("急停状态:", message);
			try {
				if (message.args && message.args.length > 0) {
					const stopEnabled = message.args[0];
					const oldStatus = this.emergencyStopEnabled;
					this.emergencyStopEnabled = stopEnabled;
					
					// 只在状态真正变化时显示消息，避免频繁提示
					if (oldStatus !== stopEnabled) {
						if (stopEnabled) {
							this.$message.warning('车辆已启用急停状态');
							// 急停启用时，清除所有导航任务
							this.isNavigating = false;
							this.navigationStatus = 'idle';
							this.currentNavigationTask = null;
							this.isTaskExecuting = false;
							this.taskExecutionStatus = 'idle';
						} else {
							this.$message.info('车辆急停状态已解除');
						}
					}
				}
			} catch (error) {
				console.error("处理急停状态失败:", error);
			}
		},
		
		// 处理障碍物感知数据
		handleObstacleData(message) {
			try {
				if (message.args && message.args.length > 0) {
					const obstacleInfo = message.args[0];
					const obsDistance = obstacleInfo.obs_distanse || obstacleInfo.obs_distance; // 兼容拼写错误
					
					if (obsDistance && Array.isArray(obsDistance) && obsDistance.length >= 3) {
						// 更新障碍物数据
						this.obstacleData = {
							left: obsDistance[0][0] || 0,    // 左侧距离
							front: obsDistance[1][0] || 0,   // 前方距离  
							right: obsDistance[2][0] || 0,   // 右侧距离
							timestamp: message.timestamp || Date.now()
						};
						
						// 检查障碍物并显示警告
						this.checkObstacleWarning();
						
						// 调试输出
						console.log("障碍物数据更新:", {
							left: this.obstacleData.left + 'm',
							front: this.obstacleData.front + 'm', 
							right: this.obstacleData.right + 'm'
						});
					}
				}
			} catch (error) {
				console.error("处理障碍物数据失败:", error);
			}
		},
		
		// 检查障碍物警告
		checkObstacleWarning() {
			if (!this.obstacleSettings.enableWarning) {
				return;
			}
			
			const { left, front, right } = this.obstacleData;
			const { warningDistance, dangerDistance } = this.obstacleSettings;
			
			// 找出最近的障碍物
			let minDistance = Infinity;
			let minDirection = '';
			
			// 检查各个方向的障碍物（0表示没有障碍物）
			if (left > 0 && left < minDistance) {
				minDistance = left;
				minDirection = '左侧';
			}
			if (front > 0 && front < minDistance) {
				minDistance = front;
				minDirection = '前方';
			}
			if (right > 0 && right < minDistance) {
				minDistance = right;
				minDirection = '右侧';
			}
			
			// 根据距离判断警告级别
			if (minDistance !== Infinity) {
				let level = 'info';
				let message = '';
				
				if (minDistance <= dangerDistance) {
					level = 'danger';
					message = `危险！${minDirection}发现障碍物，距离仅${minDistance.toFixed(1)}米`;
				} else if (minDistance <= warningDistance) {
					level = 'warning';
					message = `注意！${minDirection}发现障碍物，距离${minDistance.toFixed(1)}米`;
				} else {
					// 距离较远，不显示警告
					this.hideObstacleWarning();
					return;
				}
				
				// 显示警告
				this.showObstacleWarning(level, message, minDirection, minDistance);
			} else {
				// 没有检测到障碍物
				this.hideObstacleWarning();
			}
		},
		
		// 显示障碍物警告
		showObstacleWarning(level, message, direction, distance) {
			// 清除之前的自动隐藏定时器
			if (this.obstacleWarning.autoHideTimer) {
				clearTimeout(this.obstacleWarning.autoHideTimer);
			}
			
			// 更新警告状态
			this.obstacleWarning = {
				show: true,
				level: level,
				message: message,
				direction: direction,
				distance: distance,
				autoHideTimer: null
			};
			
			// 只在危险级别时不自动隐藏，其他级别设置自动隐藏
			if (level !== 'danger') {
				this.obstacleWarning.autoHideTimer = setTimeout(() => {
					this.hideObstacleWarning();
				}, this.obstacleSettings.autoHideDelay);
			}
		},
		
		// 隐藏障碍物警告
		hideObstacleWarning() {
			if (this.obstacleWarning.autoHideTimer) {
				clearTimeout(this.obstacleWarning.autoHideTimer);
			}
			
			this.obstacleWarning = {
				show: false,
				level: 'info',
				message: '',
				direction: '',
				distance: 0,
				autoHideTimer: null
			};
		},
		
		// 手动关闭障碍物警告
		closeObstacleWarning() {
			this.hideObstacleWarning();
		},
		
		// === 遇障停车状态处理 ===
		
		// 获取运行状态文本
		getRunStateText(runState) {
			const stateMap = {
				1: '正常行驶',
				2: '暂停状态',
				3: '停车待命',
				4: '遇障停车',
				5: '交通管制等待',
				6: '定位切换等待',
				7: '人工接管',
				8: '绕障状态'
			};
			return stateMap[runState] || '未知状态';
		},
		
		// 立即重规划
		handleReplanRequest() {
			if (this.obstacleStopState.isReplanning) {
				this.$message.warning('正在请求重规划，请稍候...');
				return;
			}
			
			const timestamp = new Date().getTime();
			
			// 构建重规划请求 - 立即重规划（等待时间为0）
			const replanRequest = {
				"timestamp": timestamp,
				"args": [0] // 0表示立即重规划
			};
			
			// 发送重规划MQTT消息
			this.$refs.mqtt.publish(this.$mqttPrefix + "/planning/action/replan", replanRequest, 2, false);
			
			// 设置重规划状态
			this.obstacleStopState.isReplanning = true;
			
			this.$message.success('重规划指令已发送');
			console.log("发送重规划请求:", replanRequest);
		},
		
		// === 定时任务调度逻辑（基于现有MQTT推断）===
		
		// 计算今日应执行的定时任务列表（优化版：使用已解析的时间信息）
		calculateTodayScheduledTasks() {
			if (!this.tasks || this.tasks.length === 0) return;
			
			// 筛选今日应执行的定时任务（使用已解析的shouldRunToday字段）
			const scheduledTasks = this.tasks.filter(task => {
				// 必须有cron配置且今天应该执行
				return task.shouldRunToday && task.scheduledTime !== null;
			});
			
			// 按执行时间排序
			scheduledTasks.sort((a, b) => {
				if (!a.scheduledTime || !b.scheduledTime) return 0;
				return a.scheduledTime.getTime() - b.scheduledTime.getTime();
			});
			
			// 更新今日应执行的任务列表
			this.scheduledTasksToday = scheduledTasks.map(task => task.taskName);
			
			console.log(`📅 今日应执行的定时任务 (${this.scheduledTasksToday.length}):`, 
				scheduledTasks.map(t => `${t.taskName} (${t.scheduledTimeStr})`));
			
			// 打印详细的任务信息（调试用）
			scheduledTasks.forEach(task => {
				console.log(`  ⏰ ${task.taskName}:`, {
					time: task.scheduledTimeStr,
					weekDays: task.scheduledWeekDays,
					points: task.points.length,
					count: task.count
				});
			});
			
			// 更新任务列表的调度状态标记
			this.updateTaskListScheduleStatus();
		},
		
		// 更新任务列表中的调度状态标记（基于推断）
		updateTaskListScheduleStatus() {
			if (!this.tasks || this.tasks.length === 0) return;
			
			this.tasks.forEach(task => {
				// 重置调度状态标记
				task.scheduleStatus = null;
				task.scheduleProgress = null;
				
				// 不是今日定时任务，跳过
				if (!this.scheduledTasksToday.includes(task.taskName)) {
					return;
				}
				
				// 标记当前正在执行的定时任务
				if (this.currentScheduledTask && task.taskName === this.currentScheduledTask.name) {
					task.scheduleStatus = 'schedule-running';
					// 如果有进度信息，显示进度
					if (this.currentExecutingTask && this.currentExecutingTask.taskName === task.taskName) {
						task.scheduleProgress = `${this.currentTaskWaypointIndex}/${this.currentExecutingTask.points?.length || 0}`;
					}
				}
				// 标记今日已执行的定时任务
				else if (this.scheduledTasksExecuted.includes(task.taskName)) {
					task.scheduleStatus = 'schedule-executed';
				}
				// 标记今日待执行的定时任务
				else {
					task.scheduleStatus = 'schedule-pending';
				}
			});
		},
		
		// === 定时任务自动执行功能 ===
		
		// 启动自动执行定时任务的定时器
		startAutoExecuteTimer() {
			if (!this.autoExecuteEnabled) {
				console.log('⏸️ 定时任务自动执行功能已禁用');
				return;
			}
			
			// 清除已存在的定时器
			this.stopAutoExecuteTimer();
			
			// 每30秒检查一次是否有任务需要执行
			this.autoExecuteTimer = setInterval(() => {
				this.checkAndExecuteScheduledTasks();
			}, 30 * 1000); // 30秒检查一次
			
			console.log('定时任务自动执行功能已启动（每30秒检查一次）');
			
			// 立即执行一次检查
			this.checkAndExecuteScheduledTasks();
		},
		
		// 停止自动执行定时器
		stopAutoExecuteTimer() {
			if (this.autoExecuteTimer) {
				clearInterval(this.autoExecuteTimer);
				this.autoExecuteTimer = null;
				console.log('🛑 定时任务自动执行功能已停止');
			}
		},
		
		// 检查并执行到期的定时任务
		checkAndExecuteScheduledTasks() {
			if (!this.autoExecuteEnabled || !this.tasks || this.tasks.length === 0) {
				return;
			}
			
			// 如果有任务正在执行，不启动新任务
			if (this.isTaskExecuting || this.isNavigating) {
				// console.log('⏳ 有任务正在执行中，跳过自动执行检查');
				return;
			}
			
			const now = new Date();
			const currentTime = now.getTime();
			
			// 查找今日应执行但还未执行的任务
			const tasksToExecute = this.tasks.filter(task => {
				// 必须是今日定时任务
				if (!task.shouldRunToday || !task.scheduledTime) {
					return false;
				}
				
				// 已经执行过了，跳过
				if (this.scheduledTasksExecuted.includes(task.taskName)) {
					return false;
				}
				
				// 正在执行中，跳过
				if (this.currentScheduledTask && this.currentScheduledTask.name === task.taskName) {
					return false;
				}
				
				// 检查是否到了执行时间（允许30秒的误差）
				const scheduledTime = task.scheduledTime.getTime();
				const timeDiff = currentTime - scheduledTime;
				
				// 如果当前时间>=预定时间，且距离预定时间不超过5分钟
				return timeDiff >= 0 && timeDiff < 5 * 60 * 1000;
			});
			
			// 按时间排序，优先执行最早的任务
			tasksToExecute.sort((a, b) => a.scheduledTime.getTime() - b.scheduledTime.getTime());
			
			if (tasksToExecute.length > 0) {
				const taskToExecute = tasksToExecute[0];
				console.log(`自动执行定时任务: ${taskToExecute.taskName} (预定时间: ${taskToExecute.scheduledTimeStr})`);
				
				// 执行任务
				this.executeScheduledTask(taskToExecute);
			}
		},
		
		// 执行定时任务
		async executeScheduledTask(task) {
			if (!task || !task.points || task.points.length === 0) {
				console.error('任务数据不完整，无法执行:', task.taskName);
				return;
			}
			
			console.log(`⏰ 开始执行定时任务: ${task.taskName}`);
			console.log(`  📍 包含 ${task.points.length} 个目标点`);
			console.log(`  🔁 执行次数: ${task.count}`);
			
			try {
				const timestamp = new Date().getTime();
				
				// 构建任务执行请求
				const taskExecRequest = {
					"timestamp": timestamp,
					"args": [
						{
							"roadmap": this.mapName,
							"task": task.taskName
						}
					]
				};
				
				// 保存任务执行状态
				this.currentExecutingTask = task;
				this.currentTaskWaypointIndex = 0;
				this.lastTaskExecRequest = taskExecRequest;
				this.isTaskExecuting = true;
				this.taskExecutionStatus = 'executing';
				
				// 更新任务状态
				task.status = 'running';
				task.executionStatus = 'executing';
				
				// 发送任务执行请求
				this.$refs.mqtt.publish(this.$mqttPrefix + "/task/procedure/action/start", taskExecRequest, 2, false);
				
				this.$message.success(`🤖 自动执行定时任务: ${task.taskName}`);
				
				console.log(`✅ 定时任务 "${task.taskName}" 执行指令已发送`);
				
			} catch (error) {
				console.error(`❌ 执行定时任务 "${task.taskName}" 失败:`, error);
				this.$message.error(`执行定时任务失败: ${error.message}`);
			}
		},
		
		// 计算当前机器人在轨迹中的进度
		calculateCurrentProgress(trajectory) {
			if (!trajectory || trajectory.length === 0) return 0;
			
			const robotPos = [this.robotPoseData.x, this.robotPoseData.y];
			let progressDistance = 0; // 沿轨迹的累计距离
			let totalDistance = 0; // 轨迹总长度
			
			// 计算轨迹总长度
			for (let i = 0; i < trajectory.length - 1; i++) {
				const segmentLength = Math.sqrt(
					Math.pow(trajectory[i + 1][0] - trajectory[i][0], 2) +
					Math.pow(trajectory[i + 1][1] - trajectory[i][1], 2)
				);
				totalDistance += segmentLength;
			}
			
			if (totalDistance === 0) return 0;
			
			let bestProjectionDistance = 0;
			let minDistanceToTrajectory = Infinity;
			
			// 遍历轨迹的每个线段，找到机器人在轨迹上的投影点
			let accumulatedDistance = 0;
			for (let i = 0; i < trajectory.length - 1; i++) {
				const segmentStart = trajectory[i];
				const segmentEnd = trajectory[i + 1];
				const segmentLength = Math.sqrt(
					Math.pow(segmentEnd[0] - segmentStart[0], 2) +
					Math.pow(segmentEnd[1] - segmentStart[1], 2)
				);
				
				// 计算机器人到当前线段的投影点
				const projection = this.projectPointToLineSegment(robotPos, segmentStart, segmentEnd);
				const distanceToSegment = projection.distance;
				
				// 如果这是到轨迹最近的投影点
				if (distanceToSegment < minDistanceToTrajectory) {
					minDistanceToTrajectory = distanceToSegment;
					// 计算投影点在轨迹上的累计距离
					const projectionDistanceOnSegment = Math.sqrt(
						Math.pow(projection.point[0] - segmentStart[0], 2) +
						Math.pow(projection.point[1] - segmentStart[1], 2)
					);
					bestProjectionDistance = accumulatedDistance + projectionDistanceOnSegment;
				}
				
				accumulatedDistance += segmentLength;
			}
			
			// 转换为轨迹点索引（基于距离比例）
			const progressRatio = bestProjectionDistance / totalDistance;
			const progressIndex = Math.floor(progressRatio * (trajectory.length - 1));
			
			// 只有当机器人距离轨迹很近时（5米内），才更新进度
			if (minDistanceToTrajectory < 5.0) {
				console.log(`机器人轨迹进度: ${progressIndex}/${trajectory.length-1}, 距轨迹距离: ${minDistanceToTrajectory.toFixed(2)}m`);
				return Math.min(progressIndex, trajectory.length - 1);
			}
			
			// 如果离轨迹太远，保持之前的进度
			return this.$refs.olmap?.trajectoryProgress || 0;
		},
		
		// 计算点到线段的投影
		projectPointToLineSegment(point, lineStart, lineEnd) {
			const [px, py] = point;
			const [x1, y1] = lineStart;
			const [x2, y2] = lineEnd;
			
			const A = px - x1;
			const B = py - y1;
			const C = x2 - x1;
			const D = y2 - y1;
			
			const dot = A * C + B * D;
			const lenSq = C * C + D * D;
			
			if (lenSq === 0) {
				// 线段退化为点
				return {
					point: [x1, y1],
					distance: Math.sqrt(A * A + B * B)
				};
			}
			
			let param = dot / lenSq;
			
			// 限制参数在[0,1]范围内，确保投影点在线段上
			param = Math.max(0, Math.min(1, param));
			
			const projectionX = x1 + param * C;
			const projectionY = y1 + param * D;
			
			const distance = Math.sqrt(
				Math.pow(px - projectionX, 2) + Math.pow(py - projectionY, 2)
			);
			
			return {
				point: [projectionX, projectionY],
				distance: distance
			};
		},
		
		// 检测是否到达目标点（备用检测，主要依赖MQTT到达事件）
		checkIfReachedTarget(trajectory) {
			if (!trajectory || trajectory.length === 0) return false;
			
			// 如果已经通过MQTT确认到达或失败，不需要本地检测
			if (this.navigationStatus === 'arrived' || this.navigationStatus === 'failed') {
				return true;
			}
			
			// 备用的本地距离检测（仅用于防止MQTT消息丢失的情况）
			const robotPos = [this.laserPositionData.x, this.laserPositionData.y];
			const targetPos = trajectory[trajectory.length - 1]; // 最后一个点是目标点
			
			const distanceToTarget = Math.sqrt(
				Math.pow(targetPos[0] - robotPos[0], 2) + Math.pow(targetPos[1] - robotPos[1], 2)
			);
			
			// 如果距离目标点很近且正在导航，打印调试信息但不执行到达逻辑
			// （到达逻辑由MQTT事件处理）
			if (distanceToTarget < 1.0 && this.isNavigating) {
				console.log(`本地检测: 机器人接近目标点，距离: ${distanceToTarget.toFixed(2)}m，等待MQTT到达确认`);
			}
			
			return false; // 不执行本地到达逻辑
		},
		
		publishMsg() {
        
    },
		updateOlCss() {
			const element = this.$el.querySelector('.map-stage');
			
			this.olWidth = element.offsetWidth;
			this.olHeight = element.offsetHeight;
		},
		
		// 地图API适配器
		getMapInstance() {
			return this.$refs.olmap && this.$refs.olmap.map ? this.$refs.olmap.map : null;
		},
		
		openDraSetting() {
			this.poseInitEnable = false;
			this.activeIndex = this.activeIndex == 0 ? -1 : 0;
			if (this.settingDrawer) {
				this.nowHandMenu = ''
				this.settingDrawer = false;
				return;
			}
			this.closeDra()
			this.nowHandMenu = '功能菜单操作'
			this.settingDrawer = true;
		},
		openPoint() {
			this.poseInitEnable = false
			this.activeIndex = this.activeIndex == 1 ? -1 : 1;
			if (this.pointDrawer) {
				this.pointDrawer = false;
				this.nowHandMenu = ''
				return;
			}
			this.closeDra()
			this.nowHandMenu = '目标点操作'
			this.pointDrawer = true;
		},
		openTask() {
			this.poseInitEnable = false
			this.activeIndex = this.activeIndex == 2 ? -1 : 2;
			if (this.taskDrawer) {
				this.taskDrawer = false;
				this.nowHandMenu = ''
				return;
			}
			this.closeDra()
			this.nowHandMenu = '任务操作'
			this.taskDrawer = true;
		},
		/**
		 * 关闭左侧菜单的抽屉
		 * type 类型(hand手动,auto自动)
		 */
		closeDra(type) {
			this.settingDrawer = false;
			this.pointDrawer = false;
			this.taskDrawer = false;
			if (type == 'hand') {
				this.activeIndex = -1;
			}
			this.nowHandMenu = ''
		},
		handleSelectionChange(selection) {
			this.pointIds = selection.map(item => item.id)
			this.single = selection.length !== 1
			this.multiple = !selection.length
		},
		// 点位编辑
		editPoint(row) {
			this.pointEditDiaShow = true;
			this.pointEditData.id = row.id;
			this.pointEditData.x = row.x;
			this.pointEditData.y = row.y;
			this.pointEditData.type = row.type;
			this.pointEditData.actionMenuList = row.action
		},
		// 点位删除
		removePoint(row) {
			const idArr = [];
			const ids = row?.id || this.pointIds;
			if (ids) {
				idArr.push(...(Array.isArray(ids) ? ids : [ids]));
				idArr.forEach(id => {
					let indexToRemove = this.pointList.findIndex(item => item?.id === id);
					if (indexToRemove !== -1) {
						this.pointList.splice(indexToRemove, 1);
						if (this.pointList.length < 1) {
							// 重置地图的id计数器
							this.$refs.olmap.restIdNum();
						}
						// this.$refs.olmap.removeIconHtmlById("pose-" + id);
						this.$refs.olmap.removeCalibrationById(id)
					}
				});
			}
		},
		// 点位上移
		moveUp() {
			const index = this.pointList.findIndex(point => point.id == this.pointIds[0]);
			if (index !== -1 && index > 0) {
				let temp = this.pointList[index];
				this.$set(this.pointList, index, this.pointList[index - 1]);
				this.$set(this.pointList, index - 1, temp);
			}
		},
		// 点位下移
		moveDown() {
			const index = this.pointList.findIndex(point => point.id == this.pointIds[0]);
			if (index !== -1 && index < this.pointList.length - 1) {
				let temp = this.pointList[index];
				this.$set(this.pointList, index, this.pointList[index + 1]);
				this.$set(this.pointList, index + 1, temp);
			}
		},
		// 追加动作按钮
		appendActionMenu() {
			this.pointEditData.actionMenuList.push({ value: 0, other: 0 })
		},
		// 删除追加动作按钮
		removeActionMenu(index) {
			this.pointEditData.actionMenuList.splice(index, 1);
		},
		// 修改动作下拉值
		changeAction(index) {
			// 判断当前修改后是否是原定等待,如果不是则删除other属性
			let item = this.pointEditData.actionMenuList[index];
			if (item && 'other' in item) {
				delete item.other;  // 删除 'other' 属性
			} else {
				item.other = 0;
			}
		},
		clearActionDia() {
			this.pointEditData.id = '';
			this.pointEditData.x = '';
			this.pointEditData.y = '';
			this.pointEditData.type = '';
			this.pointEditData.actionMenuList = [];
		},
		// 提交点位修改
		submitEditPoint() {
			this.pointEditDiaShow = false;
			// 模拟数据修改
			const point = this.pointList.find(item => item.id === this.pointEditData.id);
			if (this.pointEditData.actionMenuList)
				if (point) {
					// 找到对应元素，更新数据(真实情况下发请求修改,然后重新查询点位列表)
					point.x = this.pointEditData.x;
					point.y = this.pointEditData.y;
					point.type = this.pointEditData.type;
					point.action = this.pointEditData.actionMenuList;
					this.$modal.msgSuccess("当前点位数据已修改");
				}
		},
		// 生成任务
		async submitTaskGenerate() {
			// 使用保存的选中目标点数据
			const orderedPoints = this.generateTaskParam.selectedWaypoints || [];
			if (!this.generateTaskParam.taskName || orderedPoints.length === 0) {
				this.$message({
					message: '请完善任务数据（任务名称和目标点不能为空）!',
					type: 'warning'
				});
				return;
			}
			
			try {
				// 构建任务坐标数组 - 从目标点中提取xyz坐标
				const coordinates = orderedPoints.map(point => [
					parseFloat(point.x),
					parseFloat(point.y),
					0 // z坐标默认为0
				]);
				
				// 构建plan数组 - 根据每个目标点的type字段
				const plan = orderedPoints.map(point => {
					// type: 0 = 自由路径(free), 1 = 路网路径(route)
					return point.type === 1 ? 'route' : 'free';
				});
				
				// 构建action数组 - 从目标点的actionMenuList提取
				const action = orderedPoints.map(point => {
					if (!point.action || point.action.length === 0) {
						return []; // 没有动作
					}
					// 转换动作格式
					return point.action.map(act => {
						if (act.value === 0 && 'other' in act) {
							// 原地等待，包含等待时间
							return { type: 'wait', duration: parseFloat(act.other) || 0 };
						} else {
							// 其他动作类型
							const actionTypes = ['wait', 'start_record', 'stop_record', 'add_trajectory', 'hook_mount', 'hook_unmount'];
							return { type: actionTypes[act.value] || 'wait' };
						}
					});
				});
				
				// 构建cron表达式 - 从time和date生成
				// Quartz cron格式：秒 分 时 日 月 周 年
				// 示例：00 12 12 ? * 5 * （每周五12:12:00执行）
				let cron = '';
				if (this.generateTaskParam.time && this.generateTaskParam.date.length > 0) {
					// time 格式为 "HH:mm:ss" 字符串，直接解析
					let hours, minutes;
					if (typeof this.generateTaskParam.time === 'string') {
						// 字符串格式：HH:mm:ss
						const timeParts = this.generateTaskParam.time.split(':');
						hours = timeParts[0];
						minutes = timeParts[1];
					} else {
						// Date 对象格式（兼容）
						const timeObj = new Date(this.generateTaskParam.time);
						hours = String(timeObj.getHours()).padStart(2, '0');
						minutes = String(timeObj.getMinutes()).padStart(2, '0');
					}
					const weekdays = this.generateTaskParam.date.sort().join(',');
					// cron格式: 秒 分 时 日 月 周 年
					cron = `00 ${minutes} ${hours} ? * ${weekdays} *`;
				}
				
				// 构建API请求数据
				const taskData = {
					map: this.mapName,
					path: this.generateTaskParam.taskName,
					coord_type: 'local',
					cron: cron,
					coord: coordinates,
					plan: plan,
					action: [[]],
					repeate: this.generateTaskParam.count || 1
				};
				
				// 调用API创建任务
				const response = await addTask(taskData);
				console.log("创建任务响应:", response);
				
				if (response.status === true ) {
					this.$message.success(`任务创建成功！任务包含 ${orderedPoints.length} 个目标点`);
					
					// 重新加载任务列表
					await this.loadTaskList();
					
					// 重置表单和状态
					this.restGenerateParam();
					this.taskGenerateDiaShow = false;
					this.selectedWaypointIds = [];
					
					console.log("任务创建成功:", taskData);
				} else {
					this.$message.error('任务创建失败: ' + (response.msg || '未知错误'));
				}
			} catch (error) {
				console.error("创建任务失败:", error);
				this.$message.error('任务创建失败: ' + (error.message || '未知错误'));
			}
		},
		// 初始化导航
		initNavigation() {
			this.closeDra()
			if (this.poseInitEnable) {
				this.poseInitEnable = false;
				this.nowHandMenu = ''
			} else {
				this.poseInitEnable = true;
				this.nowHandMenu = '初始化导航'
			}
			this.pointSelectionEnabled = false;
			this.activeIndex = this.activeIndex == 3 ? -1 : 3;
		},
		// 重启导航
		restNavigation() {
			this.$confirm('将重启当前导航, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				customClass: 'el-message-box-cust',
				type: 'warning'
			}).then(() => {
				this.$message({
					type: 'success',
					message: '导航已重启!'
				});
			}).catch(() => { });
		},
		// 关闭导航
		offNavigation() {
			this.$confirm('将关闭当前导航, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				customClass: 'el-message-box-cust',
				type: 'warning'
			}).then(() => {
				this.$message({
					type: 'success',
					message: '导航已关闭!'
				});
			}).catch(() => { });
		},
		// 关闭任务生成弹窗
		closeTaskGenerate() {
			this.taskGenerateDiaShow = false;
			this.restGenerateParam();
		},
		// 重置任务创建弹窗数据
		restGenerateParam() {
			this.generateTaskParam = {
				taskId: '',
				taskName: '',
				count: 1,
				time: '',
				date: [],  // 1-7分别指代周一到周末
				selectedWaypoints: [] // 清空选中的目标点
			}
		},
		// 任务删除
		removeTaskItem(data) {
			this.$confirm('删除名为' + data.taskName + '的任务', '删除', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				customClass: 'el-message-box-cust',
				type: 'warning'
			}).then(() => {
				this.$message({
					type: 'success',
					message: '已删除!'
				});
				this.taskDataList = this.taskDataList.filter(task => task.taskId !== data.taskId);
			}).catch(() => { });
		},
		// 执行任务
		executeTask(data) {
			this.$confirm('开始执行任务' + data.taskName + '?', '执行', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				customClass: 'el-message-box-cust',
				type: 'warning'
			}).then(() => {
				this.$message({
					type: 'success',
					message: '任务已开始执行!'
				});
				this.taskDataList.forEach(task => {
					if (task.taskId === data.taskId) {
						task.status = 0;
					}
				});
			}).catch(() => { });
		},
		test() {
			console.log(this.set);
		},
		// 开启地图选点
		mapSelectEle(type) {
			if (type == 'open') {
				this.pointSelectionEnabled = true;
				this.poseInitEnable = false;
				this.$notify({
					title: '地图选择',
					message: '已开启选择模式',
					type: 'success',
					duration: 1000
				});
			} else {
				this.pointSelectionEnabled = false;
				this.$notify.info({
					title: '关闭选择',
					message: '已关闭选择模式',
					duration: 1000
				});
			}
		},
		// 将当前选择的点位数据添加到点位列表中 
		// currentCoordinate 坐标信息 currentPlace 画布位置信息
		addNowPoint(currentCoordinate, currentPlace) {
			let coordData = {
				id: currentCoordinate[0],
				name: `目标点${currentCoordinate[0]}`,
				x: currentCoordinate[1].toFixed(3),
				y: currentCoordinate[2].toFixed(3),
				placeX: currentPlace[0].toFixed(3),
				placeY: currentPlace[1].toFixed(3),
				type: 1,
				action: [{ value: 0, other: 0 }]
			}
			this.waypoints.push(coordData);
			this.$message.success(`已添加目标点: (${coordData.x}, ${coordData.y})`);
		},
		/**
		 * 位姿初始化结果回调（参考robot_map_editor实现）
		 * @param position 位置坐标 [x, y]
		 * @param yaw 机器人朝向角（弧度值）
		 * @param nid 点位ID（可选）
		 */
		initNavigationResult(position, yaw, nid) {
			console.log("=== 位姿初始化 ===");
			console.log("位置:", `x=${position[0].toFixed(3)}, y=${position[1].toFixed(3)}`);
			console.log("朝向角(弧度):", yaw.toFixed(4));
			console.log("朝向角(度):", (yaw * 180 / Math.PI).toFixed(2) + "°");
			console.log("点位ID:", nid || "null");
			
			// 发布位姿初始化MQTT消息
			this.$refs.mqtt.publish(this.$mqttPrefix + "/localization/action/init", {
				"timestamp": Date.now(),
				"args": [
					{
						"pose": {
							"xyz": [position[0], position[1], 0.0],
							"rpy": [0.0, 0.0, yaw],  // yaw为弧度值
							"blh": null
						},
						"nid": nid || null  // 如果有关联的点位ID则传递
					}
				]
			}, 2, false);
			
			// 关闭初始化模式
			this.initPoseMode = false;
			this.nowHandMenu = '';
			
			// 显示成功提示
			this.$message.success({
				message: `位姿初始化成功！位置: (${position[0].toFixed(2)}, ${position[1].toFixed(2)}), 朝向: ${(yaw * 180 / Math.PI).toFixed(1)}°`,
				duration: 3000
			});
			/* this.$refs.mqtt.publish(this.$mqttPrefix + "/localization/action/init", {
					"timestamp" : 123456,
					"args"      : [
							{"nid"  : Number(num)}
					]
				},2,false); */
			
			// console.log(position);
			// console.log(angle);
		},

		// === 新UI相关方法 ===
		
		
		// Tab切换事件
		onTabChange(tabKey) {
			this.activeTab = tabKey;
			this.lastTab = tabKey;
			
			// 根据Tab自动调整模式
			if (tabKey === 'points' && this.selectPointMode) {
				// 保持选点模式
			} else if (tabKey !== 'points') {
				// 切换到其他Tab时退出选点模式
				this.selectPointMode = false;
				this.nowHandMenu = '';
			}
		},
		
		// 切换选点模式
		toggleSelectPointMode() {
			this.selectPointMode = !this.selectPointMode;
			this.initPoseMode = false;
			this.nowHandMenu = this.selectPointMode ? '选点模式' : '';
			
			if (this.selectPointMode) {
				this.$message.success('已进入选点模式');
			} else {
				this.$message.info('已退出选点模式');
			}
		},
		
		// 清空所有点位
		clearAllPoints() {
			this.$confirm('确定要清空所有点位吗？', '确认清空', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.pointList = [];
				if (this.$refs.olmap && this.$refs.olmap.restIdNum) {
					this.$refs.olmap.restIdNum();
				}
				this.$message.success('已清空所有点位');
			}).catch(() => {});
		},
		
		// 地图缩放
		handleZoomIn() {
			try {
				const map = this.getMapInstance();
				if (map) {
					// OpenLayers API
					const view = map.getView();
					const currentZoom = view.getZoom();
					view.animate({
						zoom: currentZoom + 1,
						duration: 250
					});
				} else if (this.$refs.olmap && this.$refs.olmap.zoomIn) {
					// 备用方法
					this.$refs.olmap.zoomIn();
				}
			} catch (error) {
				console.warn('地图放大失败:', error);
				this.$message.warning('地图放大失败');
			}
		},
		
		handleZoomOut() {
			try {
				const map = this.getMapInstance();
				if (map) {
					// OpenLayers API
					const view = map.getView();
					const currentZoom = view.getZoom();
					view.animate({
						zoom: Math.max(currentZoom - 1, 1),
						duration: 250
					});
				} else if (this.$refs.olmap && this.$refs.olmap.zoomOut) {
					// 备用方法
					this.$refs.olmap.zoomOut();
				}
			} catch (error) {
				console.warn('地图缩小失败:', error);
				this.$message.warning('地图缩小失败');
			}
		},
		
		// 居中到机器人
		handleCenterToRobot() {
			try {
				const map = this.getMapInstance();
				if (map) {
					// OpenLayers API
					const view = map.getView();
					
					// 与标定页面保持一致的实现
					let centerPoint = [this.robotPoseData.x, this.robotPoseData.y];
					if (this.robotPoseData.x === 0 && this.robotPoseData.y === 0) {
						// 使用当前地图中心点作为默认位置
						centerPoint = view.getCenter();
						console.log('使用地图中心点作为居中位置:', centerPoint);
					} else {
						console.log('使用机器人位置作为居中位置:', centerPoint);
					}
					
					view.animate({
						center: centerPoint,
						zoom: Math.max(view.getZoom(), 15),
						duration: 500
					});
					this.$message.success('已居中到机器人位置');
				} else if (this.$refs.olmap && this.$refs.olmap.centerToRobot) {
					// 备用方法
					this.$refs.olmap.centerToRobot();
					this.$message.success('已居中到机器人位置');
				} else {
					console.warn('无法获取地图实例');
					this.$message.warning('地图未就绪，无法居中');
				}
			} catch (error) {
				console.error('定位机器人失败:', error);
				console.log('调试信息:', {
					robotPoseData: this.robotPoseData,
					robotPosition: this.robotPosition,
					mapReady: !!this.getMapInstance()
				});
				this.$message.warning('定位机器人失败: ' + error.message);
			}
		},
		
		// 切换全屏
		handleToggleFullscreen() {
			const mapContainer = this.$el.querySelector('.map-stage');
			if (!mapContainer) {
				this.$message.error('无法找到地图容器');
				return;
			}
			
			if (FullscreenOperations.toggleFullscreen(mapContainer)) {
				// 全屏切换成功，状态会通过监听器自动更新
			} else {
				this.$message.error('浏览器不支持全屏功能');
			}
		},
		
		// 确认初始化
		handleConfirmInit() {
			this.initPoseMode = true;
			this.selectPointMode = false;
			this.nowHandMenu = '初始化导航';
			this.$message.success('已进入位姿初始化模式');
		},
		
		// 确认重启
		handleConfirmReboot() {
			this.isBusy = true;
			const timestamp = new Date().getTime();
			
			// 构建导航重启请求，使用当前地图
			// const restartRequest = {
			// 	"timestamp": timestamp,
			// 	"args": [this.mapName] // 重启后使用当前地图
			// };
    const restartRequest = {
			"timestamp" : timestamp,
			"args"      : [
						{
								"function" : "ASM.nav_standard.start",
								"argc"     : 0,
								"argv"     : [this.mapName]
							}
					]
				}
			
			// 发送导航重启MQTT消息
			this.$refs.mqtt.publish(this.$mqttPrefix + "/ability/function/action/exec", restartRequest, 2, false);
			
			this.$message.success('导航重启指令已发送');
			console.log("发送导航重启请求:", restartRequest);
			
			// 如果15秒内没有收到响应，自动取消忙碌状态
			setTimeout(() => {
				if (this.isBusy) {
					this.isBusy = false;
					this.$message.warning('导航重启响应超时，请检查系统状态');
				}
			}, 15000);
		},
		
		// 确认停止
		handleConfirmStop() {
			this.selectPointMode = false;
			this.initPoseMode = false;
			this.nowHandMenu = '';
			
			// 弹出选择对话框，让用户选择是停止导航还是急停
			this.$confirm('请选择要执行的操作：', '操作选择', {
				confirmButtonText: '急停',
				cancelButtonText: '停止导航',
				distinguishCancelAndClose: true,
				type: 'warning',
				customClass: 'stop-action-dialog'
			}).then(() => {
				// 用户选择急停
				this.executeEmergencyStop();
			}).catch((action) => {
				if (action === 'cancel') {
					// 用户选择停止导航
					this.executeNavigationStop();
				}
				// 如果是关闭对话框(action === 'close')，则不执行任何操作
			});
		},
		
		// 执行急停操作
		executeEmergencyStop() {
			const timestamp = new Date().getTime();
			
			// 构建急停请求
			const emergencyStopRequest = {
				"timestamp": timestamp,
				"args": [true] // true表示启用急停
			};
			
			// 发送急停MQTT消息
			this.$refs.mqtt.publish(this.$mqttPrefix + "/control/vehicle/action/stop", emergencyStopRequest, 1, false);
			
			this.$message.warning('急停指令已发送');
			console.log("发送急停请求:", emergencyStopRequest);
		},
		
		// 执行导航停止操作
		executeNavigationStop() {
			const timestamp = new Date().getTime();
			
			// 构建导航停止请求
			const stopRequest = {
				"timestamp": timestamp,
				"args": null
			};
			
			// 发送导航停止MQTT消息
			this.$refs.mqtt.publish(this.$mqttPrefix + "/navigation/stack/action/stop", stopRequest, 2, false);
			
			this.$message.info('导航停止指令已发送');
			console.log("发送导航停止请求:", stopRequest);
		},
		
		// 解除急停（可以在UI中添加按钮调用）
	executeEmergencyStopRelease() {
		const timestamp = new Date().getTime();
		
		// 构建解除急停请求
		const releaseRequest = {
			"timestamp": timestamp,
			"args": [false] // false表示解除急停
		};
		
		// 发送解除急停MQTT消息
		this.$refs.mqtt.publish(this.$mqttPrefix + "/control/vehicle/action/stop", releaseRequest, 1, false);
		
		this.$message.success('解除急停指令已发送');
		console.log("发送解除急停请求:", releaseRequest);
	},
	
	// === 导航任务控制方法 ===
	
	// 暂停当前导航
	handleNavigationPause() {
		if (!this.isNavigating || this.navigationStatus === 'paused') {
			this.$message.warning('当前没有正在执行的导航任务');
			return;
		}
		
		const timestamp = new Date().getTime();
		
		// 构建暂停请求 - 发送到任务控制主题
		const pauseRequest = {
			"timestamp": timestamp,
			"args": []
		};
		
		// 发送暂停MQTT消息
		this.$refs.mqtt.publish(this.$mqttPrefix + "/task/procedure/action/pause", pauseRequest, 2, false);
		
		// 更新本地状态
		this.navigationStatus = 'paused';
		
		this.$message.success('导航已暂停');
		console.log("发送导航暂停请求:", pauseRequest);
	},
	
	// 恢复当前导航
	handleNavigationResume() {
		if (!this.currentNavigationTask || this.navigationStatus !== 'paused') {
			this.$message.warning('没有可恢复的导航任务');
			return;
		}
		
		const timestamp = new Date().getTime();
		
		// 构建恢复请求
		const resumeRequest = {
			"timestamp": timestamp,
			"args": []
		};
		
		// 发送恢复MQTT消息
		this.$refs.mqtt.publish(this.$mqttPrefix + "/task/procedure/action/resume", resumeRequest, 2, false);
		
		// 更新本地状态
		this.navigationStatus = 'navigating';
		
		this.$message.success('导航已恢复');
		console.log("发送导航恢复请求:", resumeRequest);
	},
	
	// 停止当前导航
	handleNavigationStop() {
		if (!this.isNavigating && this.navigationStatus === 'idle') {
			this.$message.warning('当前没有导航任务');
			return;
		}
		
		// 二次确认
		this.$confirm('确定要停止当前导航任务吗？', '确认停止', {
			confirmButtonText: '确定',
			cancelButtonText: '取消',
			type: 'warning'
		}).then(() => {
			const timestamp = new Date().getTime();
			
			// 构建停止请求
			const stopRequest = {
				"timestamp": timestamp,
				"args": []
			};
			
			// 发送停止MQTT消息
			this.$refs.mqtt.publish(this.$mqttPrefix + "/task/procedure/action/cancel", stopRequest, 2, false);
			
			// 更新本地状态
			this.isNavigating = false;
			this.navigationStatus = 'idle';
			this.currentNavigationTask = null;
			
			// 清除地图上的轨迹
			if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
				this.$refs.olmap.clearTrajectory();
				// 恢复路网显示
				this.settingParams.showRoadNetwork = true;
			}
			
			this.$message.success('导航任务已停止');
			console.log("发送导航停止请求:", stopRequest);
		}).catch(() => {
			// 用户取消操作
		});
	},
	
	
	// 任务相关方法
		showCreateTaskDialog() {
			this.$message.info('创建任务功能待接入');
		},
		
		startTask(task) {
			task.status = 'running';
			this.$message.success(`任务 "${task.name}" 已开始执行`);
		},
		
		pauseTask(task) {
			task.status = 'paused';
			this.$message.warning(`任务 "${task.name}" 已暂停`);
		},
		
		resumeTask(task) {
			task.status = 'running';
			this.$message.success(`任务 "${task.name}" 已继续执行`);
		},
		
		cancelTask(task) {
			this.$confirm(`确定要取消任务 "${task.name}" 吗？`, '确认取消', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				task.status = 'idle';
				this.$message.info(`任务 "${task.name}" 已取消`);
			}).catch(() => {});
		},
		
		// 切换初始化模式
		toggleInitPoseMode() {
			this.initPoseMode = !this.initPoseMode;
			this.selectPointMode = false;
			this.nowHandMenu = this.initPoseMode ? '初始化导航' : '';
			
			if (this.initPoseMode) {
				this.$message.success('已进入位姿初始化模式');
			} else {
				this.$message.info('已退出位姿初始化模式');
			}
		},
		
		// RightPanel 事件处理方法
		onRestart() {
			this.handleConfirmReboot();
		},
		
		onStop() {
			this.handleConfirmStop();
		},
		
		onInit() {
			this.handleConfirmInit();
		},
		
		// MapToolbar 方法别名
		onZoomIn() {
			this.handleZoomIn();
		},
		
		onZoomOut() {
			this.handleZoomOut();
		},
		
		onCenterRobot() {
			this.handleCenterToRobot();
		},
		
		onToggleFullscreen() {
			this.handleToggleFullscreen();
		},
		
		// 辅助方法
		getTaskStatusText(status) {
			const statusMap = {
				'idle': '空闲',
				'running': '执行中',
				'paused': '暂停'
			};
			return statusMap[status] || '未知';
		},
		
		// === 导航页RightPanel事件处理 ===
		
		// 目标点事件
		onWpSelect(waypoint) {
			console.log('选择目标点:', waypoint);
			this.$message.success(`已选择目标点: ${waypoint.name}`);
		},
		
		onWpSend(waypoint) {
			console.log('发送目标点:', waypoint);
			this.$message.success(`已发送目标点: ${waypoint.name}`);
		},
		
		onWpCreate() {
			console.log('创建目标点');
			this.$message.info('创建目标点功能待实现');
		},
		
		onWpEdit(waypoint) {
			console.log('编辑目标点:', waypoint);
			this.pointEditDiaShow = true;
			this.pointEditData.id = waypoint.id;
			this.pointEditData.x = waypoint.x;
			this.pointEditData.y = waypoint.y;
			this.pointEditData.type = waypoint.type;
			this.pointEditData.actionMenuList = waypoint.action ? [...waypoint.action] : [{ value: 0, other: 0 }];
		},
		
		onWpRemove(waypoint) {
			console.log('删除目标点:', waypoint);
			// 从waypoints数组中删除目标点
			this.waypoints = this.waypoints.filter(wp => wp.id !== waypoint.id);
			// 如果删除的是选中的目标点，也要从选中列表中移除
			this.selectedWaypointIds = this.selectedWaypointIds.filter(id => id !== waypoint.id);
			// if (this.selectedWaypointIds.length < 1) {
			// 		// 重置地图的id计数器
			// 		this.$refs.olmap.restIdNum();
			// 	}
			this.$refs.olmap.removeIconHtmlById("calibration-"+waypoint.id)
			this.$message.success(`已删除目标点: ${waypoint.name || '目标点'}`);
		},
		

		// 新增的目标点操作方法
		onWpMoveUp() {
			if (this.selectedWaypointIds.length !== 1) return;
			
			const selectedId = this.selectedWaypointIds[0];
			const index = this.waypoints.findIndex(wp => wp.id === selectedId);
			
			if (index > 0) {
				// 交换位置
				const temp = this.waypoints[index];
				this.$set(this.waypoints, index, this.waypoints[index - 1]);
				this.$set(this.waypoints, index - 1, temp);
				this.$message.success('目标点已上移');
			}
		},

		onWpMoveDown() {
			if (this.selectedWaypointIds.length !== 1) return;
			
			const selectedId = this.selectedWaypointIds[0];
			const index = this.waypoints.findIndex(wp => wp.id === selectedId);
			
			if (index < this.waypoints.length - 1) {
				// 交换位置
				const temp = this.waypoints[index];
				this.$set(this.waypoints, index, this.waypoints[index + 1]);
				this.$set(this.waypoints, index + 1, temp);
				this.$message.success('目标点已下移');
			}
		},

		onWpBatchRemove() {
			if (this.selectedWaypointIds.length === 0) return;
			
			this.$confirm(`确定要删除选中的 ${this.selectedWaypointIds.length} 个目标点吗？`, '批量删除', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				// 删除选中的目标点
				// this.waypoints = this.waypoints.filter(wp => !this.selectedWaypointIds.includes(wp.id));
				// 获取所有即将被删除的 waypoints
				const waypointsToRemove = this.waypoints.filter(
					wp => this.selectedWaypointIds.includes(wp.id)
				);

				// 从地图上移除图标
				waypointsToRemove.forEach(wp => {
					this.$refs.olmap.removeIconHtmlById("calibration-" + wp.id);
				});

				// 从数组中移除这些 waypoints
				this.waypoints = this.waypoints.filter(
					wp => !this.selectedWaypointIds.includes(wp.id)
				);
				this.selectedWaypointIds = [];
				this.selectedWaypoints = [];
				this.$message.success('目标点删除成功');
			}).catch(() => {});
		},

	onWpGoto() {
		if (this.selectedWaypointIds.length !== 1) return;
		
		// 检查是否正在导航
		if (this.isNavigating) {
			this.$message.warning('机器人正在导航中，请等待任务完成后再发送新任务');
			return;
		}
		
		const selectedWaypoint = this.waypoints.find(wp => wp.id === this.selectedWaypointIds[0]);
		console.log('前往目标点:', selectedWaypoint);
		
		if (selectedWaypoint) {
			// 清除之前的轨迹
			if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
				this.$refs.olmap.clearTrajectory();
				console.log('已清除之前的轨迹');
			}
			
			const timestamp = new Date().getTime();
			
			// 构建goto请求
			const gotoRequest = {
				"timestamp": timestamp,
				"args": [
					{
						"roadmap": this.mapName,
						"nid": [], // 使用空数组，优先使用coord
						"coord": [
							[Number(selectedWaypoint.x), Number(selectedWaypoint.y)]
						]
					}
				]
			};
			
			// 保存当前任务状态
			this.currentNavigationTask = {
				waypoint: selectedWaypoint,
				timestamp: timestamp,
				status: 'planning'
			};
			this.lastGotoRequest = gotoRequest;
			this.navigationStatus = 'planning';
				
				// 发送路径规划请求（用于轨迹显示）
				const planRequest = {
					"timestamp": timestamp,
					"args": [
						{
							"roadmap": this.mapName,
							"nid": [],
							"coord": [
								[Number(selectedWaypoint.x), Number(selectedWaypoint.y)]
							]
						}
					]
				};
				
				// 发送MQTT消息
				this.$refs.mqtt.publish(this.$mqttPrefix + "/planning/service/plan/request", planRequest, 2, false);
				this.$refs.mqtt.publish(this.$mqttPrefix + "/task/target/action/goto", gotoRequest, 2, false);
				
				this.$message.success(`正在发送前往指令: ${selectedWaypoint.name || '目标点' + selectedWaypoint.id} (${selectedWaypoint.x}, ${selectedWaypoint.y})`);
				console.log("发送前往目标点请求:", gotoRequest);
				console.log("发送路径规划请求:", planRequest);
			}
		},

	onWpGotoSingle(waypoint) {
		// 检查是否正在导航
		if (this.isNavigating) {
			this.$message.warning('机器人正在导航中，请等待任务完成后再发送新任务');
			return;
		}
		
		// 清除之前的轨迹
		if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
			this.$refs.olmap.clearTrajectory();
			console.log('已清除之前的轨迹');
		}
		
		const timestamp = new Date().getTime();
		
		// 构建goto请求
		const gotoRequest = {
			"timestamp": timestamp,
			"args": [
				{
					"roadmap": this.mapName,
					"nid": [], // 使用空数组，优先使用coord
					"coord": [
						[Number(waypoint.x), Number(waypoint.y)]
					]
				}
			]
		};
		
		// 保存当前任务状态
		this.currentNavigationTask = {
			waypoint: waypoint,
			timestamp: timestamp,
			status: 'planning'
		};
		this.lastGotoRequest = gotoRequest;
		this.navigationStatus = 'planning';
			
			// 发送路径规划请求（用于轨迹显示）
			const planRequest = {
				"timestamp": timestamp,
				"args": [
					{
						"roadmap": this.mapName,
						"nid": [],
						"coord": [
							[Number(waypoint.x), Number(waypoint.y)]
						]
					}
				]
			};
			
			// 发送MQTT消息
			this.$refs.mqtt.publish(this.$mqttPrefix + "/planning/service/plan/request", planRequest, 2, false);
			this.$refs.mqtt.publish(this.$mqttPrefix + "/task/target/action/goto", gotoRequest, 2, false);
			
			this.$message.success(`正在发送前往指令: ${waypoint.name || '目标点' + waypoint.id} (${waypoint.x}, ${waypoint.y})`);
			console.log("发送前往目标点请求:", gotoRequest);
			console.log("发送路径规划请求:", planRequest);
		},
		
		// 取消当前导航任务
		cancelCurrentNavigation() {
			if (!this.isNavigating) {
				this.$message.info('当前没有正在进行的导航任务');
				return;
			}
			
			this.$confirm('确定要取消当前的导航任务吗？', '取消导航', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				// 重置导航状态
				this.navigationStatus = 'idle';
				this.isNavigating = false;
				this.currentNavigationTask = null;
			this.lastGotoRequest = null;
			
			// 清除轨迹
			if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
				this.$refs.olmap.clearTrajectory();
				// 恢复路网显示
				this.settingParams.showRoadNetwork = true;
			}
			
			this.$message.success('导航任务已取消');
				console.log('用户取消了导航任务');
			}).catch(() => {
				// 用户点击了取消
			});
		},
		
	// 执行下一个目标点
	executeNextWaypoint() {
		if (!this.currentExecutingTask || !this.currentExecutingTask.points) {
			console.error('没有正在执行的任务或任务没有目标点');
			return;
		}
		
		const waypoints = this.currentExecutingTask.points;
		const currentIndex = this.currentTaskWaypointIndex;
		
		if (currentIndex >= waypoints.length) {
			console.log('所有目标点已执行完成');
			return;
		}
		
		const currentWaypoint = waypoints[currentIndex];
		console.log(`执行目标点 ${currentIndex + 1}/${waypoints.length}:`, currentWaypoint);
		
		// 清除之前的轨迹（执行新目标点前）
		if (this.$refs.olmap && this.$refs.olmap.clearTrajectory) {
			this.$refs.olmap.clearTrajectory();
			console.log('已清除之前的轨迹，准备执行下一个目标点');
		}
		
		const timestamp = new Date().getTime();
			
			// 构建goto请求
			const gotoRequest = {
				"timestamp": timestamp,
				"args": [
					{
						"roadmap": this.mapName,
						"nid": [],
						"coord": [
							[Number(currentWaypoint.x), Number(currentWaypoint.y)]
						]
					}
				]
			};
			
			// 发送路径规划请求（用于轨迹显示）
			const planRequest = {
				"timestamp": timestamp,
				"args": [
					{
						"roadmap": this.mapName,
						"nid": [],
						"coord": [
							[Number(currentWaypoint.x), Number(currentWaypoint.y)]
						]
					}
				]
			};
			
			// 保存当前导航状态
			this.currentNavigationTask = {
				waypoint: currentWaypoint,
				timestamp: timestamp,
				taskContext: {
					taskId: this.currentExecutingTask.taskId,
					waypointIndex: currentIndex,
					totalWaypoints: waypoints.length
				}
			};
			this.lastGotoRequest = gotoRequest;
			this.navigationStatus = 'planning';
			this.isNavigating = true;
			
			// 发送MQTT消息
			this.$refs.mqtt.publish(this.$mqttPrefix + "/planning/service/plan/request", planRequest, 2, false);
			this.$refs.mqtt.publish(this.$mqttPrefix + "/task/target/action/goto", gotoRequest, 2, false);
			
			this.$message.info(`正在前往第 ${currentIndex + 1} 个目标点: ${currentWaypoint.name || '目标点' + currentWaypoint.id} (${currentWaypoint.x}, ${currentWaypoint.y})`);
			console.log("发送前往目标点请求:", gotoRequest);
		},
		
		// 处理任务中的目标点到达事件
		handleTaskWaypointArrival() {
			if (!this.currentExecutingTask) return;
			
			this.currentTaskWaypointIndex++;
			const totalWaypoints = this.currentExecutingTask.points.length;
			
			console.log(`目标点到达，进度: ${this.currentTaskWaypointIndex}/${totalWaypoints}`);
			
			if (this.currentTaskWaypointIndex >= totalWaypoints) {
				// 所有目标点都已完成，任务结束
				this.$message.success(`任务 "${this.currentExecutingTask.taskName}" 的所有目标点已完成！`);
				console.log('任务所有目标点执行完成');
			} else {
				// 继续执行下一个目标点
				this.$message.success(`第 ${this.currentTaskWaypointIndex} 个目标点已到达，继续前往下一个目标点...`);
				setTimeout(() => {
					this.executeNextWaypoint();
				}, 2000); // 2秒后继续下一个目标点
			}
		},

		onWpCreateTask() {
			if (this.selectedWaypointIds.length === 0) {
				this.$message.warning('请先选择要添加到任务中的目标点');
				return;
			}
			
			const selectedWaypoints = this.waypoints.filter(wp => this.selectedWaypointIds.includes(wp.id));
			console.log(`准备使用 ${selectedWaypoints.length} 个目标点创建任务`, selectedWaypoints);
			
			// 将选中的目标点保存到待创建任务中
			this.generateTaskParam.selectedWaypoints = selectedWaypoints;
			
			// 打开任务创建对话框
			this.taskGenerateDiaShow = true;
		},

		onWpSelectionChange(selection) {
			this.selectedWaypointIds = selection.map(wp => wp.id);
			this.waypointSingle = selection.length !== 1;
			this.waypointMultiple = selection.length === 0;
			console.log('目标点选择变更:', this.selectedWaypointIds);
		},

		onMapSelectModeChange(isActive) {
			this.selectPointMode = isActive;
			this.initPoseMode = false; // 确保互斥
			
			if (isActive) {
				this.$message.success('已开启地图选点模式，点击地图添加目标点');
			} else {
				this.$message.info('已关闭地图选点模式');
			}
		},

		// === 目标点编辑相关方法 ===
		
		// 追加动作按钮
		appendActionMenu() {
			this.pointEditData.actionMenuList.push({ value: 0, other: 0 });
		},
		
		// 删除追加动作按钮
		removeActionMenu(index) {
			this.pointEditData.actionMenuList.splice(index, 1);
		},
		
		// 修改动作下拉值
		changeAction(index) {
			// 判断当前修改后是否是原定等待,如果不是则删除other属性
			let item = this.pointEditData.actionMenuList[index];
			if (item.value === 0) {
				// 原地等待需要等待时间参数
				if (!('other' in item)) {
					item.other = 0;
				}
			} else {
				// 其他动作不需要等待时间参数
				if ('other' in item) {
					delete item.other;
				}
			}
		},
		
		// 提交点位修改
		submitEditPoint() {
			this.pointEditDiaShow = false;
			// 查找要修改的目标点
			const waypoint = this.waypoints.find(item => item.id === this.pointEditData.id);
			if (waypoint) {
				// 更新数据
				waypoint.x = this.pointEditData.x;
				waypoint.y = this.pointEditData.y;
				waypoint.type = this.pointEditData.type;
				waypoint.action = [...this.pointEditData.actionMenuList];
				this.$message.success("目标点数据已修改");
			}
		},

		// 清空编辑对话框数据
		clearActionDia() {
			this.pointEditData.id = '';
			this.pointEditData.x = '';
			this.pointEditData.y = '';
			this.pointEditData.type = '';
			this.pointEditData.actionMenuList = [];
		},
		
		// 任务事件
		// 加载任务列表（优化版：获取完整任务信息包括cron配置）
		async loadTaskList() {
			try {
				const response = await listTask(this.mapName);
				// console.log("获取任务列表响应:", response);
				
				if (response.status && response.paths && Array.isArray(response.paths)) { 
					// 🔧 优化：保存旧的 tasks 数组，用于状态恢复
					const oldTasks = this.tasks || [];
					
					// 为每个任务获取详细信息（包括cron配置）
					const taskPromises = response.paths.map(async (taskName, index) => {
						// 优先从旧数组中查找同名任务（保留所有状态）
						const existingTask = oldTasks.find(t => t.taskName === taskName);
						
						// 基础任务对象
						let taskObj = {
							taskId: index + 1,
							taskName: taskName,
							status: 'idle',
							count: 1,
							time: '',
							date: [],
							cron: '',
							points: [],
							executionStatus: 'idle',
							currentWaypointIndex: 0,
							totalWaypoints: 0,
							// 新增：解析后的时间信息
							scheduledTime: null,      // Date对象，表示今日的执行时间
							scheduledTimeStr: '',     // 格式化的时间字符串 "HH:mm"
							scheduledWeekDays: [],    // 星期几数组 [1,2,3]
							shouldRunToday: false     // 是否应该在今天执行
						};
						
						try {
							// 获取任务详情以获取完整的cron配置
							const taskDetail = await getTask(this.mapName, taskName);
							
							if (taskDetail && taskDetail.cron) {
								// 解析cron表达式
								const cronInfo = this.parseCronExpression(taskDetail.cron);
								taskObj.cron = taskDetail.cron;
								taskObj.time = cronInfo.timeStr;
								taskObj.date = cronInfo.weekDays;
								taskObj.scheduledTimeStr = cronInfo.timeStr;
								taskObj.scheduledWeekDays = cronInfo.weekDays;
								
								// 计算今日的执行时间
								if (cronInfo.hours !== null && cronInfo.minutes !== null) {
									const scheduledTime = new Date();
									scheduledTime.setHours(cronInfo.hours, cronInfo.minutes, 0, 0);
									taskObj.scheduledTime = scheduledTime;
								}
								
								// 判断是否应该在今天执行
								const currentDay = new Date().getDay() || 7; // 0=周日转为7
								taskObj.shouldRunToday = cronInfo.weekDays.includes(String(currentDay));
							}
							
							// 保存其他任务配置
							if (taskDetail) {
								taskObj.count = taskDetail.repeate || 1;
								taskObj.points = taskDetail.coord ? taskDetail.coord.map((coord, idx) => ({
									id: idx + 1,
									x: coord[0],
									y: coord[1],
									type: taskDetail.plan && taskDetail.plan[idx] === 'route' ? 1 : 0,
									action: taskDetail.action && taskDetail.action[idx] || []
								})) : [];
								taskObj.totalWaypoints = taskObj.points.length;
							}
							
						} catch (error) {
							console.warn(`获取任务 "${taskName}" 详情失败，使用默认值:`, error);
							// 从existingTask恢复数据
							if (existingTask) {
								taskObj.time = existingTask.time || '';
								taskObj.date = existingTask.date || [];
								taskObj.cron = existingTask.cron || '';
								taskObj.count = existingTask.count || 1;
								taskObj.points = existingTask.points || [];
							}
						}
						
						// 场景1：当前正在执行的任务 - 保留执行状态
						if (this.currentExecutingTask && this.currentExecutingTask.taskName === taskName) {
							taskObj.status = this.currentExecutingTask.status || 'running';
							taskObj.executionStatus = this.currentExecutingTask.executionStatus || 'executing';
							taskObj.currentWaypointIndex = this.currentTaskWaypointIndex || 0;
							if (this.currentExecutingTask.points) {
								taskObj.points = this.currentExecutingTask.points;
							}
						}
						// 场景2：已有任务且有非空闲状态 - 完整保留状态
						else if (existingTask && existingTask.status !== 'idle') {
							console.log(`🔄 保留任务状态: ${taskName} - ${existingTask.status}`);
							taskObj.status = existingTask.status;
							taskObj.executionStatus = existingTask.executionStatus;
							taskObj.currentWaypointIndex = existingTask.currentWaypointIndex;
						}
						
						return taskObj;
					});
					
					// 等待所有任务详情加载完成
					this.tasks = await Promise.all(taskPromises);
					
					console.log("✅ 任务列表加载成功，包含完整cron配置:", this.tasks.length, "个任务");
					
					// 加载任务列表后，计算今日定时任务并更新调度状态标记
					this.calculateTodayScheduledTasks();
				} else {
					console.error("加载任务列表失败");
					this.tasks = [];
				}
			} catch (error) {
				console.error("加载任务列表异常:", error);
				this.tasks = [];
			}
		},
		
		// 解析Quartz Cron表达式
		parseCronExpression(cronStr) {
			// Quartz cron格式：秒 分 时 日 月 周 年
			// 示例：00 12 08 ? * 1,2,3 * （每周一二三 08:12:00执行）
			const result = {
				timeStr: '',
				hours: null,
				minutes: null,
				weekDays: []
			};
			
			if (!cronStr) return result;
			
			try {
				const parts = cronStr.split(' ');
				
				if (parts.length >= 6) {
					// Quartz格式：索引0=秒, 1=分, 2=时, 5=周
					const minutes = parts[1];
					const hours = parts[2];
					const weekdays = parts[5];
					
					// 解析时间
					if (hours !== '*' && hours !== '?' && minutes !== '*' && minutes !== '?') {
						result.hours = parseInt(hours);
						result.minutes = parseInt(minutes);
						result.timeStr = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:00`;
					}
					
					// 解析星期
					if (weekdays !== '*' && weekdays !== '?') {
						result.weekDays = weekdays.split(',').map(d => d.trim()).filter(d => d);
					}
				} else if (parts.length >= 5) {
					// 兼容旧格式：分 时 日 月 周
					const minutes = parts[0];
					const hours = parts[1];
					const weekdays = parts[4];
					
					if (hours !== '*' && hours !== '?' && minutes !== '*' && minutes !== '?') {
						result.hours = parseInt(hours);
						result.minutes = parseInt(minutes);
						result.timeStr = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:00`;
					}
					
					if (weekdays !== '*' && weekdays !== '?') {
						result.weekDays = weekdays.split(',').map(d => d.trim()).filter(d => d);
					}
				}
			} catch (error) {
				console.error("解析cron表达式失败:", cronStr, error);
			}
			
			return result;
		},
		
		// 启动任务列表定时刷新
		startTaskListTimer() {
			// 清除已存在的定时器
			this.stopTaskListTimer();
			
			// 创建定时器，每5秒查询一次任务列表
			this.taskListTimer = setInterval(() => {
				this.loadTaskList();
			}, 5000);
			
			console.log('任务列表定时刷新已启动（每5秒）');
		},
		
		// 停止任务列表定时刷新
		stopTaskListTimer() {
			if (this.taskListTimer) {
				clearInterval(this.taskListTimer);
				this.taskListTimer = null;
				console.log('任务列表定时刷新已停止');
			}
		},
		
		// 清除任务查看的标记点
		clearTaskViewWaypoints() {
			// 清除之前的定时器
			if (this.taskViewAutoCloseTimer) {
				clearTimeout(this.taskViewAutoCloseTimer);
				this.taskViewAutoCloseTimer = null;
			}
			
			// 清除地图上的标记点
			if (this.$refs.olmap && this.currentViewTaskWaypointIds.length > 0) {
				this.currentViewTaskWaypointIds.forEach(waypointId => {
					if (this.$refs.olmap.removeIconHtmlById) {
						this.$refs.olmap.removeIconHtmlById(waypointId);
					}
				});
				
				// 清空当前查看任务的点位ID列表
				this.currentViewTaskWaypointIds = [];
				
				console.log('已清除任务查看标记点');
			}
		},
		
		// 查看任务 - 在地图上回显点位和路径
		async onTaskView(task) {
			console.log('查看任务详情:', task);
			
			try {
				// 1. 先清除上一次查看的标记点
				this.clearTaskViewWaypoints();
				
				// 获取任务详情
				const response = await getTask(this.mapName, task.taskName);
				console.log('任务详情响应:', response);
				
				if (response && response.coord && response.coord.length > 0) {
					// 转换坐标为点位数组
					const waypoints = response.coord.map((coord, index) => ({
						id: index + 1,
						name: `点位${index + 1}`,
						x: coord[0],
						y: coord[1]
					}));
					
					// 2. 在地图上绘制新的点位标记
					waypoints.forEach((waypoint, index) => {
						if (this.$refs.olmap && this.$refs.olmap.addHtmlIcon) {
							const displayId = index + 1; // 显示的序号（1, 2, 3...）
							// 使用addHtmlIcon方法添加点位标记
							// 参数: id(显示的数字), x, y, iconSrc, type
							this.$refs.olmap.addHtmlIcon(
								displayId, // 显示序号
								waypoint.x, 
								waypoint.y, 
								'', // iconSrc留空
								'task-view' // type标记
							);
							// 记录点位ID（addHtmlIcon生成的overlay ID格式为 calibration-displayId）
							this.currentViewTaskWaypointIds.push(`calibration-${displayId}`);
						}
					});
					
					// 3. 设置10秒后自动清除标记点
					this.taskViewAutoCloseTimer = setTimeout(() => {
						this.clearTaskViewWaypoints();
					}, 10000);
					
					console.log(`显示任务点位:`, waypoints);
				} else {
					this.$message.warning('该任务没有包含点位数据');
				}
			} catch (error) {
				console.error('加载任务详情失败:', error);
				this.$message.error('加载任务详情失败: ' + (error.message || '未知错误'));
			}
		},
		
		// 编辑任务
		async onTaskEdit(task) {
			console.log('编辑任务:', task);
			
			try {
				// 获取任务详情
				const response = await getTask(this.mapName, task.taskName);
				console.log('任务详情响应:', response);
				
				if (response) {
					// 填充编辑表单
					this.editTaskParam.originalTaskName = task.taskName;
					this.editTaskParam.taskId = task.taskId;
					this.editTaskParam.taskName = task.taskName;
					this.editTaskParam.count = response.repeate || 1;
					
					// 解析cron表达式获取时间和日期
					// Quartz cron格式：秒 分 时 日 月 周 年
					// 示例：00 12 12 ? * 5 * （每周五12:12:00执行）
					if (response.cron) {
						const cronParts = response.cron.split(' ');
						if (cronParts.length >= 7) {
							// Quartz格式：索引0=秒, 1=分, 2=时, 3=日, 4=月, 5=周, 6=年
							const minutes = String(cronParts[1]).padStart(2, '0');
							const hours = String(cronParts[2]).padStart(2, '0');
							const weekdays = cronParts[5];
							
							// 设置时间为字符串格式 "HH:mm:ss"
							this.editTaskParam.time = `${hours}:${minutes}:00`;
							
							// 设置日期
							if (weekdays !== '*' && weekdays !== '?') {
								this.editTaskParam.date = weekdays.split(',').filter(d => d);
							} else {
								this.editTaskParam.date = [];
							}
						} else if (cronParts.length >= 5) {
							// 兼容旧格式：分 时 日 月 周
							const minutes = String(cronParts[0]).padStart(2, '0');
							const hours = String(cronParts[1]).padStart(2, '0');
							const weekdays = cronParts[4];
							
							// 设置时间为字符串格式 "HH:mm:ss"
							this.editTaskParam.time = `${hours}:${minutes}:00`;
							
							// 设置日期
							if (weekdays !== '*' && weekdays !== '?') {
								this.editTaskParam.date = weekdays.split(',').filter(d => d);
							} else {
								this.editTaskParam.date = [];
							}
						}
					} else {
						this.editTaskParam.time = '';
						this.editTaskParam.date = [];
					}
					
					// 转换坐标为目标点格式（供后续使用）
					this.editTaskParam.selectedWaypoints = (response.coord || []).map((coord, index) => ({
						id: index + 1,
						name: `目标点${index + 1}`,
						x: coord[0].toString(),
						y: coord[1].toString(),
						type: response.plan && response.plan[index] === 'route' ? 1 : 0,
						action: response.action && response.action[index] ? 
							this.convertApiActionToEditFormat(response.action[index]) : 
							[{ value: 0, other: 0 }]
					}));
					
					// 打开编辑对话框
					this.taskEditDiaShow = true;
				} else {
					this.$message.error('获取任务详情失败');
				}
			} catch (error) {
				console.error('加载任务详情失败:', error);
				this.$message.error('加载任务详情失败: ' + (error.message || '未知错误'));
			}
		},
		
		// 将API动作格式转换为编辑格式
		convertApiActionToEditFormat(actions) {
			if (!actions || actions.length === 0) {
				return [{ value: 0, other: 0 }];
			}
			
			return actions.map(action => {
				const actionTypeMap = {
					'wait': 0,
					'start_record': 1,
					'stop_record': 2,
					'add_trajectory': 3,
					'hook_mount': 4,
					'hook_unmount': 5
				};
				
				const value = actionTypeMap[action.type] || 0;
				const result = { value };
				
				// 如果是等待动作且有duration参数
				if (action.type === 'wait' && action.duration !== undefined) {
					result.other = action.duration;
				}
				
				return result;
			});
		},
		
		// 关闭任务编辑对话框
		closeTaskEdit() {
			this.taskEditDiaShow = false;
			this.resetEditTaskParam();
		},
		
		// 重置任务编辑参数
		resetEditTaskParam() {
			this.editTaskParam = {
				originalTaskName: '',
				taskId: '',
				taskName: '',
				count: 1,
				time: '',
				date: [],
				selectedWaypoints: []
			};
		},
		
		// 提交任务编辑
		async submitTaskEdit() {
			const orderedPoints = this.editTaskParam.selectedWaypoints || [];
			
			if (!this.editTaskParam.taskName) {
				this.$message.warning('请输入任务名称');
				return;
			}
			
			if (orderedPoints.length === 0) {
				this.$message.warning('任务必须包含至少一个目标点');
				return;
			}
			
			try {
				// 构建任务坐标数组
				const coordinates = orderedPoints.map(point => [
					parseFloat(point.x),
					parseFloat(point.y),
					0
				]);
				
				// 构建plan数组
				const plan = orderedPoints.map(point => {
					return point.type = 'route';
				});
				
				// 构建cron表达式
				// Quartz cron格式：秒 分 时 日 月 周 年
				// 示例：00 12 12 ? * 5 * （每周五12:12:00执行）
				let cron = '';
				if (this.editTaskParam.time && this.editTaskParam.date.length > 0) {
					// time 格式为 "HH:mm:ss" 字符串，直接解析
					let hours, minutes;
					if (typeof this.editTaskParam.time === 'string') {
						// 字符串格式：HH:mm:ss
						const timeParts = this.editTaskParam.time.split(':');
						hours = timeParts[0];
						minutes = timeParts[1];
					} else {
						// Date 对象格式（兼容）
						const timeObj = new Date(this.editTaskParam.time);
						hours = String(timeObj.getHours()).padStart(2, '0');
						minutes = String(timeObj.getMinutes()).padStart(2, '0');
					}
					const weekdays = this.editTaskParam.date.sort().join(',');
					// cron格式: 秒 分 时 日 月 周 年
					cron = `00 ${minutes} ${hours} ? * ${weekdays} *`;
				}
				
				// 如果任务名称改变了，需要先删除旧任务
				if (this.editTaskParam.originalTaskName !== this.editTaskParam.taskName) {
					await delTask({
						map: this.mapName,
						path: this.editTaskParam.originalTaskName
					});
				} else {
					// 即使任务名称没变，也需要先删除再创建（相当于更新）
					await delTask({
						map: this.mapName,
						path: this.editTaskParam.originalTaskName
					});
				}
				
				// 创建新任务（包含修改后的数据）
				const taskData = {
					map: this.mapName,
					path: this.editTaskParam.taskName,
					coord_type: 'local',
					cron: cron,
					coord: coordinates,
					plan: plan,
					action: [[]],
					repeate: this.editTaskParam.count || 1
				};
				
				const response = await addTask(taskData);
				console.log("更新任务响应:", response);
				
				if (response.status === true) {
					this.$message.success('任务修改成功！');
					
					// 重新加载任务列表
					await this.loadTaskList();
					
					// 关闭对话框
					this.closeTaskEdit();
				} else {
					this.$message.error('任务修改失败: ' + (response.msg || '未知错误'));
				}
			} catch (error) {
				console.error("修改任务失败:", error);
				this.$message.error('任务修改失败: ' + (error.message || '未知错误'));
			}
		},
		
		async onTaskStart(task) {
			console.log('开始任务:', task);
			
			// 检查是否有其他任务正在执行
			if (this.isTaskExecuting) {
				this.$message.warning('已有任务正在执行，请先完成或取消当前任务');
				return;
			}
			
			try {
				// 先获取任务详情，以获取点位信息
				const response = await getTask(this.mapName, task.taskName);
				console.log('任务详情响应:', response);
				
				if (response && response.coord && response.coord.length > 0) {
					// 转换坐标为点位格式
					const waypoints = response.coord.map((coord, index) => ({
						id: index + 1,
						name: `目标点${index + 1}`,
						x: coord[0],
						y: coord[1],
						type: response.plan && response.plan[index] === 'route' ? 1 : 0,
						action: response.action && response.action[index] ? response.action[index] : []
					}));
					
					// 更新任务的点位信息
					task.points = waypoints;
					task.totalWaypoints = waypoints.length;
					
					const timestamp = new Date().getTime();
					
					// 构建任务执行请求 - 使用正确的MQTT topic和格式
					const taskExecRequest = {
						"timestamp": timestamp,
						"args": [
							{
								"roadmap": this.mapName,
								"task": task.taskName
							}
						]
					};
					
					// 保存任务执行状态
					this.currentExecutingTask = task;
					this.currentTaskWaypointIndex = 0;
					this.lastTaskExecRequest = taskExecRequest;
					this.isTaskExecuting = true;
					this.taskExecutionStatus = 'executing';
					
					// 更新任务状态
					task.status = 'running';
					task.executionStatus = 'executing';
					
					console.log("===== 任务开始调试信息 =====");
					console.log("任务名称:", task.taskName);
					console.log("任务名称类型:", typeof task.taskName);
					console.log("任务名称长度:", task.taskName.length);
					console.log("任务名称字节:", [...task.taskName].map(c => `${c}(${c.charCodeAt(0)})`).join(' '));
					console.log("任务执行请求:", taskExecRequest);
					console.log("JSON字符串:", JSON.stringify(taskExecRequest));
					console.log("===========================");
					
					// 发送任务执行请求 - 修改为正确的topic
					this.$refs.mqtt.publish(this.$mqttPrefix + "/task/procedure/action/start", taskExecRequest, 2, false);
					
					this.$message.success(`正在启动任务 "${task.taskName}"，包含 ${waypoints.length} 个目标点`);
				} else {
					this.$message.error('任务没有包含目标点，无法执行');
				}
			} catch (error) {
				console.error('获取任务详情失败:', error);
				this.$message.error('获取任务详情失败: ' + (error.message || '未知错误'));
			}
		},
		
		onTaskPause(task) {
			console.log('暂停任务:', task);
			
			// 检查任务状态
			if (task.status !== 'running') {
				this.$message.warning('该任务当前未在执行中');
				return;
			}
			
			const timestamp = new Date().getTime();
			
			// 构建暂停任务请求
			const pauseRequest = {
				"timestamp": timestamp,
				"args": null
			};
			
			// 发送暂停任务请求
			this.$refs.mqtt.publish(this.$mqttPrefix + "/task/procedure/action/pause", pauseRequest, 1, false);
			
			this.$message.info('正在暂停任务...');
			console.log("发送暂停任务请求:", pauseRequest);
		},
		
		onTaskStop(task) {
			console.log('停止任务:', task);
			
			if (!this.isTaskExecuting || this.currentExecutingTask?.taskId !== task.taskId) {
				this.$message.warning('该任务当前未在执行中');
				return;
			}
			
			this.$confirm(`确定要取消任务 "${task.taskName}" 吗？`, '取消任务', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				const timestamp = new Date().getTime();
				
				// 构建取消任务请求
				const cancelRequest = {
					"timestamp": timestamp,
					"args": null
				};
				
				// 发送取消任务请求
				this.$refs.mqtt.publish(this.$mqttPrefix + "/task/procedure/action/cancel", cancelRequest, 1, false);
				
				console.log("发送取消任务请求:", cancelRequest);
			}).catch(() => {
				// 用户取消操作
			});
		},
		
		async onTaskRemove(task) {
			console.log('删除任务:', task);
			
			// 检查任务是否正在执行
			if (this.isTaskExecuting && this.currentExecutingTask?.taskId === task.taskId) {
				this.$message.warning('任务正在执行中，无法删除。请先停止任务。');
				return;
			}
			
			this.$confirm(`确定要删除任务 "${task.taskName}" 吗？`, '删除任务', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				try {
					// 调用删除API
					const response = await delTask({
						map: this.mapName,
						path: task.taskName
					});
					
					if (response.status === true) {
						this.$message.success(`任务 "${task.taskName}" 已删除`);
						
						// 重新加载任务列表
						await this.loadTaskList();
					} else {
						this.$message.error('删除任务失败: ' + (response.msg || '未知错误'));
					}
				} catch (error) {
					console.error("删除任务失败:", error);
					this.$message.error('删除任务失败: ' + (error.message || '未知错误'));
				}
			}).catch(() => {
				// 用户取消操作
			});
		},
		
		// 继续任务（用于暂停后的恢复）
		onTaskResume(task) {
			console.log('继续任务:', task);
			
			// 检查任务状态
			if (task.status !== 'paused') {
				this.$message.warning('该任务当前不在暂停状态');
				return;
			}
			
			const timestamp = new Date().getTime();
			
			// 构建继续任务请求
			const resumeRequest = {
				"timestamp": timestamp,
				"args": null
			};
			
			// 发送继续任务请求
			this.$refs.mqtt.publish(this.$mqttPrefix + "/task/procedure/action/resume", resumeRequest, 2, false);
			
			this.$message.info('正在继续任务...');
			console.log("发送继续任务请求:", resumeRequest);
		},
		
		// 格式化方法
		getTaskStatusText(status) {
			const statusMap = {
				0: '运行中',
				1: '空闲',
				'idle': '空闲',
				'running': '运行中',
				'paused': '暂停',
				'completed': '已完成',
				'error': '失败'
			}
			return statusMap[status] || '未知'
		},
		
		getTaskStatusClass(status) {
			const statusClassMap = {
				0: 'status-running',
				1: 'status-idle',
				'idle': 'status-idle',
				'running': 'status-running',
				'paused': 'status-paused',
				'completed': 'status-completed',
				'error': 'status-error'
			}
			return statusClassMap[status] || 'status-unknown'
		},
		
		formatTime(time) {
			if (!time) return '--'
			if (typeof time === 'string') return time
			if (time instanceof Date) {
				return time.toLocaleTimeString('zh-CN', { 
					hour12: false,
					hour: '2-digit',
					minute: '2-digit'
				})
			}
			return '--'
		},
		
		formatDate(dateArray) {
			if (!dateArray || !Array.isArray(dateArray) || dateArray.length === 0) return '--'
			
			const dayNames = {
				'1': '周一',
				'2': '周二', 
				'3': '周三',
				'4': '周四',
				'5': '周五',
				'6': '周六',
				'7': '周日'
			}
			
			return dateArray.map(day => dayNames[day] || day).join(', ')
		},
		
		// 格式化秒数为时分秒
		formatSeconds(seconds) {
			if (!seconds || seconds < 0) return '00:00:00';
			
			const hours = Math.floor(seconds / 3600);
			const minutes = Math.floor((seconds % 3600) / 60);
			const secs = Math.floor(seconds % 60);
			
			return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
		},
		

		// 功能设置变更处理
		onSettingChange(setting) {
			console.log('功能设置变更:', setting);
			this.settingParams[setting.key] = setting.value;
			
			// 根据设置项类型执行相应操作
			switch(setting.key) {
				case 'pointCloud':
					this.$message.info(`点云显示已${setting.value ? '开启' : '关闭'}`);
					// 这里可以调用地图组件的点云显示/隐藏方法
					break;
				case 'baseMap':
					this.$message.info(`底图显示已${setting.value ? '开启' : '关闭'}`);
					// 这里可以调用地图组件的底图显示/隐藏方法
					break;
				case 'pointId':
					this.$message.info(`点ID显示已${setting.value ? '开启' : '关闭'}`);
					// 这里可以调用地图组件的点ID显示/隐藏方法
					break;
				case 'follow':
					this.$message.info(`位置跟随已${setting.value ? '开启' : '关闭'}`);
					// 这里可以调用地图组件的跟随模式开启/关闭方法
					break;
				case 'network':
					this.$message.info(`网络邻居显示已${setting.value ? '开启' : '关闭'}`);
					// 这里可以调用相关的网络邻居显示/隐藏方法
					break;
			}
		},
		
	},
	
	watch: {
		// 监听面板可见性变化，触发地图刷新
		panelVisible() {
			this.$nextTick(() => {
				this.updateOlCss();
			});
		},
		
		// 监听选点模式变化
		selectPointMode(newVal) {
			if (newVal) {
				this.initPoseMode = false; // 确保互斥
			}
		},
		
		// 监听初始化模式变化
		initPoseMode(newVal) {
			if (newVal) {
				this.selectPointMode = false; // 确保互斥
			}
		},
		
		// 监听实时信息变化，同步机器人位姿数据（已移至handleLaserPose直接处理）
		'realtimeInfo.coordinates': {
			handler(newCoordinates) {
				if (newCoordinates) {
					const position = RobotPositionUtils.parseCoordinates(newCoordinates);
					if (position) {
						this.robotPoseData.x = position.x;
						this.robotPoseData.y = position.y;
						// 角度从heading字段解析，这里先保持不变
						// this.robotPoseData.angle = parseFloat(this.realtimeInfo.heading.replace('°', '')) || 0;
					}
				}
			},
			immediate: true
		}
	}
};
</script>

<style scoped lang="scss">
.point-edit-span {
	display: block;
	margin: 10px 0;
	font-weight: bold;
}

.drawer {
	height: 100%;
	position: absolute;
	top: 0;
	left: 100%;
	/* box-shadow: 4px 4px 12px rgba(201, 201, 201, 0.2); */
	/* 右边和下边的阴影 */
	border-radius: 0 0 12px 0;
	border-left: 1px solid #F0F0F0;
	padding: 8px 15px;
	border-right: 1px solid #ececec;
	border-bottom: 1px solid #ececec;
	overflow-y: auto;
	background-color: #fff;
	z-index: 1000;
}

.drawer-close {
	position: absolute;
	right: 3px;
	top: 3px;
	cursor: pointer;
}

.drawer-title {
	position: absolute;
	top: -23px;
	left: -8px;
	font-size: 13px;
	font-weight: bold;
	color: #838383;
}

.drawer p {
	font-size: 13px;
	border-left: 5px #D1D1D1 solid;
	padding-left: 5px;
	margin: 8px 0;
	border-radius: 3px 0 0 3px;
}

.img-container {
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	/* 垂直居中子元素 */
	border-radius: 7px;
	background: linear-gradient(135deg, #00bcd4, #009688);
	cursor: pointer;
	width: 70%;
	aspect-ratio: 1;
	/* 设置宽高比为1，即高度和宽度相等 */
	margin-top: 10px;
}

.img-container:hover {
	transform: scale(1.02);
	/* 鼠标悬停时放大 */
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
	/* 增加阴影效果 */
	background-color: #00796b;
	/* 改变背景颜色 */
}

.img-container:active {
	transform: scale(0.98);
	/* 点击时缩小 */
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
	/* 点击时加深阴影 */
	background-color: #004d40;
	/* 点击时改变背景颜色 */
	filter: brightness(1.1);
	/* 点击时稍微增加亮度 */
}

.img-container img {
	opacity: 1;
}

.img-container span {
	font-size: 12px;
	color: #ffffff;
	font-weight: bold;
}

/* 激活时的样式 */
.img-container.active {
	background: linear-gradient(135deg, #007d8d, #004b43);
}

.explore-unit {
	margin-left: 8px;
}

::v-deep .el-dialog__body {
	padding: 20px 20px 0 20px;
}

::v-deep .download-map .el-dialog__body {
	padding: 10px 20px 0 20px !important;
}

::v-deep .el-table--medium .el-table__cell {
	padding: 6px 0;
}

::v-deep .action-menu .action-menu_input .el-input__inner {
	padding: 0 5px;
}

.task-status-tag {
	margin-left: 20px;
}

::v-deep .drawer .el-collapse-item__header {
	height: 38px;
	line-height: 38px;
	color: #767676;
	font-weight: bold;
}

::v-deep .drawer .el-collapse-item__content {
	text-align: left;
	padding-bottom: 10px;
}

::v-deep .drawer .el-collapse {
	border: 1px solid #EBEEF5;
	padding: 0 8px;
	border-radius: 5px;
}

.collapse-content-div {
	margin-top: 0;
}

::v-deep .collapse-content-div .el-button--mini {
	padding: 4px 10px;
}


.hand-ment-mark {
	position: absolute;
	bottom: 12px;
	left: 12px;
	z-index: 1000;
}

/* 障碍物警告样式 */
.obstacle-warning {
	position: absolute;
	top: 20px;
	right: 20px;
	z-index: 2000;
	min-width: 320px;
	max-width: 400px;
	border-radius: 12px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
	backdrop-filter: blur(10px);
	animation: slideInRight 0.3s ease-out;
	
	&.obstacle-info {
		background: linear-gradient(135deg, rgba(59, 130, 246, 0.95) 0%, rgba(99, 102, 241, 0.95) 100%);
		border: 1px solid rgba(59, 130, 246, 0.3);
	}
	
	&.obstacle-warning {
		background: linear-gradient(135deg, rgba(245, 158, 11, 0.95) 0%, rgba(251, 191, 36, 0.95) 100%);
		border: 1px solid rgba(245, 158, 11, 0.3);
	}
	
	&.obstacle-danger {
		background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(248, 113, 113, 0.95) 100%);
		border: 1px solid rgba(239, 68, 68, 0.3);
		animation: pulse 2s infinite;
	}
	
	.warning-content {
		display: flex;
		align-items: flex-start;
		padding: 16px 20px;
		color: white;
		
		.warning-icon {
			margin-right: 12px;
			margin-top: 2px;
			flex-shrink: 0;
			
			i {
				font-size: 20px;
				color: white;
			}
		}
		
		.warning-text {
			flex: 1;
			
			.warning-title {
				font-size: 14px;
				font-weight: 600;
				margin-bottom: 4px;
				color: white;
			}
			
			.warning-message {
				font-size: 13px;
				line-height: 1.4;
				margin-bottom: 8px;
				color: rgba(255, 255, 255, 0.95);
			}
			
			.obstacle-distances {
				display: flex;
				gap: 12px;
				flex-wrap: wrap;
				
				.distance-item {
					font-size: 11px;
					background: rgba(255, 255, 255, 0.2);
					padding: 2px 8px;
					border-radius: 12px;
					color: white;
					font-weight: 500;
					border: 1px solid rgba(255, 255, 255, 0.3);
				}
			}
		}
		
		.warning-close {
			margin-left: 8px;
			margin-top: 2px;
			cursor: pointer;
			padding: 4px;
			border-radius: 50%;
			transition: all 0.2s ease;
			flex-shrink: 0;
			
			&:hover {
				background: rgba(255, 255, 255, 0.2);
			}
			
			i {
				font-size: 16px;
				color: white;
			}
		}
	}
}

/* 动画效果 */
@keyframes slideInRight {
	from {
		transform: translateX(100%);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes pulse {
	0%, 100% {
		transform: scale(1);
		box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
	}
	50% {
		transform: scale(1.02);
		box-shadow: 0 12px 32px rgba(239, 68, 68, 0.3);
	}
}

/* 遇障停车提示样式 */
.obstacle-stop-warning {
	position: absolute;
	top: 80px;
	right: 20px;
	z-index: 2000;
	min-width: 380px;
	border-radius: 12px;
	background: white;
	box-shadow: 0 8px 32px rgba(239, 68, 68, 0.2);
	border: 2px solid #FF5555;
	animation: slideInRight 0.3s ease-out, breathe 2s infinite ease-in-out;
	
	.stop-warning-content {
		display: flex;
		align-items: center;
		padding: 16px;
		gap: 16px;
		
		.countdown-circle {
			flex-shrink: 0;
			width: 80px;
			height: 80px;
			border-radius: 50%;
			background: linear-gradient(135deg, #FF5555 0%, #FF8080 100%);
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			color: white;
			box-shadow: 0 4px 12px rgba(255, 85, 85, 0.3);
			
			.countdown-number {
				font-size: 28px;
				font-weight: bold;
				line-height: 1;
			}
			
			.countdown-label {
				font-size: 12px;
				margin-top: 4px;
				opacity: 0.9;
			}
		}
		
		.stop-warning-text {
			flex: 1;
			
			.stop-warning-title {
				font-size: 16px;
				font-weight: 600;
				color: #FF5555;
				margin-bottom: 6px;
			}
			
			.stop-warning-message {
				font-size: 13px;
				color: #666;
				line-height: 1.4;
				margin-bottom: 6px;
			}
			
			.stop-warning-state {
				font-size: 12px;
				color: #999;
			}
		}
		
		.stop-warning-actions {
			flex-shrink: 0;
			
			.el-button {
				padding: 8px 16px;
				font-size: 13px;
			}
		}
	}
}

@keyframes breathe {
	0%, 100% {
		box-shadow: 0 8px 32px rgba(239, 68, 68, 0.2);
	}
	50% {
		box-shadow: 0 12px 40px rgba(239, 68, 68, 0.35);
	}
}

.notification__title {
	font-size: 1.2rem;
	/* 默认字体大小 */
}

.navigation-container {
	width: 100%;
	min-height: calc(100vh - 84px);
	overflow: hidden;
	position: relative;
	background: var(--color-bg-secondary);

	.map-stage {
		position: relative;
		width: 100%;
		height: calc(100vh - 84px);
		min-height: 600px;
		overflow: hidden;
		background: var(--color-bg-secondary);
	}
}

/* 新UI浮层样式 - 重新设计为浮动面板 */
.nav-toolbar {
	position: absolute;
	left: 16px;
	top: 96px;
	z-index: 50;
}




.main-menu {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}

/* 目标点编辑对话框样式 */
::v-deep .waypoint-edit-dialog {
	/* 修复问题1：紫色标题栏圆角对齐 */
	.el-dialog {
		border-radius: 12px !important;
		overflow: hidden !important; /* 确保子元素不会超出圆角 */
		margin-top: 0 !important; /* 移除默认的上边距 */
		margin-bottom: 0 !important; /* 移除默认的下边距 */
		
		/* 确保对话框垂直居中 */
		position: fixed !important;
		top: 50% !important;
		left: 50% !important;
		transform: translate(-50%, -50%) !important;
	}
	
	.el-dialog__header {
		background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
		padding: 20px 24px 16px;
		margin: 0;
		border-radius: 12px 12px 0 0 !important; /* 只有上方圆角 */
		
		.el-dialog__title {
			color: white;
			font-weight: 600;
			font-size: 16px;
		}
		
		.el-dialog__close {
			color: white;
			font-size: 18px;
			
			&:hover {
				color: #f0f0f0;
			}
		}
	}
	
	.el-dialog__body {
		padding: 24px;
		background: #f8fafc;
		margin: 0 !important; /* 确保没有额外边距 */
	}
	
	.el-dialog__footer {
		padding: 16px 24px 24px;
		background: #f8fafc;
		border-top: 1px solid #e2e8f0;
		border-radius: 0 0 12px 12px !important; /* 只有下方圆角 */
		margin: 0 !important; /* 确保没有额外边距 */
	}
}

.dialog-content {
	.form-section {
		background: white;
		border-radius: 10px; /* 稍微增加圆角，与整体设计更协调 */
		padding: 24px; /* 增加内边距，让内容更宽松 */
		margin-bottom: 20px; /* 增加卡片间距 */
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* 稍微增强阴影 */
		border: 1px solid #f1f5f9; /* 添加淡边框 */
		
		&:last-child {
			margin-bottom: 0;
		}
		
		.section-title {
	display: flex;
	align-items: center;
			margin: 0 0 20px 0; /* 增加标题与内容的间距 */
			font-size: 15px; /* 稍微增加字体大小 */
			font-weight: 600;
			color: #2d3748;
			border-bottom: 2px solid #e2e8f0;
			padding-bottom: 10px; /* 增加下内边距 */
			
			i {
				margin-right: 10px; /* 增加图标与文字的间距 */
				color: #667eea;
				font-size: 18px; /* 稍微增加图标大小 */
			}
			
			/* 添加动作按钮样式优化 */
			.add-action-btn {
				margin-left: 12px !important;
				display: inline-flex !important;
				align-items: center !important;
				padding: 4px 8px !important;
				
				i {
					margin-right: 4px !important; /* 减少图标与文字的间距 */
					font-size: 12px !important;
					color: #667eea !important;
					display: inline-block !important;
					vertical-align: middle !important;
				}
				
				span {
					font-size: 12px !important;
					color: #667eea !important;
					line-height: 1 !important;
					vertical-align: middle !important;
				}
				
				&:hover {
					i, span {
						color: #409eff !important;
					}
				}
			}
		}
	}
	
	.waypoint-form {
		.el-form-item {
			margin-bottom: 18px; /* 适中的表单项间距 */
			display: flex !important; /* 使用flex布局 */
			align-items: center !important; /* 标签和输入框水平对齐 */
			
			&:last-child {
				margin-bottom: 0;
			}
			
			/* 确保输入框容器占用剩余空间 */
			.el-form-item__content {
				flex: 1 !important;
				margin-left: 0 !important; /* 移除默认左边距 */
			}
		}
		
		/* 坐标输入框特殊样式 */
		.coordinate-input {
			margin-bottom: 4px; /* 坐标输入框之间的间距稍小 */
		}
		
		.el-form-item__label {
			font-weight: 600 !important; /* 增加字体粗细，更突出 */
			color: #2d3748 !important; /* 更深的颜色，更清晰 */
			padding-right: 12px !important; /* 适当的间距 */
			min-width: 100px !important; /* 稍微增加宽度，适应新的标签 */
			font-size: 14px !important; /* 统一字体大小 */
			line-height: 44px !important; /* 与输入框高度保持一致，实现垂直居中 */
			height: 44px !important; /* 设置标签高度与输入框一致 */
			display: flex !important; /* 使用flex布局 */
			align-items: center !important; /* 垂直居中对齐 */
			margin-bottom: 0 !important; /* 移除默认下边距 */
		}
		
		/* 优化坐标输入框样式 - 分行布局 */
		.coordinate-input {
			.el-input__inner {
				border-radius: 8px !important; /* 稍微增加圆角 */
				border: 1px solid #e2e8f0 !important;
				height: 44px !important; /* 增加输入框高度，更宽松 */
				font-size: 15px !important; /* 增加字体大小，更易读 */
				padding: 0 16px !important; /* 增加左右内边距 */
				background: #ffffff !important;
				transition: all 0.2s ease !important;
				
				&:focus {
					border-color: #667eea !important;
					box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
					background: #fafbff !important;
				}
				
				&:hover {
					border-color: #cbd5e0 !important;
				}
			}
		}
		
		/* 通用输入框样式 */
		.el-input {
			.el-input__inner {
				border-radius: 6px;
				border: 1px solid #e2e8f0;
				height: 40px !important;
				font-size: 14px !important;
				padding: 0 12px !important;
				
				&:focus {
					border-color: #667eea;
					box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
				}
			}
		}
		
		.el-select {
			.el-input__inner {
				border-radius: 6px;
				height: 40px !important; /* 与输入框保持一致的高度 */
				font-size: 14px !important;
			}
		}
	}
	
	.action-list {
		.action-item {
			background: #f7fafc;
			border: 1px solid #e2e8f0;
			border-radius: 8px;
			padding: 12px;
			margin-bottom: 12px;
			transition: all 0.2s ease;
			
			&:hover {
				border-color: #cbd5e0;
				box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
			}
			
			&:last-child {
				margin-bottom: 0;
			}
			
			.action-header {
	display: flex;
	align-items: center;
				gap: 12px;
				margin-bottom: 8px;
				
				.action-index {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 24px;
					height: 24px;
					background: #667eea;
					color: white;
					border-radius: 50%;
					font-size: 12px;
					font-weight: 600;
					flex-shrink: 0;
				}
				
				.remove-btn {
					color: #e53e3e;
					padding: 4px;
					
					&:hover {
						background: #fed7d7;
						color: #c53030;
					}
				}
			}
			
			.action-params {
				padding-left: 36px;
				margin-top: 12px; /* 增加与上方的间距 */
				display: flex !important; /* 使用flex布局 */
				align-items: center !important; /* 垂直居中对齐 */
				flex-wrap: nowrap !important; /* 防止换行 */
				
				/* 修复问题3：优化等待时间输入框样式 */
				.el-input {
					display: inline-flex !important; /* 改为inline-flex，防止换行 */
					width: 160px !important; /* 稍微增加宽度，给"秒"单位更多空间 */
					align-items: center !important; /* 确保垂直居中 */
					
					.el-input__inner {
						background: white;
						height: 36px !important; /* 适中的高度 */
						font-size: 14px !important;
						border-radius: 6px !important;
						border: 1px solid #e2e8f0 !important;
						padding: 0 12px !important;
						flex: 1 !important; /* 输入框占用主要空间 */
						
						&:focus {
							border-color: #667eea;
							box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
						}
					}
					
					/* 修复问题3：优化"秒"单位的append样式 */
					.el-input-group__append {
						background: #f8fafc !important;
						border-color: #e2e8f0 !important;
						color: #4a5568 !important;
						font-weight: 500 !important;
						padding: 0 12px !important; /* 调整内边距 */
						border-radius: 0 6px 6px 0 !important;
						font-size: 14px !important;
						min-width: 40px !important; /* 增加最小宽度 */
						height: 36px !important; /* 明确设置高度 */
						display: flex !important;
						align-items: center !important;
						justify-content: center !important;
						border-left: none !important; /* 移除左边框，与输入框无缝连接 */
						white-space: nowrap !important; /* 防止文字换行 */
						flex-shrink: 0 !important; /* 防止收缩 */
					}
				}
			}
		}
	}
}

::v-deep .dialog-footer {
	text-align: right;
	
	.el-button {
		padding: 10px 20px;
		border-radius: 6px;
		font-weight: 500;
		
		&.el-button--primary {
			background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
			border: none;
			
			&:hover {
				opacity: 0.9;
			}
		}
	}
}

/* 创建任务对话框样式 */
::v-deep .task-create-dialog {
	/* 修复问题1：紫色标题栏圆角对齐 */
	.el-dialog {
		border-radius: 12px !important;
		overflow: hidden !important; /* 确保子元素不会超出圆角 */
		margin-top: 0 !important; /* 移除默认的上边距 */
		margin-bottom: 0 !important; /* 移除默认的下边距 */
		
		/* 确保对话框垂直居中 */
		position: fixed !important;
		top: 50% !important;
		left: 50% !important;
		transform: translate(-50%, -50%) !important;
	}
	
	.el-dialog__header {
		background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
		color: white;
		padding: 20px 24px 16px;
		margin: 0;
		border-radius: 12px 12px 0 0 !important; /* 只有上方圆角 */
		
		.el-dialog__title {
			color: white;
			font-weight: 600;
			font-size: 16px;
		}
		
		.el-dialog__close {
			color: white;
			font-size: 18px;
			
			&:hover {
				color: #f0f0f0;
			}
		}
	}
	
	.el-dialog__body {
		padding: 24px;
		background: #fafbfc;
	}
	
	.el-dialog__footer {
		background: white;
		padding: 16px 24px;
		border-radius: 0 0 12px 12px !important; /* 只有下方圆角 */
		border-top: 1px solid #e2e8f0;
		text-align: right;
		
		.el-button {
			padding: 10px 20px;
			font-weight: 500;
			border-radius: 6px;
			
			&:not(.el-button--primary) {
				color: #64748b;
				border-color: #cbd5e1;
				background: white;
				
				&:hover {
					color: #475569;
					border-color: #94a3b8;
					background: #f8fafc;
				}
			}
			
			&.el-button--primary {
				background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
				border: none;
				
				&:hover {
					background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
				}
			}
		}
	}
}

.task-form {
	.el-form-item {
		margin-bottom: 18px; /* 适中的表单项间距 */
		display: flex !important; /* 使用flex布局 */
		align-items: center !important; /* 标签和输入框水平对齐 */
		
		.el-form-item__label {
			color: #374151;
			font-weight: 500;
			line-height: 44px !important; /* 与输入框高度保持一致，实现垂直居中 */
			height: 44px !important; /* 设置标签高度与输入框一致 */
			display: flex !important; /* 使用flex布局 */
			align-items: center !important; /* 垂直居中对齐 */
			margin-bottom: 0 !important; /* 移除默认下边距 */
		}
		
		.el-form-item__content {
			flex: 1 !important;
			margin-left: 0 !important; /* 移除默认左边距 */
		}
	}
}

.task-input {
	.el-input__inner {
		background: white;
		height: 44px !important; /* 统一输入框高度 */
		font-size: 14px !important;
		border-radius: 8px !important; /* 现代化圆角 */
		border: 1px solid #e2e8f0 !important;
		padding: 0 16px !important; /* 增加内边距 */
		transition: all 0.2s ease !important;
		
		&:focus {
			border-color: #667eea !important;
			box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
			background: white !important;
		}
		
		&::placeholder {
			color: #9ca3af !important;
			font-size: 14px !important;
		}
	}
}

.task-input-number {
	width: 100% !important;
	display: block !important; /* 确保占满整行 */
	
	.el-input-number__decrease,
	.el-input-number__increase {
		background: #f8fafc !important;
		border-color: #e2e8f0 !important;
		color: #667eea !important;
		width: 32px !important; /* 固定按钮宽度 */
		height: 22px !important; /* 调整按钮高度，让上下按钮都能显示 */
		line-height: 20px !important; /* 调整行高 */
		
		&:hover {
			background: #667eea !important;
			color: white !important;
		}
	}
	
	.el-input-number__increase {
		border-radius: 0 8px 0 0 !important; /* 上按钮圆角 */
	}
	
	.el-input-number__decrease {
		border-radius: 0 0 8px 0 !important; /* 下按钮圆角 */
	}
	
	.el-input {
		width: 100% !important; /* 确保input容器占满宽度 */
	}
	
	.el-input__inner {
		background: white !important;
		height: 44px !important;
		font-size: 14px !important;
		border-radius: 8px !important;
		border: 1px solid #e2e8f0 !important;
		padding: 0 68px 0 16px !important; /* 右侧留出按钮空间 */
		text-align: left !important;
		width: 100% !important; /* 确保输入框占满宽度 */
		
		&:focus {
			border-color: #667eea !important;
			box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
		}
	}
}

.task-time-picker {
	width: 100% !important;
	display: block !important; /* 确保占满整行 */
	
	.el-input {
		width: 100% !important; /* 确保input容器占满宽度 */
	}
	
	.el-input__inner {
		background: white !important;
		height: 44px !important;
		font-size: 14px !important;
		border-radius: 8px !important;
		border: 1px solid #e2e8f0 !important;
		padding: 0 80px 0 16px !important; /* 大幅增加右侧内边距，从60px到80px */
		width: 100% !important; /* 确保输入框占满宽度 */
		box-sizing: border-box !important; /* 确保padding计算正确 */
		text-overflow: ellipsis !important; /* 文字溢出处理 */
		overflow: hidden !important;
		white-space: nowrap !important;
		
		&:focus {
			border-color: #667eea !important;
			box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
		}
		
		&::placeholder {
			color: #9ca3af !important;
		}
	}
	
	.el-input__suffix {
		right: 24px !important; /* 进一步增加右侧距离 */
		width: 40px !important; /* 增加图标区域宽度 */
		text-align: center !important;
		display: flex !important;
		align-items: center !important;
		justify-content: center !important;
		height: 44px !important; /* 确保高度与输入框一致 */
		
		.el-input__icon {
			color: #9ca3af !important;
			font-size: 16px !important;
			margin: 0 !important; /* 移除任何默认边距 */
		}
	}
}

.task-date-group {
	display: flex !important;
	flex-wrap: wrap !important;
	gap: 8px 16px !important;
	
	.el-checkbox {
		margin-right: 0 !important;
		margin-bottom: 8px !important;
		
		.el-checkbox__label {
			color: #374151 !important;
			font-weight: 500 !important;
			font-size: 14px !important;
			padding-left: 8px !important;
		}
		
		.el-checkbox__input.is-checked {
			.el-checkbox__inner {
				background-color: #667eea !important;
				border-color: #667eea !important;
			}
		}
		
		.el-checkbox__inner {
			border-color: #d1d5db !important;
			
			&:hover {
				border-color: #667eea !important;
			}
		}
	}
}

/* 任务查看对话框样式 */
::v-deep .task-view-dialog {
	.el-dialog {
		border-radius: 12px !important;
		overflow: hidden !important;
		margin-top: 0 !important;
		margin-bottom: 0 !important;
		
		position: fixed !important;
		top: 50% !important;
		left: 50% !important;
		transform: translate(-50%, -50%) !important;
	}
	
	.el-dialog__header {
		background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
		color: white;
		padding: 20px 24px 16px;
		margin: 0;
		border-radius: 12px 12px 0 0 !important;
		
		.el-dialog__title {
			color: white;
			font-weight: 600;
			font-size: 16px;
		}
		
		.el-dialog__close {
			color: white;
			font-size: 18px;
			
			&:hover {
				color: #f0f0f0;
			}
		}
	}
	
	.el-dialog__body {
		padding: 24px;
		background: #fafbfc;
	}
	
	.el-dialog__footer {
		background: white;
		padding: 16px 24px;
		border-radius: 0 0 12px 12px !important;
		border-top: 1px solid #e2e8f0;
		text-align: right;
		
		.el-button {
			padding: 10px 20px;
			font-weight: 500;
			border-radius: 6px;
			color: #64748b;
			border-color: #cbd5e1;
			background: white;
			
			&:hover {
				color: #475569;
				border-color: #94a3b8;
				background: #f8fafc;
			}
		}
	}
}

.task-view-form {
	.el-form-item {
		margin-bottom: 20px;
		display: flex !important;
		align-items: center !important;
		min-height: 32px;
		
		&:last-child {
			margin-bottom: 20px;
		}
		
		.el-form-item__label {
			color: #374151;
			font-weight: 500;
			line-height: 1 !important;
			display: flex !important;
			align-items: center !important;
			margin-bottom: 0 !important;
			height: auto !important;
			padding: 0 !important;
		}
		
		.el-form-item__content {
			flex: 1 !important;
			margin-left: 0 !important;
			display: flex !important;
			align-items: center !important;
		}
	}
	
	.form-text {
		color: #606266;
		font-size: 14px;
		line-height: 1;
		display: flex;
		align-items: center;
		
		&.status-text {
			display: inline-flex;
			align-items: center;
			justify-content: center;
			padding: 6px 12px;
			border-radius: 16px;
			font-size: 12px;
			font-weight: 600;
			text-align: center;
			min-width: 60px;
			line-height: 1;
			border: 1px solid transparent;
			margin: 0;
			
			&.status-idle {
				background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
				color: #0369a1;
				border-color: #bae6fd;
				box-shadow: 0 1px 3px rgba(3, 105, 161, 0.1);
			}
			
			&.status-running {
				background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
				color: #15803d;
				border-color: #bbf7d0;
				box-shadow: 0 1px 3px rgba(21, 128, 61, 0.1);
			}
			
			&.status-paused {
				background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
				color: #d97706;
				border-color: #fed7aa;
				box-shadow: 0 1px 3px rgba(217, 119, 6, 0.1);
			}
			
			&.status-completed {
				background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
				color: #15803d;
				border-color: #bbf7d0;
				box-shadow: 0 1px 3px rgba(21, 128, 61, 0.1);
			}
			
			&.status-error {
				background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
				color: #dc2626;
				border-color: #fecaca;
				box-shadow: 0 1px 3px rgba(220, 38, 38, 0.1);
			}
		}
	}
	
}
</style>
