front/src/views/order/waybillManage/components/OrderDetailDrawer.vue
zzh 443032620b
All checks were successful
Build and Deploy Front / deploy (push) Successful in 12m22s
feat: 服务渠道计重/黑名单配置与应付计费重展示
渠道表单支持计重规则/进位与黑名单;订单/揽收/排货/试算区分应收与应付计费重。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-23 16:47:29 +08:00

4538 lines
137 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<DrawerPro
:footer="false"
padding-bottom="16px"
@register="register"
@cancel="handleCancel"
>
<div
class="order-detail-drawer order-detail-drawer-shell"
:class="{ 'has-action-bar': showActionBar }"
>
<div class="drawer-tabs">
<div class="tabs-slot">
<SlidingTabs
v-model="activeTab"
:items="slidingTabItems"
@change="handleTabChange"
/>
</div>
</div>
<div class="drawer-tab-content">
<!-- 基本信息 -->
<div v-if="activeTab === 'basic'" class="tab-panel basic-info">
<div v-if="predeclareFailGuide" class="predeclare-fail-guide">
<p class="predeclare-fail-guide__reason">{{ predeclareFailGuide.reason }}</p>
<p v-if="predeclareFailGuide.tips?.[0]" class="predeclare-fail-guide__tip">
<span class="predeclare-fail-guide__tip-label">
{{ $t('order.myOrders.drawer.failGuideTip') }}
</span>
{{ predeclareFailGuide.tips[0] }}
</p>
<details
v-if="predeclareFailGuide.rawReason !== predeclareFailGuide.reason"
class="predeclare-fail-guide__details"
>
<summary>{{ $t('order.myOrders.drawer.failGuideRaw') }}</summary>
<p class="predeclare-fail-guide__raw">{{ predeclareFailGuide.rawReason }}</p>
</details>
<div class="predeclare-fail-guide__actions">
<a-button class="app-btn-search" @click="startBasicEdit">
{{ $t('order.myOrders.drawer.failGuideEdit') }}
</a-button>
</div>
</div>
<div class="basic-view-switch">
<SlidingTabs
v-model="basicViewMode"
size="mini"
class="basic-view-tabs"
:items="basicViewTabs"
:aria-label="$t('order.myOrders.drawer.tabs.basic')"
/>
</div>
<template v-for="section in visibleBasicSections" :key="section.key">
<div class="detail-section" :class="section.key">
<div class="detail-section-header">
<div class="detail-section-title-wrap">
<span class="detail-section-dot" />
<span class="detail-section-title">{{ $t(section.labelKey) }}</span>
<a-tag
v-if="section.key === 'declaration'"
size="small"
color="arcoblue"
>
{{ displayDeclarationRows.length }}
</a-tag>
<div
v-if="section.key === 'declaration'"
class="declaration-header-sum"
:class="{ 'is-editable': basicEditing }"
@click.stop
>
<template v-if="basicEditing">
<a-select
v-model="basicEditForm.declaredCurrency"
size="mini"
allow-search
allow-clear
:loading="currencyOptionsLoading"
:placeholder="$t('order.myOrders.drawer.declaredCurrency')"
class="declaration-header-currency"
>
<a-option
v-for="opt in currencyOptions"
:key="opt.value"
:value="opt.value"
>
{{ opt.label }}
</a-option>
</a-select>
<a-input-number
v-model="basicEditForm.declaredSum"
size="mini"
:min="0"
:precision="2"
hide-button
class="declaration-header-amount"
:placeholder="$t('order.myOrders.drawer.declaredSum')"
/>
</template>
<span v-else class="declaration-header-sum-text">
{{ getOrderValue('declaredSum') }}
</span>
</div>
</div>
<a-button
v-if="section.key === 'declaration' && basicEditing"
class="app-btn-search"
@click="addDeclarationRow"
>
{{ $t('order.myOrders.drawer.declaration.addRow') }}
</a-button>
</div>
<!-- 订单基本信息 -->
<template v-if="section.key === 'basic'">
<div
v-for="group in orderBasicFieldGroups"
:key="group.key"
class="detail-field-group"
>
<div class="detail-field-group-title">{{ $t(group.labelKey) }}</div>
<div class="detail-fields-grid">
<div
v-for="fieldKey in group.fields"
:key="fieldKey"
class="detail-field-item"
:class="{ 'is-editable': basicEditing && isOrderFieldEditable(fieldKey) }"
>
<span class="detail-field-label">{{ $t(getOrderFieldLabelKey(fieldKey)) }}</span>
<div class="detail-field-value">
<template v-if="basicEditing && isOrderFieldEditable(fieldKey)">
<a-select
v-if="fieldKey === 'productName'"
v-model="basicEditForm.productCode"
allow-search
size="small"
:loading="salesProductOptionsLoading"
:placeholder="$t('order.myOrders.drawer.placeholder.productName')"
>
<a-option
v-for="opt in salesProductOptions"
:key="opt.value"
:value="opt.value"
>
{{ opt.label }}
</a-option>
</a-select>
<a-select
v-else-if="fieldKey === 'warehouse'"
v-model="basicEditForm.warehouseId"
allow-clear
allow-search
size="small"
:loading="warehouseOptionsLoading"
:placeholder="$t('order.myOrders.drawer.warehouse')"
>
<a-option
v-for="opt in warehouseOptions"
:key="opt.value"
:value="opt.value"
>
{{ opt.label }}
</a-option>
</a-select>
<a-select
v-else-if="getOrderEditMeta(fieldKey)?.inputType === 'select'"
v-model="basicEditForm[fieldKey]"
allow-clear
size="small"
>
<a-option
v-for="opt in getOrderEditMeta(fieldKey)?.options"
:key="opt.value"
:value="opt.value"
>
{{ $t(opt.labelKey) }}
</a-option>
</a-select>
<a-switch
v-else-if="getOrderEditMeta(fieldKey)?.inputType === 'switch'"
v-model="basicEditForm[fieldKey]"
size="small"
/>
<a-input-number
v-else-if="getOrderEditMeta(fieldKey)?.inputType === 'number'"
v-model="basicEditForm[fieldKey]"
:min="0"
size="small"
style="width: 100%"
/>
<a-input
v-else
v-model="basicEditForm[fieldKey]"
allow-clear
size="small"
/>
</template>
<template v-else-if="fieldKey === 'orderStatus' && currentOrderStatusMeta">
<a-tag
size="small"
:style="getOrderStatusTagStyle(currentOrderStatusMeta)"
>
{{ getOrderValue(fieldKey) }}
</a-tag>
</template>
<template v-else-if="shouldRenderOrderBooleanTag(fieldKey)">
<a-tag
size="small"
:style="getBooleanTagStyle(getOrderValue(fieldKey) === $t('order.myOrders.drawer.yes'))"
>
{{ getOrderValue(fieldKey) }}
</a-tag>
</template>
<span
v-else-if="fieldKey === 'channelName'"
class="detail-field-text detail-field-text--with-action"
>
{{ getOrderValue(fieldKey) }}
<a-button
v-if="canViewAllocationTrace"
type="text"
size="mini"
class="alloc-eye-btn"
:title="$t('order.myOrders.allocationTrace.view')"
@click.stop="openAllocationTrace"
>
<template #icon><icon-eye /></template>
</a-button>
</span>
<template v-else-if="fieldKey === 'additionalServices'">
<a-space v-if="orderAdditionalServices.length" wrap :size="4">
<a-tag
v-for="code in orderAdditionalServices"
:key="code"
size="small"
>
{{ labelAdditionalService(code) }}
</a-tag>
</a-space>
<span v-else class="detail-field-text">--</span>
</template>
<span v-else class="detail-field-text">{{ getOrderValue(fieldKey) }}</span>
</div>
</div>
</div>
</div>
</template>
<!-- 发件人 -->
<template v-else-if="section.key === 'sender'">
<a-empty
v-if="!basicEditing && !hasSender"
:description="$t('order.myOrders.drawer.sender.empty')"
:image-style="{ height: '48px' }"
class="detail-section-empty"
/>
<div v-else class="detail-fields-grid">
<div
v-for="field in senderFields"
:key="field.key"
class="detail-field-item"
:class="{ 'is-editable': basicEditing && isSenderFieldEditable(field.key) }"
>
<span class="detail-field-label">{{ $t(field.labelKey) }}</span>
<div class="detail-field-value">
<template v-if="basicEditing && isSenderFieldEditable(field.key)">
<a-input
v-model="senderEditForm[getSenderFormKey(field.key)]"
allow-clear
size="small"
/>
</template>
<template v-else-if="field.key === 'isDefault'">
<a-tag
size="small"
:style="getBooleanTagStyle(getSenderValue(field.key) === $t('order.myOrders.drawer.yes'))"
>
{{ getSenderValue(field.key) }}
</a-tag>
</template>
<span v-else class="detail-field-text">{{ getSenderValue(field.key) }}</span>
</div>
</div>
</div>
</template>
<!-- 收件人 -->
<template v-else-if="section.key === 'recipient'">
<div class="detail-fields-grid">
<div
v-for="field in recipientFields"
:key="field.key"
class="detail-field-item"
:class="{ 'is-editable': basicEditing && isRecipientFieldEditable(field.key) }"
>
<span class="detail-field-label">{{ $t(field.labelKey) }}</span>
<div class="detail-field-value">
<template v-if="basicEditing && isRecipientFieldEditable(field.key)">
<a-input
v-model="receiverEditForm[getRecipientFormKey(field.key)]"
allow-clear
size="small"
/>
</template>
<span v-else class="detail-field-text">{{ getRecipientValue(field.key) }}</span>
</div>
</div>
</div>
</template>
<!-- 申报信息 -->
<template v-else-if="section.key === 'declaration'">
<div v-if="displayDeclarationRows.length" class="declaration-table-wrap">
<OrderDeclarationHotTable
:data="displayDeclarationRows"
:editing="basicEditing"
@remove-row="removeDeclarationRow"
@preview-sku-image="openDeclarationSkuPreview"
/>
</div>
<a-empty
v-else
:description="$t('order.myOrders.drawer.declaration.empty')"
:image-style="{ height: '48px' }"
class="detail-section-empty"
/>
</template>
</div>
</template>
</div>
<!-- 件重尺 -->
<div v-if="activeTab === 'weight'" class="tab-panel weight-info">
<div class="weight-summary">
<button
v-for="section in weightTypeDefs"
:key="section.key"
type="button"
class="weight-summary-card"
:class="[section.key, { active: weightViewMode === section.key }]"
@click="setWeightViewMode(section.key)"
>
<span class="weight-summary-label">{{ $t(section.labelKey) }}</span>
<span class="weight-summary-value">
{{ formatWeightChargeable(getWeightRowByType(section.key)) }}
</span>
<span class="weight-summary-meta">
{{ $t('order.myOrders.drawer.weight.actualMeta', {
value: formatWeightNumber(getWeightRowByType(section.key)?.actualWeight),
}) }}
</span>
</button>
</div>
<div class="weight-detail-toolbar">
<span class="weight-detail-toolbar__title">
{{ $t('order.myOrders.drawer.weight.detailTitle') }}
</span>
<SlidingTabs
v-model="weightViewMode"
size="mini"
class="weight-view-switch"
:items="weightViewTabs"
:aria-label="$t('order.myOrders.drawer.weight.detailTitle')"
/>
</div>
<div
class="weight-sections"
:class="{ 'is-single': weightViewMode !== 'all' }"
>
<div
v-for="section in visibleWeightSections"
:key="section.key"
class="weight-section"
:class="section.key"
>
<div class="weight-section-header">
<div class="weight-section-title-wrap">
<span class="weight-section-dot" />
<span class="weight-section-title">{{ $t(section.labelKey) }}</span>
</div>
<span class="weight-section-total">
{{ formatWeightChargeable(section.row) }}
</span>
</div>
<div
v-if="section.hasData || (weightEditing && hasWeightRow(section.key))"
class="weight-metrics"
>
<div class="weight-metrics-group">
<div class="weight-metrics-group__label">
{{ $t('order.myOrders.drawer.weight.dimGroup') }}
</div>
<div class="weight-metrics-grid weight-metrics-grid--dim">
<div
v-for="field in weightDimFields"
:key="field.key"
class="weight-metric-item"
:class="{
'is-editable': weightEditing && field.editable && hasWeightRow(section.key),
}"
>
<span class="metric-label">{{ $t(field.labelKey) }}</span>
<div class="metric-value-wrap">
<template v-if="weightEditing && field.editable && hasWeightRow(section.key)">
<a-input-number
v-model="section.row[field.key]"
:min="0"
size="small"
style="width: 100%"
/>
</template>
<span v-else class="metric-value">
{{ formatWeightCellValue(section.row, field.key) }}
</span>
</div>
</div>
</div>
</div>
<div class="weight-metrics-group">
<div class="weight-metrics-group__label">
{{ $t('order.myOrders.drawer.weight.weightGroup') }}
</div>
<div class="weight-metrics-grid weight-metrics-grid--weight">
<div
v-for="field in weightMassFields"
:key="field.key"
class="weight-metric-item"
:class="{
highlight: field.highlight && !weightEditing,
'is-editable': weightEditing && field.editable && hasWeightRow(section.key),
}"
>
<span class="metric-label">{{ $t(field.labelKey) }}</span>
<div class="metric-value-wrap">
<template v-if="weightEditing && field.editable && hasWeightRow(section.key)">
<a-input-number
v-model="section.row[field.key]"
:min="0"
size="small"
style="width: 100%"
/>
</template>
<span
v-else
class="metric-value"
:class="{ 'metric-value-highlight': field.highlight && !weightEditing }"
>
{{ formatWeightCellValue(section.row, field.key) }}
</span>
</div>
</div>
</div>
</div>
</div>
<a-empty
v-else
:description="$t(section.emptyKey)"
:image-style="{ height: '48px' }"
class="weight-section-empty"
/>
</div>
</div>
<a-empty
v-if="!weightList.length && !weightEditing"
:description="$t('order.myOrders.drawer.weight.emptyAll')"
:image-style="{ height: '60px' }"
class="weight-empty-all"
/>
</div>
<!-- 应收应付 -->
<div v-if="activeTab === 'fee'" class="tab-panel fee-info">
<div class="fee-meta-bar">
<div v-if="boundRulesVersion || boundPriceVersion" class="fee-meta-group">
<span v-if="boundRulesVersion" class="fee-meta-chip">
<em>{{ $t('order.myOrders.drawer.fee.rulesVersion') }}</em>
<strong>{{ boundRulesVersion }}</strong>
</span>
<span v-if="boundPriceVersion" class="fee-meta-chip">
<em>{{ $t('order.myOrders.drawer.fee.priceVersion') }}</em>
<strong>{{ boundPriceVersion }}</strong>
</span>
</div>
<div class="fee-meta-group fee-meta-group--services">
<span class="fee-meta-label">{{ $t('order.myOrders.drawer.additionalServices') }}</span>
<template v-if="orderAdditionalServices.length">
<span
v-for="code in orderAdditionalServices"
:key="code"
class="fee-service-chip"
>
{{ labelAdditionalService(code) }}
</span>
</template>
<span v-else class="fee-meta-empty">
{{ $t('order.myOrders.drawer.fee.additionalServicesNone') }}
</span>
</div>
</div>
<div class="fee-summary">
<button
type="button"
class="fee-summary-card receivable"
:class="{ active: feeViewMode === 'receivable' }"
@click="setFeeViewMode(feeViewMode === 'receivable' ? 'all' : 'receivable')"
>
<span class="fee-summary-label">{{ $t('finance.receivablePayable.feeType.receivable') }}</span>
<span class="fee-summary-amount">{{ formatFeeTotals(receivableTotals) }}</span>
<span class="fee-summary-meta">
{{ $t('order.myOrders.drawer.fee.itemCount', { count: receivableFeeList.length }) }}
</span>
<span v-if="receivableDiscountTotals.size" class="fee-summary-discount">
{{ $t('order.myOrders.drawer.fee.includesDiscount', { amount: formatFeeTotals(receivableDiscountTotals) }) }}
</span>
</button>
<button
type="button"
class="fee-summary-card payable"
:class="{ active: feeViewMode === 'payable' }"
@click="setFeeViewMode(feeViewMode === 'payable' ? 'all' : 'payable')"
>
<span class="fee-summary-label">{{ $t('finance.receivablePayable.feeType.payable') }}</span>
<span class="fee-summary-amount">{{ formatFeeTotals(payableTotals) }}</span>
<span class="fee-summary-meta">
{{ $t('order.myOrders.drawer.fee.itemCount', { count: payableFeeList.length }) }}
</span>
</button>
<div
class="fee-summary-card gross-profit"
:class="{ 'is-negative': hasNegativeGrossProfit }"
>
<span class="fee-summary-label">{{ $t('order.myOrders.drawer.fee.grossProfit') }}</span>
<span class="fee-summary-amount">{{ formatGrossProfitTotals(feeGrossProfitTotals) }}</span>
<span class="fee-summary-meta">{{ grossProfitMarginText }}</span>
<span class="fee-summary-formula">
<span class="amount-receivable">{{ formatFeeTotals(receivableTotals) }}</span>
<i>−</i>
<span class="amount-payable">{{ formatFeeTotals(payableTotals) }}</span>
</span>
</div>
</div>
<div v-if="showForecastDiff" class="fee-forecast-panel">
<div class="fee-forecast-panel__head">
{{ $t('order.myOrders.drawer.fee.forecastDiffTitle') }}
</div>
<div class="fee-forecast-panel__grid">
<div class="fee-forecast-card">
<div class="fee-forecast-card__title">
{{ $t('finance.receivablePayable.feeType.receivable') }}
</div>
<div class="fee-forecast-card__row">
<span>{{ $t('order.myOrders.drawer.fee.forecastReceivable') }}</span>
<strong>{{ formatPlainAmount(forecastReceivableAmount) }}</strong>
</div>
<div class="fee-forecast-card__row">
<span>{{ $t('order.myOrders.drawer.fee.currentReceivable') }}</span>
<strong>{{ formatCurrentReceivableText }}</strong>
</div>
<div class="fee-forecast-card__diff" :class="{ 'is-up': (receivableForecastDiff ?? 0) > 0, 'is-down': (receivableForecastDiff ?? 0) < 0 }">
<span>{{ $t('order.myOrders.drawer.fee.diff') }}</span>
<strong>{{ formatSignedAmount(receivableForecastDiff) }}</strong>
</div>
</div>
<div v-if="forecastPayableAmount != null" class="fee-forecast-card">
<div class="fee-forecast-card__title">
{{ $t('finance.receivablePayable.feeType.payable') }}
</div>
<div class="fee-forecast-card__row">
<span>{{ $t('order.myOrders.drawer.fee.forecastPayable') }}</span>
<strong>{{ formatPlainAmount(forecastPayableAmount) }}</strong>
</div>
<div class="fee-forecast-card__row">
<span>{{ $t('order.myOrders.drawer.fee.currentPayable') }}</span>
<strong>{{ formatCurrentPayableText }}</strong>
</div>
<div class="fee-forecast-card__diff" :class="{ 'is-up': (payableForecastDiff ?? 0) > 0, 'is-down': (payableForecastDiff ?? 0) < 0 }">
<span>{{ $t('order.myOrders.drawer.fee.diff') }}</span>
<strong>{{ formatSignedAmount(payableForecastDiff) }}</strong>
</div>
</div>
</div>
</div>
<a-alert
v-if="hasNegativeGrossProfit"
type="warning"
show-icon
class="fee-warn"
>
{{ $t('order.myOrders.drawer.fee.negativeGrossProfitWarn') }}
</a-alert>
<div class="fee-detail-toolbar">
<span class="fee-detail-toolbar__title">
{{ $t('order.myOrders.drawer.fee.detailTitle') }}
</span>
<SlidingTabs
v-model="feeViewMode"
size="mini"
class="fee-view-switch"
:items="feeViewTabs"
:aria-label="$t('order.myOrders.drawer.fee.detailTitle')"
/>
</div>
<template v-for="section in visibleFeeSections" :key="section.key">
<div class="fee-section" :class="section.key">
<div class="fee-section-header">
<div class="fee-section-title-wrap">
<span class="fee-section-dot" />
<span class="fee-section-title">{{ $t(section.titleKey) }}</span>
<span class="fee-section-count">{{ section.list.length }}</span>
</div>
<span class="fee-section-total">{{ formatFeeTotals(section.totals) }}</span>
</div>
<div v-if="section.list.length" class="fee-table-wrap">
<div class="fee-table">
<div class="table-header">
<div
v-for="col in feeDetailColumns"
:key="col.key"
class="header-cell"
:class="col.key"
>
{{ $t(col.labelKey) }}
</div>
</div>
<div
v-for="(row, idx) in section.list"
:key="`${section.key}-${idx}`"
class="table-row"
>
<div
v-for="col in feeDetailColumns"
:key="col.key"
class="table-cell"
:class="col.key"
>
<template v-if="col.key === 'amount'">
<span
class="fee-amount"
:class="isDiscountFeeRow(row) ? 'amount-discount' : section.amountClass"
>
{{ formatFeeAmount(row.amount) }}
</span>
</template>
<template v-else-if="col.key === 'chargingStage'">
<a-tag
v-if="getChargingStage(row)"
size="small"
:color="getChargingStageColor(getChargingStage(row))"
>
{{ getChargingStageLabel(getChargingStage(row)) }}
</a-tag>
<span v-else>--</span>
</template>
<template v-else>
{{ getFeeCellValue(row, col) }}
</template>
</div>
</div>
</div>
</div>
<a-empty
v-else
:description="$t(section.emptyKey)"
:image-style="{ height: '48px' }"
class="fee-section-empty"
/>
</div>
</template>
</div>
<!-- 轨迹 -->
<div v-if="activeTab === 'track'" class="tab-panel track-info">
<a-spin :loading="trackLoading" class="track-spin">
<div v-if="displayTrackTimeline.length" class="track-timeline">
<div
v-for="(item, i) in displayTrackTimeline"
:key="i"
class="track-item"
:class="{ active: isTrackNodeActive(item, i) }"
>
<div class="track-left">
<span class="track-dot" :class="{ active: isTrackNodeActive(item, i) }" />
<span
v-if="i < displayTrackTimeline.length - 1"
class="track-line"
:class="{ active: isTrackNodeActive(item, i) }"
/>
</div>
<div class="track-right">
<div class="track-row-head">
<span class="track-status">{{ getTrackStatusLabel(item) }}</span>
<a-tag v-if="isTrackNodeActive(item, i)" size="small" color="green">
{{ $t('order.myOrders.drawer.track.latest') }}
</a-tag>
</div>
<div v-if="getTrackZhDetail(item)" class="track-content track-content--zh">
{{ getTrackZhDetail(item) }}
</div>
<div v-if="getTrackEnDetail(item)" class="track-content track-content--en">
{{ getTrackEnDetail(item) }}
</div>
<div class="track-meta-row">
<span v-if="formatTrackTimeDisplay(item)" class="track-meta-time">
{{ item.trackTimePrefix || '' }}{{ formatTrackTimeDisplay(item) }}
</span>
<span v-if="formatTrackPlace(item)" class="track-meta-place">
{{ formatTrackPlace(item) }}
</span>
<span v-if="item.trackTimeZone" class="track-meta-zone">
{{ item.trackTimeZone }}
</span>
<span v-if="item.trackCode" class="track-meta-code">{{ item.trackCode }}</span>
</div>
<div v-if="item.remark" class="track-remark">
{{ $t('order.myOrders.drawer.track.remark') }}:{{ item.remark }}
</div>
</div>
</div>
</div>
<a-empty
v-else-if="!trackLoading"
:description="$t('order.myOrders.drawer.track.empty')"
:image-style="{ height: '60px' }"
class="track-empty"
/>
</a-spin>
</div>
<!-- 附件 -->
<div v-if="activeTab === 'attachments'" class="tab-panel attachments-info">
<OrderAttachmentsTab
:order-id="orderId"
:active="activeTab === 'attachments'"
/>
</div>
<!-- 绑定包裹/库存 -->
<div v-if="activeTab === 'stockBind'" class="tab-panel stock-bind-info">
<OrderStockBindTab
ref="stockBindTabRef"
:order-id="orderId"
:active="activeTab === 'stockBind'"
hide-refresh
/>
</div>
<!-- 问题处理 -->
<div v-if="activeTab === 'issueHandling'" class="tab-panel issue-handling-info">
<OrderIssueHandlingTab
:order-id="orderId"
:active="activeTab === 'issueHandling'"
@changed="handleIssueChanged"
/>
</div>
<!-- 操作日志 -->
<div v-if="activeTab === 'operationLog'" class="tab-panel operation-log-info">
<div class="operation-log-filter" role="tablist">
<button
v-for="opt in operationLogFilterOptions"
:key="opt.key"
type="button"
class="operation-log-filter__btn"
:class="{ 'is-active': operationLogFilter === opt.key }"
@click="operationLogFilter = opt.key"
>
{{ opt.label }}
</button>
</div>
<a-spin :loading="operationLogLoading" class="operation-log-spin">
<a-table
v-if="operationLogFilter === 'notify' ? notifyLogList.length : filteredOperationLogList.length"
class="operation-log-table"
row-key="id"
size="small"
:pagination="false"
:bordered="{ cell: true }"
:columns="operationLogFilter === 'notify' ? notifyLogColumns : operationLogColumns"
:data="operationLogFilter === 'notify' ? notifyLogTableData : operationLogTableData"
/>
<a-empty
v-else-if="!operationLogLoading"
:description="
operationLogFilter === 'notify'
? $t('order.myOrders.drawer.operationLog.notifyEmpty')
: $t('order.myOrders.drawer.operationLog.empty')
"
:image-style="{ height: '60px' }"
/>
</a-spin>
</div>
</div>
<div v-if="showActionBar" class="drawer-action-bar">
<div class="drawer-action-bar__meta">
<template v-if="activeTab === 'track' && !showEditFooter">
<span class="action-bar-meta">
<span class="action-bar-meta-label">{{ $t('order.myOrders.drawer.trackNo') }}</span>
<span class="action-bar-meta-value">{{ trackOrderNumber || '--' }}</span>
</span>
<a-tag
v-if="currentOrderStatusMeta"
size="small"
:style="getOrderStatusTagStyle(currentOrderStatusMeta)"
>
{{ $t(currentOrderStatusMeta.labelKey) }}
</a-tag>
<a-tag v-if="trackTimeline.length" size="small" color="arcoblue">
{{ $t('order.myOrders.drawer.track.count', { count: trackTimeline.length }) }}
</a-tag>
</template>
<a-tag
v-else-if="activeTab === 'operationLog' && !showEditFooter && operationLogVisibleCount > 0"
size="small"
color="arcoblue"
>
{{ $t('order.myOrders.drawer.operationLog.count', { count: operationLogVisibleCount }) }}
</a-tag>
</div>
<div class="drawer-action-bar__actions">
<template v-if="showEditFooter">
<a-button
@click="activeTab === 'weight' ? cancelWeightEdit() : cancelBasicEdit()"
>
{{ $t('order.myOrders.drawer.actions.cancel') }}
</a-button>
<a-button
type="primary"
class="app-btn-primary-soft"
:loading="activeTab === 'weight' ? weightSaving : basicSaving"
@click="activeTab === 'weight' ? handleWeightEditSave() : handleBasicEditSave()"
>
{{ $t('order.myOrders.drawer.actions.save') }}
</a-button>
</template>
<template v-else-if="activeTab === 'basic'">
<a-button class="app-btn-search" @click="startBasicEdit">
{{ $t('order.myOrders.drawer.actions.edit') }}
</a-button>
<a-button class="app-btn-search" @click="handleAskAdvisor">
{{ $t('ediAssistant.askAboutWaybill') }}
</a-button>
</template>
<template v-else-if="activeTab === 'weight'">
<a-button class="app-btn-search" @click="startWeightEdit">
{{ $t('order.myOrders.drawer.actions.edit') }}
</a-button>
</template>
<template v-else-if="activeTab === 'fee'">
<a-button
class="app-btn-search"
:loading="additionalServicesLoading"
@click="openAdditionalServicesModal"
>
{{ $t('order.myOrders.drawer.actions.additionalServices') }}
<template v-if="orderAdditionalServices.length">
({{ orderAdditionalServices.length }})
</template>
</a-button>
<a-button class="app-btn-search" @click="openAddFeeModal">
{{ $t('order.myOrders.drawer.actions.addFee') }}
</a-button>
<a-button
class="app-btn-search"
:loading="recalcReceivableLoading"
@click="handleRecalculateReceivable"
>
{{ $t('order.myOrders.drawer.actions.recalculateReceivable') }}
</a-button>
<a-button
class="app-btn-search"
:loading="recalcPayableLoading"
@click="handleRecalculatePayable"
>
{{ $t('order.myOrders.drawer.actions.recalculatePayable') }}
</a-button>
<a-button class="app-btn-search" @click="openBindSnapshotVersionsModal">
{{ $t('order.myOrders.drawer.actions.bindSnapshotVersions') }}
</a-button>
</template>
<template v-else-if="activeTab === 'track'">
<a-button
class="app-btn-search"
:loading="trackLoading"
@click="loadTrackTimeline"
>{{ $t('order.myOrders.drawer.track.refresh') }}
</a-button>
</template>
<template v-else-if="activeTab === 'stockBind'">
<a-button
class="app-btn-search"
:loading="stockBindLoading"
@click="reloadStockBind"
>{{ $t('order.myOrders.drawer.track.refresh') }}
</a-button>
</template>
<template v-else-if="activeTab === 'operationLog'">
<a-button
class="app-btn-search"
:loading="operationLogLoading"
@click="loadOperationLogs"
>{{ $t('order.myOrders.drawer.operationLog.refresh') }}
</a-button>
</template>
</div>
</div>
</div>
</DrawerPro>
<AddOrderFeeModal
v-model:visible="addFeeModalVisible"
:order-id="orderId"
:default-type="addFeeDefaultType"
@success="handleAddFeeSuccess"
/>
<BindSnapshotVersionsModal
v-if="bindSnapshotVersionsVisible && orderId != null"
v-model:visible="bindSnapshotVersionsVisible"
:order-id="Number(orderId)"
:sales-product-id="bindSnapshotSalesProductId"
:current-rules-version="boundRulesVersion"
:current-price-version="boundPriceVersion"
@success="handleBindSnapshotVersionsSuccess"
/>
<a-modal
v-model:visible="declarationSkuPreviewVisible"
:title="$t('order.myOrders.drawer.declarationSkuImage')"
:footer="false"
width="640px"
unmount-on-close
>
<div class="declaration-sku-preview">
<img
v-if="declarationSkuPreviewUrl"
:src="declarationSkuPreviewUrl"
:alt="$t('order.myOrders.drawer.declarationSkuImage')"
referrerpolicy="no-referrer"
/>
</div>
</a-modal>
<AllocationTraceModal
v-model:visible="allocationTraceVisible"
:order-id="orderId"
/>
<a-modal
v-model:visible="additionalServicesModalVisible"
:title="
canEditAdditionalServices
? $t('order.myOrders.drawer.fee.additionalServicesManageTitle')
: $t('order.myOrders.drawer.fee.additionalServicesViewTitle')
"
:ok-loading="additionalServicesSaving"
:ok-text="
canEditAdditionalServices
? $t('order.myOrders.drawer.fee.additionalServicesSave')
: $t('order.myOrders.drawer.fee.additionalServicesClose')
"
:hide-cancel="!canEditAdditionalServices"
unmount-on-close
@ok="handleAdditionalServicesSubmit"
>
<a-spin :loading="additionalServicesLoading">
<p class="additional-services-hint">
{{
canEditAdditionalServices
? $t('order.myOrders.drawer.fee.additionalServicesHint')
: $t('order.myOrders.drawer.fee.additionalServicesPaidHint')
}}
</p>
<div class="additional-services-current">
<div class="additional-services-current__label">
{{ $t('order.myOrders.drawer.fee.additionalServicesCurrent') }}
</div>
<a-space v-if="orderAdditionalServices.length" wrap :size="4">
<a-tag
v-for="code in orderAdditionalServices"
:key="`cur-${code}`"
size="small"
color="arcoblue"
>
{{ labelAdditionalService(code) }}
</a-tag>
</a-space>
<span v-else class="additional-services-current__empty">
{{ $t('order.myOrders.drawer.fee.additionalServicesNone') }}
</span>
</div>
<template v-if="canEditAdditionalServices">
<div
v-if="visibleOrphanAdditionalServices.length"
class="additional-services-orphan"
>
<div class="additional-services-orphan__label">
{{ $t('order.myOrders.drawer.fee.additionalServicesOrphan') }}
</div>
<a-space wrap :size="4">
<a-tag
v-for="code in visibleOrphanAdditionalServices"
:key="`orphan-${code}`"
size="small"
color="orangered"
closable
@close="dismissOrphanAdditionalService(code)"
>
{{ labelAdditionalService(code) }}
</a-tag>
</a-space>
</div>
<div class="additional-services-options-label">
{{ $t('order.myOrders.drawer.fee.additionalServicesPick') }}
</div>
<a-checkbox-group
v-if="productAdditionalServiceOptions.length"
v-model="selectedAdditionalServices"
class="additional-services-checkbox-group"
>
<a-checkbox
v-for="opt in productAdditionalServiceOptions"
:key="opt.value"
:value="opt.value"
>
{{ opt.label }}
</a-checkbox>
</a-checkbox-group>
<a-empty
v-else
:description="$t('order.myOrders.drawer.fee.additionalServicesEmpty')"
/>
</template>
</a-spin>
</a-modal>
</template>
<script setup lang="ts">
import { ref, computed, watch, reactive, nextTick } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { Message } from '@arco-design/web-vue';
import { IconRefresh, IconRobot, IconEye } from '@arco-design/web-vue/es/icon';
import type { TableColumnData } from '@arco-design/web-vue';
import useDrawer from '@/components/DrawerPro/useDrawer';
import { postGetDetailTimeline } from '@/api/TrackOrder/trackOrder';
import {
postOrderUpdate,
postOrderChangeProduct,
postOrderWeightUpdate,
postOrderRecalculateReceivable,
postOrderRecalculatePayable,
postOrderAdditionalServicesUpdate,
getOrderNotifyLogList,
getOrderOperationLogList,
type OrderNotifyLogItem,
type OrderOperationLogItem,
} from '@/api/order';
import { getSalesProductDetail, getSalesProductList } from '@/api/channel/salesProduct';
import { getDictListAll, type DictDto } from '@/api/system/dict';
import { getWarehouseList } from '@/api/system/warehouse';
import { getOrderStatusMeta, getOrderStatusTagStyle, resolveOrderStatusCode } from '@/constants/orderStatus';
import { isDiscountCostItem } from '@/constants/feeCostItems';
import { getBooleanTagStyle } from '@/utils/statusTag';
import { resolveOmsAssetUrl } from '@/api/oms/common';
import SlidingTabs from '@/components/SlidingTabs/index.vue';
import AddOrderFeeModal from './AddOrderFeeModal.vue';
import BindSnapshotVersionsModal from './BindSnapshotVersionsModal.vue';
import AllocationTraceModal from './AllocationTraceModal.vue';
import OrderStockBindTab from '../../myOrders/components/OrderStockBindTab.vue';
import OrderAttachmentsTab from '../../components/OrderAttachmentsTab.vue';
import OrderIssueHandlingTab from '../../components/OrderIssueHandlingTab.vue';
import OrderDeclarationHotTable from '../../components/OrderDeclarationHotTable.vue';
import {
ORDER_DETAIL_VALUE_FIELD_MAP,
buildDeclarationPayloadFromRows,
cloneDeclarationItemRows,
formatOrderDetailBooleanLabel,
formatOrderDetailExtendedValue,
isOrderDetailBooleanField,
isOrderDetailYesNoLabel,
mergeOrderBasicFields,
parseAdditionalServiceCodes,
patchOrderBasicFieldGroups,
pickOrderDetailArray,
pickOrderDetailBooleanRaw,
pickOrderDetailNested,
} from '../../components/orderDetailFieldConfig';
import { openAskAdvisor } from '@/composables/useAskAdvisor';
import { buildFailGuideFromReason } from '@/utils/parcelCreateFailGuide';
const { t } = useI18n();
const router = useRouter();
interface OrderRow {
id?: number;
waybillNo?: string;
customerOrderNo?: string;
trackingNo?: string;
[key: string]: any;
}
interface Props {
order?: OrderRow | null;
}
const props = withDefaults(defineProps<Props>(), {
order: null,
});
const emit = defineEmits<{
cancel: [];
updated: [order: OrderRow];
}>();
const detail = ref<OrderRow | null>(null);
const basicEditing = ref(false);
const weightEditing = ref(false);
const basicSaving = ref(false);
const weightSaving = ref(false);
const recalcReceivableLoading = ref(false);
const recalcPayableLoading = ref(false);
const addFeeModalVisible = ref(false);
const bindSnapshotVersionsVisible = ref(false);
const bindSnapshotSalesProductId = ref<number | string | null>(null);
const allocationTraceVisible = ref(false);
const addFeeDefaultType = ref<'receivable' | 'payable'>('receivable');
const additionalServicesModalVisible = ref(false);
const additionalServicesLoading = ref(false);
const additionalServicesSaving = ref(false);
const productAdditionalServiceOptions = ref<Array<{ value: string; label: string }>>([]);
const selectedAdditionalServices = ref<string[]>([]);
const productHasAdditionalServices = ref(false);
const additionalServiceDictRows = ref<DictDto[]>([]);
const exportCustomsDictRows = ref<DictDto[]>([]);
const stockBindTabRef = ref<{ reload?: () => Promise<void> | void } | null>(null);
const stockBindLoading = ref(false);
async function reloadStockBind() {
stockBindLoading.value = true;
try {
await stockBindTabRef.value?.reload?.();
} finally {
stockBindLoading.value = false;
}
}
type BasicViewMode = 'all' | 'basic' | 'sender' | 'recipient' | 'declaration';
const basicViewMode = ref<BasicViewMode>('all');
const basicSectionDefs = [
{ key: 'basic' as const, labelKey: 'order.myOrders.drawer.orderBasic' },
{ key: 'sender' as const, labelKey: 'order.myOrders.drawer.sender' },
{ key: 'recipient' as const, labelKey: 'order.myOrders.drawer.recipient' },
{ key: 'declaration' as const, labelKey: 'order.myOrders.drawer.declaration' },
];
const basicViewTabs = computed(() => [
{ key: 'all', label: t('order.myOrders.drawer.basic.viewAll') },
...basicSectionDefs.map((section) => ({
key: section.key,
label: t(section.labelKey),
})),
]);
const visibleBasicSections = computed(() => {
if (basicViewMode.value === 'all') return basicSectionDefs;
return basicSectionDefs.filter((section) => section.key === basicViewMode.value);
});
const currentOrderStatusMeta = computed(() => {
const code = resolveOrderStatusCode(detail.value);
return code ? getOrderStatusMeta(code) : null;
});
const predeclareFailGuide = computed(() => {
const status = resolveOrderStatusCode(detail.value);
if (status !== 'draft') return null;
const reason = String(getOrderValue('predeclareFailReason') || '').trim();
if (!reason) return null;
return buildFailGuideFromReason(reason);
});
type FieldInputType = 'text' | 'number' | 'select' | 'switch';
interface FormFieldDef {
key: string;
labelKey: string;
inputType?: FieldInputType;
span?: 2;
options?: Array<{ value: string; labelKey: string }>;
}
const orderEditFieldDefs: FormFieldDef[] = [
{ key: 'clientNo', labelKey: 'order.myOrders.drawer.clientNo' },
{ key: 'trackNo', labelKey: 'order.myOrders.drawer.trackNo' },
{ key: 'downstreamServiceNo', labelKey: 'order.myOrders.drawer.downstreamServiceNo' },
{ key: 'warehouse', labelKey: 'order.myOrders.drawer.warehouse', inputType: 'select' },
{
key: 'cargoAttribute',
labelKey: 'order.myOrders.drawer.cargoAttribute',
inputType: 'select',
options: [
{ value: 'general', labelKey: 'order.myOrders.drawer.cargoAttribute.general' },
{ value: 'electronics', labelKey: 'order.myOrders.drawer.cargoAttribute.electronics' },
{ value: 'sensitive', labelKey: 'order.myOrders.drawer.cargoAttribute.sensitive' },
],
},
{ key: 'isCod', labelKey: 'order.myOrders.drawer.isCod', inputType: 'switch' },
{ key: 'codCurrency', labelKey: 'order.myOrders.drawer.codCurrency' },
{ key: 'codSum', labelKey: 'order.myOrders.drawer.codSum', inputType: 'number' },
];
const orderEditMetaMap = Object.fromEntries(
orderEditFieldDefs.map((def) => [def.key, def])
) as Record<string, FormFieldDef>;
const SENDER_READONLY_KEYS = new Set(['isDefault']);
const SENDER_FORM_KEY_MAP: Record<string, string> = { country: 'countryCode' };
const RECIPIENT_FORM_KEY_MAP: Record<string, string> = { country: 'countryCode' };
const CHANGE_PRODUCT_STATUSES = new Set([
'draft',
'predeclared',
'pendingAllocation',
'pendingPayment',
]);
const canChangeProduct = computed(() => {
if (!isOrderUnpaid.value) return false;
const code = resolveOrderStatusCode(detail.value);
return !!code && CHANGE_PRODUCT_STATUSES.has(code);
});
function isOrderFieldEditable(key: string) {
if (key === 'productName') return canChangeProduct.value;
return key in orderEditMetaMap;
}
function getOrderEditMeta(key: string) {
return orderEditMetaMap[key];
}
function isSenderFieldEditable(key: string) {
return !SENDER_READONLY_KEYS.has(key);
}
function getSenderFormKey(key: string) {
return SENDER_FORM_KEY_MAP[key] ?? key;
}
function isRecipientFieldEditable(_key: string) {
return true;
}
function getRecipientFormKey(key: string) {
return RECIPIENT_FORM_KEY_MAP[key] ?? key;
}
const basicEditForm = reactive({
clientNo: '',
trackNo: '',
downstreamServiceNo: '',
warehouseId: undefined as number | undefined,
cargoAttribute: 'general',
isCod: false,
codSum: undefined as number | undefined,
codCurrency: '',
declaredCurrency: '',
declaredSum: undefined as number | undefined,
productCode: '',
});
const initialProductCode = ref('');
const currencyOptions = ref<Array<{ value: string; label: string }>>([]);
const currencyOptionsLoading = ref(false);
const warehouseOptions = ref<Array<{ value: number; label: string }>>([]);
const warehouseOptionsLoading = ref(false);
const salesProductOptions = ref<Array<{ value: string; label: string }>>([]);
const salesProductOptionsLoading = ref(false);
async function ensureSalesProductOptions() {
if (salesProductOptions.value.length > 0) return;
salesProductOptionsLoading.value = true;
try {
const res = await getSalesProductList({ page: 1, pageSize: 500, isActive: 2 });
salesProductOptions.value = (res.items ?? [])
.map((row: any) => {
const code = String(row?.productCode ?? row?.ProductCode ?? '').trim();
const name = String(row?.productName ?? row?.ProductName ?? '').trim();
if (!code) return null;
return { value: code, label: name ? `${name} ${code}` : code };
})
.filter(Boolean) as Array<{ value: string; label: string }>;
} catch {
salesProductOptions.value = [];
} finally {
salesProductOptionsLoading.value = false;
}
}
async function ensureWarehouseOptions(preferred?: {
id?: number;
name?: string;
}) {
warehouseOptionsLoading.value = true;
try {
if (warehouseOptions.value.length === 0) {
const { items } = await getWarehouseList({ page: 1, pageSize: 200 });
warehouseOptions.value = (items || [])
.map((row: any) => {
const id = Number(row?.id ?? row?.Id);
if (!Number.isFinite(id) || id <= 0) return null;
const name = String(row?.warehouseName ?? row?.WarehouseName ?? '').trim();
return { value: id, label: name || `#${id}` };
})
.filter((item): item is { value: number; label: string } => !!item);
}
const id = preferred?.id != null && preferred.id > 0 ? preferred.id : undefined;
const name = String(preferred?.name ?? '').trim();
if (id && !warehouseOptions.value.some((opt) => opt.value === id)) {
warehouseOptions.value = [
...warehouseOptions.value,
{ value: id, label: name || `#${id}` },
];
}
} catch {
if (warehouseOptions.value.length === 0) warehouseOptions.value = [];
} finally {
warehouseOptionsLoading.value = false;
}
}
async function ensureCurrencyOptions(preferredCode?: string) {
currencyOptionsLoading.value = true;
try {
if (currencyOptions.value.length === 0) {
const rows = await getDictListAll({ dictType: 'currency' });
currencyOptions.value = (Array.isArray(rows) ? rows : [])
.map((row: DictDto | Record<string, any>) => {
const code = String((row as any).dictCode ?? (row as any).DictCode ?? '').trim();
if (!code) return null;
return { value: code, label: code };
})
.filter((item): item is { value: string; label: string } => !!item)
.sort((a, b) => a.value.localeCompare(b.value));
}
const code = String(preferredCode ?? '').trim();
if (code && !currencyOptions.value.some((opt) => opt.value === code)) {
currencyOptions.value = [...currencyOptions.value, { value: code, label: code }].sort((a, b) =>
a.value.localeCompare(b.value)
);
}
} catch {
if (currencyOptions.value.length === 0) currencyOptions.value = [];
} finally {
currencyOptionsLoading.value = false;
}
}
const senderEditForm = reactive<Record<string, string>>({
senderName: '',
company: '',
countryCode: '',
province: '',
city: '',
zipCode: '',
streetAddress1: '',
streetAddress2: '',
streetAddress3: '',
houseNumber: '',
phone: '',
telePhone: '',
email: '',
});
const receiverEditForm = reactive<Record<string, string>>({
recipientsName: '',
companyName: '',
countryCode: '',
phone: '',
telePhone: '',
zipCode: '',
province: '',
city: '',
streetNumber: '',
streetAddress1: '',
streetAddress2: '',
streetAddress3: '',
email: '',
taxType: '',
taxNo: '',
certificateType: '',
certificateNo: '',
eori: '',
vat: '',
});
const declarationEditList = ref<any[]>([]);
const weightEditForm = ref<
Array<{
type: string;
length?: number;
width?: number;
height?: number;
actualWeight?: number;
}>
>([]);
const hasSender = computed(() => Object.keys(sender.value).length > 0);
const orderId = computed(() => detail.value?.id);
const canViewAllocationTrace = computed(() => {
const o: any = detail.value || {};
if (!orderId.value) return false;
const product = o.productCode ?? o.ProductCode;
const channel = o.channelCode ?? o.ChannelCode ?? o.channelName ?? o.ChannelName;
const pending = o.allocationPendingReason ?? o.AllocationPendingReason;
const hasTrace = o.hasAllocationTrace ?? o.HasAllocationTrace;
return Boolean(product || channel || pending || hasTrace);
});
function openAllocationTrace() {
if (!orderId.value) {
Message.warning(t('order.myOrders.allocationTrace.noOrder'));
return;
}
allocationTraceVisible.value = true;
}
const displayDeclarationRows = computed(() =>
basicEditing.value ? declarationEditList.value : declarationList.value
);
function getOrderFieldLabelKey(fieldKey: string) {
return orderBasicFields.find((field) => field.key === fieldKey)?.labelKey ?? fieldKey;
}
function shouldRenderOrderBooleanTag(fieldKey: string) {
if (isOrderDetailBooleanField(fieldKey)) return true;
return isOrderDetailYesNoLabel(getOrderValue(fieldKey), t);
}
const declarationSkuPreviewVisible = ref(false);
const declarationSkuPreviewUrl = ref('');
function openDeclarationSkuPreview(raw?: string | null) {
const value = String(raw ?? '').trim();
if (!value || value === '0' || value === '--') return;
const src = resolveOmsAssetUrl(value) || value;
if (!src) return;
declarationSkuPreviewUrl.value = src;
declarationSkuPreviewVisible.value = true;
}
function cloneDeclarationRows(rows: any[]) {
return cloneDeclarationItemRows(rows);
}
function addDeclarationRow() {
declarationEditList.value.push({
cnName: '',
enName: '',
sku: '',
unit: '',
quantity: 1,
isMagnetic: false,
});
}
function removeDeclarationRow(index: number) {
declarationEditList.value.splice(index, 1);
}
function buildDeclarationPayload() {
return buildDeclarationPayloadFromRows(declarationEditList.value);
}
function parseOptionalInt(value: string) {
const trimmed = String(value ?? '').trim();
if (!trimmed) return undefined;
const num = Number(trimmed);
return Number.isNaN(num) ? undefined : num;
}
const displayWeightRows = computed(() => {
if (!weightEditing.value) {
return weightList.value;
}
return weightEditForm.value.map((row) => {
const orig = weightList.value.find((w: any) => w.type === row.type) || {};
return { ...orig, ...row };
});
});
function resetEditState() {
basicEditing.value = false;
weightEditing.value = false;
}
const [register, { openDrawer: innerOpenDrawer, setDrawerProps, closeDrawer }] = useDrawer();
const activeTab = ref('basic');
const showEditFooter = computed(
() =>
(activeTab.value === 'basic' && basicEditing.value) ||
(activeTab.value === 'weight' && weightEditing.value),
);
const showActionBar = computed(() =>
['basic', 'weight', 'fee', 'track', 'stockBind', 'operationLog'].includes(activeTab.value),
);
const tabList = computed(() => [
{ key: 'basic', label: t('order.myOrders.drawer.tabs.basic') },
{ key: 'weight', label: t('order.myOrders.drawer.tabs.weight') },
{ key: 'fee', label: t('order.myOrders.drawer.tabs.fee') },
{ key: 'track', label: t('order.myOrders.drawer.tabs.track') },
{ key: 'attachments', label: t('order.myOrders.drawer.tabs.attachments') },
{ key: 'stockBind', label: t('order.myOrders.drawer.tabs.stockBind') },
{ key: 'issueHandling', label: t('order.myOrders.drawer.tabs.issueHandling') },
{ key: 'operationLog', label: t('order.myOrders.drawer.tabs.operationLog') },
]);
const NOTIFY_OPS_ACTIONS = new Set(['notifyWechat', 'notifyEmail']);
type OperationLogFilter = 'all' | 'business' | 'notify';
const operationLogList = ref<OrderOperationLogItem[]>([]);
const notifyLogList = ref<OrderNotifyLogItem[]>([]);
const operationLogLoading = ref(false);
const operationLogFilter = ref<OperationLogFilter>('all');
const operationLogFilterOptions = computed(() => [
{ key: 'all' as const, label: t('order.myOrders.drawer.operationLog.filterAll') },
{ key: 'business' as const, label: t('order.myOrders.drawer.operationLog.filterBusiness') },
{ key: 'notify' as const, label: t('order.myOrders.drawer.operationLog.filterNotify') },
]);
const filteredOperationLogList = computed(() => {
if (operationLogFilter.value === 'business') {
return operationLogList.value.filter((x) => !NOTIFY_OPS_ACTIONS.has(x.action));
}
return operationLogList.value;
});
const operationLogVisibleCount = computed(() =>
operationLogFilter.value === 'notify'
? notifyLogList.value.length
: filteredOperationLogList.value.length,
);
const operationLogColumns = computed<TableColumnData[]>(() => [
{
title: t('order.myOrders.drawer.operationLog.time'),
dataIndex: 'createTime',
width: 188,
bodyCellClass: 'operation-log-time-cell',
},
{
title: t('order.myOrders.drawer.operationLog.action'),
dataIndex: 'actionName',
width: 140,
},
{
title: t('order.myOrders.drawer.operationLog.content'),
dataIndex: 'summary',
ellipsis: true,
tooltip: true,
},
{
title: t('order.myOrders.drawer.operationLog.operator'),
dataIndex: 'operatorName',
width: 120,
},
]);
const notifyLogColumns = computed<TableColumnData[]>(() => [
{
title: t('order.myOrders.drawer.operationLog.time'),
dataIndex: 'createTime',
width: 188,
bodyCellClass: 'operation-log-time-cell',
},
{
title: t('order.myOrders.drawer.operationLog.channel'),
dataIndex: 'channelName',
width: 80,
},
{
title: t('order.myOrders.drawer.operationLog.event'),
dataIndex: 'eventName',
width: 110,
},
{
title: t('order.myOrders.drawer.operationLog.status'),
dataIndex: 'statusLabel',
width: 80,
},
{
title: t('order.myOrders.drawer.operationLog.content'),
dataIndex: 'summary',
ellipsis: true,
tooltip: true,
},
]);
const operationLogTableData = computed(() =>
filteredOperationLogList.value.map((item) => ({
id: item.id,
createTime: formatOperationLogTime(item.createTime),
actionName: item.actionName || item.action || '--',
summary: item.summary || item.remark || '—',
operatorName: item.operatorName || '--',
})),
);
const notifyLogTableData = computed(() =>
notifyLogList.value.map((item) => ({
id: item.id,
createTime: formatOperationLogTime(item.createTime),
channelName: item.channelName || item.channel || '--',
eventName: item.eventName || item.eventCode || '--',
statusLabel: formatNotifyStatus(item.status),
summary: item.summary || item.errMsg || '—',
})),
);
const slidingTabItems = computed(() =>
tabList.value.map((tab) => ({ key: tab.key, label: tab.label })),
);
// 订单基本信息字段 (t_order) - 按文档表结构
const orderBasicFields = mergeOrderBasicFields([
{ key: 'serviceNo', labelKey: 'order.myOrders.drawer.serviceNo' },
{ key: 'clientNo', labelKey: 'order.myOrders.drawer.clientNo' },
{ key: 'trackNo', labelKey: 'order.myOrders.drawer.trackNo' },
{ key: 'downstreamServiceNo', labelKey: 'order.myOrders.drawer.downstreamServiceNo' },
{ key: 'productCode', labelKey: 'order.myOrders.drawer.productCode' },
{ key: 'productName', labelKey: 'order.myOrders.drawer.productName' },
{ key: 'channelCode', labelKey: 'order.myOrders.drawer.channelCode' },
{ key: 'channelName', labelKey: 'order.myOrders.drawer.channelName' },
{ key: 'downstreamSupplierName', labelKey: 'order.myOrders.drawer.downstreamSupplierName' },
{ key: 'downstreamSupplierCode', labelKey: 'order.myOrders.drawer.downstreamSupplierCode' },
{ key: 'consigneeCountry', labelKey: 'order.myOrders.drawer.consigneeCountry' },
{ key: 'consigneeCountryName', labelKey: 'order.myOrders.drawer.consigneeCountryName' },
{ key: 'cargoAttribute', labelKey: 'order.myOrders.drawer.cargoAttribute' },
{ key: 'orderStatus', labelKey: 'order.myOrders.drawer.orderStatus' },
{ key: 'predeclareFailReason', labelKey: 'order.myOrders.drawer.predeclareFailReason' },
{ key: 'allocationPendingReason', labelKey: 'order.myOrders.drawer.allocationPendingReason' },
{ key: 'warehouse', labelKey: 'order.myOrders.drawer.warehouse' },
{ key: 'receiveTime', labelKey: 'order.myOrders.drawer.receiveTime' },
{ key: 'shipTime', labelKey: 'order.myOrders.drawer.shipTime' },
{ key: 'payTime', labelKey: 'order.myOrders.drawer.payTime' },
{ key: 'isPaid', labelKey: 'order.myOrders.drawer.isPaid' },
{ key: 'signTime', labelKey: 'order.myOrders.drawer.signTime' },
{ key: 'isCod', labelKey: 'order.myOrders.drawer.isCod' },
{ key: 'codCurrency', labelKey: 'order.myOrders.drawer.codCurrency' },
{ key: 'codSum', labelKey: 'order.myOrders.drawer.codSum' },
{ key: 'isIntercept', labelKey: 'order.myOrders.drawer.isIntercept' },
{ key: 'isRemote', labelKey: 'order.myOrders.drawer.isRemote' },
{ key: 'createTime', labelKey: 'order.myOrders.drawer.createTime' },
{ key: 'createBy', labelKey: 'order.myOrders.drawer.createBy' },
{ key: 'updateTime', labelKey: 'order.myOrders.drawer.updateTime' },
{ key: 'updateBy', labelKey: 'order.myOrders.drawer.updateBy' },
]);
const orderBasicFieldGroups = patchOrderBasicFieldGroups(
[
{
key: 'identity',
labelKey: 'order.myOrders.drawer.basic.group.identity',
fields: ['serviceNo', 'clientNo', 'trackNo', 'downstreamServiceNo'],
},
{
key: 'product',
labelKey: 'order.myOrders.drawer.basic.group.product',
fields: [
'productCode',
'productName',
'channelCode',
'channelName',
'warehouse',
'consigneeCountry',
'consigneeCountryName',
'cargoAttribute',
],
},
{
key: 'timeline',
labelKey: 'order.myOrders.drawer.basic.group.timeline',
fields: ['orderStatus', 'predeclareFailReason', 'allocationPendingReason', 'receiveTime', 'shipTime', 'signTime', 'payTime', 'isPaid'],
},
{
key: 'flags',
labelKey: 'order.myOrders.drawer.basic.group.flags',
fields: ['isCod', 'codCurrency', 'codSum', 'isIntercept', 'isRemote'],
},
{
key: 'audit',
labelKey: 'order.myOrders.drawer.basic.group.audit',
fields: ['createTime', 'createBy', 'updateTime', 'updateBy'],
},
],
{ includeChannel: true },
);
// 发件人表单字段 (t_order_sender) - 补齐全部字段
const senderFields = [
{ key: 'senderName', labelKey: 'order.myOrders.drawer.senderName' },
{ key: 'company', labelKey: 'order.myOrders.drawer.company' },
{ key: 'country', labelKey: 'order.myOrders.drawer.country' },
{ key: 'province', labelKey: 'order.myOrders.drawer.province' },
{ key: 'city', labelKey: 'order.myOrders.drawer.city' },
{ key: 'zipCode', labelKey: 'order.myOrders.drawer.zipCode' },
{ key: 'streetAddress1', labelKey: 'order.myOrders.drawer.streetAddress1' },
{ key: 'streetAddress2', labelKey: 'order.myOrders.drawer.streetAddress2' },
{ key: 'streetAddress3', labelKey: 'order.myOrders.drawer.streetAddress3' },
{ key: 'houseNumber', labelKey: 'order.myOrders.drawer.houseNumber' },
{ key: 'phone', labelKey: 'order.myOrders.drawer.phone' },
{ key: 'telePhone', labelKey: 'order.myOrders.drawer.telePhone' },
{ key: 'email', labelKey: 'order.myOrders.drawer.email' },
{ key: 'isDefault', labelKey: 'order.myOrders.drawer.isDefault' },
];
// 收件人表单字段 (t_order_recipient) - 补齐全部字段
const recipientFields = [
{ key: 'recipientsName', labelKey: 'order.myOrders.drawer.recipientsName' },
{ key: 'companyName', labelKey: 'order.myOrders.drawer.companyName' },
{ key: 'country', labelKey: 'order.myOrders.drawer.recipientCountry' },
{ key: 'phone', labelKey: 'order.myOrders.drawer.recipientPhone' },
{ key: 'telePhone', labelKey: 'order.myOrders.drawer.recipientTelePhone' },
{ key: 'zipCode', labelKey: 'order.myOrders.drawer.recipientZipCode' },
{ key: 'province', labelKey: 'order.myOrders.drawer.province' },
{ key: 'city', labelKey: 'order.myOrders.drawer.city' },
{ key: 'streetNumber', labelKey: 'order.myOrders.drawer.streetNumber' },
{ key: 'streetAddress1', labelKey: 'order.myOrders.drawer.streetAddress1' },
{ key: 'streetAddress2', labelKey: 'order.myOrders.drawer.streetAddress2' },
{ key: 'streetAddress3', labelKey: 'order.myOrders.drawer.streetAddress3' },
{ key: 'email', labelKey: 'order.myOrders.drawer.email' },
{ key: 'taxType', labelKey: 'order.myOrders.drawer.taxType' },
{ key: 'taxNo', labelKey: 'order.myOrders.drawer.taxNo' },
{ key: 'certificateType', labelKey: 'order.myOrders.drawer.certificateType' },
{ key: 'certificateNo', labelKey: 'order.myOrders.drawer.certificateNo' },
{ key: 'eori', labelKey: 'order.myOrders.drawer.eori' },
{ key: 'vat', labelKey: 'order.myOrders.drawer.vat' },
];
// 申报信息列表列 (t_order_declaration) - 补齐全部字段
// 件重尺:类型独立展示,明细区不再含类型列
type WeightViewMode = 'all' | 'forecast' | 'receive' | 'ship' | 'downstream';
const weightViewMode = ref<WeightViewMode>('all');
const weightTypeDefs = [
{
key: 'forecast' as const,
labelKey: 'order.myOrders.drawer.weightType.forecast',
emptyKey: 'order.myOrders.drawer.weight.empty.forecast',
},
{
key: 'receive' as const,
labelKey: 'order.myOrders.drawer.weightType.receive',
emptyKey: 'order.myOrders.drawer.weight.empty.receive',
},
{
key: 'ship' as const,
labelKey: 'order.myOrders.drawer.weightType.ship',
emptyKey: 'order.myOrders.drawer.weight.empty.ship',
},
{
key: 'downstream' as const,
labelKey: 'order.myOrders.drawer.weightType.downstream',
emptyKey: 'order.myOrders.drawer.weight.empty.downstream',
},
];
const weightViewTabs = computed(() => [
{ key: 'all', label: t('order.myOrders.drawer.weight.viewAll') },
...weightTypeDefs.map((section) => ({
key: section.key,
label: t(section.labelKey),
})),
]);
const weightMetricFields = [
{ key: 'length', labelKey: 'order.myOrders.drawer.weightLength', editable: true, highlight: false },
{ key: 'width', labelKey: 'order.myOrders.drawer.weightWidth', editable: true, highlight: false },
{ key: 'height', labelKey: 'order.myOrders.drawer.weightHeight', editable: true, highlight: false },
{ key: 'actualWeight', labelKey: 'order.myOrders.drawer.actualWeight', editable: true, highlight: false },
{ key: 'volumetricWeight', labelKey: 'order.myOrders.drawer.volumetricWeight', editable: false, highlight: false },
{ key: 'chargeableWeight', labelKey: 'order.myOrders.drawer.chargeableWeight', editable: false, highlight: true },
{ key: 'payableChargeableWeight', labelKey: 'order.myOrders.drawer.payableChargeableWeight', editable: false, highlight: true },
{ key: 'cubic', labelKey: 'order.myOrders.drawer.cubic', editable: false, highlight: false },
];
const weightDimFields = weightMetricFields.filter((field) =>
['length', 'width', 'height'].includes(field.key),
);
const weightMassFields = weightMetricFields.filter((field) =>
!['length', 'width', 'height'].includes(field.key),
);
// 费用明细列(类型已从列表拆出,按应收/应付分区展示)
const feeDetailColumns = [
{ key: 'costItem', labelKey: 'order.myOrders.drawer.costItem' },
{ key: 'amount', labelKey: 'order.myOrders.drawer.amount' },
{ key: 'currency', labelKey: 'order.myOrders.drawer.currency' },
{ key: 'chargingStage', labelKey: 'order.myOrders.drawer.chargingStage' },
{ key: 'downstreamProvider', labelKey: 'order.myOrders.drawer.downstreamProvider' },
{ key: 'priceNo', labelKey: 'order.myOrders.drawer.priceNo' },
{ key: 'priceEffectiveTime', labelKey: 'order.myOrders.drawer.priceEffectiveTime' },
];
type FeeViewMode = 'all' | 'receivable' | 'payable';
const feeViewMode = ref<FeeViewMode>('all');
const feeViewTabs = computed(() => [
{ key: 'all', label: t('order.myOrders.drawer.fee.viewAll') },
{ key: 'receivable', label: t('finance.receivablePayable.feeType.receivable') },
{ key: 'payable', label: t('finance.receivablePayable.feeType.payable') },
]);
// 详情数据(从 order 或 API 获取)
const sender = ref<Record<string, any>>({});
const recipient = ref<Record<string, any>>({});
const declarationList = ref<any[]>([]);
const weightList = ref<any[]>([]);
const feeList = ref<any[]>([]);
const feeItemDictRows = ref<DictDto[]>([]);
let feeItemDictLoadPromise: Promise<void> | null = null;
const trackTimeline = ref<any[]>([]);
const trackLoading = ref(false);
const trackOrderNumber = computed(
() =>
detail.value?.trackNo ||
detail.value?.trackingNo ||
detail.value?.waybillNo ||
detail.value?.customerOrderNo ||
''
);
function getWeightRowByType(type: string) {
return displayWeightRows.value.find((row) => row.type === type);
}
function hasWeightRow(type: string) {
return displayWeightRows.value.some((row) => row.type === type);
}
function hasWeightData(row: any) {
if (!row) return false;
return weightMetricFields.some((field) => {
const val = row[field.key];
return val != null && val !== '';
});
}
const visibleWeightSections = computed(() => {
const sections = weightTypeDefs.map((def) => {
const row = getWeightRowByType(def.key) ?? { type: def.key };
return {
...def,
row,
hasData: hasWeightData(row),
};
});
if (weightViewMode.value === 'all') return sections;
return sections.filter((section) => section.key === weightViewMode.value);
});
function setWeightViewMode(mode: WeightViewMode) {
weightViewMode.value = weightViewMode.value === mode ? 'all' : mode;
}
function formatWeightNumber(value: unknown) {
const num = Number(value);
return Number.isFinite(num) ? num.toFixed(3).replace(/\.?0+$/, '') : '--';
}
function formatWeightChargeable(row?: {
chargeableWeight?: number | string | null;
payableChargeableWeight?: number | string | null;
}) {
const val = row?.chargeableWeight;
if (val == null || val === '') return '--';
return `${formatWeightNumber(val)} kg`;
}
function formatWeightCellValue(row: any, key: string) {
const val = row?.[key];
if (val == null || val === '') return '--';
if (['length', 'width', 'height'].includes(key)) return `${formatWeightNumber(val)} cm`;
if (['actualWeight', 'volumetricWeight', 'chargeableWeight', 'payableChargeableWeight'].includes(key)) {
return `${formatWeightNumber(val)} kg`;
}
if (key === 'cubic') return `${formatWeightNumber(val)} m³`;
return String(val);
}
function handleAskAdvisor() {
const pick = (key: string) => {
const text = getOrderValue(key);
return text && text !== '--' ? text : undefined;
};
openAskAdvisor(router, {
orderId: orderId.value != null ? String(orderId.value) : undefined,
waybillNo: pick('serviceNo'),
trackingNo: pick('trackNo'),
customerOrderNo: pick('clientNo'),
from: 'waybillManage',
orderStatus: resolveOrderStatusCode(detail.value) || undefined,
});
}
function getOrderDetailFormatContext() {
return {
t,
resolveOrderStatusCode,
getOrderStatusMeta,
exportCustomsDict: exportCustomsDictRows.value,
additionalServiceDict: additionalServiceDictRows.value,
};
}
// 订单基本信息取值(兼容 API 驼峰与 mock 字段名)
function getOrderValue(key: string) {
const o = detail.value;
if (!o) return '--';
const fieldMap: Record<string, string[]> = {
serviceNo: ['serviceNo', 'waybillNo'],
clientNo: ['clientNo', 'customerOrderNo'],
trackNo: ['trackNo', 'trackingNo'],
downstreamServiceNo: ['downstreamServiceNo', 'DownstreamServiceNo'],
productCode: ['productCode'],
productName: ['productName', 'shippingMethod'],
channelCode: ['channelCode'],
channelName: ['channelName', 'serviceChannel'],
consigneeCountry: ['consigneeCountry'],
consigneeCountryName: ['consigneeCountryName'],
cargoAttribute: ['cargoAttribute'],
orderStatus: ['status', 'orderStatus'],
predeclareFailReason: ['predeclareFailReason', 'PredeclareFailReason'],
allocationPendingReason: ['allocationPendingReason', 'AllocationPendingReason'],
warehouse: ['warehouse', 'warehouseName'],
receiveTime: ['receiveTime'],
shipTime: ['shipTime'],
payTime: ['payTime'],
signTime: ['signTime'],
createTime: ['createTime'],
createBy: ['createBy'],
updateTime: ['updateTime'],
updateBy: ['updateBy'],
...ORDER_DETAIL_VALUE_FIELD_MAP,
};
if (isOrderDetailBooleanField(key)) {
return formatOrderDetailBooleanLabel(pickOrderDetailBooleanRaw(o, key), t);
}
const keys = fieldMap[key] || [key];
let val: any;
for (const k of keys) {
if (o[k] != null && o[k] !== '') {
val = o[k];
break;
}
}
if (val == null || val === '') return '--';
if (key === 'orderStatus') {
const code = resolveOrderStatusCode(o);
const meta = getOrderStatusMeta(code);
if (meta) return t(meta.labelKey);
const statusKey = `order.myOrders.status.${val}`;
const translated = t(statusKey);
return translated !== statusKey ? translated : String(val);
}
if (key === 'cargoAttribute') {
const cargoKey = `order.myOrders.drawer.cargoAttribute.${val}`;
const translated = t(cargoKey);
return translated !== cargoKey ? translated : String(val);
}
const extended = formatOrderDetailExtendedValue(key, val, o, getOrderDetailFormatContext());
if (extended != null) return extended;
return String(val);
}
function getSenderValue(key: string) {
if (key === 'country') {
return sender.value.country ?? sender.value.countryCode ?? '--';
}
const val = sender.value[key];
if (key === 'isDefault') {
return formatOrderDetailBooleanLabel(val, t);
}
return val ?? '--';
}
function getRecipientValue(key: string) {
if (key === 'country') {
return recipient.value.country ?? recipient.value.countryCode ?? '--';
}
return recipient.value[key] ?? '--';
}
function formatTrackTime(timestamp?: number | string) {
if (timestamp == null || timestamp === '') return '';
const raw = typeof timestamp === 'string' ? Number(timestamp) : timestamp;
if (!Number.isFinite(raw)) return String(timestamp);
const d = new Date(raw);
if (Number.isNaN(d.getTime())) return String(timestamp);
return d.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
});
}
function formatTrackTimeDisplay(item: any) {
return formatTrackTime(item?.trackTime);
}
function normalizeTrackText(value: unknown) {
const text = value == null ? '' : String(value).trim();
return !text || text === '--' ? '' : text;
}
function formatTrackPlace(item: any) {
const structured = [item?.trackPlaceNation, item?.trackPlaceProvince, item?.trackPlaceCity]
.map(normalizeTrackText)
.filter(Boolean);
if (structured.length) return structured.join(' · ');
return normalizeTrackText(item?.trackPlace);
}
function getTrackStatusLabel(item: any) {
return (
normalizeTrackText(item?.trackStatus) ||
normalizeTrackText(item?.content) ||
t('order.myOrders.drawer.track.statusUnknown')
);
}
/** 有独立状态时,中文内容作为详情;否则中文已作标题 */
function getTrackZhDetail(item: any) {
const status = normalizeTrackText(item?.trackStatus);
const zh = normalizeTrackText(item?.content);
if (!zh || !status || zh === status) return '';
return zh;
}
/** 英文内容;与标题/中文相同则不重复展示 */
function getTrackEnDetail(item: any) {
const en = normalizeTrackText(item?.enContent);
if (!en) return '';
const zh = normalizeTrackText(item?.content);
const status = normalizeTrackText(item?.trackStatus);
if (en === zh || en === status) return '';
return en;
}
const displayTrackTimeline = computed(() => {
const list = [...trackTimeline.value];
if (!list.length) return [];
// 与顺丰/京东一致:最新在上
return list.sort((a, b) => Number(b?.trackTime || 0) - Number(a?.trackTime || 0));
});
function isTrackNodeActive(item: any, index: number) {
if (item?.isHighlight) return true;
const list = displayTrackTimeline.value;
if (list.some((node) => node?.isHighlight)) return false;
return index === 0;
}
function normalizeFeeType(row: any): 'receivable' | 'payable' | '' {
const raw = String(row?.type ?? row?.feeType ?? row?.FeeType ?? '').toLowerCase();
if (raw === 'receivable' || raw === 'payable') return raw;
return '';
}
function getChargingStageRank(stage?: string) {
const s = String(stage ?? '').toLowerCase();
if (s === 'outbound') return 3;
if (s === 'inbound') return 2;
if (s === 'forecast') return 1;
return 0;
}
/** 同费用项只保留最高计费阶段,避免预报+入库叠算 */
function filterEffectiveStageFees(list: any[]) {
const winners = new Map<string, any>();
for (const row of list) {
const feeType = normalizeFeeType(row) || 'unknown';
const costItem = String(row?.costItem ?? row?.CostItem ?? '').trim() || '_';
const key = `${feeType}|${costItem}`;
const current = winners.get(key);
if (!current) {
winners.set(key, row);
continue;
}
const rowStage = String(row?.chargingStage ?? row?.ChargingStage ?? '');
const curStage = String(current?.chargingStage ?? current?.ChargingStage ?? '');
if (getChargingStageRank(rowStage) > getChargingStageRank(curStage)) {
winners.set(key, row);
}
}
return [...winners.values()];
}
function sumFeesByCurrency(list: any[]) {
const totals = new Map<string, number>();
for (const row of list) {
const currency = String(row?.currency ?? 'CNY').trim() || 'CNY';
const amount = Number(row?.amount);
if (!Number.isFinite(amount)) continue;
totals.set(currency, (totals.get(currency) ?? 0) + amount);
}
return totals;
}
const receivableFeeList = computed(() =>
filterEffectiveStageFees(feeList.value.filter((row) => normalizeFeeType(row) === 'receivable'))
);
const payableFeeList = computed(() =>
filterEffectiveStageFees(feeList.value.filter((row) => normalizeFeeType(row) === 'payable'))
);
const receivableTotals = computed(() => sumFeesByCurrency(receivableFeeList.value));
function isDiscountFeeRow(row: any) {
return isDiscountCostItem(row?.costItem ?? row?.CostItem);
}
/** 支付写入的优惠券抵扣 / 会员折扣(负数),用于应收卡片「含优惠」提示 */
const receivableDiscountTotals = computed(() =>
sumFeesByCurrency(receivableFeeList.value.filter(isDiscountFeeRow)),
);
/** 折前应收:预报快照不含营销抵扣,差额对比需同口径 */
const receivableGrossTotals = computed(() =>
sumFeesByCurrency(receivableFeeList.value.filter((row) => !isDiscountFeeRow(row))),
);
const payableTotals = computed(() => sumFeesByCurrency(payableFeeList.value));
function calcGrossProfitTotals(
receivable: Map<string, number>,
payable: Map<string, number>
) {
const currencies = new Set([...receivable.keys(), ...payable.keys()]);
const result = new Map<string, number>();
for (const currency of currencies) {
result.set(currency, (receivable.get(currency) ?? 0) - (payable.get(currency) ?? 0));
}
return result;
}
const feeGrossProfitTotals = computed(() =>
calcGrossProfitTotals(receivableTotals.value, payableTotals.value)
);
const hasNegativeGrossProfit = computed(() =>
[...feeGrossProfitTotals.value.values()].some((amount) => amount < 0)
);
function pickPrimaryTotal(totals: Map<string, number>, fallback?: unknown) {
if (totals.size) {
const preferred = ['CNY', 'RMB', 'USD', 'EUR'];
for (const c of preferred) {
if (totals.has(c)) return { currency: c, amount: totals.get(c)! };
}
const [currency, amount] = [...totals.entries()][0];
return { currency, amount };
}
const n = Number(fallback);
if (Number.isFinite(n)) return { currency: '', amount: n };
return null;
}
const forecastReceivableAmount = computed(() => {
const raw = detail.value?.forecastReceivableAmount ?? detail.value?.ForecastReceivableAmount;
if (raw == null || raw === '') return null;
const n = Number(raw);
return Number.isFinite(n) ? n : null;
});
const forecastPayableAmount = computed(() => {
const raw = detail.value?.forecastPayableAmount ?? detail.value?.ForecastPayableAmount;
if (raw == null || raw === '') return null;
const n = Number(raw);
return Number.isFinite(n) ? n : null;
});
const showForecastDiff = computed(() => forecastReceivableAmount.value != null);
const currentReceivablePrimary = computed(() =>
pickPrimaryTotal(
receivableGrossTotals.value,
detail.value?.receivableAmount ?? detail.value?.ReceivableAmount
)
);
const currentPayablePrimary = computed(() =>
pickPrimaryTotal(payableTotals.value, detail.value?.payableAmount ?? detail.value?.PayableAmount)
);
const receivableForecastDiff = computed(() => {
if (forecastReceivableAmount.value == null || !currentReceivablePrimary.value) return null;
return currentReceivablePrimary.value.amount - forecastReceivableAmount.value;
});
const payableForecastDiff = computed(() => {
if (forecastPayableAmount.value == null || !currentPayablePrimary.value) return null;
return currentPayablePrimary.value.amount - forecastPayableAmount.value;
});
const formatCurrentReceivableText = computed(() => {
const p = currentReceivablePrimary.value;
if (!p) return '--';
return p.currency ? `${p.currency} ${p.amount.toFixed(2)}` : p.amount.toFixed(2);
});
const formatCurrentPayableText = computed(() => {
const p = currentPayablePrimary.value;
if (!p) return '--';
return p.currency ? `${p.currency} ${p.amount.toFixed(2)}` : p.amount.toFixed(2);
});
const orderAdditionalServices = computed(() =>
parseAdditionalServiceCodes(
detail.value?.additionalServices ?? detail.value?.AdditionalServices
)
);
const isOrderUnpaid = computed(() => {
const v = detail.value?.isPaid ?? detail.value?.IsPaid;
return !(v === true || v === 1 || v === '1');
});
/** 未支付可勾选/取消附加服务;已支付仅可查看。 */
const canEditAdditionalServices = computed(() => isOrderUnpaid.value);
/** 订单上有、但当前产品配置已不包含的附加服务(保存时只能去掉,不能再写回)。 */
const orphanAdditionalServices = computed(() => {
const allowed = new Set(productAdditionalServiceOptions.value.map((o) => o.value));
if (!allowed.size) {
return [...orderAdditionalServices.value];
}
return orderAdditionalServices.value.filter((code) => !allowed.has(code));
});
const dismissedOrphanServices = ref<string[]>([]);
const visibleOrphanAdditionalServices = computed(() =>
orphanAdditionalServices.value.filter((code) => !dismissedOrphanServices.value.includes(code))
);
const grossProfitMarginText = computed(() => {
const margins: string[] = [];
for (const [currency, recv] of receivableTotals.value) {
if (!recv) continue;
const profit = feeGrossProfitTotals.value.get(currency) ?? 0;
margins.push(
t('order.myOrders.drawer.fee.grossMargin', {
value: `${((profit / recv) * 100).toFixed(1)}%`,
})
);
}
return margins.length ? margins.join(' / ') : t('order.myOrders.drawer.fee.grossMarginEmpty');
});
const visibleFeeSections = computed(() => {
const sections = [
{
key: 'receivable' as const,
titleKey: 'order.myOrders.drawer.fee.receivableTitle',
emptyKey: 'order.myOrders.drawer.fee.emptyReceivable',
list: receivableFeeList.value,
totals: receivableTotals.value,
tagColor: 'green',
amountClass: 'amount-receivable',
},
{
key: 'payable' as const,
titleKey: 'order.myOrders.drawer.fee.payableTitle',
emptyKey: 'order.myOrders.drawer.fee.emptyPayable',
list: payableFeeList.value,
totals: payableTotals.value,
tagColor: 'red',
amountClass: 'amount-payable',
},
];
if (feeViewMode.value === 'all') return sections;
return sections.filter((section) => section.key === feeViewMode.value);
});
function setFeeViewMode(mode: FeeViewMode) {
feeViewMode.value = feeViewMode.value === mode ? 'all' : mode;
}
function openAddFeeModal() {
if (orderId.value == null) return;
addFeeDefaultType.value =
feeViewMode.value === 'payable'
? 'payable'
: feeViewMode.value === 'receivable'
? 'receivable'
: 'receivable';
addFeeModalVisible.value = true;
}
function handleAddFeeSuccess(order: OrderRow) {
applyDetailFromApi(order);
void ensureFeeItemDictLoaded();
}
function handleIssueChanged() {
if (detail.value) {
emit('updated', detail.value as OrderRow);
}
}
function formatFeeAmount(value: unknown) {
const num = Number(value);
return Number.isFinite(num) ? num.toFixed(2) : '--';
}
function formatFeeTotals(totals: Map<string, number>) {
if (!totals.size) return '--';
return [...totals.entries()]
.map(([currency, amount]) => `${currency} ${amount.toFixed(2)}`)
.join(' + ');
}
function formatGrossProfitTotals(totals: Map<string, number>) {
if (!totals.size) return '--';
return [...totals.entries()]
.map(([currency, amount]) => {
const sign = amount > 0 ? '+' : '';
return `${sign}${currency} ${amount.toFixed(2)}`;
})
.join(' + ');
}
function formatPlainAmount(value: number | null | undefined) {
if (value == null || !Number.isFinite(value)) return '--';
return value.toFixed(2);
}
function formatSignedAmount(value: number | null | undefined) {
if (value == null || !Number.isFinite(value)) return '--';
const sign = value > 0 ? '+' : '';
return `${sign}${value.toFixed(2)}`;
}
function labelAdditionalService(code: string) {
const hit = additionalServiceDictRows.value.find((r) => r.dictCode === code);
return hit?.dictName || code;
}
async function ensureAdditionalServiceDictLoaded() {
const tasks: Promise<void>[] = [];
if (!additionalServiceDictRows.value.length) {
tasks.push(
getDictListAll({ dictType: 'additional_service' })
.then((rows) => {
additionalServiceDictRows.value = rows;
})
.catch(() => {
additionalServiceDictRows.value = [];
}),
);
}
if (!exportCustomsDictRows.value.length) {
tasks.push(
getDictListAll({ dictType: 'export_customs_mode' })
.then((rows) => {
exportCustomsDictRows.value = rows;
})
.catch(() => {
exportCustomsDictRows.value = [];
}),
);
}
if (tasks.length) {
await Promise.all(tasks);
}
}
async function resolveProductIdByCode(productCode: string): Promise<number | string | null> {
const code = String(productCode ?? '').trim();
if (!code) return null;
try {
const { items } = await getSalesProductList({
page: 1,
pageSize: 20,
keyword: code,
isActive: 2,
});
const hit = (items ?? []).find(
(it: any) =>
String(it?.productCode ?? it?.ProductCode ?? '').trim().toLowerCase() ===
code.toLowerCase()
);
return hit?.id ?? hit?.Id ?? null;
} catch {
return null;
}
}
async function refreshProductAdditionalServicesCapability() {
const code = String(detail.value?.productCode ?? detail.value?.ProductCode ?? '').trim();
if (!code) {
productHasAdditionalServices.value = false;
productAdditionalServiceOptions.value = [];
return;
}
try {
await ensureAdditionalServiceDictLoaded();
const productId = await resolveProductIdByCode(code);
if (productId == null) {
productHasAdditionalServices.value = false;
productAdditionalServiceOptions.value = [];
return;
}
const product = await getSalesProductDetail(productId);
const codes = parseAdditionalServiceCodes(
product?.additionalServices ?? product?.AdditionalServices
);
productHasAdditionalServices.value = codes.length > 0;
productAdditionalServiceOptions.value = codes.map((c) => ({
value: c,
label: labelAdditionalService(c),
}));
} catch {
productHasAdditionalServices.value = false;
productAdditionalServiceOptions.value = [];
}
}
async function openAdditionalServicesModal() {
additionalServicesModalVisible.value = true;
additionalServicesLoading.value = true;
dismissedOrphanServices.value = [];
try {
await refreshProductAdditionalServicesCapability();
const allowed = new Set(productAdditionalServiceOptions.value.map((o) => o.value));
selectedAdditionalServices.value = orderAdditionalServices.value.filter((c) =>
allowed.size ? allowed.has(c) : false
);
} finally {
additionalServicesLoading.value = false;
}
}
function dismissOrphanAdditionalService(code: string) {
if (!dismissedOrphanServices.value.includes(code)) {
dismissedOrphanServices.value = [...dismissedOrphanServices.value, code];
}
}
async function handleAdditionalServicesSubmit() {
if (!canEditAdditionalServices.value) {
additionalServicesModalVisible.value = false;
return;
}
const id = orderId.value;
if (id == null) return Promise.reject(new Error('missing order'));
additionalServicesSaving.value = true;
try {
const allowed = new Set(productAdditionalServiceOptions.value.map((o) => o.value));
const next = selectedAdditionalServices.value.filter((c) => allowed.has(c));
if (orphanAdditionalServices.value.length) {
Message.info(
t('order.myOrders.drawer.fee.additionalServicesOrphanCleared', {
names: orphanAdditionalServices.value.map((c) => labelAdditionalService(c)).join('、'),
})
);
}
const result = await postOrderAdditionalServicesUpdate({
id,
additionalServices: next,
});
applyDetailFromApi(result);
additionalServicesModalVisible.value = false;
Message.success(t('order.myOrders.drawer.fee.additionalServicesSuccess'));
} catch (e: any) {
Message.error(e?.message || t('order.myOrders.drawer.fee.additionalServicesFailed'));
throw e;
} finally {
additionalServicesSaving.value = false;
}
}
function getChargingStage(row: any) {
const stage = row?.chargingStage ?? row?.ChargingStage;
return stage != null && stage !== '' ? String(stage) : '';
}
function getChargingStageLabel(stage: string) {
const key = `finance.receivablePayable.chargingStage.${stage}`;
const translated = t(key);
return translated !== key ? translated : stage;
}
function getChargingStageColor(stage: string) {
const map: Record<string, string> = {
forecast: 'arcoblue',
inbound: 'orange',
outbound: 'purple',
};
return map[stage] || 'gray';
}
async function ensureFeeItemDictLoaded() {
if (feeItemDictRows.value.length) return;
if (feeItemDictLoadPromise) {
await feeItemDictLoadPromise;
return;
}
feeItemDictLoadPromise = (async () => {
try {
feeItemDictRows.value = await getDictListAll({ dictType: 'fee_item' });
} catch {
feeItemDictRows.value = [];
}
})();
await feeItemDictLoadPromise;
}
function getCostItemLabel(row: any) {
const fromApi = row?.costItemName ?? row?.CostItemName;
if (fromApi != null && fromApi !== '') return String(fromApi);
const code = row?.costItem ?? row?.CostItem;
if (code == null || code === '') return '--';
const c = String(code).trim();
const hit = feeItemDictRows.value.find(
(r) => String(r.dictCode ?? (r as any).DictCode ?? '').trim() === c
);
if (hit?.dictName) return hit.dictName;
const byName = feeItemDictRows.value.find(
(r) => String(r.dictName ?? (r as any).DictName ?? '').trim() === c
);
return byName?.dictName || c;
}
function getFeeCellValue(row: any, col: { key: string }) {
if (col.key === 'costItem') return getCostItemLabel(row);
if (col.key === 'priceEffectiveTime') {
const v = row[col.key];
if (v == null) return '--';
if (typeof v === 'number') return formatTrackTime(v);
return String(v);
}
return row[col.key] ?? '--';
}
// 加载轨迹(复用 track/order 的接口)
async function loadTrackTimeline() {
const orderNumber = detail.value?.waybillNo;
if (!orderNumber) {
trackTimeline.value = [];
return;
}
trackLoading.value = true;
try {
const res: any = await postGetDetailTimeline({ orderNumber });
trackTimeline.value = res?.data || res || [];
} catch {
trackTimeline.value = [];
} finally {
trackLoading.value = false;
}
}
// 加载详情数据(优先使用 list 接口返回的 sender/receiver/items/weightList,与 parcel/create 对应)
function loadDetailData() {
const o = detail.value;
if (!o) return;
const senderRaw = pickOrderDetailNested<Record<string, any>>(o, 'sender', 'Sender');
if (senderRaw && typeof senderRaw === 'object') {
sender.value = {
...senderRaw,
country: senderRaw.country ?? senderRaw.countryCode ?? senderRaw.CountryCode,
};
} else {
sender.value = {};
}
const receiverRaw = pickOrderDetailNested<Record<string, any>>(o, 'receiver', 'Receiver');
if (receiverRaw && typeof receiverRaw === 'object') {
recipient.value = {
...receiverRaw,
country: receiverRaw.country ?? receiverRaw.countryCode ?? receiverRaw.CountryCode,
};
} else {
recipient.value = {
recipientsName: o.consignee || '',
companyName: '',
country: o.consigneeCountry || '',
phone: o.consigneePhone || '',
telePhone: '',
zipCode: o.consigneePostcode || '',
province: o.consigneeState || '',
city: o.consigneeCity || '',
streetNumber: '',
streetAddress1: o.consigneeAddress || '',
streetAddress2: '',
streetAddress3: '',
email: '',
taxType: '',
taxNo: '',
certificateType: '',
certificateNo: '',
eori: o.eori || '',
vat: '',
};
}
const itemsRaw = pickOrderDetailArray(o, 'items', 'Items');
declarationList.value = itemsRaw.length > 0 ? cloneDeclarationItemRows(itemsRaw) : [];
weightList.value = pickOrderDetailArray(o, 'weightList', 'WeightList');
feeList.value = pickOrderDetailArray(o, 'feeList', 'FeeList', 'orderFees', 'fees');
}
function applyDetailFromApi(raw: any) {
if (!raw || typeof raw !== 'object') return;
detail.value = { ...(detail.value || {}), ...raw };
loadDetailData();
emit('updated', detail.value as OrderRow);
}
function fillBasicEditForm() {
const o = detail.value;
if (!o?.id) return;
basicEditForm.clientNo = String(o.clientNo ?? o.customerOrderNo ?? '');
basicEditForm.trackNo = String(o.trackNo ?? o.trackingNo ?? '');
basicEditForm.downstreamServiceNo = String(o.downstreamServiceNo ?? o.DownstreamServiceNo ?? '');
const warehouseIdRaw = o.warehouseId ?? o.WarehouseId;
const warehouseIdNum = warehouseIdRaw != null ? Number(warehouseIdRaw) : NaN;
basicEditForm.warehouseId =
Number.isFinite(warehouseIdNum) && warehouseIdNum > 0 ? warehouseIdNum : undefined;
basicEditForm.cargoAttribute = String(o.cargoAttribute ?? 'general');
basicEditForm.isCod = !!(o.isCod ?? o.IsCod);
basicEditForm.codSum = o.codSum != null ? Number(o.codSum) : undefined;
basicEditForm.codCurrency = String(o.codCurrency ?? '');
basicEditForm.declaredCurrency = String(o.declaredCurrency ?? o.DeclaredCurrency ?? '');
const declaredSumRaw = o.declaredSum ?? o.DeclaredSum;
basicEditForm.declaredSum =
declaredSumRaw != null && declaredSumRaw !== '' && Number.isFinite(Number(declaredSumRaw))
? Number(declaredSumRaw)
: undefined;
const productCode = String(o.productCode ?? o.ProductCode ?? '').trim();
basicEditForm.productCode = productCode;
initialProductCode.value = productCode;
senderEditForm.senderName = String(sender.value.senderName ?? '');
senderEditForm.company = String(sender.value.company ?? '');
senderEditForm.countryCode = String(sender.value.countryCode ?? sender.value.country ?? '');
senderEditForm.province = String(sender.value.province ?? '');
senderEditForm.city = String(sender.value.city ?? '');
senderEditForm.zipCode = String(sender.value.zipCode ?? '');
senderEditForm.streetAddress1 = String(sender.value.streetAddress1 ?? '');
senderEditForm.streetAddress2 = String(sender.value.streetAddress2 ?? '');
senderEditForm.streetAddress3 = String(sender.value.streetAddress3 ?? '');
senderEditForm.houseNumber = String(sender.value.houseNumber ?? '');
senderEditForm.phone = String(sender.value.phone ?? '');
senderEditForm.telePhone = String(sender.value.telePhone ?? '');
senderEditForm.email = String(sender.value.email ?? '');
receiverEditForm.recipientsName = String(recipient.value.recipientsName ?? o.consignee ?? '');
receiverEditForm.companyName = String(recipient.value.companyName ?? '');
receiverEditForm.countryCode = String(
recipient.value.countryCode ?? recipient.value.country ?? o.consigneeCountry ?? ''
);
receiverEditForm.phone = String(recipient.value.phone ?? o.consigneePhone ?? '');
receiverEditForm.telePhone = String(recipient.value.telePhone ?? '');
receiverEditForm.zipCode = String(recipient.value.zipCode ?? o.consigneePostcode ?? '');
receiverEditForm.province = String(recipient.value.province ?? o.consigneeState ?? '');
receiverEditForm.city = String(recipient.value.city ?? o.consigneeCity ?? '');
receiverEditForm.streetNumber = String(recipient.value.streetNumber ?? '');
receiverEditForm.streetAddress1 = String(recipient.value.streetAddress1 ?? o.consigneeAddress ?? '');
receiverEditForm.streetAddress2 = String(recipient.value.streetAddress2 ?? '');
receiverEditForm.streetAddress3 = String(recipient.value.streetAddress3 ?? '');
receiverEditForm.email = String(recipient.value.email ?? '');
receiverEditForm.taxType = recipient.value.taxType != null ? String(recipient.value.taxType) : '';
receiverEditForm.taxNo = String(recipient.value.taxNo ?? '');
receiverEditForm.certificateType =
recipient.value.certificateType != null ? String(recipient.value.certificateType) : '';
receiverEditForm.certificateNo = String(recipient.value.certificateNo ?? '');
receiverEditForm.eori = String(recipient.value.eori ?? o.eori ?? '');
receiverEditForm.vat = String(recipient.value.vat ?? '');
declarationEditList.value = cloneDeclarationRows(declarationList.value);
}
async function focusFirstEditableField(rootSelector: string) {
await nextTick();
await nextTick();
const root = document.querySelector(rootSelector);
if (!root) return;
const el = root.querySelector(
'.is-editable input:not([disabled]), .is-editable textarea:not([disabled]), .is-editable .arco-select-view',
) as HTMLElement | null;
el?.focus?.();
}
function startBasicEdit() {
fillBasicEditForm();
void ensureCurrencyOptions(basicEditForm.declaredCurrency);
void ensureWarehouseOptions({
id: basicEditForm.warehouseId,
name: String(detail.value?.warehouse ?? detail.value?.warehouseName ?? ''),
});
if (canChangeProduct.value) {
void ensureSalesProductOptions();
}
basicEditing.value = true;
void focusFirstEditableField('.order-detail-drawer .basic-info');
}
function cancelBasicEdit() {
basicEditing.value = false;
declarationEditList.value = [];
loadDetailData();
}
function startWeightEdit() {
weightEditForm.value = (weightList.value || []).map((row: any) => ({
type: row.type,
length: row.length != null ? Number(row.length) : undefined,
width: row.width != null ? Number(row.width) : undefined,
height: row.height != null ? Number(row.height) : undefined,
actualWeight: row.actualWeight != null ? Number(row.actualWeight) : undefined,
}));
weightEditing.value = true;
void focusFirstEditableField('.order-detail-drawer .weight-info');
}
function cancelWeightEdit() {
weightEditing.value = false;
loadDetailData();
}
async function handleBasicEditSave() {
const id = orderId.value;
if (id == null) return;
basicSaving.value = true;
try {
const nextProductCode = String(basicEditForm.productCode ?? '').trim();
const prevProductCode = String(initialProductCode.value ?? '').trim();
if (
canChangeProduct.value
&& nextProductCode
&& nextProductCode.toLowerCase() !== prevProductCode.toLowerCase()
) {
const changed = await postOrderChangeProduct({ id, productCode: nextProductCode });
applyDetailFromApi(changed);
initialProductCode.value = nextProductCode;
}
const result = await postOrderUpdate({
id,
clientNo: basicEditForm.clientNo,
trackNo: basicEditForm.trackNo,
downstreamServiceNo: basicEditForm.downstreamServiceNo,
warehouseId: basicEditForm.warehouseId ?? 0,
cargoAttribute: basicEditForm.cargoAttribute,
isCod: basicEditForm.isCod,
codSum: basicEditForm.codSum,
codCurrency: basicEditForm.codCurrency,
declaredCurrency: basicEditForm.declaredCurrency,
declaredSum: basicEditForm.declaredSum,
sender: hasSender.value
? {
senderName: senderEditForm.senderName,
company: senderEditForm.company,
countryCode: senderEditForm.countryCode,
province: senderEditForm.province,
city: senderEditForm.city,
zipCode: senderEditForm.zipCode,
streetAddress1: senderEditForm.streetAddress1,
streetAddress2: senderEditForm.streetAddress2,
streetAddress3: senderEditForm.streetAddress3,
houseNumber: senderEditForm.houseNumber,
phone: senderEditForm.phone,
telePhone: senderEditForm.telePhone,
email: senderEditForm.email,
}
: undefined,
receiver: {
recipientsName: receiverEditForm.recipientsName,
companyName: receiverEditForm.companyName,
countryCode: receiverEditForm.countryCode,
phone: receiverEditForm.phone,
telePhone: receiverEditForm.telePhone,
zipCode: receiverEditForm.zipCode,
province: receiverEditForm.province,
city: receiverEditForm.city,
streetNumber: receiverEditForm.streetNumber,
streetAddress1: receiverEditForm.streetAddress1,
streetAddress2: receiverEditForm.streetAddress2,
streetAddress3: receiverEditForm.streetAddress3,
email: receiverEditForm.email,
taxType: parseOptionalInt(receiverEditForm.taxType),
taxNo: receiverEditForm.taxNo,
certificateType: parseOptionalInt(receiverEditForm.certificateType),
certificateNo: receiverEditForm.certificateNo,
eori: receiverEditForm.eori,
vat: receiverEditForm.vat,
},
items: buildDeclarationPayload(),
});
applyDetailFromApi(result);
basicEditing.value = false;
Message.success(t('order.myOrders.drawer.message.saveSuccess'));
} catch (e: any) {
Message.error(e?.message || '保存失败');
} finally {
basicSaving.value = false;
}
}
async function handleWeightEditSave() {
const id = orderId.value;
if (id == null) return;
weightSaving.value = true;
try {
const result = await postOrderWeightUpdate({
id,
weights: weightEditForm.value.map((row) => ({
type: row.type,
length: row.length,
width: row.width,
height: row.height,
actualWeight: row.actualWeight,
})),
});
applyDetailFromApi(result);
weightEditing.value = false;
Message.success(t('order.myOrders.drawer.message.saveSuccess'));
} catch (e: any) {
Message.error(e?.message || '保存失败');
} finally {
weightSaving.value = false;
}
}
async function handleRecalculateReceivable() {
const id = orderId.value;
if (id == null) return;
recalcReceivableLoading.value = true;
try {
const result = await postOrderRecalculateReceivable({ id });
applyDetailFromApi(result);
Message.success(t('order.myOrders.drawer.message.recalculateSuccess'));
} catch (e: any) {
Message.error(e?.message || '重算应收失败');
} finally {
recalcReceivableLoading.value = false;
}
}
async function handleRecalculatePayable() {
const id = orderId.value;
if (id == null) return;
recalcPayableLoading.value = true;
try {
const result = await postOrderRecalculatePayable({ id });
applyDetailFromApi(result);
Message.success(t('order.myOrders.drawer.message.recalculateSuccess'));
} catch (e: any) {
Message.error(e?.message || '重算应付失败');
} finally {
recalcPayableLoading.value = false;
}
}
const boundRulesVersion = computed(() => {
const o = detail.value;
if (!o) return '';
return String(o.salesProductRulesVersion ?? o.SalesProductRulesVersion ?? '').trim();
});
const boundPriceVersion = computed(() => {
const o = detail.value;
if (!o) return '';
return String(o.salesProductPriceVersion ?? o.SalesProductPriceVersion ?? '').trim();
});
async function openBindSnapshotVersionsModal() {
const code = String(detail.value?.productCode ?? detail.value?.ProductCode ?? '').trim();
if (!code) {
Message.warning(t('order.myOrders.drawer.bindSnapshot.noProduct'));
return;
}
bindSnapshotSalesProductId.value = await resolveProductIdByCode(code);
if (bindSnapshotSalesProductId.value == null) {
Message.warning(t('order.myOrders.drawer.bindSnapshot.noProduct'));
return;
}
bindSnapshotVersionsVisible.value = true;
}
function handleBindSnapshotVersionsSuccess(result: any) {
applyDetailFromApi(result);
}
async function loadOperationLogs() {
const id = orderId.value;
if (!id) {
operationLogList.value = [];
notifyLogList.value = [];
return;
}
operationLogLoading.value = true;
try {
const [ops, notify] = await Promise.all([
getOrderOperationLogList(id),
getOrderNotifyLogList(id),
]);
operationLogList.value = ops.items || [];
notifyLogList.value = notify.items || [];
} catch {
operationLogList.value = [];
notifyLogList.value = [];
} finally {
operationLogLoading.value = false;
}
}
function formatOperationLogTime(value?: string) {
if (!value) return '--';
const d = new Date(value);
if (Number.isNaN(d.getTime())) return String(value);
const pad = (n: number) => String(n).padStart(2, '0');
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
}
function formatNotifyStatus(status?: string) {
const key = String(status || '').toLowerCase();
if (key === 'sent') return t('order.myOrders.drawer.operationLog.statusSent');
if (key === 'failed') return t('order.myOrders.drawer.operationLog.statusFailed');
if (key === 'skipped') return t('order.myOrders.drawer.operationLog.statusSkipped');
return status || '--';
}
function handleTabChange(tabKey: string) {
resetEditState();
if (tabKey === 'basic') {
basicViewMode.value = 'all';
}
if (tabKey === 'weight') {
weightViewMode.value = 'all';
}
if (tabKey === 'fee') {
feeViewMode.value = 'all';
void ensureFeeItemDictLoaded();
void refreshProductAdditionalServicesCapability();
}
if (tabKey === 'track') {
loadTrackTimeline();
}
if (tabKey === 'operationLog') {
void loadOperationLogs();
}
}
function handleCancel() {
resetEditState();
emit('cancel');
}
watch(
() => props.order,
(newOrder) => {
detail.value = newOrder ? { ...newOrder } : null;
resetEditState();
if (newOrder) {
void ensureAdditionalServiceDictLoaded();
loadDetailData();
if (activeTab.value === 'fee') {
void ensureFeeItemDictLoaded();
void refreshProductAdditionalServicesCapability();
}
if (activeTab.value === 'track') {
loadTrackTimeline();
}
if (activeTab.value === 'operationLog') {
void loadOperationLogs();
}
}
},
{ immediate: true, deep: true }
);
defineExpose({
openDrawer: (opts?: { tab?: 'basic' | 'weight' | 'fee' | 'track' | 'attachments' | 'stockBind' | 'issueHandling' | 'operationLog' }) => {
activeTab.value = opts?.tab || 'basic';
basicViewMode.value = 'all';
feeViewMode.value = 'all';
weightViewMode.value = 'all';
resetEditState();
setDrawerProps({
content: '',
placement: 'right',
width: 1000,
title: '',
});
innerOpenDrawer();
if (opts?.tab === 'track') {
void loadTrackTimeline();
} else if (opts?.tab === 'fee') {
void ensureFeeItemDictLoaded();
void refreshProductAdditionalServicesCapability();
}
},
startBasicEdit,
setDrawerProps,
closeDrawer,
});
</script>
<style lang="less" scoped>
:deep(.arco-drawer-header) {
display: none;
}
.order-detail-drawer {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.drawer-tabs {
margin-bottom: 12px;
flex-shrink: 0;
min-width: 0;
.tabs-slot {
min-width: 0;
overflow: hidden;
}
}
.drawer-action-bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-shrink: 0;
margin-top: 8px;
padding-top: 12px;
border-top: 1px solid var(--color-border-2);
background: #fff;
}
.drawer-action-bar__meta {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
min-width: 0;
flex: 1;
}
.drawer-action-bar__actions {
display: flex;
align-items: center;
justify-content: flex-end;
flex-wrap: wrap;
gap: 8px;
flex-shrink: 0;
margin-left: auto;
}
.action-bar-meta {
display: inline-flex;
align-items: baseline;
gap: 6px;
}
.action-bar-meta-label {
font-size: 13px;
color: var(--color-text-3);
}
.action-bar-meta-value {
font-size: 13px;
font-weight: 500;
color: var(--color-text-1);
}
/* 编辑态:仅高亮输入控件本身 */
.detail-field-item.is-editable,
.weight-metric-item.is-editable,
.declaration-header-sum.is-editable {
:deep(.arco-input-wrapper),
:deep(.arco-select-view-single),
:deep(.arco-input-number),
:deep(.arco-textarea-wrapper) {
background: #fff;
border-color: var(--app-primary-color, #1d7281);
box-shadow: 0 0 0 1px color-mix(in srgb, var(--app-primary-color, #1d7281) 25%, transparent);
}
:deep(.arco-input-wrapper:hover),
:deep(.arco-select-view-single:hover),
:deep(.arco-input-number:hover),
:deep(.arco-textarea-wrapper:hover),
:deep(.arco-input-wrapper.arco-input-focus),
:deep(.arco-select-view-single.arco-select-view-focus),
:deep(.arco-input-number.arco-input-number-focus),
:deep(.arco-textarea-wrapper.arco-input-focus) {
border-color: var(--app-primary-color, #1d7281);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--app-primary-color, #1d7281) 18%, transparent);
}
}
.drawer-tab-content {
flex: 1;
overflow-y: auto;
min-height: 0;
padding-bottom: 8px;
}
.tab-panel {
padding: 0 4px;
}
.inline-edit-form {
:deep(.arco-form-item) {
margin-bottom: 12px;
}
:deep(.arco-form-item-label) {
font-size: 13px;
color: var(--color-text-3);
}
}
.edit-field {
display: flex;
flex-direction: column;
gap: 4px;
min-width: 0;
margin-bottom: 12px;
.edit-field-label {
font-size: 13px;
color: var(--color-text-3);
line-height: 20px;
}
:deep(.arco-input),
:deep(.arco-select),
:deep(.arco-input-number) {
width: 100%;
}
}
.readonly-field {
.readonly-value {
min-height: 32px;
padding: 4px 0;
font-size: 13px;
color: var(--color-text-1);
word-break: break-all;
}
}
.form-grid-empty {
grid-column: 1 / -1;
}
.declaration-toolbar {
display: flex;
justify-content: flex-end;
margin-bottom: 8px;
}
.readonly-inline {
align-items: flex-start;
}
.edit-form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0 16px;
}
.edit-form-span-2 {
grid-column: span 2;
}
.basic-info {
display: flex;
flex-direction: column;
gap: 12px;
}
.predeclare-fail-guide {
margin-top: 12px;
padding: 12px 14px;
border-radius: 8px;
background: #fff7f7;
border-left: 3px solid #f53f3f;
border-top: 1px solid #ffd8d2;
border-right: 1px solid #ffd8d2;
border-bottom: 1px solid #ffd8d2;
&__reason {
margin: 0;
font-size: 15px;
font-weight: 600;
line-height: 1.45;
color: var(--color-text-1);
}
&__tip {
margin: 8px 0 0;
font-size: 13px;
line-height: 1.5;
color: var(--color-text-2);
}
&__tip-label {
margin-right: 4px;
color: var(--app-primary-color, #2d8c8c);
font-weight: 500;
}
&__details {
margin-top: 8px;
font-size: 12px;
color: var(--color-text-3);
summary {
cursor: pointer;
user-select: none;
}
}
&__raw {
margin: 6px 0 0;
font-size: 12px;
color: var(--color-text-3);
word-break: break-word;
}
&__actions {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-top: 10px;
}
}
.detail-field-text--with-action {
display: inline-flex;
align-items: center;
gap: 2px;
max-width: 100%;
}
.alloc-eye-btn {
color: var(--color-text-3);
padding: 0 2px;
&:hover {
color: var(--app-primary-color);
}
}
.basic-view-switch {
display: flex;
justify-content: flex-end;
}
.basic-view-tabs {
width: fit-content;
max-width: 100%;
}
.detail-section {
border: 1px solid var(--color-border-2);
border-radius: 6px;
overflow: hidden;
background: var(--app-card-bg);
&.basic .detail-section-dot {
background: var(--app-primary-color, #2d8c8c);
}
&.sender .detail-section-dot {
background: #165dff;
}
&.recipient .detail-section-dot {
background: #00b42a;
}
&.declaration .detail-section-dot {
background: #ff7d00;
}
}
.detail-section-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 10px 12px;
background: var(--color-fill-2);
border-bottom: 1px solid var(--color-border-2);
}
.detail-section-title-wrap {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.detail-section-dot {
width: 6px;
height: 6px;
border-radius: 50%;
flex-shrink: 0;
}
.detail-section-title {
font-size: 13px;
font-weight: 600;
color: var(--color-text-1);
}
.detail-field-group {
padding: 12px 12px 0;
&:last-child {
padding-bottom: 12px;
}
}
.detail-field-group-title {
margin-bottom: 8px;
font-size: 12px;
font-weight: 500;
color: var(--color-text-3);
line-height: 20px;
}
.detail-fields-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 10px;
padding: 12px;
}
.detail-field-item {
display: flex;
flex-direction: column;
gap: 4px;
min-width: 0;
padding: 8px 10px;
border: 1px solid var(--color-border-2);
border-radius: 4px;
background: var(--color-fill-2);
}
.detail-field-label {
font-size: 12px;
color: var(--color-text-3);
line-height: 18px;
}
.detail-field-value {
min-height: 24px;
display: flex;
align-items: center;
:deep(.arco-input),
:deep(.arco-select),
:deep(.arco-input-number) {
width: 100%;
}
}
.detail-field-text {
font-size: 13px;
color: var(--color-text-1);
font-weight: 500;
word-break: break-all;
line-height: 20px;
}
.detail-section-empty {
padding: 16px 12px;
}
.declaration-header-sum {
display: inline-flex;
align-items: center;
gap: 8px;
margin-left: 4px;
min-width: 0;
}
.declaration-header-sum-text {
font-size: 12px;
font-weight: 500;
color: var(--color-text-2);
line-height: 20px;
white-space: nowrap;
}
.declaration-header-currency {
width: 96px;
}
.declaration-header-amount {
width: 120px;
}
.declaration-table-wrap {
max-height: 280px;
overflow: hidden;
padding: 12px;
}
.declaration-sku-preview {
display: flex;
align-items: center;
justify-content: center;
min-height: 200px;
img {
max-width: 100%;
max-height: 70vh;
object-fit: contain;
}
}
@media (max-width: 900px) {
.detail-fields-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
.weight-info {
display: flex;
flex-direction: column;
gap: 14px;
}
.weight-summary {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 10px;
}
.weight-summary-card {
display: flex;
flex-direction: column;
gap: 4px;
min-height: 92px;
padding: 12px 14px;
border: 1px solid var(--color-border-2);
border-radius: 8px;
background: var(--app-card-bg);
text-align: left;
cursor: pointer;
transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
min-width: 0;
&:hover {
border-color: color-mix(in srgb, var(--app-primary-color) 35%, var(--color-border-2));
}
&.active {
border-color: var(--app-primary-color);
box-shadow: 0 0 0 1px color-mix(in srgb, var(--app-primary-color) 35%, transparent);
}
&.forecast {
background: linear-gradient(180deg, color-mix(in srgb, #165dff 7%, var(--app-card-bg)) 0%, var(--app-card-bg) 48%);
.weight-summary-value {
color: #165dff;
}
}
&.receive {
background: linear-gradient(180deg, color-mix(in srgb, #ff7d00 8%, var(--app-card-bg)) 0%, var(--app-card-bg) 48%);
.weight-summary-value {
color: #ff7d00;
}
}
&.ship {
background: linear-gradient(180deg, color-mix(in srgb, #00b42a 7%, var(--app-card-bg)) 0%, var(--app-card-bg) 48%);
.weight-summary-value {
color: #00b42a;
}
}
&.downstream {
background: linear-gradient(180deg, color-mix(in srgb, #722ed1 7%, var(--app-card-bg)) 0%, var(--app-card-bg) 48%);
.weight-summary-value {
color: #722ed1;
}
}
}
.weight-summary-label {
font-size: 12px;
color: var(--color-text-3);
line-height: 20px;
}
.weight-summary-value {
font-size: 18px;
font-weight: 700;
line-height: 26px;
font-variant-numeric: tabular-nums;
word-break: break-all;
}
.weight-summary-meta {
font-size: 12px;
color: var(--color-text-2);
line-height: 20px;
}
.weight-detail-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 32px;
}
.weight-detail-toolbar__title {
font-size: 13px;
font-weight: 600;
color: var(--color-text-1);
}
.weight-view-switch {
flex-shrink: 0;
max-width: 100%;
}
.weight-sections {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
&.is-single {
grid-template-columns: 1fr;
}
}
.weight-section {
border: 1px solid var(--color-border-2);
border-radius: 8px;
overflow: hidden;
background: var(--app-card-bg);
&.forecast .weight-section-dot {
background: #165dff;
}
&.receive .weight-section-dot {
background: #ff7d00;
}
&.ship .weight-section-dot {
background: #00b42a;
}
&.downstream .weight-section-dot {
background: #722ed1;
}
}
.weight-section-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 10px 12px;
background: var(--color-fill-1);
border-bottom: 1px solid var(--color-border-2);
}
.weight-section-title-wrap {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.weight-section-dot {
width: 6px;
height: 6px;
border-radius: 50%;
flex-shrink: 0;
}
.weight-section-title {
font-size: 13px;
font-weight: 600;
color: var(--color-text-1);
}
.weight-section-total {
font-size: 13px;
font-weight: 700;
color: var(--color-text-1);
font-variant-numeric: tabular-nums;
flex-shrink: 0;
}
.weight-metrics {
display: flex;
flex-direction: column;
gap: 12px;
padding: 12px;
}
.weight-metrics-group__label {
margin-bottom: 6px;
font-size: 12px;
font-weight: 500;
color: var(--color-text-3);
line-height: 18px;
}
.weight-metrics-grid {
display: grid;
gap: 8px;
&--dim {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
&--weight {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
.weight-metric-item {
display: flex;
flex-direction: column;
gap: 4px;
min-width: 0;
padding: 8px 10px;
border: 1px solid var(--color-border-2);
border-radius: 6px;
background: var(--color-fill-1);
&.highlight {
border-color: color-mix(in srgb, #00b42a 28%, var(--color-border-2));
background: color-mix(in srgb, #00b42a 8%, var(--app-card-bg));
}
&.is-editable {
background: var(--app-card-bg);
}
}
.metric-label {
font-size: 12px;
color: var(--color-text-3);
line-height: 18px;
}
.metric-value-wrap {
min-height: 24px;
}
.metric-value {
font-size: 13px;
color: var(--color-text-1);
font-weight: 600;
font-variant-numeric: tabular-nums;
word-break: break-all;
&.metric-value-highlight {
color: #00b42a;
}
}
.weight-section-empty {
padding: 16px 0;
}
.weight-empty-all {
margin-top: 4px;
}
@media (max-width: 900px) {
.weight-summary {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.weight-sections {
grid-template-columns: 1fr;
}
.weight-detail-toolbar {
flex-wrap: wrap;
}
}
.fee-info {
display: flex;
flex-direction: column;
gap: 14px;
}
.fee-meta-bar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px 16px;
padding: 10px 12px;
border: 1px solid var(--color-border-2);
border-radius: 8px;
background: var(--color-fill-1);
}
.fee-meta-group {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
min-width: 0;
}
.fee-meta-group--services {
margin-left: auto;
}
.fee-meta-chip {
display: inline-flex;
align-items: baseline;
gap: 6px;
max-width: 100%;
padding: 4px 8px;
border-radius: 6px;
background: var(--app-card-bg);
border: 1px solid var(--color-border-2);
font-size: 12px;
line-height: 1.4;
em {
color: var(--color-text-3);
font-style: normal;
flex-shrink: 0;
}
strong {
color: var(--color-text-1);
font-weight: 600;
word-break: break-all;
}
}
.fee-meta-label {
color: var(--color-text-3);
font-size: 12px;
flex-shrink: 0;
}
.fee-meta-empty {
color: var(--color-text-3);
font-size: 12px;
}
.fee-service-chip {
display: inline-flex;
align-items: center;
height: 24px;
padding: 0 8px;
border-radius: 999px;
color: var(--app-primary-color);
background: color-mix(in srgb, var(--app-primary-color) 10%, transparent);
font-size: 12px;
line-height: 1;
}
.fee-summary {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
}
.fee-summary-card {
display: flex;
flex-direction: column;
gap: 4px;
min-height: 108px;
padding: 14px 16px;
border: 1px solid var(--color-border-2);
border-radius: 8px;
background: var(--app-card-bg);
text-align: left;
cursor: pointer;
transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
&:hover {
border-color: color-mix(in srgb, var(--app-primary-color) 35%, var(--color-border-2));
}
&.active {
border-color: var(--app-primary-color);
box-shadow: 0 0 0 1px color-mix(in srgb, var(--app-primary-color) 35%, transparent);
background: color-mix(in srgb, var(--app-primary-color) 4%, var(--app-card-bg));
}
&.receivable {
background:
linear-gradient(180deg, color-mix(in srgb, #00b42a 6%, var(--app-card-bg)) 0%, var(--app-card-bg) 42%);
.fee-summary-amount {
color: #00b42a;
}
}
&.payable {
background:
linear-gradient(180deg, color-mix(in srgb, #f53f3f 6%, var(--app-card-bg)) 0%, var(--app-card-bg) 42%);
.fee-summary-amount {
color: #f53f3f;
}
}
&.gross-profit {
cursor: default;
background:
linear-gradient(180deg, color-mix(in srgb, #ff7d00 7%, var(--app-card-bg)) 0%, var(--app-card-bg) 42%);
&:hover {
border-color: var(--color-border-2);
box-shadow: none;
}
.fee-summary-amount,
.fee-summary-meta {
color: #ff7d00;
}
&.is-negative {
.fee-summary-amount,
.fee-summary-meta {
color: #f53f3f;
}
}
}
}
.fee-summary-label {
font-size: 12px;
color: var(--color-text-3);
line-height: 20px;
}
.fee-summary-amount {
font-size: 20px;
font-weight: 700;
line-height: 28px;
font-variant-numeric: tabular-nums;
word-break: break-all;
}
.fee-summary-meta {
font-size: 12px;
color: var(--color-text-2);
line-height: 20px;
}
.fee-summary-discount {
font-size: 12px;
color: #ff7d00;
line-height: 20px;
}
.fee-summary-formula {
display: inline-flex;
align-items: center;
flex-wrap: wrap;
gap: 4px;
margin-top: 2px;
font-size: 12px;
color: var(--color-text-3);
line-height: 18px;
i {
font-style: normal;
color: var(--color-text-4);
}
.amount-receivable {
color: #00b42a;
}
.amount-payable {
color: #f53f3f;
}
}
.fee-forecast-panel {
border: 1px solid var(--color-border-2);
border-radius: 8px;
background: var(--app-card-bg);
overflow: hidden;
}
.fee-forecast-panel__head {
padding: 10px 12px;
border-bottom: 1px solid var(--color-border-2);
background: var(--color-fill-1);
font-size: 12px;
font-weight: 600;
color: var(--color-text-2);
}
.fee-forecast-panel__grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0;
}
.fee-forecast-card {
display: flex;
flex-direction: column;
gap: 8px;
padding: 12px 14px;
& + & {
border-left: 1px solid var(--color-border-2);
}
}
.fee-forecast-card__title {
font-size: 13px;
font-weight: 600;
color: var(--color-text-1);
}
.fee-forecast-card__row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
font-size: 12px;
color: var(--color-text-3);
strong {
color: var(--color-text-1);
font-weight: 600;
font-variant-numeric: tabular-nums;
}
}
.fee-forecast-card__diff {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 2px;
padding-top: 8px;
border-top: 1px dashed var(--color-border-2);
font-size: 12px;
color: var(--color-text-3);
strong {
font-weight: 700;
font-variant-numeric: tabular-nums;
color: var(--color-text-1);
}
&.is-up strong {
color: #f53f3f;
}
&.is-down strong {
color: #00b42a;
}
}
.fee-warn {
border-radius: 8px;
}
.fee-detail-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 32px;
}
.fee-detail-toolbar__title {
font-size: 13px;
font-weight: 600;
color: var(--color-text-1);
}
.fee-view-switch {
flex-shrink: 0;
max-width: 100%;
}
.fee-section {
border: 1px solid var(--color-border-2);
border-radius: 8px;
overflow: hidden;
background: var(--app-card-bg);
&.receivable {
.fee-section-dot {
background: #00b42a;
}
.fee-section-count {
color: #00b42a;
background: color-mix(in srgb, #00b42a 10%, transparent);
}
}
&.payable {
.fee-section-dot {
background: #f53f3f;
}
.fee-section-count {
color: #f53f3f;
background: color-mix(in srgb, #f53f3f 10%, transparent);
}
}
}
.fee-section-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 10px 12px;
background: var(--color-fill-1);
border-bottom: 1px solid var(--color-border-2);
}
.fee-section-title-wrap {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.fee-section-dot {
width: 6px;
height: 6px;
border-radius: 50%;
flex-shrink: 0;
}
.fee-section-title {
font-size: 13px;
font-weight: 600;
color: var(--color-text-1);
}
.fee-section-count {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 20px;
height: 20px;
padding: 0 6px;
border-radius: 999px;
font-size: 12px;
font-weight: 600;
line-height: 1;
}
.fee-section-total {
font-size: 13px;
font-weight: 700;
color: var(--color-text-1);
font-variant-numeric: tabular-nums;
flex-shrink: 0;
}
@media (max-width: 720px) {
.fee-summary {
grid-template-columns: 1fr;
}
.fee-forecast-panel__grid {
grid-template-columns: 1fr;
}
.fee-forecast-card + .fee-forecast-card {
border-left: none;
border-top: 1px solid var(--color-border-2);
}
.fee-meta-group--services {
margin-left: 0;
}
.fee-detail-toolbar {
flex-wrap: wrap;
}
}
.fee-table-wrap {
max-height: 220px;
overflow: auto;
&::-webkit-scrollbar {
width: 6px;
height: 6px;
}
&::-webkit-scrollbar-thumb {
background: #c9cdd4;
border-radius: 3px;
}
}
.fee-table {
min-width: 100%;
.table-header,
.table-row {
display: grid;
grid-template-columns: 1.2fr 0.9fr 0.6fr 0.8fr 1fr 1fr 1.3fr;
align-items: center;
}
.table-header {
position: sticky;
top: 0;
z-index: 1;
background: var(--color-fill-2);
font-size: 12px;
font-weight: 500;
color: var(--color-text-3);
border-bottom: 1px solid var(--color-border-2);
}
.table-row {
font-size: 12px;
color: var(--color-text-2);
border-bottom: 1px solid var(--color-border-2);
&:last-child {
border-bottom: none;
}
&:hover {
background: var(--color-fill-2);
}
}
.header-cell,
.table-cell {
padding: 8px 12px;
min-width: 0;
word-break: break-all;
&.amount {
text-align: right;
}
&.priceEffectiveTime {
min-width: 152px;
white-space: nowrap;
word-break: normal;
}
}
.header-cell.amount {
text-align: right;
}
}
.fee-amount {
font-weight: 600;
font-variant-numeric: tabular-nums;
&.amount-receivable {
color: #00b42a;
}
&.amount-discount {
color: #ff7d00;
}
&.amount-payable {
color: #f53f3f;
}
}
.fee-section-empty {
padding: 16px 0;
}
.fee-empty-all {
margin-top: 8px;
}
.track-info {
display: flex;
flex-direction: column;
gap: 12px;
min-height: 200px;
}
.track-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 10px 12px;
border: 1px solid var(--color-border-2);
border-radius: 6px;
background: var(--color-fill-2);
}
.track-toolbar-left {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.track-toolbar-label {
font-size: 12px;
color: var(--color-text-3);
flex-shrink: 0;
}
.track-toolbar-value {
font-size: 13px;
font-weight: 600;
color: var(--color-text-1);
word-break: break-all;
}
.track-toolbar-right {
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
}
.track-spin {
width: 100%;
min-height: 160px;
}
.track-empty {
padding: 24px 0;
}
.track-timeline {
padding: 4px 0 8px;
.track-item {
display: flex;
margin-bottom: 0;
&.active {
.track-status {
color: var(--app-primary-color, #2d8c8c);
}
.track-content {
color: var(--color-text-1);
}
}
.track-left {
display: flex;
flex-direction: column;
align-items: center;
width: 16px;
margin-right: 14px;
flex-shrink: 0;
padding-top: 5px;
.track-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--color-fill-3);
border: 2px solid var(--color-border-2);
box-sizing: border-box;
flex-shrink: 0;
&.active {
width: 12px;
height: 12px;
background: var(--app-primary-color, #2d8c8c);
border-color: color-mix(in srgb, var(--app-primary-color, #2d8c8c) 35%, #fff);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-primary-color, #2d8c8c) 18%, transparent);
}
}
.track-line {
width: 2px;
flex: 1;
min-height: 18px;
background: var(--color-fill-3);
margin: 4px 0 0;
&.active {
background: color-mix(in srgb, var(--app-primary-color, #2d8c8c) 45%, var(--color-fill-3));
}
}
}
.track-right {
flex: 1;
min-width: 0;
padding-bottom: 18px;
}
.track-row-head {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
.track-status {
font-size: 14px;
font-weight: 600;
color: var(--color-text-2);
line-height: 22px;
word-break: break-word;
}
.track-content {
margin-top: 4px;
font-size: 13px;
line-height: 20px;
color: var(--color-text-2);
word-break: break-word;
&--en {
margin-top: 2px;
font-size: 12px;
line-height: 18px;
color: var(--color-text-3);
}
}
.track-meta-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 4px 10px;
margin-top: 6px;
font-size: 12px;
line-height: 18px;
color: var(--color-text-3);
}
.track-meta-place {
color: var(--color-text-2);
}
.track-meta-code {
padding: 0 6px;
border-radius: 3px;
background: var(--color-fill-2);
color: var(--color-text-3);
font-family: var(--app-font-mono);
font-size: 11px;
line-height: 18px;
}
.track-remark {
margin-top: 4px;
font-size: 12px;
line-height: 18px;
color: var(--color-text-3);
word-break: break-word;
}
}
.track-item:last-child .track-right {
padding-bottom: 0;
}
}
.operation-log-filter {
display: inline-flex;
align-items: center;
gap: 2px;
margin-bottom: 10px;
padding: 2px;
border-radius: 8px;
background: var(--color-fill-2, #e5e6eb);
flex-shrink: 0;
}
.operation-log-filter__btn {
height: 26px;
padding: 0 12px;
border: 0;
border-radius: 6px;
background: transparent;
color: var(--color-text-2);
font-size: 12px;
font-weight: 500;
cursor: pointer;
&.is-active {
background: #fff;
color: var(--color-text-1);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
}
.operation-log-info {
display: flex;
flex-direction: column;
min-height: 0;
height: 100%;
}
.operation-log-spin {
width: 100%;
flex: 1;
min-height: 0;
:deep(.arco-spin-children) {
height: 100%;
}
}
.operation-log-table {
width: 100%;
:deep(.arco-table-th) {
background: var(--color-fill-2);
font-weight: 500;
}
:deep(.arco-table-td) {
font-size: 13px;
vertical-align: top;
}
:deep(.operation-log-time-cell .arco-table-td-content) {
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
}
.additional-services-hint {
margin: 0 0 12px;
font-size: 13px;
line-height: 1.5;
color: var(--color-text-3);
}
.additional-services-current {
margin-bottom: 16px;
padding: 10px 12px;
border-radius: 4px;
background: var(--color-fill-1);
}
.additional-services-current__label,
.additional-services-orphan__label,
.additional-services-options-label {
margin-bottom: 8px;
font-size: 13px;
font-weight: 500;
color: var(--color-text-1);
}
.additional-services-current__empty {
font-size: 13px;
color: var(--color-text-3);
}
.additional-services-orphan {
margin-bottom: 16px;
padding: 10px 12px;
border-radius: 4px;
background: rgba(255, 125, 0, 0.08);
}
.additional-services-checkbox-group {
display: flex;
flex-direction: column;
gap: 8px;
}
</style>