Commit 57265fcdc8176a5c8dc41d602bd1e4acf9c0382f

Authored by shaofan
1 parent 2a496b6c

新增配送阶段信息展示,优化订单和配送订单列表,增加相关字段和格式化函数。

.claude/settings.local.json 0 → 100644
  1 +{
  2 + "permissions": {
  3 + "allow": [
  4 + "Bash(npm run *)"
  5 + ]
  6 + }
  7 +}
... ...
src/views/delivery/DeliveryOrderList.vue
... ... @@ -32,6 +32,9 @@
32 32 <template v-if="column.key === 'status'">
33 33 <a-tag :color="statusColor[record.status]">{{ statusMap[record.status] }}</a-tag>
34 34 </template>
  35 + <template v-if="column.key === 'deliveryStage'">
  36 + <a-tag :color="deliveryStageOf(record).color">{{ deliveryStageOf(record).text }}</a-tag>
  37 + </template>
35 38 <template v-if="column.key === 'action'">
36 39 <a-space>
37 40 <a @click="openDetail(record)">详情</a>
... ... @@ -56,9 +59,21 @@
56 59 <a-descriptions-item label="配送订单号">{{ queryResult.orderNo }}</a-descriptions-item>
57 60 <a-descriptions-item label="外部订单号">{{ queryResult.outOrderNo }}</a-descriptions-item>
58 61 <a-descriptions-item label="状态">{{ statusMap[queryResult.status] }}</a-descriptions-item>
  62 + <a-descriptions-item label="配送阶段">
  63 + <a-tag :color="deliveryStageOf(queryResult).color">{{ deliveryStageOf(queryResult).text }}</a-tag>
  64 + </a-descriptions-item>
59 65 <a-descriptions-item label="配送费">¥{{ queryResult.totalFee }}</a-descriptions-item>
60 66 <a-descriptions-item label="距离">{{ queryResult.distance }} km</a-descriptions-item>
61 67 <a-descriptions-item label="预计时间">{{ queryResult.estimatedMinutes }} 分钟</a-descriptions-item>
  68 + <a-descriptions-item label="骑手ID">{{ queryResult.riderId || '-' }}</a-descriptions-item>
  69 + <a-descriptions-item label="接单时间">{{ formatNodeTime(queryResult.grapTime) }}</a-descriptions-item>
  70 + <a-descriptions-item label="到店时间">{{ formatNodeTime(queryResult.arriveShopTime) }}</a-descriptions-item>
  71 + <a-descriptions-item label="到店位置">
  72 + {{ queryResult.arriveShopLng && queryResult.arriveShopLat ? `${queryResult.arriveShopLng}, ${queryResult.arriveShopLat}` : '-' }}
  73 + </a-descriptions-item>
  74 + <a-descriptions-item label="到店距离">{{ formatArriveDistance(queryResult.arriveShopDistance) }}</a-descriptions-item>
  75 + <a-descriptions-item label="取货时间">{{ formatNodeTime(queryResult.pickTime) }}</a-descriptions-item>
  76 + <a-descriptions-item label="完成时间">{{ formatNodeTime(queryResult.completeTime) }}</a-descriptions-item>
