feat: 优化切换步骤时的必填校验,限制往后切换时才触发必填校验优化用户体验

This commit is contained in:
GoldenZqqqq
2024-12-24 20:10:58 +08:00
parent a6461da0f8
commit ab11818ce2
2 changed files with 13 additions and 656 deletions

View File

@ -228,14 +228,20 @@ const handleStepClick = async (index: number) => {
return
}
}
// 校验当前步骤
try {
if (typeof steps[currentStep.value].validator === 'function') {
await steps[currentStep.value].validator()
// 只有在向后切换时才进行校验
if (index > currentStep.value) {
try {
if (typeof steps[currentStep.value].validator === 'function') {
await steps[currentStep.value].validator()
}
currentStep.value = index
} catch (error) {
message.warning('请先完善当前步骤必填信息')
}
} else {
// 向前切换时直接切换
currentStep.value = index
} catch (error) {
message.warning('请先完善当前步骤必填信息')
}
}
@ -244,6 +250,7 @@ const handleDesignSuccess = (bpmnXml?: string) => {
if (bpmnXml) {
formData.value.bpmnXml = bpmnXml
}
handleSave() // 自动保存
message.success('保存成功')
}