fix: 优化天河链确认策略
This commit is contained in:
@@ -263,6 +263,7 @@ const qrSrc = ref('');
|
||||
const qrUrl = ref('');
|
||||
let qrBlobUrl = '';
|
||||
const exporting = ref(false);
|
||||
const confirmingProofIds = ref<number[]>([]);
|
||||
|
||||
const groupModal = ref(false);
|
||||
const groupForm = reactive<{ name: string }>({ name: '' });
|
||||
@@ -311,7 +312,7 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
align: 'center',
|
||||
render: (r) =>
|
||||
r.latestAnyProof
|
||||
? h(NTag, { size: 'small', type: statusType(r.latestAnyProof.status) }, { default: () => t(`common.status.${r.latestAnyProof.status}`) })
|
||||
? h(NTag, { size: 'small', type: proofStatusType(r.latestAnyProof) }, { default: () => proofStatusText(r.latestAnyProof) })
|
||||
: h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noOnchain') }),
|
||||
},
|
||||
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 120, align: 'center', ellipsis: { tooltip: true } },
|
||||
@@ -615,17 +616,23 @@ function batchDelete() {
|
||||
}
|
||||
|
||||
function rowActionOptions(row: any): DropdownOption[] {
|
||||
return [
|
||||
const options: DropdownOption[] = [
|
||||
{ label: t('pages.traceCode.changeGroup'), key: 'changeGroup', children: rowGroupOptions.value },
|
||||
{ label: t('pages.traceCode.changeBatch'), key: 'batch:open' },
|
||||
{ label: t('pages.traceCode.registerOutbound'), key: 'outbound:open' },
|
||||
];
|
||||
if (canManualConfirm(row.latestAnyProof)) {
|
||||
options.push({ label: t('pages.traceCode.reconfirmOnchain'), key: 'onchain:confirm' });
|
||||
}
|
||||
options.push(
|
||||
{ type: 'divider', key: 'divider-1' },
|
||||
{
|
||||
label: row.status === TraceCodeStatus.DISABLED ? t('pages.traceCode.enableOne') : t('pages.traceCode.disableOne'),
|
||||
key: row.status === TraceCodeStatus.DISABLED ? 'status:enable' : 'status:disable',
|
||||
},
|
||||
{ label: t('common.action.delete'), key: 'delete' },
|
||||
];
|
||||
);
|
||||
return options;
|
||||
}
|
||||
|
||||
async function onRowAction(row: any, key: string) {
|
||||
@@ -648,6 +655,11 @@ async function onRowAction(row: any, key: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'onchain:confirm') {
|
||||
await confirmProof(row.latestAnyProof);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'status:disable' || key === 'status:enable') {
|
||||
await traceCodeApi.update(String(row.id), { disabled: key === 'status:disable' });
|
||||
message.success(t('common.msg.operationSuccess'));
|
||||
@@ -673,6 +685,39 @@ async function onRowAction(row: any, key: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function proofRaw(proof: any) {
|
||||
return proof?.rawResponse && typeof proof.rawResponse === 'object' ? proof.rawResponse : {};
|
||||
}
|
||||
|
||||
function isUnconfirmedProof(proof: any) {
|
||||
return proof?.status === 'CONFIRMING' && proofRaw(proof).confirmationManualRequired === true;
|
||||
}
|
||||
|
||||
function proofStatusText(proof: any) {
|
||||
return isUnconfirmedProof(proof) ? t('pages.traceCode.unconfirmed') : t(`common.status.${proof.status}`);
|
||||
}
|
||||
|
||||
function proofStatusType(proof: any): 'default' | 'success' | 'warning' | 'error' | 'info' {
|
||||
return isUnconfirmedProof(proof) ? 'warning' : statusType(proof?.status);
|
||||
}
|
||||
|
||||
function canManualConfirm(proof: any) {
|
||||
return Boolean(proof?.id && proof?.txHash && proof.status !== 'ONCHAIN');
|
||||
}
|
||||
|
||||
async function confirmProof(proof: any) {
|
||||
if (!canManualConfirm(proof) || confirmingProofIds.value.includes(proof.id)) return;
|
||||
confirmingProofIds.value.push(proof.id);
|
||||
try {
|
||||
await traceCodeApi.confirmProof(proof.id);
|
||||
message.success(t('pages.traceCode.confirmSubmitted'));
|
||||
await load();
|
||||
emit('changed');
|
||||
} finally {
|
||||
confirmingProofIds.value = confirmingProofIds.value.filter((id) => id !== proof.id);
|
||||
}
|
||||
}
|
||||
|
||||
function openBatchModal(row?: any) {
|
||||
batchTarget.value = row || null;
|
||||
batchForm.batchValue = row?.batch?.id ?? null;
|
||||
|
||||
Reference in New Issue
Block a user