fix(protocol): save DJ pay details without blocking on due-sum mismatch
Persist payment before samples to avoid consuming sample codes on validation failure, soft-delete samples on create rollback, and surface DJ due-amount mismatch as a hint only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f661d40f3a
commit
57487fd0dc
18 files changed
+13425
-12458
No files matched your search
@@ -1106,6 +1106,7 @@
|
||||
applyPayModeSwitch,
|
||||
canAddPaymentDetail,
|
||||
createPaymentDetailRow,
|
||||
djDueAmountMismatchHint,
|
||||
evaluatePayModeSwitch,
|
||||
isPayDetailLocked,
|
||||
markPayDetailLocks,
|
||||
@@ -2144,10 +2145,17 @@
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate()
|
||||
if (!formRef.value || submitLoading.value) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
} catch {
|
||||
submitLoading.value = false
|
||||
return
|
||||
}
|
||||
const sampleCount = getActiveSampleCount(formData.samples)
|
||||
if (!isPayModeValidForSampleCount(formData.payMode as PresetPayMode, sampleCount)) {
|
||||
submitLoading.value = false
|
||||
await ElMessageBox.alert(
|
||||
formData.payMode === 'djfq'
|
||||
? '「趸交+分期」仅适用于 2 个样本,请切换缴费模式'
|
||||
@@ -2162,12 +2170,18 @@
|
||||
if (!sampleRow.sampleCodeId) continue
|
||||
const sc = sampleCodeOptions.value.find((x) => x.id === sampleRow.sampleCodeId)
|
||||
if (sc?.usedInProtocol) {
|
||||
submitLoading.value = false
|
||||
ElMessage.warning(`样本编码「${sampleRow.sampleCode || sc.sampleCode}」已被占用,请更换`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
submitLoading.value = true
|
||||
if (formData.payMode === 'dj') {
|
||||
const dueHint = djDueAmountMismatchHint(formData.contractAmount, formData.paymentDetails)
|
||||
if (dueHint) {
|
||||
ElMessage.warning(dueHint)
|
||||
}
|
||||
}
|
||||
try {
|
||||
syncFqPaymentDetailRowCount(fqPaymentContext(), formData.paymentDetails)
|
||||
const protocolAttachmentUrls = formData.attachments
|
||||
|
||||
Reference in new issue
Block a user