refactor: 合并追溯码上链入口
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,6 @@
|
||||
"groupName": "Group Name",
|
||||
"batchGroup": "Set Group",
|
||||
"batchMove": "Move Batch",
|
||||
"batchOnchain": "Batch On-chain",
|
||||
"batchEnable": "Enable",
|
||||
"batchDisable": "Disable",
|
||||
"changeGroup": "Change Group",
|
||||
@@ -291,6 +290,8 @@
|
||||
"selectCodePlaceholder": "Search by short code / trace code / archive no.",
|
||||
"onchainSection": "On-chain info (optional; filling a hash records the result)",
|
||||
"txHashTip": "Paste the on-chain transaction/attestation hash",
|
||||
"saveRecord": "Save Record",
|
||||
"saveAndTriggerOnchain": "Save & Trigger On-chain",
|
||||
"selectFile": "Select File",
|
||||
"importing": "Importing…",
|
||||
"importResult": "Import Result",
|
||||
|
||||
@@ -261,7 +261,6 @@
|
||||
"groupName": "分组名称",
|
||||
"batchGroup": "批量分组",
|
||||
"batchMove": "批量修改批次",
|
||||
"batchOnchain": "批量上链",
|
||||
"batchEnable": "批量启用",
|
||||
"batchDisable": "批量停用",
|
||||
"changeGroup": "修改分组",
|
||||
@@ -291,6 +290,8 @@
|
||||
"selectCodePlaceholder": "输入短码 / 追溯码 / 档案号搜索",
|
||||
"onchainSection": "上链信息(选填,填写哈希即登记上链结果)",
|
||||
"txHashTip": "粘贴链上交易/存证哈希",
|
||||
"saveRecord": "保存登记",
|
||||
"saveAndTriggerOnchain": "保存并触发上链",
|
||||
"selectFile": "选择文件",
|
||||
"importing": "导入中…",
|
||||
"importResult": "导入结果",
|
||||
|
||||
Reference in New Issue
Block a user