62 77 </a-descriptions>
63 78 </div>
64 79 </a-modal>
... ... @@ -106,6 +121,7 @@ const columns = computed(() =&gt; {
106 121 { title: '收件人', dataIndex: 'recipName' },
107 122 { title: '配送费', dataIndex: 'moneyDelivery' },
108 123 { title: '状态', key: 'status' },
  124 + { title: '配送阶段', key: 'deliveryStage' },
109 125 { title: '操作', key: 'action' },
110 126 ]
111 127 if (!isAdmin.value) {
... ... @@ -204,6 +220,38 @@ async function cancelOrder(record: any) {
204 220 await loadList()
205 221 }
206 222  
  223 +function hasNodeTime(value: any) {
  224 + return value !== undefined && value !== null && value !== '' && Number(value) > 0
  225 +}
  226 +
  227 +function deliveryStageOf(record: any) {
  228 + if (record.status === 3) {
  229 + return hasNodeTime(record.arriveShopTime)
  230 + ? { text: '已到店待取货', color: 'purple' }
  231 + : { text: '待到店', color: 'cyan' }
  232 + }
  233 + if (record.status === 4) return { text: '配送中', color: 'processing' }
  234 + if (record.status === 6) return { text: '已完成', color: 'green' }
  235 + if (record.status === 2) return { text: '待接单', color: 'blue' }
  236 + if (record.status === 10) return { text: '已取消', color: 'red' }
  237 + return { text: statusMap[record.status] || '-', color: 'default' }
  238 +}
  239 +
  240 +function formatNodeTime(value: any) {
  241 + if (!hasNodeTime(value)) return '-'
  242 + if (typeof value === 'string' && Number.isNaN(Number(value))) return value
  243 + const date = new Date(Number(value) * 1000)
  244 + if (Number.isNaN(date.getTime())) return '-'
  245 + const pad = (n: number) => String(n).padStart(2, '0')
  246 + return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
  247 +}
  248 +
  249 +function formatArriveDistance(value: any) {
  250 + if (value === undefined || value === null || value === '') return '-'
  251 + const meters = Number(value)
  252 + return Number.isFinite(meters) ? `${meters.toFixed(2)} 米` : '-'
  253 +}
  254 +
207 255 onMounted(async () => {
208 256 await loadCities()
209 257 await loadList()
... ...
src/views/order/OrderList.vue
... ... @@ -50,6 +50,9 @@
50 50 <template v-if="column.key === 'status'">
51 51 <a-tag :color="statusColor[record.status]">{{ statusMap[record.status] }}</a-tag>
52 52 </template>
  53 + <template v-if="column.key === 'deliveryStage'">
  54 + <a-tag :color="deliveryStageOf(record).color">{{ deliveryStageOf(record).text }}</a-tag>
  55 + </template>
53 56 <template v-if="column.key === 'isTrans'">
54 57 <a-tag v-if="record.isTrans === 2" color="orange">申请中</a-tag>
55 58 <a-tag v-else-if="record.isTrans === 1" color="blue">已转单</a-tag>
... ... @@ -203,6 +206,7 @@ const columns = computed(() =&gt; {
203 206 { title: 'ID', dataIndex: 'id', width: 80 },
204 207 { title: '订单号', dataIndex: 'orderNo', ellipsis: true },
205 208 { title: '状态', key: 'status' },
  209 + { title: '配送阶段', key: 'deliveryStage' },
206 210 { title: '骑手ID', dataIndex: 'riderId' },
207 211 { title: '转单', key: 'isTrans' },
208 212 { title: '配送费', dataIndex: 'moneyDelivery' },
... ... @@ -362,6 +366,23 @@ async function handleRefund(status: number) {
362 366 } finally { saving.value = false }
363 367 }
364 368  
  369 +function hasNodeTime(value: any) {
  370 + return value !== undefined && value !== null && value !== '' && Number(value) > 0
  371 +}
  372 +
  373 +function deliveryStageOf(record: any) {
  374 + if (record.status === 3) {
  375 + return hasNodeTime(record.arriveShopTime)
  376 + ? { text: '已到店待取货', color: 'purple' }
  377 + : { text: '待到店', color: 'cyan' }
  378 + }
  379 + if (record.status === 4) return { text: '配送中', color: 'processing' }
  380 + if (record.status === 6) return { text: '已完成', color: 'green' }
  381 + if (record.status === 2) return { text: '待接单', color: 'blue' }
  382 + if (record.status === 10) return { text: '已取消', color: 'red' }
  383 + return { text: statusMap[record.status] || '-', color: 'default' }
  384 +}
  385 +
365 386 onMounted(async () => {
366 387 await loadCities()
367 388 await loadList()
... ...