fix: 移除导航前清除数据的逻辑,防止另一种类型人员丢失
问题:当用户没有输入内容就点击"选择审批人/抄送人"时, 会清除 sessionStorage 中所有人员数据,导致另一种类型的人员消失。 解决方案:移除导航前清除数据的逻辑,让 sessionStorage 中的数据在用户明确操作(提交、保存等)时才清除。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -202,30 +202,12 @@ export default function BusinessTripApply() {
|
||||
const handleSelectApprovers = () => {
|
||||
console.log('🚀 Navigating to select approvers')
|
||||
saveDraft() // 导航前保存草稿
|
||||
|
||||
// 如果草稿中没有实际内容(空理由且没有有效行程),清除旧的人员数据
|
||||
const hasContent = reason.trim() !== '' || itineraries.some(item => item.startTime || item.destination.trim() !== '')
|
||||
if (!hasContent) {
|
||||
sessionStorage.removeItem('selectedApprovers')
|
||||
sessionStorage.removeItem('selectedCc')
|
||||
console.log('🧹 Cleared old selection data (no content)')
|
||||
}
|
||||
|
||||
navigate('/business-trip/apply/select-approver', { state: { selected: approvers, type: 'approver' } })
|
||||
}
|
||||
|
||||
const handleSelectCc = () => {
|
||||
console.log('🚀 Navigating to select CC')
|
||||
saveDraft() // 导航前保存草稿
|
||||
|
||||
// 如果草稿中没有实际内容(空理由且没有有效行程),清除旧的人员数据
|
||||
const hasContent = reason.trim() !== '' || itineraries.some(item => item.startTime || item.destination.trim() !== '')
|
||||
if (!hasContent) {
|
||||
sessionStorage.removeItem('selectedApprovers')
|
||||
sessionStorage.removeItem('selectedCc')
|
||||
console.log('🧹 Cleared old selection data (no content)')
|
||||
}
|
||||
|
||||
navigate('/business-trip/apply/select-cc', { state: { selected: ccUsers, type: 'cc' } })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user