7-8 修复成本核算显示功能

This commit is contained in:
wsb1224 2026-07-14 12:36:08 +08:00
parent e204d1a7c1
commit ab2c5eac9f
4 changed files with 100 additions and 16 deletions

View File

@ -60,6 +60,28 @@ function getStatusBadge(status) {
return map[status] || "badge-gray";
}
var LOGISTICS_STATUS_MAP = {
pending: '待接单', accepted: '已接单', picked_up: '已揾货',
canceled: '已取消',
};
var SOURCE_PLATFORM_MAP = {
driver: '司机上报', backend: '后台录入', kuaidi100: '快递100',
third_party: '第三方', manual: '手动录入',
};
function mapLogisticsStatus(value) { return LOGISTICS_STATUS_MAP[value] || value || '-'; }
function mapSourcePlatform(value) { return SOURCE_PLATFORM_MAP[value] || value || ''; }
function getExpressCompanyName(value) {
var raw = (value || "").toString().trim();
if (!raw) return "";
for (var i = 0; i < EXPRESS_COMPANY_OPTIONS.length; i++) {
if (EXPRESS_COMPANY_OPTIONS[i].code === raw || EXPRESS_COMPANY_OPTIONS[i].name === raw) return EXPRESS_COMPANY_OPTIONS[i].name;
}
return raw;
}
function fmt(v) { return Number(v || 0).toFixed(2); }
/** 计算总需求面积0.35m × 0.55m × 500 = 96.25 m² */
@ -87,6 +109,8 @@ Page({
products: [],
approveLogs: [],
logistics: null,
logisticsStatusText: "",
logisticsExpressName: "",
traceList: [],
factoryList: [],
selectedFactoryIndex: -1,
@ -232,17 +256,17 @@ Page({
profitArrow: profit >= 0 ? "↑" : "↓",
feeItems: feeItems,
rawItems: data.items || [],
expressCompanyName: getExpressCompanyName(data.express_company),
}),
products: products,
approveLogs: approveLogs,
logistics: logistics,
traceList: [],
logisticsStatusText: logistics ? mapLogisticsStatus(logistics.status) : "",
logisticsExpressName: logistics ? getExpressCompanyName(logistics.express_company) : "",
traceList: (data.logistics_info && data.logistics_info.trace_list || []).map(function(item) {
return Object.assign({}, item, { source_platform_text: mapSourcePlatform(item.source_platform) });
}),
});
// 加载物流轨迹:有物流任务单号或订单单号都加载
if ((logistics && logistics.tracking_number) || (data && data.tracking_number)) {
this.loadTrace();
}
} catch (error) {
this.setData({ message: error.message || "加载失败" });
} finally {

View File

@ -148,23 +148,23 @@
<view class="action-link" bindtap="openPendingTrackingEdit">填写快递单号</view>
</view>
<!-- 物流信息 -->
<!-- 物流信息(有物流任务时) -->
<view wx:if="{{logistics}}" class="card info-card">
<view class="section-title-row">
<text class="section-title">物流信息</text>
<text class="action-link" bindtap="openLogisticsTrackingEdit">修改单号</text>
</view>
<view class="info-row" wx:if="{{logistics.express_company}}">
<view class="info-row" wx:if="{{logisticsExpressName}}">
<text class="info-label">快递公司</text>
<text class="info-value">{{logistics.express_company}}</text>
<text class="info-value">{{logisticsExpressName}}</text>
</view>
<view class="info-row" wx:if="{{logistics.tracking_number}}">
<text class="info-label">快递单号</text>
<text class="info-value">{{logistics.tracking_number}}</text>
</view>
<view class="info-row" wx:if="{{logistics.task_status}}">
<view class="info-row" wx:if="{{logisticsStatusText}}">
<text class="info-label">任务状态</text>
<text class="info-value">{{logistics.task_status}}</text>
<text class="info-value">{{logisticsStatusText}}</text>
</view>
<view wx:if="{{traceList.length}}" class="trace-timeline">
<view wx:for="{{traceList}}" wx:key="index" class="trace-item">
@ -173,13 +173,38 @@
<view class="trace-card">
<text class="trace-time">{{item.node_time}}</text>
<text class="trace-desc">{{item.node_desc}}</text>
<text wx:if="{{item.source_platform}}" class="trace-source">{{item.source_platform}}</text>
<text wx:if="{{item.source_platform_text}}" class="trace-source">{{item.source_platform_text}}</text>
</view>
</view>
</view>
<view wx:elif="{{logistics.tracking_number}}" class="empty-hint">暂无物流轨迹</view>
</view>
<!-- 自发订单物流轨迹(无物流任务但有快递单号时) -->
<view wx:if="{{!logistics && orderInfo.tracking_number}}" class="card info-card">
<view class="section-title">快递信息</view>
<view class="info-row" wx:if="{{orderInfo.expressCompanyName}}">
<text class="info-label">快递公司</text>
<text class="info-value">{{orderInfo.expressCompanyName}}</text>
</view>
<view class="info-row">
<text class="info-label">快递单号</text>
<text class="info-value">{{orderInfo.tracking_number}}</text>
</view>
<view wx:if="{{traceList.length}}" class="trace-timeline">
<view wx:for="{{traceList}}" wx:key="index" class="trace-item">
<view class="trace-dot {{index === 0 ? 'trace-dot-active' : ''}}"></view>
<view wx:if="{{index < traceList.length - 1}}" class="trace-line"></view>
<view class="trace-card">
<text class="trace-time">{{item.node_time}}</text>
<text class="trace-desc">{{item.node_desc}}</text>
<text wx:if="{{item.source_platform_text}}" class="trace-source">{{item.source_platform_text}}</text>
</view>
</view>
</view>
<view wx:else class="empty-hint">暂无物流轨迹</view>
</view>
<!-- 自发订单提示(待审批+自发) -->
<view wx:if="{{orderInfo.self_delivery && orderInfo.order_status !== 'canceled' && orderInfo.order_status !== 'settled'}}" class="card action-card">
<view class="approval-hint">马甸工厂自发 — 已填写快递单号({{orderInfo.tracking_number}}),审批通过后跳过工厂下发</view>

View File

@ -191,9 +191,9 @@
.field-group:last-child { margin-bottom: 0; }
.field-label { font-size: 24rpx; color: #64748b; font-weight: 600; margin-bottom: 8rpx; }
.field-input {
width: 100%; padding: 16rpx 20rpx; background: #f8fafc;
width: 100%; height: 72rpx; padding: 0 20rpx; background: #f8fafc;
border: 1rpx solid #d1d5db; border-radius: 12rpx;
font-size: 28rpx; color: #0f172a; box-sizing: border-box;
font-size: 28rpx; color: #0f172a; line-height: 72rpx; box-sizing: border-box;
}
/* 取消按钮 */
@ -299,7 +299,8 @@
}
.edit-items-scroll {
max-height: 60vh;
flex: 1;
overflow-y: auto;
margin-top: 16rpx;
}

View File

@ -1 +1,35 @@

export const expressCompanyOptions = [
{ name: "顺丰速运", code: "shunfeng" },
{ name: "顺丰快运", code: "shunfengkuaiyun" },
{ name: "圆通速递", code: "yuantong" },
{ name: "中通快递", code: "zhongtong" },
{ name: "中通快运", code: "zhongtongkuaiyun" },
{ name: "韵达快递", code: "yunda" },
{ name: "韵达快运", code: "yundakuaiyun" },
{ name: "申通快递", code: "shentong" },
{ name: "极兔速递", code: "jtexpress" },
{ name: "安能物流", code: "annengwuliu" },
{ name: "德邦快递", code: "debangwuliu" },
{ name: "德邦物流", code: "debangwuliu" },
{ name: "壹米滴答", code: "yimidida" },
{ name: "百世快运", code: "baishiwuliu" },
{ name: "跨越速运", code: "kuayue" },
{ name: "京东快运", code: "jingdongkuaiyun" },
{ name: "天地华宇", code: "tiandihuayu" },
{ name: "顺心捷达", code: "sxjdfreight" },
{ name: "优速快递", code: "yousuwuliu" },
{ name: "佳怡物流", code: "jiayiwuliu" },
{ name: "佳运美物流", code: "jiayunmeiwuliu" },
{ name: "信丰物流", code: "xinfengwuliu" },
{ name: "速尔快递", code: "suer" },
{ name: "品骏快递", code: "pjbest" },
{ name: "龙邦快递", code: "lbex" },
{ name: "京东物流", code: "jd" },
{ name: "EMS", code: "ems" },
{ name: "宅急送", code: "zhaijisong" },
];
export function getExpressCompanyName(value) {
const option = expressCompanyOptions.find((item) => item.code === value || item.name === value);
return option?.name || value || "";
}