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
+8
View File
@@ -441,3 +441,11 @@
- 安全加固:操作日志和天河 provider 全链路密钥脱敏,成功 raw 响应在入库前清洗;网关可能已受理的 HTTP 状态不再误标 FAILED;本地主图相对 URL 不再写入链上。 - 安全加固:操作日志和天河 provider 全链路密钥脱敏,成功 raw 响应在入库前清洗;网关可能已受理的 HTTP 状态不再误标 FAILED;本地主图相对 URL 不再写入链上。
- 最终自动验证:API 33 个测试套件、252 项全部通过;Prisma generate/validate、单迁移目录检查、admin 804 个与 client 73 个中英文键对齐、shared/API/admin/client 全量生产构建及 `git diff --check` 通过。管理端构建仍有 Naive UI 大 chunk 警告,为既有非阻塞项。 - 最终自动验证:API 33 个测试套件、252 项全部通过;Prisma generate/validate、单迁移目录检查、admin 804 个与 client 73 个中英文键对齐、shared/API/admin/client 全量生产构建及 `git diff --check` 通过。管理端构建仍有 Naive UI 大 chunk 警告,为既有非阻塞项。
- 手工/真实环境验证:空 MySQL 迁移+seed、schema 反向 diff、三角色 22 项审批流程、批量上链、ZIP 导入、备份创建/预检/恢复、队列重投、天河链真实小批量和公开 DApp URL 均通过;QA 数据、临时文件和测试备份已清理。浏览器自动化在本轮后半段未再使用,避免 Codex 客户端闪退。 - 手工/真实环境验证:空 MySQL 迁移+seed、schema 反向 diff、三角色 22 项审批流程、批量上链、ZIP 导入、备份创建/预检/恢复、队列重投、天河链真实小批量和公开 DApp URL 均通过;QA 数据、临时文件和测试备份已清理。浏览器自动化在本轮后半段未再使用,避免 Codex 客户端闪退。
## 2026-07-16 · 追溯码与出库管理交互修正
- 登记出库、上链详情和批量任务结果等 Teleport 弹窗不再依赖组件内 `scoped` 选择器控制根卡片宽度,统一仿照“新建溯源模板”在 `n-modal` 上直接设置宽度和 `max-width: 94vw`;高度继续由全局 modal 规则限制视口并让内容区滚动。
- 未出库追溯码可直接点击“录入实况图”。前端在文件格式/大小初检通过后,先用表单中的出库时间和备注静默创建 `OutboundRecord`,成功后再调用现有图片上传接口;已出库时按钮显示“补录实况图”。后端“图片必须归属既有出库记录”的约束保持不变。
- 出库实况图复用现有作品媒体卡片规范:分隔线居中显示标题,不显示总张数;图片以 96px 卡片排列,上传卡片位于图片列表末尾,无图片时单独居中显示。图片仍分页加载。追溯码管理页的当前页单选/多选工具栏新增批量出库、批量上链,直接复用现有 IDS 异步任务接口。
- 单件上链只保留确认、提交成功提示和列表状态刷新,不主动打开或登记为“批量任务进度”;只有多选/筛选批量操作打开逐码进度弹窗。出库管理 Tabs 补齐 pane wrapper 的 flex 高度链,空结果时数据表区域仍填满页面、分页固定在底部。
- 验证范围按用户要求收敛为管理端生产构建、语言 JSON 解析和 `git diff --check`,均通过;未启动服务、未连接数据库,也未使用内置浏览器。
+6 -4
View File
@@ -1,5 +1,10 @@
<template> <template>
<n-modal v-model:show="visible" preset="card" :title="title" class="batch-job-modal"> <n-modal
v-model:show="visible"
preset="card"
:title="title"
style="width: 720px; max-width: 94vw"
>
<n-space v-if="job" align="center" wrap class="job-summary"> <n-space v-if="job" align="center" wrap class="job-summary">
<n-statistic :label="t('pages.operations.total')" :value="jobTotal" /> <n-statistic :label="t('pages.operations.total')" :value="jobTotal" />
<n-statistic :label="t('pages.operations.success')" :value="successCount" /> <n-statistic :label="t('pages.operations.success')" :value="successCount" />
@@ -232,9 +237,6 @@ onUnmounted(stopPolling);
</script> </script>
<style scoped> <style scoped>
.batch-job-modal {
width: min(900px, calc(100vw - 32px));
}
.job-summary { .job-summary {
margin-bottom: 12px; margin-bottom: 12px;
} }
@@ -1,5 +1,10 @@
<template> <template>
<n-modal v-model:show="visible" preset="card" :title="t('pages.blockchain.title')" class="proof-modal"> <n-modal
v-model:show="visible"
preset="card"
:title="t('pages.blockchain.title')"
style="width: 680px; max-width: 94vw"
>
<n-descriptions :column="1" label-placement="left" bordered size="small"> <n-descriptions :column="1" label-placement="left" bordered size="small">
<n-descriptions-item :label="t('pages.traceCode.shortCode')"> <n-descriptions-item :label="t('pages.traceCode.shortCode')">
{{ traceCode?.shortCode || '-' }} {{ traceCode?.shortCode || '-' }}
@@ -232,9 +237,6 @@ watch(
</script> </script>
<style scoped> <style scoped>
.proof-modal {
width: min(680px, calc(100vw - 32px));
}
.proof-link { .proof-link {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -1,66 +1,71 @@
<template> <template>
<div class="outbound-images"> <div class="outbound-images">
<div class="images-toolbar">
<n-text depth="3">{{ t('pages.outbound.imageCount', { n: total }) }}</n-text>
<div class="spacer" />
<n-upload
:show-file-list="false"
accept=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp"
:custom-request="upload"
:disabled="disabled || uploading"
>
<n-button size="small" :loading="uploading" :disabled="disabled">
<template #icon><n-icon :component="CloudUploadOutline" /></template>
{{ t('pages.outbound.addImage') }}
</n-button>
</n-upload>
</div>
<n-spin :show="loading"> <n-spin :show="loading">
<n-empty v-if="!items.length" :description="t('common.msg.noData')" class="empty-images" /> <div v-if="items.length || !disabled" :class="['image-grid', { empty: !items.length }]">
<div v-else class="image-grid">
<div v-for="(item, index) in items" :key="imageId(item)" class="image-tile"> <div v-for="(item, index) in items" :key="imageId(item)" class="image-tile">
<button class="image-preview" type="button" @click="preview(index)"> <button
class="image-preview"
type="button"
:title="item.name || item.key"
@click="preview(index)"
>
<img :src="imageUrl(item)" :alt="item.name || t('pages.outbound.outImage')" loading="lazy" /> <img :src="imageUrl(item)" :alt="item.name || t('pages.outbound.outImage')" loading="lazy" />
</button> </button>
<div class="image-meta"> <span class="image-order">{{ globalIndex(index) + 1 }}</span>
<span class="image-name" :title="item.name || item.key">{{ item.name || item.key || '-' }}</span> <template v-if="!disabled">
<button
class="image-delete"
type="button"
:title="t('common.action.delete')"
@click="remove(item)"
>
×
</button>
<div class="image-actions"> <div class="image-actions">
<n-button <n-button
class="image-move-button"
quaternary quaternary
circle circle
size="tiny" size="tiny"
:disabled="disabled || globalIndex(index) === 0" :disabled="globalIndex(index) === 0"
:title="t('pages.outbound.moveImageUp')" :title="t('pages.outbound.moveImageUp')"
@click="move(item, index, 'UP')" @click="move(item, index, 'UP')"
> >
<template #icon><n-icon :component="ArrowUpOutline" /></template> <template #icon><n-icon :component="ArrowUpOutline" /></template>
</n-button> </n-button>
<n-button <n-button
class="image-move-button"
quaternary quaternary
circle circle
size="tiny" size="tiny"
:disabled="disabled || globalIndex(index) === total - 1" :disabled="globalIndex(index) === total - 1"
:title="t('pages.outbound.moveImageDown')" :title="t('pages.outbound.moveImageDown')"
@click="move(item, index, 'DOWN')" @click="move(item, index, 'DOWN')"
> >
<template #icon><n-icon :component="ArrowDownOutline" /></template> <template #icon><n-icon :component="ArrowDownOutline" /></template>
</n-button> </n-button>
<n-button
quaternary
circle
size="tiny"
type="error"
:disabled="disabled"
:title="t('common.action.delete')"
@click="remove(item)"
>
<template #icon><n-icon :component="TrashOutline" /></template>
</n-button>
</div> </div>
</div> </template>
</div> </div>
<n-upload
v-if="!disabled"
:show-file-list="false"
accept=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp"
:custom-request="upload"
:disabled="uploading"
style="width: auto"
>
<div :class="['upload-tile', { uploading }]">
<n-spin v-if="uploading" size="small" />
<template v-else>
<n-icon :component="AddOutline" :size="22" />
<span>{{ t(recorded ? 'pages.outbound.addImage' : 'pages.outbound.recordImage') }}</span>
</template>
</div>
</n-upload>
</div> </div>
<n-empty v-else :description="t('common.msg.noData')" class="empty-images" />
</n-spin> </n-spin>
<div v-if="total > pageSize" class="images-pagination"> <div v-if="total > pageSize" class="images-pagination">
@@ -80,7 +85,7 @@ import { onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import type { UploadCustomRequestOptions } from 'naive-ui'; import type { UploadCustomRequestOptions } from 'naive-ui';
import { NIcon } from 'naive-ui'; import { NIcon } from 'naive-ui';
import { ArrowDownOutline, ArrowUpOutline, CloudUploadOutline, TrashOutline } from '@vicons/ionicons5'; import { AddOutline, ArrowDownOutline, ArrowUpOutline } from '@vicons/ionicons5';
import { outboundApi } from '@/api'; import { outboundApi } from '@/api';
import { dialog, message } from '@/utils/feedback'; import { dialog, message } from '@/utils/feedback';
import { resolveMediaUrl } from '@/utils/mediaUrl'; import { resolveMediaUrl } from '@/utils/mediaUrl';
@@ -89,8 +94,11 @@ import { openMediaViewer } from '@/composables/openMediaViewer';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
traceCodeId: string; traceCodeId: string;
disabled?: boolean; disabled?: boolean;
recorded?: boolean;
beforeUpload?: () => Promise<void>;
}>(), { }>(), {
disabled: false, disabled: false,
recorded: false,
}); });
const emit = defineEmits<{ (event: 'changed'): void }>(); const emit = defineEmits<{ (event: 'changed'): void }>();
@@ -148,6 +156,7 @@ async function upload({ file, onFinish, onError }: UploadCustomRequestOptions) {
} }
uploading.value = true; uploading.value = true;
try { try {
await props.beforeUpload?.();
const data = new FormData(); const data = new FormData();
data.append('file', raw); data.append('file', raw);
await outboundApi.uploadImage(props.traceCodeId, data); await outboundApi.uploadImage(props.traceCodeId, data);
@@ -219,37 +228,35 @@ defineExpose({ reload: load });
.outbound-images { .outbound-images {
min-width: 0; min-width: 0;
} }
.images-toolbar {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 10px;
}
.spacer {
flex: 1 1 auto;
}
.empty-images { .empty-images {
padding: 28px 0; padding: 28px 0;
} }
.image-grid { .image-grid {
display: grid; display: flex;
grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); flex-wrap: wrap;
gap: 12px; gap: 10px;
min-height: 96px;
} }
.image-tile { .image-grid.empty {
min-width: 0; justify-content: center;
border: 1px solid var(--n-border-color); }
border-radius: 6px; .image-tile,
.upload-tile {
position: relative;
width: 96px;
height: 96px;
border-radius: 8px;
overflow: hidden; overflow: hidden;
background: var(--n-color); border: 1px solid var(--n-border-color, #e0e0e6);
background: #f4f7fc;
} }
.image-preview { .image-preview {
display: block; display: block;
width: 100%; width: 100%;
aspect-ratio: 4 / 3; height: 100%;
padding: 0; padding: 0;
border: 0; border: 0;
background: #f4f7f8; background: transparent;
cursor: zoom-in; cursor: zoom-in;
} }
.image-preview img { .image-preview img {
@@ -258,24 +265,70 @@ defineExpose({ reload: load });
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
} }
.image-meta { .image-order {
display: flex; position: absolute;
align-items: center; left: 4px;
gap: 6px; bottom: 4px;
min-height: 38px; min-width: 18px;
padding: 4px 6px 4px 8px; height: 18px;
padding: 0 5px;
border-radius: 9px;
background: rgba(0, 0, 0, 0.6);
color: #fff;
font-size: 11px;
line-height: 18px;
text-align: center;
pointer-events: none;
} }
.image-name { .image-delete {
min-width: 0; position: absolute;
flex: 1 1 auto; top: 2px;
overflow: hidden; right: 2px;
text-overflow: ellipsis; width: 20px;
white-space: nowrap; height: 20px;
font-size: 12px; padding: 0;
border: 0;
border-radius: 50%;
background: rgba(0, 0, 0, 0.55);
color: #fff;
font-size: 14px;
line-height: 20px;
cursor: pointer;
}
.image-delete:hover {
background: #d03050;
} }
.image-actions { .image-actions {
display: inline-flex; position: absolute;
flex: 0 0 auto; right: 3px;
bottom: 3px;
display: flex;
align-items: center;
gap: 1px;
padding: 1px;
border-radius: 12px;
background: rgba(0, 0, 0, 0.55);
}
:deep(.image-move-button) {
color: #fff;
}
:deep(.image-move-button.n-button--disabled) {
color: rgba(255, 255, 255, 0.42);
}
.upload-tile {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
border-style: dashed;
background: #fafcff;
color: #6b7280;
font-size: 12px;
cursor: pointer;
}
.upload-tile.uploading {
cursor: default;
} }
.images-pagination { .images-pagination {
display: flex; display: flex;
@@ -1,5 +1,10 @@
<template> <template>
<n-modal v-model:show="visible" preset="card" :title="modalTitle" class="outbound-record-modal"> <n-modal
v-model:show="visible"
preset="card"
:title="modalTitle"
style="width: 720px; max-width: 94vw"
>
<n-spin :show="loading"> <n-spin :show="loading">
<n-descriptions :column="2" label-placement="top" size="small" bordered class="trace-summary"> <n-descriptions :column="2" label-placement="top" size="small" bordered class="trace-summary">
<n-descriptions-item :label="t('pages.traceCode.shortCode')"> <n-descriptions-item :label="t('pages.traceCode.shortCode')">
@@ -46,7 +51,9 @@
v-if="traceCodeId" v-if="traceCodeId"
ref="imageManager" ref="imageManager"
:trace-code-id="traceCodeId" :trace-code-id="traceCodeId"
:disabled="!auth.canWrite || !hasRecord" :disabled="!auth.canWrite || saving"
:recorded="hasRecord"
:before-upload="ensureRecordForUpload"
@changed="emit('changed')" @changed="emit('changed')"
/> />
</n-spin> </n-spin>
@@ -110,6 +117,7 @@ function formatDate(value?: string | Date | null) {
async function load() { async function load() {
if (!traceCodeId.value) return; if (!traceCodeId.value) return;
const version = ++loadVersion; const version = ++loadVersion;
record.value = null;
loading.value = true; loading.value = true;
try { try {
let next: any = null; let next: any = null;
@@ -129,10 +137,10 @@ async function load() {
} }
} }
async function saveRecord() { async function persistRecord(notify: boolean) {
if (!traceCodeId.value || !form.outTime) { if (!traceCodeId.value || !form.outTime) {
message.warning(t('pages.outbound.outTimeRequired')); message.warning(t('pages.outbound.outTimeRequired'));
return; return false;
} }
saving.value = true; saving.value = true;
try { try {
@@ -147,14 +155,24 @@ async function saveRecord() {
outTime, outTime,
remark: form.remark.trim() || null, remark: form.remark.trim() || null,
}; };
message.success(t('common.msg.saved')); if (notify) message.success(t('common.msg.saved'));
emit('changed'); emit('changed');
await imageManager.value?.reload(); return true;
} finally { } finally {
saving.value = false; saving.value = false;
} }
} }
async function saveRecord() {
await persistRecord(true);
}
async function ensureRecordForUpload() {
if (hasRecord.value) return;
const saved = await persistRecord(false);
if (!saved) throw new Error('Outbound record is required before uploading images.');
}
watch( watch(
() => [props.show, traceCodeId.value] as const, () => [props.show, traceCodeId.value] as const,
([show]) => { ([show]) => {
@@ -169,9 +187,6 @@ watch(
</script> </script>
<style scoped> <style scoped>
.outbound-record-modal {
width: min(780px, calc(100vw - 32px));
}
.trace-summary { .trace-summary {
margin-bottom: 16px; margin-bottom: 16px;
} }
@@ -132,7 +132,12 @@
<n-pagination v-bind="pagination" :disabled="loading" /> <n-pagination v-bind="pagination" :disabled="loading" />
</div> </div>
<n-modal v-model:show="matchVisible" preset="card" :title="t('pages.operations.matchCodes')" class="match-modal"> <n-modal
v-model:show="matchVisible"
preset="card"
:title="t('pages.operations.matchCodes')"
style="width: 920px; max-width: 94vw"
>
<n-input <n-input
v-model:value="matchText" v-model:value="matchText"
type="textarea" type="textarea"
@@ -191,7 +196,7 @@
v-model:show="outboundBatchVisible" v-model:show="outboundBatchVisible"
preset="card" preset="card"
:title="t('pages.operations.batchOutbound')" :title="t('pages.operations.batchOutbound')"
class="outbound-batch-modal" style="width: 520px; max-width: 94vw"
> >
<n-form :model="outboundForm" label-placement="top"> <n-form :model="outboundForm" label-placement="top">
<n-form-item :label="t('pages.outbound.outTime')" required> <n-form-item :label="t('pages.outbound.outTime')" required>
@@ -903,9 +908,10 @@ function runSingleOnchain(row: any) {
} }
async function submitSingleOnchain(row: any) { async function submitSingleOnchain(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; proofVisible.value = false;
openJob(extractJobId(result)); message.success(t('pages.operations.jobSubmitted'));
void load();
} }
function openOutboundRecord(row: any) { function openOutboundRecord(row: any) {
@@ -980,12 +986,6 @@ onUnmounted(() => {
justify-content: space-between; justify-content: space-between;
gap: 12px; gap: 12px;
} }
.match-modal {
width: min(920px, calc(100vw - 32px));
}
.outbound-batch-modal {
width: min(520px, calc(100vw - 32px));
}
.match-actions, .match-actions,
.match-summary { .match-summary {
margin-top: 12px; margin-top: 12px;
+129 -12
View File
@@ -30,6 +30,14 @@
<n-card v-if="auth.canWrite && checkedKeys.length" size="small" class="batch-bar" :bordered="false"> <n-card v-if="auth.canWrite && checkedKeys.length" size="small" class="batch-bar" :bordered="false">
<n-space align="center"> <n-space align="center">
<span>{{ t('pages.traceCode.selected', { n: checkedKeys.length }) }}</span> <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-dropdown trigger="click" :options="groupAssignOptions" @select="batchAssignGroup">
<n-button size="small"> <n-button size="small">
<template #icon><n-icon :component="FolderOutline" /></template> <template #icon><n-icon :component="FolderOutline" /></template>
@@ -144,6 +152,47 @@
</template> </template>
</n-modal> </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 <outbound-record-modal
v-model:show="outboundRecordVisible" v-model:show="outboundRecordVisible"
:trace-code="operationTarget" :trace-code="operationTarget"
@@ -158,7 +207,7 @@
<batch-job-modal <batch-job-modal
v-model:show="jobVisible" v-model:show="jobVisible"
:job-id="jobId" :job-id="jobId"
:title="t('pages.operations.onchainProgress')" :title="batchJobTitle"
@completed="reloadAfterOperation" @completed="reloadAfterOperation"
/> />
</div> </div>
@@ -168,10 +217,11 @@
import { computed, h, onMounted, onUnmounted, reactive, ref, watch } from 'vue'; import { computed, h, onMounted, onUnmounted, reactive, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import dayjs from 'dayjs';
import { NButton, NDropdown, NIcon, NTag, NText, type DataTableColumns, type DropdownOption } from 'naive-ui'; 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 { 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 { useAuthStore } from '@/stores/auth';
import { message, dialog } from '@/utils/feedback'; import { message, dialog } from '@/utils/feedback';
import { fmt, statusType } from '@/utils/format'; import { fmt, statusType } from '@/utils/format';
@@ -266,11 +316,20 @@ const editingGroup = ref<number | null>(null);
const batchModal = ref(false); const batchModal = ref(false);
const batchTarget = ref<any | null>(null); const batchTarget = ref<any | null>(null);
const batchForm = reactive<{ batchValue: number | string | null }>({ batchValue: 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 outboundRecordVisible = ref(false);
const proofVisible = ref(false); const proofVisible = ref(false);
const operationTarget = ref<any | null>(null); const operationTarget = ref<any | null>(null);
const jobVisible = ref(false); const jobVisible = ref(false);
const jobId = ref(''); const jobId = ref('');
const batchJobTitle = computed(() =>
batchJobType.value === 'ONCHAIN'
? t('pages.operations.onchainProgress')
: t('pages.operations.outboundProgress'),
);
function rowIsOutbound(row: any) { function rowIsOutbound(row: any) {
if (!row) return false; if (!row) return false;
@@ -747,6 +806,65 @@ async function batchStatus(disabled: boolean) {
emit('changed'); 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() { function batchDelete() {
if (!checkedKeys.value.length) return; if (!checkedKeys.value.length) return;
dialog.warning({ dialog.warning({
@@ -945,16 +1063,10 @@ function runOnchainRow(row: any) {
} }
async function submitOnchainRow(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; proofVisible.value = false;
const id = String(result?.jobId || result?.id || result?.job?.id || ''); message.success(t('pages.operations.jobSubmitted'));
if (id) { void load();
jobId.value = id;
jobVisible.value = true;
} else {
message.success(t('pages.operations.jobSubmitted'));
}
await load();
} }
async function reloadAfterOperation() { async function reloadAfterOperation() {
@@ -1071,6 +1183,11 @@ onUnmounted(() => {
.batch-bar { .batch-bar {
margin-bottom: 12px; margin-bottom: 12px;
} }
.modal-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
}
.group-toolbar { .group-toolbar {
margin-bottom: 14px; margin-bottom: 14px;
} }
+2 -2
View File
@@ -447,8 +447,8 @@
"saveRecord": "Save Record", "saveRecord": "Save Record",
"registerRecord": "Register Outbound", "registerRecord": "Register Outbound",
"editRecord": "Edit Outbound Record", "editRecord": "Edit Outbound Record",
"addImage": "Add Outbound Photo", "recordImage": "Add Outbound Photo",
"imageCount": "{n} photo(s)", "addImage": "Add Another Outbound Photo",
"moveImageUp": "Move earlier", "moveImageUp": "Move earlier",
"moveImageDown": "Move later", "moveImageDown": "Move later",
"imageFormatTip": "Only JPG, JPEG, PNG, and WebP images are supported", "imageFormatTip": "Only JPG, JPEG, PNG, and WebP images are supported",
+1 -1
View File
@@ -447,8 +447,8 @@
"saveRecord": "保存登记", "saveRecord": "保存登记",
"registerRecord": "登记出库", "registerRecord": "登记出库",
"editRecord": "编辑出库记录", "editRecord": "编辑出库记录",
"recordImage": "录入实况图",
"addImage": "补录实况图", "addImage": "补录实况图",
"imageCount": "共 {n} 张",
"moveImageUp": "前移", "moveImageUp": "前移",
"moveImageDown": "后移", "moveImageDown": "后移",
"imageFormatTip": "仅支持 JPG、JPEG、PNG、WebP 图片", "imageFormatTip": "仅支持 JPG、JPEG、PNG、WebP 图片",
+6 -2
View File
@@ -34,12 +34,16 @@ const activeTab = ref<'records' | 'zip'>('records');
.operation-tabs :deep(.n-tabs-nav) { .operation-tabs :deep(.n-tabs-nav) {
flex: 0 0 auto; flex: 0 0 auto;
} }
.operation-tabs :deep(.n-tabs-pane-wrapper), .operation-tabs :deep(.n-tabs-pane-wrapper) {
.operation-tabs :deep(.n-tab-pane) {
flex: 1 1 auto; flex: 1 1 auto;
min-height: 0; min-height: 0;
display: flex;
flex-direction: column;
} }
.operation-tabs :deep(.n-tab-pane) { .operation-tabs :deep(.n-tab-pane) {
flex: 1 1 0;
height: 100%;
min-height: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-top: 12px; padding-top: 12px;