diff --git a/apps/ios/ItemAtlas/IntakeView.swift b/apps/ios/ItemAtlas/IntakeView.swift index c455652..5588a8a 100644 --- a/apps/ios/ItemAtlas/IntakeView.swift +++ b/apps/ios/ItemAtlas/IntakeView.swift @@ -101,8 +101,10 @@ struct IntakeView: View { if let operation { Section { Text(statusText(operation.status)) - if ["COMPLETED", "FAILED", "REJECTED"].contains(operation.status) { - Button("新的录入") { draft = nil; selections = [:]; text = ""; self.operation = nil } + if operation.status == "COMPLETED" { + Button("继续录入") { reset(clearText: true) } + } else if ["FAILED", "REJECTED"].contains(operation.status) { + Button("返回核对") { reset(clearText: false) } } else if operation.status == "NEEDS_REVIEW" { Button("重试交付") { Task { await retry(operation) } }.disabled(busy) } else { @@ -217,10 +219,12 @@ struct IntakeView: View { } private func submit(_ draft: Draft, automatic: Bool = false) async { + guard draft.originalText == text else { return } let items = draft.candidates.enumerated().compactMap { index, candidate -> ItemInput? in guard let location = selections[index], candidate.action != "SKIP" else { return nil } return ItemInput(name: candidate.name, quantity: candidate.quantity ?? 1, notes: "", locationId: location, aliases: []) } + guard !items.isEmpty else { return } busy = true defer { busy = false } do { @@ -234,6 +238,15 @@ struct IntakeView: View { } } + private func reset(clearText: Bool) { + if clearText { text = "" } + draft = nil + selections = [:] + operation = nil + receipt = nil + error = nil + } + private func retry(_ operation: Operation) async { busy = true defer { busy = false }