fix(ios): 写入失败后保留转写原话
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
2c48b119b2
commit
6fb69f234a
|
|
@ -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 }
|
||||
|
|
|
|||
Loading…
Reference in New Issue