fix: 优化追溯码批量操作与出库界面

This commit is contained in:
Nixevol
2026-07-16 16:18:59 +08:00
parent 8eeba3a83f
commit cd84e0ab11
10 changed files with 315 additions and 114 deletions
+129 -12
View File
@@ -30,6 +30,14 @@
<n-card v-if="auth.canWrite && checkedKeys.length" size="small" class="batch-bar" :bordered="false">
<n-space align="center">
<span>{{ t('pages.traceCode.selected', { n: checkedKeys.length }) }}</span>
<n-button size="small" type="primary" :disabled="batchSubmitting" @click="openBatchOutbound">
<template #icon><n-icon :component="CubeOutline" /></template>
{{ t('pages.operations.batchOutboundWithCount', { n: checkedKeys.length }) }}
</n-button>
<n-button size="small" :disabled="batchSubmitting" @click="confirmBatchOnchain">
<template #icon><n-icon :component="ShieldCheckmarkOutline" /></template>
{{ t('pages.operations.batchOnchain', { n: checkedKeys.length }) }}
</n-button>
<n-dropdown trigger="click" :options="groupAssignOptions" @select="batchAssignGroup">
<n-button size="small">
<template #icon><n-icon :component="FolderOutline" /></template>
@@ -144,6 +152,47 @@
</template>
</n-modal>
<n-modal
v-model:show="batchOutboundVisible"
preset="card"
:title="t('pages.operations.batchOutbound')"
style="width: 520px; max-width: 94vw"
>
<n-form :model="batchOutboundForm" label-placement="top">
<n-form-item :label="t('pages.outbound.outTime')" required>
<n-date-picker
v-model:formatted-value="batchOutboundForm.outTime"
value-format="yyyy-MM-dd HH:mm"
type="datetime"
clearable
style="width: 100%"
/>
</n-form-item>
<n-form-item :label="t('common.label.remark')">
<n-input
v-model:value="batchOutboundForm.remark"
type="textarea"
:rows="3"
:maxlength="191"
show-count
/>
</n-form-item>
</n-form>
<template #footer>
<div class="modal-actions">
<n-button @click="batchOutboundVisible = false">{{ t('common.action.cancel') }}</n-button>
<n-button
type="primary"
:loading="batchSubmitting"
:disabled="!batchOutboundForm.outTime"
@click="submitBatchOutbound"
>
{{ t('pages.operations.confirmBatch', { n: checkedKeys.length }) }}
</n-button>
</div>
</template>
</n-modal>
<outbound-record-modal
v-model:show="outboundRecordVisible"
:trace-code="operationTarget"
@@ -158,7 +207,7 @@
<batch-job-modal
v-model:show="jobVisible"
:job-id="jobId"
:title="t('pages.operations.onchainProgress')"
:title="batchJobTitle"
@completed="reloadAfterOperation"
/>
</div>
@@ -168,10 +217,11 @@
import { computed, h, onMounted, onUnmounted, reactive, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import dayjs from 'dayjs';
import { NButton, NDropdown, NIcon, NTag, NText, type DataTableColumns, type DropdownOption } from 'naive-ui';
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline, EllipsisHorizontalOutline, FilterOutline } from '@vicons/ionicons5';
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline, EllipsisHorizontalOutline, FilterOutline, CubeOutline, ShieldCheckmarkOutline } from '@vicons/ionicons5';
import { TraceCodeStatus } from '@artveris/shared';
import { traceCodeApi, jobApi, artworkApi, onchainApi } from '@/api';
import { traceCodeApi, jobApi, artworkApi, onchainApi, outboundApi } from '@/api';
import { useAuthStore } from '@/stores/auth';
import { message, dialog } from '@/utils/feedback';
import { fmt, statusType } from '@/utils/format';
@@ -266,11 +316,20 @@ const editingGroup = ref<number | null>(null);
const batchModal = ref(false);
const batchTarget = ref<any | null>(null);
const batchForm = reactive<{ batchValue: number | string | null }>({ batchValue: null });
const batchOutboundVisible = ref(false);
const batchOutboundForm = reactive({ outTime: '', remark: '' });
const batchSubmitting = ref(false);
const batchJobType = ref<'ONCHAIN' | 'OUTBOUND'>('ONCHAIN');
const outboundRecordVisible = ref(false);
const proofVisible = ref(false);
const operationTarget = ref<any | null>(null);
const jobVisible = ref(false);
const jobId = ref('');
const batchJobTitle = computed(() =>
batchJobType.value === 'ONCHAIN'
? t('pages.operations.onchainProgress')
: t('pages.operations.outboundProgress'),
);
function rowIsOutbound(row: any) {
if (!row) return false;
@@ -747,6 +806,65 @@ async function batchStatus(disabled: boolean) {
emit('changed');
}
function openBatchOutbound() {
if (!checkedKeys.value.length) return;
batchOutboundForm.outTime = dayjs().format('YYYY-MM-DD HH:mm');
batchOutboundForm.remark = '';
batchOutboundVisible.value = true;
}
function confirmBatchOnchain() {
if (!checkedKeys.value.length) return;
dialog.warning({
title: t('pages.operations.batchOnchainTitle'),
content: t('pages.operations.batchOnchainConfirm', { n: checkedKeys.value.length }),
positiveText: t('common.action.confirm'),
negativeText: t('common.action.cancel'),
onPositiveClick: submitBatchOnchain,
});
}
function openSubmittedBatch(result: any, type: 'ONCHAIN' | 'OUTBOUND') {
const id = String(result?.jobId || result?.id || result?.job?.id || '');
batchJobType.value = type;
checkedKeys.value = [];
if (id) {
jobId.value = id;
jobVisible.value = true;
} else {
message.success(t('pages.operations.jobSubmitted'));
}
void load();
emit('changed');
}
async function submitBatchOnchain() {
if (!checkedKeys.value.length || batchSubmitting.value) return;
batchSubmitting.value = true;
try {
const result = await onchainApi.createJob({ mode: 'IDS', ids: checkedKeys.value.map(String) });
openSubmittedBatch(result, 'ONCHAIN');
} finally {
batchSubmitting.value = false;
}
}
async function submitBatchOutbound() {
if (!checkedKeys.value.length || !batchOutboundForm.outTime || batchSubmitting.value) return;
batchSubmitting.value = true;
try {
const result = await outboundApi.createJob(
{ mode: 'IDS', ids: checkedKeys.value.map(String) },
dayjs(batchOutboundForm.outTime).toISOString(),
batchOutboundForm.remark.trim() || undefined,
);
batchOutboundVisible.value = false;
openSubmittedBatch(result, 'OUTBOUND');
} finally {
batchSubmitting.value = false;
}
}
function batchDelete() {
if (!checkedKeys.value.length) return;
dialog.warning({
@@ -945,16 +1063,10 @@ function runOnchainRow(row: any) {
}
async function submitOnchainRow(row: any) {
const result: any = await onchainApi.createJob({ mode: 'IDS', ids: [String(row.id)] });
await onchainApi.createJob({ mode: 'IDS', ids: [String(row.id)] });
proofVisible.value = false;
const id = String(result?.jobId || result?.id || result?.job?.id || '');
if (id) {
jobId.value = id;
jobVisible.value = true;
} else {
message.success(t('pages.operations.jobSubmitted'));
}
await load();
message.success(t('pages.operations.jobSubmitted'));
void load();
}
async function reloadAfterOperation() {
@@ -1071,6 +1183,11 @@ onUnmounted(() => {
.batch-bar {
margin-bottom: 12px;
}
.modal-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
}
.group-toolbar {
margin-bottom: 14px;
}