feat(shipping-notice): 行编辑改按钮触发并修复缺失徽标i18n解析

- 行编辑入口改为更多操作列编辑按钮(防单元格误触),值列回退纯文本展示
- 编辑态更多操作列替换为保存/取消,其余动作隐藏;库存源下拉并入编辑态随保存提交
- 展示态动作收纳进更多菜单(Teleport+fixed 定位,修复被表格 overflow 裁剪成滚动)
- 缺失徽标改纯文本键+脚本拼接数量:规避 vue-i18n 11.4.7 深层嵌套键命名插值解析异常
  (te=false 且 t 回原始 key,已用 vitest 分层断言复现,详见 src/i18n.spec.ts 文件头说明)
- 后端缺口放行不再强制原因(人工放行事实由审计链记录,结案/重开仍必填)
- i18n 四语言补编辑/保存/取消/更多操作/放行补录文案
This commit is contained in:
hugo committed 2026-09-18 15:53:43 +08:00
1 parent 1bdefc0d71
commit f57bfc3bee
6 files changed
+77 -5

No files matched your search

@@ -2760,6 +2760,16 @@ function releaseBarLineRequiredFields(line: { snapshot_line_id?: number | null }
return fulfillment?.release_required_fields || [];
}
/**
* 缺失徽标文案:前缀 + 数量 + 后缀(纯文本键拼接)。
* 【注】不用 vue-i18n 命名插值 `{n}`——11.4.7 对该实例深层键+插值组合存在解析异常
* (te=false、t 回原始 key,已用 vitest 分层断言复现,见 src/i18n.spec.ts)。
*/
function releaseMissingBadgeLabel(line: { snapshot_line_id?: number | null }): string {
const n = releaseBarLineRequiredFields(line).length;
return `${t('chat.shippingOrderReview.releaseBar.missingPrefix')}${n}${t('chat.shippingOrderReview.releaseBar.missingSuffix')}`;
}
/** 缺字段型短缺行:放行走行内补录(而非仅原因的旧弹窗路径)。 */
function releaseBarHasFields(line: {
snapshot_line_id?: number | null;
@@ -5309,7 +5319,7 @@ watch(
<div class="overflow-x-auto overscroll-x-contain" data-testid="review-fulfillment-prep-table-scroll">
<table class="review-fulfillment-prep-table min-w-[1060px] text-xs">
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.odmConflict.column') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
<tbody><template v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`"><tr :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.reservation_id" type="text" class="w-28 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultReservation')" :data-testid="`review-fulfillment-line-edit-reservation-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.reservation_id || '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.part_number" type="text" class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultPartNumber')" :data-testid="`review-fulfillment-line-edit-part-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else class="block max-w-[220px] truncate" :title="line.part_number || '—'">{{ line.part_number || '—' }}</span></td><td class="whitespace-nowrap px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input :value="editingLine.required_qty" type="number" min="0" step="any" class="w-20 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.requiredQty')" :data-testid="`review-fulfillment-line-edit-qty-${line.snapshot_line_id}`" @input="updateInlineEditQty(($event.target as HTMLInputElement).value)" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.required_qty ?? '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="isInlineEditing(line) && inlineSourceOptions(line).length"><select class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-fulfillment-line-edit-source-${line.snapshot_line_id}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="editingLine?.source_code" :disabled="inlineEditSaving" @change="updateInlineEditSource(($event.target as HTMLSelectElement).value)"><option v-for="option in inlineSourceOptions(line)" :key="option.value" :value="option.value">{{ option.label }}</option></select></template><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) || '—' }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-odm-${line.snapshot_line_id || lineIndex}`"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-odm-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.odmConflict.title')" :value="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || line.chosen_odm_id || ''" @change="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.odmConflict.placeholder') }}</option><option v-for="value in line.odm_values" :key="value" :value="value">{{ value }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-odm-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || lineOdmBusy" :aria-label="t('chat.shippingOrderReLine truncated
<tbody><template v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`"><tr :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.reservation_id" type="text" class="w-28 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultReservation')" :data-testid="`review-fulfillment-line-edit-reservation-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.reservation_id || '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.part_number" type="text" class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultPartNumber')" :data-testid="`review-fulfillment-line-edit-part-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else class="block max-w-[220px] truncate" :title="line.part_number || '—'">{{ line.part_number || '—' }}</span></td><td class="whitespace-nowrap px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input :value="editingLine.required_qty" type="number" min="0" step="any" class="w-20 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.requiredQty')" :data-testid="`review-fulfillment-line-edit-qty-${line.snapshot_line_id}`" @input="updateInlineEditQty(($event.target as HTMLInputElement).value)" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.required_qty ?? '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="isInlineEditing(line) && inlineSourceOptions(line).length"><select class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-fulfillment-line-edit-source-${line.snapshot_line_id}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="editingLine?.source_code" :disabled="inlineEditSaving" @change="updateInlineEditSource(($event.target as HTMLSelectElement).value)"><option v-for="option in inlineSourceOptions(line)" :key="option.value" :value="option.value">{{ option.label }}</option></select></template><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) || '—' }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-odm-${line.snapshot_line_id || lineIndex}`"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-odm-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.odmConflict.title')" :value="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || line.chosen_odm_id || ''" @change="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.odmConflict.placeholder') }}</option><option v-for="value in line.odm_values" :key="value" :value="value">{{ value }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-odm-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || lineOdmBusy" :aria-label="t('chat.shippingOrderReLine truncated
</table>
</div>
</div>
+58
View File
@@ -0,0 +1,58 @@
/**
* src/i18n.spec.ts
*
* 用途:锁定应用真实 i18n 实例的键解析行为,防止"原始 key 直接渲染"回归。
* 依赖:vitest、vue-i18n、src/i18n(mergeExternalLocales 合并后的全局实例)、zh-CN/chat.json。
* 逻辑:分层断言——模块原始对象 → 实例消息表 → t() 解析;并留存 vue-i18n 11.4.7 插值异常的复现记录。
*
* 【已知库级异常(2026-09-18 复现,vue-i18n 11.4.7)】
* 深层嵌套键(如 chat.shippingOrderReview.releaseBar.badge)的**命名插值**消息
* `{n}` 会 te()=false 且 t() 返回原始 key——尽管 getLocaleMessage 与源 JSON 均含该键;
* 最小纯净实例上同名插值正常;同父对象的纯文本键正常。
* 因此本项目交互内联文案(如缺失徽标)采用「纯文本键 + 脚本拼接数量」规避;
* 升级 vue-i18n 后可用 git 历史中的插值断言复检是否已修复。
*/
import { describe, expect, it } from 'vitest';
import { createI18n } from 'vue-i18n';
import i18n from './i18n';
import zhCNChat from './locales/zh-CN/chat.json';
describe('vue-i18n 最小实例:{n} 插值(库能力基线)', () => {
it('纯净顶层实例可解析 {n} 命名插值', () => {
const minimal = createI18n({
legacy: false,
locale: 'zh-CN',
messages: { 'zh-CN': { badge: '缺 {n} 项放行信息' } },
});
// 断言:{n} 插值在顶层键上可用(深层嵌套键存在 11.4.7 异常,见文件头说明)。
expect(minimal.global.t('badge', { n: 2 })).toBe('缺 2 项放行信息');
});
});
describe('应用 i18n 实例:releaseBar 补录条键解析', () => {
it('模块原始对象包含补录条纯文本键', () => {
const subtree = (zhCNChat as Record<string, any>).shippingOrderReview as Record<string, any>;
// 断言:Vite JSON 管线加载后前缀/后缀键完整(徽标文案由脚本拼接,不依赖命名插值)。
expect(subtree?.releaseBar?.missingPrefix).toBe('缺 ');
expect(subtree?.releaseBar?.missingSuffix).toBe(' 项放行信息');
});
it('实例消息表包含补录条纯文本键', () => {
const instanceMessages = i18n.global.getLocaleMessage('zh-CN') as Record<string, any>;
const releaseBar = instanceMessages?.chat?.shippingOrderReview?.releaseBar;
// 断言:createI18n 合并后的实例消息表携带前缀/后缀。
expect(releaseBar?.missingPrefix).toBe('缺 ');
expect(releaseBar?.missingSuffix).toBe(' 项放行信息');
});
it('纯文本键端到端可解析(label 与 missingPrefix/missingSuffix)', () => {
// 断言:纯文本键在应用实例上全部正常解析(插值键的库级异常与此互不影响)。
expect(i18n.global.t('chat.shippingOrderReview.releaseBar.label')).toBe('放行补录');
expect(i18n.global.t('chat.shippingOrderReview.releaseBar.missingPrefix')).toBe('缺 ');
expect(i18n.global.t('chat.shippingOrderReview.releaseBar.missingSuffix')).toBe(' 项放行信息');
});
it('te() 对缺失键返回 false(回退语义不变)', () => {
expect(i18n.global.te('chat.shippingOrderReview.releaseBar.notExists')).toBe(false);
});
});
+2 -1
View File
@@ -2758,7 +2758,8 @@
},
"releaseBar": {
"label": "Release info",
"badge": "{n} missing release field(s)"
"missingPrefix": "Missing ",
"missingSuffix": " release field(s)"
}
},
"shippingOrderExtractionElapsed": "Elapsed {elapsed}",
+2 -1
View File
@@ -2758,7 +2758,8 @@
},
"releaseBar": {
"label": "ข้อมูลเพิ่มเติมเพื่อปล่อยของ",
"badge": "ขาด {n} รายการก่อนปล่อย"
"missingPrefix": "ขาด ",
"missingSuffix": " รายการก่อนปล่อย"
}
},
"shippingOrderExtractionElapsed": "ใช้เวลา {elapsed}",
+2 -1
View File
@@ -2866,7 +2866,8 @@
},
"releaseBar": {
"label": "放行补录",
"badge": "缺 {n} 项放行信息"
"missingPrefix": "缺 ",
"missingSuffix": " 项放行信息"
}
},
"shippingProcessing": {
+2 -1
View File
@@ -2758,7 +2758,8 @@
},
"releaseBar": {
"label": "放行補錄",
"badge": "缺 {n} 項放行資訊"
"missingPrefix": "缺 ",
"missingSuffix": " 項放行資訊"
}
},
"shippingOrderExtractionElapsed": "已用時 {elapsed}",