refactor: 合并追溯码上链入口

This commit is contained in:
Nixevol
2026-07-04 06:11:06 +08:00
parent cfce2d9a75
commit 8922272ed3
4 changed files with 18 additions and 26 deletions
+13 -23
View File
@@ -63,7 +63,6 @@
</n-button>
</n-dropdown>
<n-button size="small" @click="openBatchModal()">{{ t('pages.traceCode.batchMove') }}</n-button>
<n-button size="small" @click="batchOnchain">{{ t('pages.traceCode.batchOnchain') }}</n-button>
<n-button size="small" @click="batchStatus(false)">{{ t('pages.traceCode.batchEnable') }}</n-button>
<n-button size="small" type="warning" @click="batchStatus(true)">{{ t('pages.traceCode.batchDisable') }}</n-button>
</n-space>
@@ -197,7 +196,8 @@
<template #footer>
<div style="text-align: right">
<n-button class="mr8" @click="outboundModal = false">{{ t('common.action.cancel') }}</n-button>
<n-button type="primary" :loading="outboundSaving" @click="saveOutbound">{{ t('common.action.save') }}</n-button>
<n-button class="mr8" :loading="outboundSaving" @click="saveOutbound(false)">{{ t('pages.outbound.saveRecord') }}</n-button>
<n-button type="primary" :loading="outboundTriggering" @click="saveOutbound(true)">{{ t('pages.outbound.saveAndTriggerOnchain') }}</n-button>
</div>
</template>
</n-modal>
@@ -293,6 +293,7 @@ const batchTarget = ref<any | null>(null);
const batchForm = reactive<{ batchValue: number | string | null }>({ batchValue: null });
const outboundModal = ref(false);
const outboundSaving = ref(false);
const outboundTriggering = ref(false);
const outboundTarget = ref<any | null>(null);
const outImages = ref<any[]>([]);
const outboundForm = reactive<any>({
@@ -529,22 +530,11 @@ async function batchStatus(disabled: boolean) {
emit('changed');
}
async function batchOnchain() {
for (const id of checkedKeys.value.map(String)) {
await traceCodeApi.onchain(id);
}
message.success(t('pages.blockchain.triggered'));
checkedKeys.value = [];
await load();
emit('changed');
}
function rowActionOptions(row: any): DropdownOption[] {
return [
{ 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' },
{ label: t('pages.blockchain.trigger'), key: 'onchain' },
{ type: 'divider', key: 'divider-1' },
{
label: row.status === TraceCodeStatus.DISABLED ? t('pages.traceCode.enableOne') : t('pages.traceCode.disableOne'),
@@ -574,14 +564,6 @@ async function onRowAction(row: any, key: string) {
return;
}
if (key === 'onchain') {
await traceCodeApi.onchain(String(row.id));
message.success(t('pages.blockchain.triggered'));
await load();
emit('changed');
return;
}
if (key === 'status:disable' || key === 'status:enable') {
await traceCodeApi.update(String(row.id), { disabled: key === 'status:disable' });
message.success(t('common.msg.operationSuccess'));
@@ -659,9 +641,13 @@ function openOutboundModal(row: any) {
outboundModal.value = true;
}
async function saveOutbound() {
async function saveOutbound(triggerOnchain: boolean) {
if (!outboundTarget.value) return;
outboundSaving.value = true;
if (triggerOnchain) {
outboundTriggering.value = true;
} else {
outboundSaving.value = true;
}
try {
await outboundApi.updateSingle(String(outboundTarget.value.id), {
outTime: outboundForm.outTime ? dayjs(outboundForm.outTime).toISOString() : null,
@@ -671,6 +657,9 @@ async function saveOutbound() {
blockHeight: outboundForm.blockHeight ?? undefined,
remark: outboundForm.remark || null,
});
if (triggerOnchain) {
await traceCodeApi.onchain(String(outboundTarget.value.id));
}
message.success(t('common.msg.saved'));
outboundModal.value = false;
outboundTarget.value = null;
@@ -678,6 +667,7 @@ async function saveOutbound() {
emit('changed');
} finally {
outboundSaving.value = false;
outboundTriggering.value = false;
}
}