@@ -0,0 +1,569 @@
/**
* features/order-delivery-reply/views/OrderDeliveryReplyPage.vue
* 用途:订单交期回复工作台操作页——筛选分页、单行/联合回复批次、单行/批量通知、手动同步。
* 依赖:api/orderDeliveryReply.api(统一 requestJson)、useMessage、auth store( manage/access 权限)。
* 逻辑:所有数据只读本地快照;保存与通知是两步(联合回复只保存,批量通知才发送并锁定);
* 保存/通知成功后即时刷新列表(需求 §9);仅 access 用户隐藏全部写操作。
* 列顺序:客户编号(简称副文案) → 订单日期 → 订单单号:项次 → 产品编号(品名副文案) →
* 客户产品编号 → 数量 → 约定交货日 → 交期回复状态 → 交期回复 → 交期回复人员 →
* 业务员(部门副文案) → 客户订单 → 规格 → 单位;独立的部门列/品名列已并入合并展示。
*/
< script setup lang = "ts" >
import { computed , onMounted , reactive , ref } from 'vue' ;
import { useRoute } from 'vue-router' ;
import { useI18n } from 'vue-i18n' ;
import { useAuthStore } from '@/features/auth/stores/auth.store' ;
import { useMessage } from '@/shared/composables/useMessage' ;
import PaginationBar from '@/shared/components/PaginationBar.vue' ;
import {
ORDER _DELIVERY _REPLY _MANAGE _PERMISSION ,
} from '@/features/order-delivery-reply/constants' ;
import {
batchReplyOrderDelivery ,
getLatestOrderDeliverySync ,
listOrderDeliveryLines ,
notifyOrderDeliveryBatch ,
runOrderDeliverySync ,
saveOrderDeliveryBatches ,
type BatchSummary ,
type OrderDeliveryLine ,
type OrderDeliverySyncRun ,
} from '@/features/order-delivery-reply/api/orderDeliveryReply.api' ;
const { t } = useI18n ( ) ;
const msg = useMessage ( ) ;
const auth = useAuthStore ( ) ;
/** manage 可写(保存/通知/同步);access 或 manage 可看(路由与侧栏已按 access 守卫)。 */
const canManage = computed ( ( ) => auth . hasFeaturePermission ( ORDER _DELIVERY _REPLY _MANAGE _PERMISSION ) ) ;
/* ============ 列表查询 ============ */
const filters = reactive ( { order _no : '' , product _q : '' , customer _q : '' , order _date : '' , status : '' as '' | 'replied' | 'not_fully_replied' } ) ;
const appliedFilters = reactive ( { ... filters } ) ;
const items = ref < OrderDeliveryLine [ ] > ( [ ] ) ;
const total = ref ( 0 ) ;
const page = ref ( 1 ) ;
const pageSize = ref ( 50 ) ;
const pageSizeOptions = [ 20 , 50 , 100 , 200 ] ;
const loading = ref ( false ) ;
const latestSync = ref < OrderDeliverySyncRun | null > ( null ) ;
async function loadLines ( ) {
loading . value = true ;
try {
const data = await listOrderDeliveryLines ( { ... appliedFilters , page : page . value , page _size : pageSize . value } ) ;
items . value = data . items ;
total . value = data . total ;
if ( data . page !== page . value ) page . value = data . page ;
} catch ( error ) {
msg . error ( error instanceof Error ? error . message : t ( 'workspace.orderDeliveryReply.loadFailed' ) ) ;
} finally {
loading . value = false ;
}
}
async function loadLatestSync ( ) {
try {
latestSync . value = await getLatestOrderDeliverySync ( ) ;
} catch {
latestSync . value = null ;
}
}
function doSearch ( ) {
Object . assign ( appliedFilters , filters ) ;
page . value = 1 ;
void loadLines ( ) ;
}
function doReset ( ) {
Object . assign ( filters , { order _no : '' , product _q : '' , customer _q : '' , order _date : '' , status : '' } ) ;
doSearch ( ) ;
}
/** 分页条:页码跳转(与管理控制台数据报表同一 PaginationBar 组件)。 */
function goToPage ( next : number ) {
if ( next === page . value ) return ;
page . value = next ;
void loadLines ( ) ;
}
/** 切换每页条数:回到第 1 页并重查。 */
function changePageSize ( size : number ) {
if ( size === pageSize . value ) return ;
pageSize . value = size ;
page . value = 1 ;
void loadLines ( ) ;
}
/** 手动同步(manage):同步执行完成后刷新列表与最近同步时间。 */
const syncing = ref ( false ) ;
async function doSync ( ) {
syncing . value = true ;
try {
const result = await runOrderDeliverySync ( ) ;
if ( result . status === 'skipped' ) {
msg . warning ( t ( 'workspace.orderDeliveryReply.syncSkipped' ) ) ;
} else {
msg . success ( t ( 'workspace.orderDeliveryReply.syncDone' , { count : result . line _count } ) ) ;
}
await Promise . all ( [ loadLines ( ) , loadLatestSync ( ) ] ) ;
} catch ( error ) {
msg . error ( error instanceof Error ? error . message : t ( 'workspace.orderDeliveryReply.syncFailedTitle' ) ) ;
} finally {
syncing . value = false ;
}
}
/* ============ 勾选(全选仅本页) ============ */
const selected = ref < string [ ] > ( [ ] ) ;
const expanded = ref < string [ ] > ( [ ] ) ;
const lineKey = ( line : OrderDeliveryLine ) => ` ${ line . order _no } : ${ line . line _no } ` ;
const selectedLines = computed ( ( ) => items . value . filter ( ( line ) => selected . value . includes ( lineKey ( line ) ) ) ) ;
const allChecked = computed ( ( ) => items . value . length > 0 && items . value . every ( ( line ) => selected . value . includes ( lineKey ( line ) ) ) ) ;
const someChecked = computed ( ( ) => ! allChecked . value && items . value . some ( ( line ) => selected . value . includes ( lineKey ( line ) ) ) ) ;
/** 勾选中「已有批次且未锁定」的行才可批量通知(无批次/已锁定会被后端 skipped)。 */
const notifiableSelected = computed ( ( ) => selectedLines . value . filter ( ( line ) => line . batches . length > 0 && ! line . locked ) ) ;
function toggleLine ( line : OrderDeliveryLine , on : boolean ) {
const key = lineKey ( line ) ;
selected . value = on ? [ ... selected . value , key ] : selected . value . filter ( ( k ) => k !== key ) ;
}
function togglePageAll ( on : boolean ) {
if ( on ) {
const keys = new Set ( selected . value ) ;
items . value . forEach ( ( line ) => keys . add ( lineKey ( line ) ) ) ;
selected . value = [ ... keys ] ;
} else {
const pageKeys = new Set ( items . value . map ( lineKey ) ) ;
selected . value = selected . value . filter ( ( k ) => ! pageKeys . has ( k ) ) ;
}
}
function toggleExpand ( key : string ) {
expanded . value = expanded . value . includes ( key )
? expanded . value . filter ( ( k ) => k !== key )
: [ ... expanded . value , key ] ;
}
/* ============ 派生展示 ============ */
const repliedQty = ( line : OrderDeliveryLine ) =>
line . batches . reduce ( ( sum , batch ) => sum + Number ( batch . qty || 0 ) , 0 ) ;
const undelivered = ( line : OrderDeliveryLine ) => Number ( line . undelivered _qty || 0 ) ;
type LineStatus = OrderDeliveryLine [ 'status' ] ;
const statusMeta = ( status : LineStatus ) => {
const map : Record < LineStatus , { label : string ; cls : string } > = {
not _replied : { label : t ( 'workspace.orderDeliveryReply.statusNotReplied' ) , cls : 'bg-rose-50 text-rose-600' } ,
partial _replied : { label : t ( 'workspace.orderDeliveryReply.statusPartial' ) , cls : 'bg-orange-50 text-orange-600' } ,
replied : { label : t ( 'workspace.orderDeliveryReply.statusReplied' ) , cls : 'bg-emerald-50 text-emerald-600' } ,
} ;
return map [ status ] ;
} ;
/* ============ 回复弹窗(单行 / 联合) ============ */
interface EditableBatch { planned _date : string ; qty : string ; remark : string }
interface EditableLine { line : OrderDeliveryLine ; batches : EditableBatch [ ] }
const modalVisible = ref ( false ) ;
const modalTitle = ref ( '' ) ;
const modalLines = ref < EditableLine [ ] > ( [ ] ) ;
const quickDate = ref ( '' ) ;
const saving = ref ( false ) ;
function openReplyModal ( lines : OrderDeliveryLine [ ] , title : string ) {
modalLines . value = lines . map ( ( line ) => ( {
line ,
batches : line . batches . map ( ( batch ) => ( {
planned _date : batch . planned _date ,
qty : String ( Number ( batch . qty ) ) ,
remark : batch . remark || '' ,
} ) ) ,
} ) ) ;
// 无批次的行默认给一条空批次,便于快速填写。
modalLines . value . forEach ( ( entry ) => {
if ( entry . batches . length === 0 ) entry . batches . push ( { planned _date : '' , qty : '' , remark : '' } ) ;
} ) ;
modalTitle . value = title ;
quickDate . value = '' ;
modalVisible . value = true ;
}
function openSingleReply ( line : OrderDeliveryLine ) {
openReplyModal ( [ line ] , t ( 'workspace.orderDeliveryReply.modalTitleSingle' , { order : line . order _no , item : line . line _no } ) ) ;
}
function openBatchReply ( ) {
const lines = selectedLines . value . filter ( ( line ) => ! line . locked ) ;
if ( ! lines . length ) return ;
openReplyModal ( lines , t ( 'workspace.orderDeliveryReply.modalTitleBatch' , { count : lines . length } ) ) ;
}
function applyQuickDate ( ) {
if ( ! quickDate . value ) return ;
modalLines . value . forEach ( ( entry ) => entry . batches . forEach ( ( batch ) => { batch . planned _date = quickDate . value ; } ) ) ;
}
/** 拆分合计超出未交数量时仅提醒不拦截(需求 §9)。 */
const overQtyEntries = computed ( ( ) =>
modalLines . value
. filter ( ( entry ) => entry . batches . some ( ( batch ) => batch . planned _date && Number ( batch . qty ) > 0 ) )
. map ( ( entry ) => ( {
entry ,
total : entry . batches . reduce ( ( sum , batch ) => sum + ( batch . planned _date && Number ( batch . qty ) > 0 ? Number ( batch . qty ) : 0 ) , 0 ) ,
} ) )
. filter ( ( { entry , total } ) => total > undelivered ( entry . line ) ) ,
) ;
async function saveReplies ( ) {
const validItems : { order _no : string ; line _no : number ; batches : { planned _date : string ; qty : string ; remark : string | null } [ ] } [ ] = [ ] ;
for ( const { line , batches } of modalLines . value ) {
const cleaned = batches
. filter ( ( batch ) => batch . planned _date && Number ( batch . qty ) > 0 )
. map ( ( batch ) => ( { planned _date : batch . planned _date , qty : batch . qty , remark : batch . remark . trim ( ) || null } ) ) ;
if ( line . locked ) continue ; // 锁定行不允许再改(后端也会 409)
if ( ! cleaned . length ) continue ;
validItems . push ( { order _no : line . order _no , line _no : line . line _no , batches : cleaned } ) ;
}
if ( ! validItems . length ) {
msg . warning ( t ( 'workspace.orderDeliveryReply.noValidBatches' ) ) ;
return ;
}
saving . value = true ;
try {
const [ singleItem ] = validItems ;
if ( validItems . length === 1 && singleItem ) {
// 仅一行时走单行接口;多行必须走批量接口逐行保存(此前误判为 if (singleItem),
// 恒为真导致联合回复只保存第一行,批量分支成死代码)。
await saveOrderDeliveryBatches ( singleItem . order _no , singleItem . line _no , singleItem . batches ) ;
msg . success ( t ( 'workspace.orderDeliveryReply.saveSingleDone' ) ) ;
} else {
const summary : BatchSummary = await batchReplyOrderDelivery ( validItems ) ;
if ( summary . failed > 0 ) {
const failedText = summary . items . filter ( ( item ) => ! item . ok ) . map ( ( item ) => ` ${ item . order _no } : ${ item . line _no } ${ item . error || '' } ` ) . join ( '; ' ) ;
msg . warning ( t ( 'workspace.orderDeliveryReply.saveBatchPartial' , { ok : summary . succeeded , fail : summary . failed , detail : failedText } ) ) ;
} else {
msg . success ( t ( 'workspace.orderDeliveryReply.saveBatchDone' , { ok : summary . succeeded } ) ) ;
}
}
modalVisible . value = false ;
selected . value = [ ] ;
await loadLines ( ) ; // 保存或通知后即时刷新(需求 §9)
} catch ( error ) {
msg . error ( error instanceof Error ? error . message : t ( 'workspace.orderDeliveryReply.saveFailedTitle' ) ) ;
// 行已不在同步范围(erp_missing/被新同步剔除):旧列表过期,自动刷新让该行消失。
const message = error instanceof Error ? error . message : '' ;
if ( message . includes ( 'LINE_NOT_FOUND' ) || message . includes ( '不在同步范围' ) || message . includes ( 'not found' ) ) {
await loadLines ( ) ;
}
} finally {
saving . value = false ;
}
}
/* ============ 通知 ============ */
const notifying = ref ( false ) ;
/** 批量通知:部分成功 warning 汇总,全部失败 error;提示后刷新列表让锁定即时生效。 */
async function doNotifyBatch ( ) {
const lines = notifiableSelected . value ;
if ( ! lines . length ) return ;
const ok = window . confirm ( t ( 'workspace.orderDeliveryReply.notifyBatchConfirm' , { count : lines . length } ) ) ;
if ( ! ok ) return ;
notifying . value = true ;
try {
const summary = await notifyOrderDeliveryBatch ( lines . map ( ( line ) => ( { order _no : line . order _no , line _no : line . line _no } ) ) ) ;
const failedText = summary . items . filter ( ( item ) => ! item . ok ) . map ( ( item ) => ` ${ item . order _no } : ${ item . line _no } ${ item . error || '' } ` ) . join ( '; ' ) ;
if ( summary . failed > 0 && summary . succeeded > 0 ) {
msg . warning ( t ( 'workspace.orderDeliveryReply.notifyPartial' , { ok : summary . succeeded , fail : summary . failed , skip : summary . skipped , detail : failedText } ) ) ;
} else if ( summary . failed > 0 && summary . succeeded === 0 ) {
msg . error ( t ( 'workspace.orderDeliveryReply.notifyAllFailed' , { fail : summary . failed , detail : failedText } ) ) ;
} else {
msg . success ( t ( 'workspace.orderDeliveryReply.notifyBatchDone' , { ok : summary . succeeded , skip : summary . skipped } ) ) ;
}
selected . value = [ ] ;
await loadLines ( ) ;
} catch ( error ) {
msg . error ( error instanceof Error ? error . message : t ( 'workspace.orderDeliveryReply.notifyFailedTitle' ) ) ;
} finally {
notifying . value = false ;
}
}
/* ============ 同步状态展示 ============ */
const latestSyncText = computed ( ( ) => {
const run = latestSync . value ;
if ( ! run ) return t ( 'workspace.orderDeliveryReply.syncNever' ) ;
const time = ( run . finished _at || run . started _at || '' ) . replace ( 'T' , ' ' ) . slice ( 0 , 19 ) ;
if ( run . status === 'success' ) return t ( 'workspace.orderDeliveryReply.syncAt' , { time } ) ;
if ( run . status === 'running' ) return t ( 'workspace.orderDeliveryReply.syncRunning' ) ;
return t ( 'workspace.orderDeliveryReply.syncFailedAt' , { time } ) ;
} ) ;
const latestSyncFailed = computed ( ( ) => latestSync . value ? . status === 'failed' ) ;
onMounted ( ( ) => {
// 企微卡片 jump_path 带 order_no/line_no 直达:自动填入筛选并命中该行。
const query = useRoute ( ) . query ;
if ( typeof query . order _no === 'string' && query . order _no ) {
filters . order _no = query . order _no ;
Object . assign ( appliedFilters , filters ) ;
}
void loadLines ( ) ;
void loadLatestSync ( ) ;
} ) ;
< / script >
< template >
<!-- 全页统一字号 : 与表头一致 ( text - xs 12 px ) , 根容器设定基准 , 子元素不再覆写 -- >
< div class = "flex min-h-screen flex-col gap-4 p-6 text-xs" >
<!-- 页头 : 标题 + 最近同步 + 手动刷新 -- >
< div class = "flex flex-wrap items-center gap-3" >
< h1 class = "font-bold text-primary" > { { t ( 'workspace.nav.orderDeliveryReply' ) } } < / h1 >
< span class = "rounded-full px-3 py-1 text-xs" : class = "latestSyncFailed ? 'bg-rose-50 text-rose-600' : 'bg-blue-50 text-blue-600'" >
{ { latestSyncText } }
< / span >
< div class = "flex-1" / >
< button v-if = "canManage" type="button" class="btn-ghost" :disabled="syncing" @click="doSync" >
{{ syncing ? t ( ' workspace.orderDeliveryReply.syncing ' ) : t ( ' workspace.orderDeliveryReply.syncNow ' ) }}
< / button >
< / div >
< ! - - 搜索区 - - >
< div class = "flex flex-wrap items-end gap-4 rounded-2xl border border-default bg-surface px-4 py-4" >
< label class = "flex flex-col gap-1 text-xs text-muted" >
{ { t ( 'workspace.orderDeliveryReply.filterOrderNo' ) } }
< input v-model = "filters.order_no" class="h-9 min-w-[168px] rounded-lg border border-default px-3 text-primary outline-none focus:border-blue-500" :placeholder="t('workspace.orderDeliveryReply.filterOrderNoPh')" / >
< / label >
< label class = "flex flex-col gap-1 text-xs text-muted" >
{ { t ( 'workspace.orderDeliveryReply.filterProduct' ) } }
< input v-model = "filters.product_q" class="h-9 min-w-[200px] rounded-lg border border-default px-3 text-primary outline-none focus:border-blue-500" :placeholder="t('workspace.orderDeliveryReply.filterProductPh')" / >
< / label >
< label class = "flex flex-col gap-1 text-xs text-muted" >
{ { t ( 'workspace.orderDeliveryReply.filterCustomer' ) } }
< input v-model = "filters.customer_q" class="h-9 min-w-[150px] rounded-lg border border-default px-3 text-primary outline-none focus:border-blue-500" :placeholder="t('workspace.orderDeliveryReply.filterCustomerPh')" / >
< / label >
< label class = "flex flex-col gap-1 text-xs text-muted" >
{ { t ( 'workspace.orderDeliveryReply.filterOrderDate' ) } }
< input v-model = "filters.order_date" type="date" class="h-9 rounded-lg border border-default px-3 text-primary outline-none focus:border-blue-500" / >
< / label >
< label class = "flex flex-col gap-1 text-xs text-muted" >
{ { t ( 'workspace.orderDeliveryReply.filterStatus' ) } }
<!-- 状态筛选选择即生效 ( 无需再点查询 ) ; 其余条件仍由 「 查询 」 统一提交 -- >
< select v-model = "filters.status" class="h-9 min-w-[140px] rounded-lg border border-default bg-white px-3 text-primary outline-none focus:border-blue-500" @change="doSearch" >
< option value = "" > { { t ( 'workspace.orderDeliveryReply.statusAll' ) } } < / option >
< option value = "replied" > { { t ( 'workspace.orderDeliveryReply.statusReplied' ) } } < / option >
< option value = "not_fully_replied" > { { t ( 'workspace.orderDeliveryReply.statusNotFully' ) } } < / option >
< / select >
< / label >
< button type = "button" class = "btn-primary h-9" @click ="doSearch" > {{ t ( ' workspace.orderDeliveryReply.search ' ) }} < / button >
< button type = "button" class = "btn-ghost h-9" @click ="doReset" > {{ t ( ' workspace.orderDeliveryReply.reset ' ) }} < / button >
< div class = "flex-1" / >
< span class = "text-xs text-muted" > { { t ( 'workspace.orderDeliveryReply.totalCount' , { count : total } ) } } < / span >
< / div >
<!-- 工具栏 : 全选 + 联合回复 + 批量通知 -- >
< div class = "flex flex-wrap items-center gap-3 rounded-2xl border border-default bg-surface px-4 py-3" >
< label class = "flex items-center gap-2 text-primary" >
< input type = "checkbox" class = "h-4 w-4 rounded border-default text-blue-600" :checked = "allChecked" :indeterminate.prop = "someChecked" @change ="togglePageAll(($event.target as HTMLInputElement).checked)" / >
{ { t ( 'workspace.orderDeliveryReply.selectAll' ) } }
< / label >
< span class = "text-muted" > { { t ( 'workspace.orderDeliveryReply.selectedCount' , { count : selectedLines . length } ) } } < / span >
< template v-if = "canManage" >
< button type = "button" class = "btn-primary h-9" : disabled = "selectedLines.length === 0" @click ="openBatchReply" >
{{ t ( ' workspace.orderDeliveryReply.batchReply ' ) }}
< / button >
< button type = "button" class = "btn-primary h-9" : disabled = "notifiableSelected.length === 0 || notifying" @click ="doNotifyBatch" >
{{ t ( ' workspace.orderDeliveryReply.batchNotify ' ) }}
< / button >
< / template >
< div class = "flex-1" / >
< span class = "whitespace-nowrap rounded-full bg-slate-100 px-3 py-1 text-xs text-muted" > { { t ( 'workspace.orderDeliveryReply.toolbarHint' ) } } < / span >
< / div >
<!-- 列表 -- >
< div class = "min-h-0 flex-1 overflow-auto rounded-2xl border border-default bg-surface" >
< table class = "w-full border-collapse" >
< thead class = "sticky top-0 z-10 bg-slate-50 text-xs text-muted [&_th]:whitespace-nowrap" >
< tr >
< th class = "w-10 px-2 py-2" / >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colCustomer' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colOrderDate' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colOrderLine' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colPartNo' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colCustomerPartNo' ) } } < / th >
< th class = "px-2 py-2 text-right" > { { t ( 'workspace.orderDeliveryReply.colQty' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colAgreedDate' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colStatus' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colReply' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colReplyPerson' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colSalesperson' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colCustomerPo' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colSpec' ) } } < / th >
< th class = "px-2 py-2 text-left" > { { t ( 'workspace.orderDeliveryReply.colUnit' ) } } < / th >
< / tr >
< / thead >
< tbody >
< tr
v-for = "line in items"
:key = "lineKey(line)"
class = "border-t border-default hover:bg-slate-50"
: class = "selected.includes(lineKey(line)) ? 'bg-blue-50/60' : ''"
>
< td class = "px-2 py-2" >
< input type = "checkbox" class = "h-4 w-4 rounded border-default text-blue-600" :checked = "selected.includes(lineKey(line))" @change ="toggleLine(line, ($event.target as HTMLInputElement).checked)" / >
< / td >
< td class = "px-2 py-2" : title = "line.customer_full_name || line.customer_short_name || ''" >
< div > { { line . customer _no || '—' } } < / div >
< div class = "text-xs text-muted" > { { line . customer _short _name || '' } } < / div >
< / td >
< td class = "whitespace-nowrap px-2 py-2" > { { line . order _date || '—' } } < / td >
< td class = "whitespace-nowrap px-2 py-2 font-mono text-xs" > { { line . order _no } } : { { line . line _no } } < / td >
< td class = "px-2 py-2" : title = "line.part_name || ''" >
< div class = "whitespace-nowrap font-mono text-xs" > { { line . part _no || '—' } } < / div >
< div class = "text-xs text-muted" > { { line . part _name || '' } } < / div >
< / td >
< td class = "whitespace-nowrap px-2 py-2 font-mono text-xs" > { { line . customer _part _no || '—' } } < / td >
< td class = "px-2 py-2 text-right tabular-nums" > { { line . qty ? ? '—' } } < / td >
< td class = "whitespace-nowrap px-2 py-2" > { { line . agreed _date || '—' } } < / td >
< td class = "px-2 py-2" >
< span class = "whitespace-nowrap rounded-full px-2.5 py-0.5 text-xs font-semibold" :class = "statusMeta(line.status).cls" >
{ { statusMeta ( line . status ) . label } }
< / span >
< / td >
<!-- 交期回复 : 无批次 = 回复交期 ; 有批次可展开 ; 锁定 = 已锁定 -- >
< td class = "px-2 py-2 align-top" >
< template v-if = "line.batches.length === 0" >
< span class = "text-muted" > { { t ( 'workspace.orderDeliveryReply.statusNotReplied' ) } } < / span >
< div v-if = "canManage" class="mt-1" >
< button type = "button" class = "rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-xs text-blue-600" @click ="openSingleReply(line)" >
{{ t ( ' workspace.orderDeliveryReply.replyAction ' ) }}
< / button >
< / div >
< / template >
< template v-else >
< div class = "flex items-center gap-2" >
< span class = "rounded-full border border-default bg-slate-50 px-2 py-0.5 text-xs text-muted" >
{ { t ( 'workspace.orderDeliveryReply.batchCount' , { count : line . batches . length } ) } } ·
{ { t ( 'workspace.orderDeliveryReply.repliedOf' , { replied : repliedQty ( line ) , remain : undelivered ( line ) } ) } }
< span v-if = "repliedQty(line) > undelivered(line)" class="ml-1 font-semibold text-orange-500" > {{ t ( ' workspace.orderDeliveryReply.overTag ' ) }} < / span >
< / span >
< button v-if = "line.batches.length > 1" type="button" class="rounded-full border border-default px-2 py-0.5 text-xs text-blue-600" @click="toggleExpand(lineKey(line))" >
{{ expanded.includes ( lineKey ( line ) ) ? t ( ' workspace.orderDeliveryReply.collapse ' ) : t ( ' workspace.orderDeliveryReply.expand ' , { count : line.batches.length - 1 } ) }}
< / button >
< / div >
< div class = "mt-1 flex flex-col gap-0.5" >
< div
v-for = "(batch, idx) in line.batches"
: key = "batch.seq ?? idx"
v-show = "expanded.includes(lineKey(line)) || idx === 0"
class = "rounded border-l-[3px] border-blue-500 bg-blue-50/50 px-2 py-0.5 text-xs text-secondary"
>
{ { batch . planned _date } } · < b class = "text-blue-600" > { { batch . qty } } < / b > { { line . unit } }
< i v-if = "batch.remark" class="ml-1 not-italic text-muted" > {{ batch.remark }} < / i >
< / div >
< / div >
< div class = "mt-1" >
< span v-if = "line.locked" class="rounded-full bg-emerald-50 px-2.5 py-0.5 text-xs font-semibold text-emerald-600" > {{ t ( ' workspace.orderDeliveryReply.lockedTag ' ) }} < / span >
< button v-else-if = "canManage" type="button" class="rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-xs text-blue-600" @click="openSingleReply(line)" >
{{ t ( ' workspace.orderDeliveryReply.editReplyAction ' ) }}
< / button >
< / div >
< / template >
< / td >
< ! - - 交期回复人员 : 锁定行附带已通知对象与时间 ( 原 「 通知业务部门 」 列已取消 , 信息并入此处 ) - - >
< td class = "px-2 py-2" >
< template v-if = "line.notified_employee_id || line.notified_user_name" >
< div class = "font-mono text-xs" > { { line . notified _employee _id || '' } } < / div >
< div class = "text-xs text-muted" > { { line . notified _user _name || '' } } < / div >
< div v-if = "line.locked" class="text-xs text-emerald-600" >
{{ t ( ' workspace.orderDeliveryReply.notifiedTag ' , { name : line.salesperson_name | | line.salesperson_code | | ' ' } ) }}
< span class = "text-muted" > { { line . notified _at || '' } } < / span >
< / div >
< / template >
< span v-else class = "text-muted" > { { t ( 'workspace.orderDeliveryReply.pendingNotify' ) } } < / span >
< / td >
<!-- 业务员 ( 副文案部门 ) : 与客户编号 / 简称同款合并展示 , 独立部门列已取消 -- >
< td class = "px-2 py-2" : title = "line.salesperson_code || ''" >
< div class = "whitespace-nowrap" > { { line . salesperson _name || line . salesperson _code || '—' } } < / div >
< div class = "text-xs text-muted" > { { line . dept _name || line . dept _code || '' } } < / div >
< / td >
< td class = "whitespace-nowrap px-2 py-2 font-mono text-xs" > { { line . customer _po || '—' } } < / td >
< td class = "px-2 py-2" > { { line . spec || '—' } } < / td >
< td class = "px-2 py-2" > { { line . unit || '—' } } < / td >
< / tr >
< tr v-if = "!loading && items.length === 0" >
< td colspan = "15" class = "px-4 py-16 text-center text-muted" > { { t ( 'workspace.orderDeliveryReply.empty' ) } } < / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- 分页 : 复用管理控制台 - 数据报表的 PaginationBar ( 摘要 + 每页条数 + 页码按钮 ) -- >
< PaginationBar
class = "[&_*]:!text-xs"
:page = "page"
:page-size = "pageSize"
:total = "total"
:page-size-options = "pageSizeOptions"
@ update :page = "goToPage"
@ update :page-size = "changePageSize"
/ >
<!-- 回复弹窗 -- >
< div v-if = "modalVisible" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40" @click.self="modalVisible = false" >
< div class = "flex max-h-[88vh] w-[min(960px,94vw)] flex-col overflow-hidden rounded-2xl bg-white shadow-2xl" >
< div class = "flex items-center gap-3 border-b border-default px-5 py-4" >
< h3 class = "font-bold text-primary" > { { modalTitle } } < / h3 >
< div class = "flex-1" / >
< button type = "button" class = "text-muted" @click ="modalVisible = false" > × < / button >
< / div >
< div class = "flex-1 overflow-auto px-5 py-4" >
<!-- 快速统一交期 -- >
< div class = "mb-4 flex flex-wrap items-end gap-3 rounded-xl border border-default bg-blue-50/40 px-4 py-3" >
< label class = "flex flex-col gap-1 text-xs text-muted" >
{ { t ( 'workspace.orderDeliveryReply.quickDate' ) } }
< input v-model = "quickDate" type="date" class="h-9 rounded-lg border border-default px-3 text-primary" / >
< / label >
< button type = "button" class = "h-9 rounded-lg border border-default px-3 text-primary" @click ="applyQuickDate" >
{{ t ( ' workspace.orderDeliveryReply.applyQuickDate ' ) }}
< / button >
< span class = "text-xs text-muted" > { { t ( 'workspace.orderDeliveryReply.modalHint' ) } } < / span >
< / div >
<!-- 每行批次编辑器 -- >
< div v-for = "entry in modalLines" :key="lineKey(entry.line)" class="mb-4 overflow-hidden rounded-xl border border-default" >
< div class = "flex flex-wrap items-center gap-2 bg-slate-50 px-3 py-2 text-xs" >
< span class = "rounded bg-indigo-50 px-2 py-0.5 font-semibold text-indigo-600" > { { entry . line . order _no } } < / span >
< span > { { t ( 'workspace.orderDeliveryReply.itemLabel' , { item : entry . line . line _no } ) } } < / span >
< span class = "text-muted" > { { entry . line . customer _no } } · { { entry . line . customer _short _name } } < / span >
< span class = "text-muted" > { { entry . line . part _no } } · { { entry . line . part _name } } < / span >
< span class = "ml-auto" >
{ { t ( 'workspace.orderDeliveryReply.undeliveredLabel' , { remain : undelivered ( entry . line ) , unit : entry . line . unit || '' } ) } }
< / span >
< / div >
< div class = "flex flex-col gap-2 px-3 py-3" >
< div v-for = "(batch, idx) in entry.batches" :key="idx" class="grid grid-cols-[170px_120px_1fr_36px] items-center gap-2" >
< input v-model = "batch.planned_date" type="date" class="h-9 rounded-lg border border-default px-2 text-primary" / >
< input v-model = "batch.qty" type="number" min="0" :placeholder="t('workspace.orderDeliveryReply.qtyPh')" class="h-9 rounded-lg border border-default px-2 text-primary" / >
< input v-model = "batch.remark" :placeholder="t('workspace.orderDeliveryReply.remarkPh')" class="h-9 rounded-lg border border-default px-2 text-primary" / >
< button type = "button" class = "h-9 rounded-lg bg-rose-50 text-rose-600" :title = "t('workspace.orderDeliveryReply.removeBatch')" @click ="entry.batches.splice(idx, 1)" > ✕ < / button >
< / div >
< button type = "button" class = "w-full rounded-lg border border-dashed border-slate-300 py-2 text-blue-600" @click ="entry.batches.push({ planned_date: '', qty: '', remark: '' })" >
{{ t ( ' workspace.orderDeliveryReply.addBatch ' ) }}
< / button >
< / div >
< / div >
< p v-if = "overQtyEntries.length" class="text-xs text-orange-500" >
{{ t ( ' workspace.orderDeliveryReply.overWarning ' , { detail : overQtyEntries.map ( ( { entry , total } ) = > ` ${ entry . line . order _no } : ${ entry . line . line _no } ${ total } > ${ undelivered ( entry . line ) } ` ) . join ( '; ' ) } ) } }
< / p >
< / div >
< div class = "flex justify-end gap-3 border-t border-default bg-slate-50 px-5 py-3" >
< button type = "button" class = "btn-ghost" @click ="modalVisible = false" > {{ t ( ' common.cancel ' ) }} < / button >
< button type = "button" class = "btn-primary" :disabled = "saving" @click ="saveReplies" >
{{ saving ? t ( ' workspace.orderDeliveryReply.saving ' ) : t ( ' workspace.orderDeliveryReply.saveReply ' ) }}
< / button >
< / div >
< / div >
< / div >
< / div >
< / template >