All checks were successful
Build and Deploy Front / deploy (push) Successful in 12m22s
渠道表单支持计重规则/进位与黑名单;订单/揽收/排货/试算区分应收与应付计费重。 Co-authored-by: Cursor <cursoragent@cursor.com>
459 lines
12 KiB
Vue
459 lines
12 KiB
Vue
<script setup lang="ts">
|
|
import { computed, ref, watch } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { Message } from '@arco-design/web-vue'
|
|
import { IconRefresh } from '@arco-design/web-vue/es/icon'
|
|
import { getOrderAllocationTrace, type OrderAllocationTrace } from '@/api/order'
|
|
|
|
const props = defineProps<{
|
|
visible: boolean
|
|
orderId?: number | null
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
'update:visible': [value: boolean]
|
|
}>()
|
|
|
|
const { t } = useI18n()
|
|
const loading = ref(false)
|
|
const trace = ref<OrderAllocationTrace | null>(null)
|
|
const expandedKeys = ref<number[]>([])
|
|
|
|
const scheme = computed(() => trace.value?.scheme || 'costLowest')
|
|
|
|
const primaryMetricLabel = computed(() => {
|
|
switch (scheme.value) {
|
|
case 'timeFastest':
|
|
return t('order.myOrders.allocationTrace.col.minTime')
|
|
case 'overallBest':
|
|
return t('order.myOrders.allocationTrace.col.weight')
|
|
default:
|
|
return t('order.myOrders.allocationTrace.col.payable')
|
|
}
|
|
})
|
|
|
|
function formatMetric(row: OrderAllocationTrace['candidates'][number]) {
|
|
switch (scheme.value) {
|
|
case 'timeFastest':
|
|
return row.minTime == null ? '-' : t('order.myOrders.allocationTrace.days', { n: row.minTime })
|
|
case 'overallBest':
|
|
return String(row.weight ?? 0)
|
|
default:
|
|
return formatMoney(row.totalPayableCost)
|
|
}
|
|
}
|
|
|
|
function formatMoney(n: number) {
|
|
if (!Number.isFinite(n)) return '-'
|
|
return n.toFixed(2)
|
|
}
|
|
|
|
function formatWeight(n?: number | null) {
|
|
if (n == null || !Number.isFinite(Number(n))) return '-'
|
|
return `${Number(n)} KG`
|
|
}
|
|
|
|
function stageLabel(stage?: string) {
|
|
switch (stage) {
|
|
case 'condition':
|
|
return t('order.myOrders.allocationTrace.stage.condition')
|
|
case 'customer':
|
|
return t('order.myOrders.allocationTrace.stage.customer')
|
|
case 'channel':
|
|
return t('order.myOrders.allocationTrace.stage.channel')
|
|
case 'buyPrice':
|
|
return t('order.myOrders.allocationTrace.stage.buyPrice')
|
|
default:
|
|
return stage || ''
|
|
}
|
|
}
|
|
|
|
async function loadTrace(live = false) {
|
|
if (!props.orderId) return
|
|
loading.value = true
|
|
try {
|
|
trace.value = await getOrderAllocationTrace({ id: props.orderId, live })
|
|
const selected = trace.value.candidates.find((c) => c.selected)
|
|
expandedKeys.value = selected ? [selected.serviceChannelId] : []
|
|
} catch (e: any) {
|
|
trace.value = null
|
|
Message.error(e?.message || t('order.myOrders.allocationTrace.loadFailed'))
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
watch(
|
|
() => [props.visible, props.orderId] as const,
|
|
([open, id]) => {
|
|
if (open && id) {
|
|
loadTrace(false)
|
|
}
|
|
if (!open) {
|
|
trace.value = null
|
|
expandedKeys.value = []
|
|
}
|
|
},
|
|
)
|
|
|
|
function handleClose() {
|
|
emit('update:visible', false)
|
|
}
|
|
|
|
function toggleExpand(id: number) {
|
|
if (expandedKeys.value.includes(id)) {
|
|
expandedKeys.value = expandedKeys.value.filter((x) => x !== id)
|
|
} else {
|
|
expandedKeys.value = [...expandedKeys.value, id]
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<a-modal
|
|
:visible="visible"
|
|
:title="$t('order.myOrders.allocationTrace.title')"
|
|
:width="780"
|
|
:footer="false"
|
|
unmount-on-close
|
|
@cancel="handleClose"
|
|
@update:visible="(v: boolean) => emit('update:visible', v)"
|
|
>
|
|
<a-spin :loading="loading" style="width: 100%">
|
|
<div v-if="trace" class="alloc-trace">
|
|
<div class="alloc-trace__banner" :class="trace.fromSnapshot ? 'is-snapshot' : 'is-live'">
|
|
<span>
|
|
{{
|
|
trace.fromSnapshot
|
|
? $t('order.myOrders.allocationTrace.fromSnapshot')
|
|
: $t('order.myOrders.allocationTrace.fromLive')
|
|
}}
|
|
</span>
|
|
<a-button type="text" size="mini" :loading="loading" @click="loadTrace(true)">
|
|
<template #icon><icon-refresh /></template>
|
|
{{ $t('order.myOrders.allocationTrace.recalcLive') }}
|
|
</a-button>
|
|
</div>
|
|
|
|
<div class="alloc-trace__meta">
|
|
<div class="alloc-trace__meta-item">
|
|
<span class="label">{{ $t('order.myOrders.allocationTrace.scheme') }}</span>
|
|
<span class="value">{{ trace.schemeName || trace.scheme || '-' }}</span>
|
|
</div>
|
|
<div class="alloc-trace__meta-item">
|
|
<span class="label">{{ $t('order.myOrders.allocationTrace.source') }}</span>
|
|
<span class="value">{{ trace.schemeSourceName || trace.schemeSource || '-' }}</span>
|
|
</div>
|
|
<div class="alloc-trace__meta-item">
|
|
<span class="label">{{ $t('order.myOrders.allocationTrace.weight') }}</span>
|
|
<span class="value">{{ formatWeight(trace.payableChargeableWeight ?? trace.chargeableWeight) }}</span>
|
|
</div>
|
|
<div class="alloc-trace__meta-item">
|
|
<span class="label">{{ $t('order.myOrders.allocationTrace.stage') }}</span>
|
|
<span class="value">{{ trace.chargingStageName || trace.chargingStage || '-' }}</span>
|
|
</div>
|
|
<div
|
|
v-if="trace.poolCount != null || trace.conditionPassCount != null"
|
|
class="alloc-trace__meta-item"
|
|
>
|
|
<span class="label">{{ $t('order.myOrders.allocationTrace.poolSummary', {
|
|
pool: trace.poolCount ?? 0,
|
|
pass: trace.conditionPassCount ?? 0,
|
|
cand: trace.candidateCount ?? trace.candidates.length,
|
|
}) }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<a-alert
|
|
v-if="trace.failReason"
|
|
type="warning"
|
|
style="margin-bottom: 12px"
|
|
>
|
|
{{ trace.failReason }}
|
|
</a-alert>
|
|
|
|
<div v-else class="alloc-trace__conclusion">
|
|
{{
|
|
$t('order.myOrders.allocationTrace.conclusion', {
|
|
scheme: trace.schemeName || '-',
|
|
channel: trace.selectedChannelName || trace.selectedChannelCode || '-',
|
|
count: trace.candidates.length,
|
|
})
|
|
}}
|
|
</div>
|
|
|
|
<div class="alloc-trace__table-head">
|
|
<span class="col-channel">{{ $t('order.myOrders.allocationTrace.col.channel') }}</span>
|
|
<span class="col-metric primary">{{ primaryMetricLabel }}</span>
|
|
<span class="col-metric">{{ $t('order.myOrders.allocationTrace.col.payable') }}</span>
|
|
<span class="col-metric">{{ $t('order.myOrders.allocationTrace.col.minTime') }}</span>
|
|
<span class="col-metric">{{ $t('order.myOrders.allocationTrace.col.weight') }}</span>
|
|
</div>
|
|
|
|
<div v-if="!trace.candidates.length" class="alloc-trace__empty">
|
|
{{ $t('order.myOrders.allocationTrace.emptyCandidates') }}
|
|
</div>
|
|
|
|
<div
|
|
v-for="row in trace.candidates"
|
|
:key="row.serviceChannelId"
|
|
class="alloc-trace__row"
|
|
:class="{ selected: row.selected }"
|
|
>
|
|
<div class="alloc-trace__row-main" @click="toggleExpand(row.serviceChannelId)">
|
|
<span class="col-channel">
|
|
<a-tag v-if="row.selected" size="small" color="arcoblue" class="sel-tag">
|
|
{{ $t('order.myOrders.allocationTrace.selected') }}
|
|
</a-tag>
|
|
<span class="channel-text">
|
|
{{ row.channelName || row.channelCode }}
|
|
<span v-if="row.channelName && row.channelCode" class="channel-code">
|
|
{{ row.channelCode }}
|
|
</span>
|
|
</span>
|
|
</span>
|
|
<span class="col-metric primary">{{ formatMetric(row) }}</span>
|
|
<span class="col-metric">{{ formatMoney(row.totalPayableCost) }}</span>
|
|
<span class="col-metric">
|
|
{{ row.minTime == null ? '-' : $t('order.myOrders.allocationTrace.days', { n: row.minTime }) }}
|
|
</span>
|
|
<span class="col-metric">{{ row.weight }}</span>
|
|
</div>
|
|
<div
|
|
v-if="expandedKeys.includes(row.serviceChannelId) && row.feeLines?.length"
|
|
class="alloc-trace__fees"
|
|
>
|
|
<div v-for="(fee, idx) in row.feeLines" :key="idx" class="fee-line">
|
|
<span>{{ fee.costItem || '-' }}</span>
|
|
<span>{{ formatMoney(fee.amount) }} {{ fee.currency || '' }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="trace.skipped?.length" class="alloc-trace__skipped">
|
|
<div class="alloc-trace__skipped-title">
|
|
{{ $t('order.myOrders.allocationTrace.skippedTitle') }}
|
|
</div>
|
|
<div
|
|
v-for="(s, idx) in trace.skipped"
|
|
:key="idx"
|
|
class="alloc-trace__skipped-row"
|
|
>
|
|
<div class="skipped-main">
|
|
<span class="skipped-channel">
|
|
{{ s.channelName || s.channelCode || s.serviceChannelId || '-' }}
|
|
</span>
|
|
<a-tag v-if="s.stage" size="small" color="gray">{{ stageLabel(s.stage) }}</a-tag>
|
|
<span class="reason">{{ s.reason }}</span>
|
|
</div>
|
|
<div v-if="s.matchCondition" class="skipped-formula" :title="s.matchCondition">
|
|
{{ s.matchCondition }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<p v-if="trace.traceTime" class="alloc-trace__time">
|
|
{{ $t('order.myOrders.allocationTrace.traceTime') }}?{{ trace.traceTime }}
|
|
</p>
|
|
</div>
|
|
</a-spin>
|
|
</a-modal>
|
|
</template>
|
|
|
|
<style scoped lang="less">
|
|
.alloc-trace__banner {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 8px;
|
|
margin-bottom: 12px;
|
|
padding: 8px 12px;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
|
|
&.is-snapshot {
|
|
background: #e8fffb;
|
|
color: #0d9494;
|
|
}
|
|
|
|
&.is-live {
|
|
background: #fff7e8;
|
|
color: #ff7d00;
|
|
}
|
|
}
|
|
|
|
.alloc-trace__meta {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
gap: 8px 16px;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.alloc-trace__meta-item {
|
|
display: flex;
|
|
gap: 8px;
|
|
font-size: 13px;
|
|
|
|
.label {
|
|
color: var(--color-text-3);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.value {
|
|
color: var(--color-text-1);
|
|
font-weight: 500;
|
|
}
|
|
}
|
|
|
|
.alloc-trace__conclusion {
|
|
margin-bottom: 12px;
|
|
padding: 10px 12px;
|
|
background: var(--color-fill-2);
|
|
border-radius: 4px;
|
|
font-size: 13px;
|
|
color: var(--color-text-1);
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.alloc-trace__table-head,
|
|
.alloc-trace__row-main {
|
|
display: grid;
|
|
grid-template-columns: minmax(160px, 1.6fr) 1fr 1fr 1fr 0.8fr;
|
|
gap: 8px;
|
|
align-items: center;
|
|
}
|
|
|
|
.alloc-trace__table-head {
|
|
padding: 8px 10px;
|
|
font-size: 12px;
|
|
color: var(--color-text-3);
|
|
background: var(--color-fill-2);
|
|
border-radius: 4px 4px 0 0;
|
|
}
|
|
|
|
.alloc-trace__row {
|
|
border: 1px solid var(--color-border-2);
|
|
border-top: none;
|
|
|
|
&.selected {
|
|
background: #f0f9ff;
|
|
border-color: #bedaff;
|
|
}
|
|
|
|
&:last-of-type {
|
|
border-radius: 0 0 4px 4px;
|
|
}
|
|
}
|
|
|
|
.alloc-trace__row-main {
|
|
padding: 10px;
|
|
cursor: pointer;
|
|
font-size: 13px;
|
|
|
|
&:hover {
|
|
background: rgba(0, 0, 0, 0.02);
|
|
}
|
|
}
|
|
|
|
.col-metric.primary {
|
|
font-weight: 600;
|
|
color: var(--app-primary-color);
|
|
}
|
|
|
|
.col-channel {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.channel-text {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.channel-code {
|
|
margin-left: 4px;
|
|
color: var(--color-text-3);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.sel-tag {
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.alloc-trace__fees {
|
|
padding: 0 12px 10px 28px;
|
|
font-size: 12px;
|
|
color: var(--color-text-2);
|
|
}
|
|
|
|
.fee-line {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding: 2px 0;
|
|
}
|
|
|
|
.alloc-trace__empty {
|
|
padding: 24px;
|
|
text-align: center;
|
|
color: var(--color-text-3);
|
|
border: 1px solid var(--color-border-2);
|
|
border-top: none;
|
|
}
|
|
|
|
.alloc-trace__skipped {
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.alloc-trace__skipped-title {
|
|
margin-bottom: 8px;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
color: var(--color-text-1);
|
|
}
|
|
|
|
.alloc-trace__skipped-row {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
padding: 8px 0;
|
|
font-size: 12px;
|
|
color: var(--color-text-2);
|
|
border-bottom: 1px dashed var(--color-border-2);
|
|
|
|
.skipped-main {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.skipped-channel {
|
|
min-width: 0;
|
|
font-weight: 500;
|
|
color: var(--color-text-1);
|
|
}
|
|
|
|
.reason {
|
|
color: #f77234;
|
|
}
|
|
|
|
.skipped-formula {
|
|
padding-left: 2px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
font-family: var(--app-font-mono);
|
|
color: var(--color-text-3);
|
|
}
|
|
}
|
|
|
|
.alloc-trace__time {
|
|
margin: 12px 0 0;
|
|
font-size: 12px;
|
|
color: #c9cdd4;
|
|
}
|
|
</style>
|