| | |
| | | |
| | | /** 步骤切换处理 */ |
| | | async function handleStepClick(index: number) { |
| | | // 往回退(点击更靠前的步骤)不做校验,避免用户在第 2 步「表单设计」未完成时被卡住无法返回 |
| | | if (index < currentStep.value) { |
| | | currentStep.value = index; |
| | | return; |
| | | } |
| | | try { |
| | | if (index !== 0) { |
| | | await validateBasic(); |
| | | } |
| | | if (index !== 1) { |
| | | await validateForm(); |
| | | } |
| | | if (index !== 2) { |
| | | await validateProcess(); |
| | | } |
| | | if (index !== 3) { |
| | | await validateExtra(); |
| | | } |
| | | // 切换步骤 |
| | | currentStep.value = index; |
| | | } catch (error) { |
| | | console.error('步骤切换失败:', error); |
| | | if (currentStep.value !== 2) { |
| | | message.warning('请先完善当前步骤必填信息'); |
| | | } |
| | | } |
| | | // 步骤之间允许自由切换(含前进和后退),切换时不做校验; |
| | | // 必填信息的校验统一在「保存」「发布」时执行(validateAllSteps),避免卡在中间步骤出不去 |
| | | currentStep.value = index; |
| | | } |
| | | |
| | | /** 返回列表页 */ |