@@ -17,8 +17,9 @@
-- >
< script setup lang = "ts" >
import { computed , defineAsyncComponent , nextTick , onBeforeUnmount , onMounted , ref , watch } from 'vue' ;
import type { Component } from 'vue' ;
import { useRoute , useRouter } from 'vue-router' ;
import { Bot , Check , ChevronDown , Crosshair , Download , MoreHorizontal , Plus , RefreshCw , Undo2 , Copy , Trash2 } from 'lucide-vue-next' ;
import { Bot , Check , ChevronDown , Crosshair , Download , MoreHorizontal , Pencil , Plus , RefreshCw , Undo2 , Copy , Trash2 , X } from 'lucide-vue-next' ;
import { useI18n } from 'vue-i18n' ;
import { BusinessError } from '@/shared/api/client' ;
import { useMessage } from '@/shared/composables/useMessage' ;
@@ -37,6 +38,7 @@ import {
retryWorkspaceShippingOrderStpAutoCreate ,
retryShippingNoticeIntake ,
decideWorkspaceShippingOrderReviewLineFulfillment ,
updateWorkspaceShippingNoticeLine ,
waveWorkspaceShippingOrderReviewLineFulfillment ,
setWorkspaceShippingTaskOdmChoice ,
viewWorkspaceShippingOrderReviewHighlightDiagnostic ,
@@ -1930,7 +1932,8 @@ async function handleCurrentTaskAction(
break ;
case 'open_inventory_match_review' :
if ( hasFormalOt . value ) {
scrollWorkbenchAnchor ( 'review-order-lines-table' ) ;
/ / 正 式 O T 后 匹 配 / 缺 口 语 境 的 真 实 宿 主 是 通 知 准 备 工 作 区 ; 订 单 明 细 表 不 承 载 库 存 结 果 。
scrollWorkbenchAnchor ( 'review-fulfillment-prep-workspace' ) ;
} else {
workbenchMode . value = 'inventory' ;
scrollWorkbenchAnchor ( 'review-inventory-issue-list' ) ;
@@ -2603,9 +2606,8 @@ function formalPreparationLineSource(line: {
/** 锁定边界 = Excel 生成(D7):后端 preparation.source_locked 下发,生成后行源只读。 */
const formalPreparationSourceLocked = computed ( ( ) => Boolean ( formalPreparationContext . value ? . source _locked ) ) ;
/** 多文件冲突行的行内选源暂存(line_no → 选定 source_code),提交后由后端映射快照行并重匹配。 */
const lineSourceSelections = ref < Record < string , string > > ( { } ) ;
const lineSourceBusy = ref ( false ) ;
/ * * 库 存 源 选 择 不 再 有 独 立 确 认 流 : 行 进 入 就 地 编 辑 态 后 在 下 拉 中 改 选 , 随 行 级 「 保 存 」 统 一 提 交
* ( override _line _inventory _source Gate 动作 , 见 saveInlineEdit ) ; 展示态回退为文本 。 * /
/** 选源下拉项文案:源编码始终可见(等宽语义由样式层保证)。 */
function lineSourceOptionLabel ( code : string ) : string {
@@ -2613,58 +2615,14 @@ function lineSourceOptionLabel(code: string): string {
return String ( code || '' ) . trim ( ) . toUpperCase ( ) ;
}
/ * *
* 提交歧义行选定源 : 走正式 Gate 动作 override _line _inventory _source ( 方案 3 · 放开 , 唯一选源入口 ) ,
* 后端校验启用 / Excel 锁并仅重匹配该行 ; 成功后清空行内暂存并刷新任务详情 。
* /
async function submitLineSourceSelection ( line : { snapshot _line _id ? : number | null ; line _no ? : string | number | null } ) {
const selectionKey = String ( line . snapshot _line _id ? ? '' ) ;
const sourceCode = String ( lineSourceSelections . value [ selectionKey ] || '' ) . trim ( ) ;
const lineNo = Number ( line . line _no ) ;
if ( ! sourceCode || ! Number . isInteger ( lineNo ) || lineNo < 1 || lineSourceBusy . value ) return ;
lineSourceBusy . value = true ;
try {
await submitFormalGateAction ( 'override_line_inventory_source' , {
line _no : lineNo ,
source _code : sourceCode ,
} ) ;
delete lineSourceSelections . value [ selectionKey ] ;
} finally {
lineSourceBusy . value = false ;
}
}
/** 人工覆写库存源(方案 3·放开):后端下发全部已启用源 source_options,供行级下拉人工指定。 */
const formSourceOptions = computed ( ( ) => formalPreparationContext . value ? . source _options || [ ] ) ;
const overrideSourceSelections = ref < Record < string , string > > ( { } ) ;
const overrideSourceBusy = ref ( false ) ;
function overrideSourceOptionLabel ( code : string ) : string {
/ / 兜 底 : 下 拉 只 展 示 源 编 码 ( 如 D S V 3 6 0 _ A W S S G ) , 不 展 示 冗 长 d i s p l a y _ n a m e , 便 于 快 速 识 别 。
return String ( code || '' ) . trim ( ) . toUpperCase ( ) ;
}
/ * *
* 提交人工覆写行库存源 : 走正式 Gate 动作 override _line _inventory _source ( 方案 3 · 放开 ) ,
* 后端校验源启用 / Excel 锁并仅重匹配该行 ; 成功后清空暂存并刷新任务详情 。
* /
async function submitOverrideSource ( line : { snapshot _line _id ? : number | null ; line _no ? : string | number | null } ) {
const selectionKey = String ( line . snapshot _line _id ? ? '' ) ;
const sourceCode = String ( overrideSourceSelections . value [ selectionKey ] || '' ) . trim ( ) ;
const lineNo = Number ( line . line _no ) ;
if ( ! sourceCode || ! Number . isInteger ( lineNo ) || lineNo < 1 || overrideSourceBusy . value ) return ;
overrideSourceBusy . value = true ;
try {
await submitFormalGateAction ( 'override_line_inventory_source' , {
line _no : lineNo ,
source _code : sourceCode ,
} ) ;
delete overrideSourceSelections . value [ selectionKey ] ;
} finally {
overrideSourceBusy . value = false ;
}
}
/** 整单 ODM 裁决列可见性:任一行候选多于一个时展示(候选已经客户范围过滤)。 */
const formalPreparationOdmColumnVisible = computed ( ( ) =>
( formalPreparationContext . value ? . lines || [ ] ) . some ( ( line ) => ( line . odm _values ? . length || 0 ) > 1 ) ,
@@ -2761,7 +2719,7 @@ async function confirmReleaseInventoryShortage() {
const caseNo = activeCase . value ? . case _no ;
const reason = releaseInventoryReason . value . trim ( ) ;
const requiredFields = line ? . release _required _fields || [ ] ;
if ( ! line || ! caseNo || ! reason || requiredFields . some ( ( field ) => ! releaseInventoryFieldValues . value [ field . field _id ] ? . trim ( ) ) || releaseInventoryBusy . value ) return ;
if ( ! line || ! caseNo || requiredFields . some ( ( field ) => ! releaseInventoryFieldValues . value [ field . field _id ] ? . trim ( ) ) || releaseInventoryBusy . value ) return ;
releaseInventoryBusy . value = true ;
try {
await decideWorkspaceShippingOrderReviewLineFulfillment ( caseNo , {
@@ -2788,6 +2746,160 @@ function formalPreparationLineInventoryFileNo(line: { snapshot_line_id?: number
return String ( line . inventory _file _no || fulfillment ? . inventory _file _no || '' ) . trim ( ) ;
}
/** 行内放行补录条(常显子行):短缺行携带必填放行字段时直接在行下补填,替代弹窗。 */
const releaseBarValues = ref < Record < string , Record < string , string > >> ( { } ) ;
const releaseBarBusy = ref < Record < string , boolean > > ( { } ) ;
function releaseBarKey ( line : { snapshot _line _id ? : number | null } ) : string {
return String ( line . snapshot _line _id ? ? '' ) ;
}
/** 放行必填字段:仅短缺行且投影声明了必填补录项(有候选缺失才需要补录)。 */
function releaseBarLineRequiredFields ( line : { snapshot _line _id ? : number | null } ) {
const fulfillment = formalPreparationLineFulfillment ( line ) ;
return fulfillment ? . release _required _fields || [ ] ;
}
/** 缺字段型短缺行:放行走行内补录(而非仅原因的旧弹窗路径)。 */
function releaseBarHasFields ( line : {
snapshot _line _id ? : number | null ;
shortage _qty ? : string | number | null ;
} ) : boolean {
return Number ( line . shortage _qty || 0 ) > 0 && releaseBarLineRequiredFields ( line ) . length > 0 ;
}
/** 补录条展开态:默认收起(表格保持干净),由 ⋯ 菜单「放行缺口」或缺 N 项徽标点击展开。 */
const releaseBarExpandedFor = ref < string | null > ( null ) ;
function expandReleaseBar ( line : { snapshot _line _id ? : number | null } ) {
if ( inlineEditBusy . value ) {
msg . warning ( t ( 'chat.shippingOrderReview.inlineEdit.busy' ) ) ;
return ;
}
releaseBarExpandedFor . value = releaseBarKey ( line ) ;
}
function releaseBarValue (
line : { snapshot _line _id ? : number | null } ,
field : { field _id ? : string | null } ,
) : string {
return releaseBarValues . value [ releaseBarKey ( line ) ] ? . [ String ( field . field _id ) ] ? ? '' ;
}
function updateReleaseBarValue (
line : { snapshot _line _id ? : number | null } ,
field : { field _id ? : string | null } ,
value : string ,
) {
const key = releaseBarKey ( line ) ;
releaseBarValues . value = {
... releaseBarValues . value ,
[ key ] : { ... ( releaseBarValues . value [ key ] || { } ) , [ String ( field . field _id ) ] : value } ,
} ;
}
/** 放行按钮可用性:后端授权 + 必填补录项全部已填 + 非保存中。 */
function releaseBarReadyFor ( line : { snapshot _line _id ? : number | null } ) : boolean {
const fulfillment = formalPreparationLineFulfillment ( line ) ;
const required = releaseBarLineRequiredFields ( line ) ;
return Boolean (
fulfillment ? . line _allowed _actions ? . includes ( 'release_inventory_shortage' )
&& required . every ( ( field ) => releaseBarValue ( line , field ) . trim ( ) )
&& ! releaseBarBusy . value [ releaseBarKey ( line ) ] ,
) ;
}
/** 行内放行提交:走既有 decide 通道;原因可选(人工放行事实由审计链记录)。 */
async function confirmReleaseBar ( line : { snapshot _line _id ? : number | null } ) {
const caseNo = activeCase . value ? . case _no ;
const fulfillment = formalPreparationLineFulfillment ( line ) ;
const key = releaseBarKey ( line ) ;
const required = releaseBarLineRequiredFields ( line ) ;
if (
! caseNo || ! fulfillment ? . draft _line _id
|| ! required . every ( ( field ) => releaseBarValue ( line , field ) . trim ( ) )
|| releaseBarBusy . value [ key ]
) return ;
releaseBarBusy . value = { ... releaseBarBusy . value , [ key ] : true } ;
try {
await decideWorkspaceShippingOrderReviewLineFulfillment ( caseNo , {
draft _line _id : String ( fulfillment . draft _line _id || '' ) ,
decision _code : 'release_inventory_shortage' ,
reason : '' ,
release _field _values : { ... ( releaseBarValues . value [ key ] || { } ) } ,
expected _draft _version : activeCase . value ? . draft ? . draft _version ,
} ) ;
const next = { ... releaseBarValues . value } ;
delete next [ key ] ;
releaseBarValues . value = next ;
/ / 放 行 写 入 成 功 即 结 束 用 户 交 互 ; N o t i c e / E x c e l 由 后 端 J o b 异 步 创 建 ( 与 原 弹 窗 通 道 一 致 ) 。
handleGateRecoveryAccepted ( { releaseAutoAdvance : true } ) ;
} catch ( error ) {
msg . warning ( error instanceof Error ? error . message : t ( 'chat.shippingOrderReview.workbench.resultNotReady' ) ) ;
} finally {
releaseBarBusy . value = { ... releaseBarBusy . value , [ key ] : false } ;
}
}
/** 行结案弹窗状态;与放行缺口弹窗同款交互(原因必填),走 line-fulfillment decide 通道。 */
const closeLineDialogLine = ref < ShippingOrderReviewLineFulfillmentLine | null > ( null ) ;
const closeLineReason = ref ( '' ) ;
const closeLineBusy = ref ( false ) ;
/ * *
* 结案按钮可见性 : 仅 「 无货可发 」 的未终态 prep 行开放 。
* 核心逻辑 : line _allowed _actions 由后端投影下发 ( 终态行返回空数组 , 天然排除已结案 /
* 已放行 / 已入波次行 ) , 前端再叠加短缺信号 ( is _shortage / 缺量 > 0 / not _found ) 过滤 ;
* 后端 decide API 才是权威闸门 , 这里只做入口收敛 。
* /
function formalPreparationLineCloseVisible ( line : { snapshot _line _id ? : number | null ; shortage _qty ? : string | number | null } ) : boolean {
if ( ! formalPreparationLineAllows ( line , 'close_unfulfillable' ) ) return false ;
const fulfillment = formalPreparationLineFulfillment ( line ) ;
if ( fulfillment ? . decision ? . decision _code === 'close_unfulfillable' ) return false ;
const notFound = String ( fulfillment ? . match _result || '' ) . trim ( ) . toLowerCase ( ) === 'not_found' ;
const shortageQty = Number ( line . shortage _qty ? ? fulfillment ? . shortage _qty ? ? 0 ) > 0 ;
return Boolean ( fulfillment ? . is _shortage ) || shortageQty || notFound ;
}
/ * *
* 打开行结案弹窗 : 按快照行身份定位履约投影行 ( 携带 draft _line _id ) 。
* 核心逻辑 : 与行内编辑互斥 — — 弹窗打开即取消该行编辑态 , 避免两套写路径叠加 。
* /
function openCloseLineDialog ( line : { snapshot _line _id ? : number | null } ) {
const fulfillment = formalPreparationLineFulfillment ( line ) ;
if ( ! fulfillment ) return ;
cancelInlineEdit ( ) ;
closeLineDialogLine . value = fulfillment ;
closeLineReason . value = '' ;
}
/ * *
* 提交行结案决定 ( decision _code = 'close_unfulfillable' , 原因必填 ) 。
* 核心逻辑 : 复用既有 line - fulfillment decide API ; 成功后走恢复协调刷新三投影 ,
* prep 表即时反映已结案状态 ( 后端拒绝无效流转时以 BusinessError 文案提示 ) 。
* /
async function confirmCloseLine ( ) {
const line = closeLineDialogLine . value ;
const caseNo = activeCase . value ? . case _no ;
const reason = closeLineReason . value . trim ( ) ;
if ( ! line || ! caseNo || ! reason || closeLineBusy . value ) return ;
closeLineBusy . value = true ;
try {
await decideWorkspaceShippingOrderReviewLineFulfillment ( caseNo , {
draft _line _id : String ( line . draft _line _id || '' ) ,
decision _code : 'close_unfulfillable' ,
reason ,
expected _draft _version : activeCase . value ? . draft ? . draft _version ,
} ) ;
closeLineDialogLine . value = null ;
handleGateRecoveryAccepted ( ) ;
} catch ( error ) {
msg . warning ( error instanceof Error ? error . message : t ( 'chat.shippingOrderReview.workbench.resultNotReady' ) ) ;
} finally {
closeLineBusy . value = false ;
}
}
/** 下载行级实际匹配快照,禁止退回到任务级 active link。 */
async function downloadFormalPreparationLineInventoryFile ( line : {
snapshot _line _id ? : number | null ;
@@ -2812,6 +2924,257 @@ async function retryFormalPreparationLine(
await submitFormalGateAction ( actionCode , { snapshot _line _id : Number ( snapshotLineId ) } ) ;
}
/ * *
* 库存 RPA 是否运行中 ( 就地编辑的 busy 禁用条件 ) 。
* 核心逻辑 : 后端 preparation 摘要当前未下发 inventory _rpa _is _running ( 仅内部计算 ) ,
* 故先消费可选下发字段 ( 后端补发即生效 ) , 缺失时以 status === 'processing'
* ( 尚无匹配结果且无门禁 → 首轮抓取进行中 ) 兜底 ; 重匹配期间的写冲突由
* 后端 SHIPPING . EDIT _WINDOW _SYSTEM _BUSY 守卫兜底 。
* /
const inlineEditBusy = computed ( ( ) => {
const preparation = formalTaskDetail . value ? . ui _state ? . stage _context ? . preparation ;
if ( ! preparation ) return false ;
const running = ( preparation as { inventory _rpa _is _running ? : unknown } ) . inventory _rpa _is _running ;
if ( typeof running === 'boolean' ) return running ;
return preparation . status === 'processing' ;
} ) ;
/ * * 就 地 编 辑 状 态 : 仅 一 行 处 于 编 辑 态 ; 保 存 走 既 有 u p d a t e - n o t i c e - l i n e 通 道 ( 免 证 据 人 工 修 订 ) 。
* 编辑入口 = 行级 「 编辑 」 按钮 ( 防单元格误触 ) ; 编辑态下更多操作列替换为保存 / 取消 。 * /
const editingLine = ref < {
snapshot _line _id : number ;
line _no : number ;
part _number : string ;
reservation _id : string ;
required _qty : string ;
source _code : string ;
} | null > ( null ) ;
const inlineEditSaving = ref ( false ) ;
/ * *
* 就地编辑草稿种子值 : 把展示占位 「 — 」 还原为空串 , 避免占位符被当作真实值提交 。
* @ param value - prep 行展示值 ( 可能为 null / '—' / 数字 )
* @ returns 可直接进入输入框的字符串
* /
function inlineEditSeedValue ( value : unknown ) : string {
const text = String ( value ? ? '' ) . trim ( ) ;
return text === '—' ? '' : text ;
}
/ * *
* 进入单个准备行的就地编辑 ( 料号 / 预约号 / 需求数量三个值列 ) 。
* @ param line - prep 展示行 ; snapshot _line _id 定位编辑行 , line _no - 1 与后端 line _index 0 基对齐
* /
function startInlineEdit ( line : {
snapshot _line _id ? : number | null ;
line _no ? : string | number | null ;
part _number ? : string | null ;
reservation _id ? : string | null ;
required _qty ? : string | number | null ;
selected _source _code ? : string | null ;
source _code ? : string | null ;
} ) {
if ( ! line . snapshot _line _id || inlineEditSaving . value ) return ;
/ / 库 存 R P A 运 行 中 禁 止 改 值 : 匹 配 进 行 中 修 改 会 与 重 匹 配 竞 态 。
if ( inlineEditBusy . value ) {
msg . warning ( t ( 'chat.shippingOrderReview.inlineEdit.busy' ) ) ;
return ;
}
editingLine . value = {
snapshot _line _id : Number ( line . snapshot _line _id ) ,
line _no : Number ( line . line _no || 0 ) ,
part _number : inlineEditSeedValue ( line . part _number ) ,
reservation _id : inlineEditSeedValue ( line . reservation _id ) ,
required _qty : inlineEditSeedValue ( line . required _qty ) ,
source _code : inlineEditSeedValue ( line . selected _source _code || line . source _code ) ,
} ;
}
/** 行是否处于就地编辑态(统一 Number 收敛,避免模板严格等于的类型漂移)。 */
function isInlineEditing ( line : { snapshot _line _id ? : number | null } ) : boolean {
return editingLine . value ? . snapshot _line _id === Number ( line . snapshot _line _id ) ;
}
/ * *
* 编辑态库存源下拉选项 : 多文件冲突行优先取候选源 , 其余行取全部已启用源 ;
* 无可用项返回空 — — 此时编辑态库存源保持文本展示 ( 无可选即不可改 ) 。
* /
function inlineSourceOptions ( line : {
source _ambiguous ? : boolean ;
source _candidates ? : Array < string > ;
} ) : Array < { value : string ; label : string } > {
if ( line . source _ambiguous && ( line . source _candidates ? . length || 0 ) > 0 ) {
return ( line . source _candidates || [ ] ) . map ( ( code ) => ( { value : String ( code ) , label : lineSourceOptionLabel ( String ( code ) ) } ) ) ;
}
if ( formSourceOptions . value . length ) {
return formSourceOptions . value . map ( ( s ) => ( { value : String ( s . source _code ) , label : overrideSourceOptionLabel ( String ( s . source _code ) ) } ) ) ;
}
return [ ] ;
}
/** 同步编辑态库存源草稿(与三个值列一致:改动仅在保存时提交)。 */
function updateInlineEditSource ( value : string ) {
if ( editingLine . value ) editingLine . value . source _code = value ;
}
/ * * 行 级 动 作 收 纳 菜 单 ( ⋯ ) 打 开 状 态 : 键 = s n a p s h o t _ l i n e _ i d , 单 行 互 斥 ; 坐 标 视 口 固 定 定 位 ,
* Teleport 到 body — — 表格祖先容器 overflow - auto 会裁剪 absolute 浮层并转为滚动高度 。 * /
const overflowMenuOpenFor = ref < string | null > ( null ) ;
const overflowMenuPos = ref < { top : number ; left : number } > ( { top : 0 , left : 0 } ) ;
function toggleOverflowMenu ( key : string , event ? : MouseEvent ) {
if ( overflowMenuOpenFor . value === key ) {
overflowMenuOpenFor . value = null ;
return ;
}
const rect = ( event ? . currentTarget as HTMLElement | undefined ) ? . getBoundingClientRect ( ) ;
const menuWidth = 176 ;
overflowMenuPos . value = {
top : rect ? Math . min ( rect . bottom + 4 , window . innerHeight - 8 ) : 0 ,
left : rect ? Math . max ( 8 , Math . min ( rect . right - menuWidth , window . innerWidth - menuWidth - 8 ) ) : 0 ,
} ;
overflowMenuOpenFor . value = key ;
}
/ * *
* 行级收纳菜单项 : 低频 / 诊断类动作入口 ( 守卫条件与原常显按钮完全一致 ) ,
* 高频的 「 编辑 」 保持常显 ; 无可用项时 ⋯ 整体不渲染 。
* /
function overflowItems ( line : {
snapshot _line _id ? : number | null ;
shortage _qty ? : string | number | null ;
} ) : Array < { key : string ; icon : Component ; labelKey : string ; run : ( ) => void | Promise < void > } > {
const items : Array < { key : string ; icon : Component ; labelKey : string ; run : ( ) => void | Promise < void > } > = [ ] ;
if ( formalPreparationLineAllows ( line , 'retry_inventory_matching' ) ) {
items . push ( {
key : 'retry_inventory_matching' ,
icon : RefreshCw ,
labelKey : inventoryActionLabelKey ( 'retry_inventory_matching' ) ! ,
run : ( ) => retryFormalPreparationLine ( Number ( line . snapshot _line _id ) , 'retry_inventory_matching' ) ,
} ) ;
}
/ / 放 行 缺 口 : 缺 字 段 型 短 缺 行 → 行 内 展 开 补 录 条 ( 替 代 弹 窗 ) ; 仅 缺 原 因 的 行 → 旧 弹 窗 ( 原 因 已 可 选 ) 。
if ( formalPreparationLineAllows ( line , 'release_inventory_shortage' ) ) {
items . push ( {
key : 'release_inventory_shortage' ,
icon : Check ,
labelKey : inventoryActionLabelKey ( 'release_inventory_shortage' ) ! ,
run : ( ) => {
if ( releaseBarHasFields ( line ) ) expandReleaseBar ( line ) ;
else openReleaseInventoryShortage ( line ) ;
} ,
} ) ;
}
if ( formalPreparationLineCloseVisible ( line ) ) {
items . push ( {
key : 'close_unfulfillable' ,
icon : X ,
labelKey : 'chat.shippingOrderReview.lineActions.closeLine' ,
run : ( ) => openCloseLineDialog ( line ) ,
} ) ;
}
if ( formalPreparationLineAllows ( line , 'retry_inventory_preparation' ) ) {
items . push ( {
key : 'retry_inventory_preparation' ,
icon : Bot ,
labelKey : inventoryActionLabelKey ( 'retry_inventory_preparation' ) ! ,
run : ( ) => retryFormalPreparationLine ( Number ( line . snapshot _line _id ) , 'retry_inventory_preparation' ) ,
} ) ;
}
if ( formalPreparationLineInventoryFileNo ( line ) ) {
items . push ( {
key : 'download_inventory_file' ,
icon : Download ,
labelKey : inventoryActionLabelKey ( 'download_inventory_file' ) || 'chat.shippingOrderReview.lifecycle.prepare.downloadInventory' ,
run : ( ) => downloadFormalPreparationLineInventoryFile ( line ) ,
} ) ;
}
return items ;
}
/** 同步需求数量输入:数字输入框经 @input 手动回写,避免 v-model 的隐式 number 转型。 */
function updateInlineEditQty ( value : string ) {
if ( editingLine . value ) editingLine . value . required _qty = value ;
}
/** 退出就地编辑并丢弃未保存修改。 */
function cancelInlineEdit ( ) {
editingLine . value = null ;
}
/ * *
* 保存就地编辑 : 仅提交有变化且非空的字段 ( part _number / reservation _id / qty ) ,
* 成功后提示 「 请点击重新匹配库存 」 并刷新任务详情 ( 值列即刻显示新值 , 重匹配仍需手动触发 ) 。
* @ param line - 当前编辑行 , 用于与编辑起始值比对计算差量补丁
* /
async function saveInlineEdit ( line : {
snapshot _line _id ? : number | null ;
part _number ? : string | null ;
reservation _id ? : string | null ;
required _qty ? : string | number | null ;
selected _source _code ? : string | null ;
source _code ? : string | null ;
} ) {
const draft = editingLine . value ;
if ( ! draft || ! draft . snapshot _line _id || inlineEditSaving . value ) return ;
/ / 编 辑 态 行 与 触 发 行 的 快 照 身 份 不 一 致 ( 如 刷 新 后 错 位 ) 时 直 接 丢 弃 , 禁 止 错 行 提 交 。
if ( draft . snapshot _line _id !== Number ( line . snapshot _line _id ) ) {
cancelInlineEdit ( ) ;
return ;
}
const taskNo = String ( formalTaskDetail . value ? . task _no || '' ) . trim ( ) ;
const lineIndex = Number ( draft . line _no ) - 1 ;
if ( ! taskNo || ! Number . isInteger ( lineIndex ) || lineIndex < 0 ) {
cancelInlineEdit ( ) ;
return ;
}
const patch : Record < string , string > = { } ;
const nextPartNumber = draft . part _number . trim ( ) ;
if ( nextPartNumber !== inlineEditSeedValue ( line . part _number ) ) patch . part _number = nextPartNumber ;
const nextReservationId = draft . reservation _id . trim ( ) ;
if ( nextReservationId !== inlineEditSeedValue ( line . reservation _id ) ) patch . reservation _id = nextReservationId ;
const nextQty = draft . required _qty . trim ( ) ;
if ( nextQty !== inlineEditSeedValue ( line . required _qty ) && nextQty ) patch . qty = nextQty ;
/ / 库 存 源 草 稿 与 进 入 编 辑 时 的 种 子 值 比 对 : 变 化 即 随 保 存 提 交 行 级 源 覆 写 。
const seedSourceCode = inlineEditSeedValue ( line . selected _source _code || line . source _code ) ;
const nextSourceCode = draft . source _code . trim ( ) ;
const sourceChanged = Boolean ( nextSourceCode ) && nextSourceCode !== seedSourceCode ;
if ( ! Object . keys ( patch ) . length && ! sourceChanged ) {
cancelInlineEdit ( ) ;
return ;
}
inlineEditSaving . value = true ;
try {
/ / 字 段 值 先 落 库 ( u p d a t e - n o t i c e - l i n e ) ; 随 后 的 源 覆 写 会 触 发 单 行 重 匹 配 , 读 到 的 是 修 正 后 的 字 段 值 。
if ( Object . keys ( patch ) . length ) {
await updateWorkspaceShippingNoticeLine (
taskNo ,
lineIndex ,
patch ,
undefined ,
/ / 免 证 据 人 工 修 订 ( 后 端 T a s k 2 已 放 宽 e v i d e n c e / r e a s o n ) ; 乐 观 锁 版 本 缺 失 时
/ / 退 回 后 端 初 值 1 , 冲 突 由 后 端 O R D E R _ D A T A _ V E R S I O N _ M I S M A T C H 的 4 0 9 语 义 兜 底 。
{ expectedOrderDataVersion : Number ( formalTaskDetail . value ? . order _data _version ? ? 1 ) } ,
) ;
}
/ / 库 存 源 覆 写 沿 用 既 有 G a t e 动 作 ( o v e r r i d e _ l i n e _ i n v e n t o r y _ s o u r c e ) , 后 端 校 验 后 仅 重 匹 配 该 行 。
if ( sourceChanged ) {
await submitFormalGateAction ( 'override_line_inventory_source' , {
line _no : draft . line _no ,
source _code : nextSourceCode ,
} ) ;
}
cancelInlineEdit ( ) ;
msg . success ( t ( 'chat.shippingOrderReview.inlineEdit.saved' ) ) ;
await loadFormalTaskDetail ( ) ;
} catch ( error ) {
/ / B u s i n e s s E r r o r . m e s s a g e 即 后 端 业 务 文 案 ( 版 本 冲 突 / 系 统 处 理 中 ) , 复 用 既 有 提 示 通 道 。
msg . warning ( error instanceof Error ? error . message : t ( 'chat.shippingOrderReview.workbench.resultNotReady' ) ) ;
} finally {
inlineEditSaving . value = false ;
}
}
/ * *
* 人工上传登记是后端 Gate 的受控写动作 ; 仅进入 「 货代上传 」 工作面不构成授权 。
* [ § 2 单源 ] 授权从 A ( shippingProcessingProjection . ui _state ) 读 — — § 2.5 差异① 已归一 , A 的
@@ -4104,13 +4467,10 @@ const closeAuxiliaryPanelsForCaseSwitch = () => {
llmSuggestionOpen : false ,
versionHistoryOpen : false ,
} ;
/ / [ N O - O P T I M I S T I C M E M O R Y ] 行 级 选 源 / 覆 写 是 「 点 保 存 才 生 效 」 的 实 提 交 , 未 保 存 的 暂 存 选 择
/ / 不 得 跨 文 件 / 切 换 残 留 ( 否 则 会 把 上 一 文 件 的 未 保 存 意 图 带 进 新 行 ) 。 切 换 即 清 空 暂 存 ,
/ / 行 回 到 后 端 s e l e c t e d _ s o u r c e _ c o d e / s o u r c e _ c o d e , 用 户 须 重 新 选 择 并 点 保 存 。
lineSourceSelections . value = { } ;
lineSourceBusy . value = false ;
overrideSourceSelections . value = { } ;
overrideSourceBusy . value = false ;
/ / [ N O - O P T I M I S T I C M E M O R Y ] 行 级 就 地 编 辑 是 「 点 保 存 才 生 效 」 的 实 提 交 , 未 保 存 的 编 辑 草 稿
/ / 不 得 跨 文 件 / 切 换 残 留 ( 否 则 会 把 上 一 文 件 的 未 保 存 意 图 带 进 新 行 ) 。 切 换 即 丢 弃 草 稿 ,
/ / 行 回 到 后 端 s e l e c t e d _ s o u r c e _ c o d e / s o u r c e _ c o d e , 用 户 须 重 新 进 入 编 辑 并 保 存 。
cancelInlineEdit ( ) ;
} ;
/ * *
@@ -4949,7 +5309,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 > < tr v-for = "(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`" :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">{{ line.reservation_id || '—' }}</td><td class="max-w-[220px] truncate px-3 py-2" :title="line.part_number || '—'">{{ line.part_number || '—' }}</td><td class="whitespace-nowrap px-3 py-2">{{ line.required_qty ?? '—' }}</td><td class="max-w-[220px] px-3 py-2"><div v-if="line.source_ambiguous && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-source-ambiguous-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceAmbiguous')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.source_code || ''" @change="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="code in line.source_candidates || []" :key="code" :value="code">{{ lineSourceOptionLabel(code) }}</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-source-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || lineSourceBusy || !preparationEditable" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" @click="submitLineSourceSelection(line)"><Check class="h-3.5 w-3.5" /></button></div><span v-else-if="line.source_ambiguous && formalPreparationSourceLocked" class="text-xs text-secondary" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked')">{{ t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked') }}</span><span v-else-if="!formalPreparationSourceLocked && formSourceOptions.length" class="flex items-center gap-1" :data-testid="`review-line-source-override-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-override-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.selected_source_code || line.source_code || ''" @change="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="s in formSourceOptions" :key="String(s.source_code)" :value="String(s.source_code)">{{ overrideSourceOptionLabel(String(s.source_code)) }}</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-source-override-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || overrideSourceBusy" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :data-line-index="lineIndex" @click="submitOverrideSource(line)"><Check class="h-3.5 w-3.5" /></button></span><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 && ! formal Line 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.shippingOrderRe Line truncated
< / table >
< / div >
< / div >
@@ -5728,7 +6088,31 @@ watch(
< / label >
< div class = "mt-4 flex justify-end gap-2" >
< button type = "button" class = "rounded border border-default px-3 py-1.5 text-sm" :disabled = "releaseInventoryBusy" @click ="releaseInventoryLine = null" > {{ t ( ' chat.shippingOrderReview.workbench.close ' ) }} < / button >
< button type = "button" class = "rounded bg-amber-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" : disabled = "releaseInventoryBusy || !releaseInventoryReason.trim() || (releaseInventoryLine.release_required_fields || []).some((field) => !releaseInventoryFieldValues[field.field_id]?.trim())" @click ="confirmReleaseInventoryShortage" > {{ t ( ' chat.shippingOrderReview.lifecycle.prepare.releaseConfirm ' ) }} < / button >
< button type = "button" class = "rounded bg-amber-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" : disabled = "releaseInventoryBusy || (releaseInventoryLine.release_required_fields || []).some((field) => !releaseInventoryFieldValues[field.field_id]?.trim())" @click ="confirmReleaseInventoryShortage" > {{ t ( ' chat.shippingOrderReview.lifecycle.prepare.releaseConfirm ' ) }} < / button >
< / div >
< / div >
< / div >
< div
v - if = "closeLineDialogLine"
class = "fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
data - testid = "review-close-line-dialog"
@ click . self = "closeLineDialogLine = null"
>
< div class = "w-full max-w-md rounded-xl border border-default bg-surface p-4 shadow-xl" >
< h2 class = "text-sm font-semibold" > { { t ( 'chat.shippingOrderReview.lineActions.closeLine' ) } } < / h2 >
< p class = "mt-1 text-xs text-muted" > { { t ( 'chat.shippingOrderReview.closeFulfillment.subtitle' ) } } < / p >
< textarea
v - model = "closeLineReason"
rows = "3"
class = "mt-3 w-full rounded-md border border-default bg-surface px-2.5 py-2 text-sm"
data - testid = "review-close-line-reason"
: placeholder = "t('chat.shippingOrderReview.lineActions.closeLineReason')"
: disabled = "closeLineBusy"
/ >
< div class = "mt-4 flex justify-end gap-2" >
< button type = "button" class = "rounded border border-default px-3 py-1.5 text-sm" :disabled = "closeLineBusy" @click ="closeLineDialogLine = null" > {{ t ( ' chat.shippingOrderReview.workbench.close ' ) }} < / button >
< button type = "button" class = "rounded bg-rose-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" data -testid = " review -close -line -submit " : disabled = "closeLineBusy || !closeLineReason.trim()" @click ="confirmCloseLine" > {{ t ( ' chat.shippingOrderReview.lineActions.closeLineConfirm ' ) }} < / button >
< / div >
< / div >
< / div >