feat(web-admin): auto-submit paid earnest transfers after saving presign order
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e56d8d7f51
commit
e16afdee95
1 file changed
+21
-2
@@ -411,6 +411,10 @@
|
||||
fetchSubmitPresignTransferFinance,
|
||||
fetchWithdrawPresignTransfer
|
||||
} from '@/api/presign-order'
|
||||
import {
|
||||
formatAutoSubmitFinanceFailureMessage,
|
||||
submitDfjTransfersOnSave
|
||||
} from '@/utils/presign-save-auto-submit'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -838,17 +842,20 @@
|
||||
sampleTypeIds: form.sampleTypeIds,
|
||||
remark: form.remark || undefined
|
||||
}
|
||||
let transfersForSubmit: Array<Record<string, any>> = []
|
||||
|
||||
if (props.orderId) {
|
||||
await fetchUpdatePresignOrder(props.orderId, payload)
|
||||
for (const tr of form.transfers) {
|
||||
if (!tr.id && tr.payStatus === 'dfj') {
|
||||
await fetchCreatePresignTransfer(props.orderId, {
|
||||
const created: any = await fetchCreatePresignTransfer(props.orderId, {
|
||||
transferType: tr.transferType,
|
||||
transferAmount: tr.transferAmount,
|
||||
transferTime: tr.transferTime || undefined,
|
||||
transferAttachments: attachmentsToUrls(tr.attachments) || undefined,
|
||||
remark: tr.remark || undefined
|
||||
})
|
||||
if (created?.id) tr.id = String(created.id)
|
||||
} else if (tr.id && tr.payStatus === 'dfj') {
|
||||
await fetchUpdatePresignTransfer(String(tr.id), {
|
||||
transferType: tr.transferType,
|
||||
@@ -859,6 +866,7 @@
|
||||
})
|
||||
}
|
||||
}
|
||||
transfersForSubmit = form.transfers
|
||||
} else {
|
||||
payload.transfers = form.transfers
|
||||
.filter((t) => t.payStatus === 'dfj' || !t.payStatus)
|
||||
@@ -869,8 +877,19 @@
|
||||
transferAttachments: attachmentsToUrls(t.attachments) || undefined,
|
||||
remark: t.remark || undefined
|
||||
}))
|
||||
await fetchCreatePresignOrder(payload)
|
||||
const createdOrder: any = await fetchCreatePresignOrder(payload)
|
||||
transfersForSubmit = Array.isArray(createdOrder?.transfers)
|
||||
? createdOrder.transfers
|
||||
: []
|
||||
}
|
||||
|
||||
const failures = await submitDfjTransfersOnSave(transfersForSubmit, (transferId) =>
|
||||
fetchSubmitPresignTransferFinance(transferId, { showSuccessMessage: false })
|
||||
)
|
||||
if (failures.length) {
|
||||
ElMessage.warning(formatAutoSubmitFinanceFailureMessage(failures))
|
||||
}
|
||||
|
||||
emit('update:modelValue', false)
|
||||
emit('saved')
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user