@@ -101,8 +101,21 @@ function customerName(customerId: string, snapshot?: string) {
}
function sourceTypeDisplay ( value : unknown ) {
const code = String ( value || '' ) . trim ( ) . toUpperCase ( )
const label = financeSourceTypeLabel ( code )
return label === '其他来源' ? ( code ? ` 未识别来源( ${ code } ) ` : '来源类型暂不可用 ') : label
const labels : Record < string , string > = {
INBOUND _FEE : '入库费用' , ORDER _FEE : '订单费用' , CONTAINER _COST : '整柜成本 ', CONTAINER _FEE : '柜次费用' ,
MANUAL _COST : '人工成本' , STORAGE _FEE : '仓储费用' ,
}
return labels [ code ] || ( code ? '其他费用来源' : '来源类型暂不可用' )
}
function feeDocumentLabel ( direction : ArapRow [ 'direction' ] , feeName : unknown ) {
const prefix = direction === 'RECEIVABLE' ? '应收费用' : '应付费用'
const name = String ( feeName || '' ) . trim ( )
return name ? ` ${ prefix } · ${ name } ` : prefix
}
function sourceSummary ( sourceType : unknown , orderId : unknown , inboundId : unknown , containerId : unknown ) {
const relations = [ inboundId ? '关联入库单' : '' , orderId ? '关联订单' : '' , containerId ? '关联柜次' : '' ] . filter ( Boolean )
const type = sourceTypeDisplay ( sourceType )
return relations . length ? ` ${ type } · ${ relations . join ( '、' ) } ` : type
}
function formatDateTime ( value : unknown ) {
const raw = String ( value || '' ) . trim ( )
@@ -137,7 +150,7 @@ async function load(model: QueryModel = filters.value) {
try {
const direction = String ( filters . value . direction || '' ) as 'RECEIVABLE' | 'PAYABLE' | ''
const items = await listFinanceFeePool ( customerId || undefined , direction || undefined )
allRows . value = items . map ( ( item ) : ArapRow => ( { id : item . poolItemId , feeSourceId : item . feeSourceId , customerId : item . customerId , customerName : customerName ( item . customerId , item . customerName ) , direction : item . direction , documentNo : item . poolItemId , sourceType : item . sourceType , sourceId : [ item . inboundId ? ` 入库单 ${ item . inboundId } ` : '' , item . orderId ? ` 订单 ${ item . orderId } ` : '' , item . containerId ? ` 柜次 ${ item . containerId } ` : '' , ` 来源 ${ item . sourceId } /v ${ item . sourceVersion } ` ] . filter ( Boolean ) . join ( ' · ' ) , orderId : item . orderId || '' , inboundId : item . inboundId || '' , containerId : item . containerId || '' , feeName : item . feeItemName , amount : item . amount , status : item . status , occurredAt : item . createdAt , businessDate : item . createdAt , reviewStatus : item . status , settlementIncluded : null , statementGenerated : null } ) )
allRows . value = items . map ( ( item ) : ArapRow => ( { id : item . poolItemId , feeSourceId : item . feeSourceId , customerId : item . customerId , customerName : customerName ( item . customerId , item . customerName ) , direction : item . direction , documentNo : feeDocumentLabel ( item . direction , item . feeItemName ) , sourceType : item . sourceType , sourceId : sourceSummary ( item . sourceType , item . orderId , item . inboundId , item . containerId ) , orderId : item . orderId || '' , inboundId : item . inboundId || '' , containerId : item . containerId || '' , feeName : item . feeItemName , amount : item . amount , status : item . status , occurredAt : item . createdAt , businessDate : item . createdAt , reviewStatus : item . status , settlementIncluded : null , statementGenerated : null } ) )
} catch ( error ) { loadError . value = getApiErrorDetails ( error , '客户应收应付加载失败,请重试' ) }
finally { loading . value = false }
}
@@ -233,10 +246,11 @@ watch(() => [route.name, String(route.params.feeSourceId || '')], ([name, feeSou
< template # toolbar -actions > < div v-if = "canCreateStatement" class="generation-actions"><el-button :disabled="!filters.customerId" @click="openGeneration('BY_CUTOFF')"><FilePlus2 :size="16" />按截止日期生成</el-button><el-button type="primary" :disabled="!selectedRows.length" @click="openGeneration('SELECTED')"><FilePlus2 :size="16" / > 按勾选生成 < / el-button > < / div > < / template >
< template # actions = "{ row }" > < div class = "row-actions" > < template v-if = "row.feeSourceId"><el-button v-if="canViewSource" link type="primary" @click="openDetail(row)"><Eye :size="15" />详情</el-button><el-button v-if="canReviewSource" link type="primary" @click="openReview(row)"><FileCheck2 :size="15" />审核</el-button><el-button v-if="canSettleSource" link type="primary" @click="openInclusion(row)"><Link2 :size="15" />结算</el-button></template><span v-else class="muted-action" > 手工成本 < / span > < / div > < / template >
< template # customerName = "{ row }" > { { customerName ( row . customerId , row . customerName ) } } < / template > < template # direction = "{ row }" > < el-tag : type = "row.direction === 'RECEIVABLE' ? 'success' : row.direction === 'PAYABLE' ? 'warning' : 'info'" > { { financeDirectionLabel ( row . direction ) } } < / el-tag > < / template >
< template # documentNo = "{ row }" > { { feeDocumentLabel ( row . direction , row . feeName ) } } < / template > < template # sourceType = "{ row }" > { { sourceTypeDisplay ( row . sourceType ) } } < / template > < template # sourceId = "{ row }" > { { row . sourceId } } < / template >
< template # status = "{ row }" > < el-tag : type = "row.reviewStatus === 'APPROVED' ? 'success' : row.reviewStatus === 'REJECTED' ? 'danger' : 'warning'" > { { statusLabel ( row . reviewStatus ) } } < / el-tag > < / template >
< template # included = "{ row }" > { { row . settlementIncluded == null ? '待加载' : row . settlementIncluded ? '参与' : '不参与' } } < / template >
< template # generated = "{ row }" > { { row . statementGenerated == null ? '待加载' : row . statementGenerated ? '已生成' : '未生成' } } < / template >
< template # pagination -left > 已选 { { selectedRows . length } } 笔 · 应收金额 { { money ( selectedAmount ) } } CNY < / template >
< template # businessDate = "{ row }" > { { formatDateTime ( row . businessDate ) } } < / template > < template # pagination -left > 已选 { { selectedRows . length } } 笔 · 应收金额 { { money ( selectedAmount ) } } CNY < / template >
< / DataTable > < / section >
< / ListPageLayout >
< AdminPage v-else as = "div" class = "finance-arap-detail" spacing = "normal" >