预校验、签到流程跑通
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -165,7 +165,11 @@ async function handlePrimary() {
|
||||
}
|
||||
const status = order.value.status
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') {
|
||||
await acceptServiceOrder(orderId.value)
|
||||
const result = await acceptServiceOrder(orderId.value)
|
||||
if (!result.ok) {
|
||||
uni.showToast({ title: result.message != '' ? result.message : '接单失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: '已接单', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
@@ -174,14 +178,18 @@ async function handlePrimary() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId.value })
|
||||
return
|
||||
}
|
||||
if (status == 'departed' || status == 'on_the_way') {
|
||||
if (status == 'assigned' || status == 'order_accepted' || status == 'ORDER_ACCEPTED') {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId.value })
|
||||
return
|
||||
}
|
||||
if (status == 'arrived') {
|
||||
if (status == 'departed' || status == 'on_the_way' || status == 'order_departed' || status == 'ORDER_DEPARTED') {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/checkin?id=' + orderId.value })
|
||||
return
|
||||
}
|
||||
if (status == 'arrival_pending' || status == 'ARRIVAL_PENDING') {
|
||||
uni.showToast({ title: '等待消费者确认到达', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (status == 'in_service' || status == 'serving' || status == 'completed') {
|
||||
goRecord()
|
||||
return
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<text v-if="item.acceptedByName != ''" class="meta-text accepted-by">接单人:{{ item.acceptedByName }}</text>
|
||||
</view>
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goDetail(item.id)"><text class="outline-btn-text">查看详情</text></view>
|
||||
<view v-if="getActionText(item.status) != '查看详情'" class="outline-btn" @click="goDetail(item.id)"><text class="outline-btn-text">查看详情</text></view>
|
||||
<view v-if="showReject(item.status)" class="warn-btn" @click="rejectOrder(item.id)"><text class="warn-btn-text">拒单</text></view>
|
||||
<view class="primary-btn" @click="handleAction(item.id, item.status)"><text class="primary-btn-text">{{ getActionText(item.status) }}</text></view>
|
||||
</view>
|
||||
@@ -162,14 +162,83 @@ function sortOrderList(list: Array<DeliveryOrderType>): Array<DeliveryOrderType>
|
||||
return wrapped.map((entry) => entry.item)
|
||||
}
|
||||
|
||||
function normalizeStatus(status: string): string {
|
||||
return String(status ?? '').trim().toLowerCase()
|
||||
}
|
||||
|
||||
function isPendingStatus(status: string): boolean {
|
||||
const s = normalizeStatus(status)
|
||||
return s == 'pending' || s == 'pending_assignment' || s == 'pending_accept' || s == 'pending_assign' || s == 'pending_dispatch' || s == 'pending_acceptance_new'
|
||||
}
|
||||
|
||||
function isOngoingStatus(status: string): boolean {
|
||||
const s = normalizeStatus(status)
|
||||
return s == 'assigned' || s == 'accepted' || s == 'waiting_departure' || s == 'departed' || s == 'on_the_way' || s == 'arrived' || s == 'in_service' || s == 'serving' || s == 'pending_acceptance' || s == 'arrival_pending' || s == 'order_accepted' || s == 'order_departed' || s == 'order_checked_in' || s == 'order_in_service'
|
||||
}
|
||||
|
||||
function isHistoryStatus(status: string): boolean {
|
||||
const s = normalizeStatus(status)
|
||||
return s == 'completed' || s == 'settled' || s == 'archived' || s == 'cancelled' || s == 'canceled' || s == 'rejected' || s == 'abnormal' || s == 'exception_pending' || s == 'order_completed' || s == 'order_cancelled'
|
||||
}
|
||||
|
||||
function getOrderCanonicalKey(item: DeliveryOrderType): string {
|
||||
const orderNo = String(item.orderNo ?? '').trim()
|
||||
if (orderNo != '') return 'orderNo:' + orderNo
|
||||
const sourceOrderId = String(item.sourceOrderId ?? '').trim()
|
||||
if (sourceOrderId != '') return 'sourceOrderId:' + sourceOrderId
|
||||
const legacyServiceOrderId = String(item.legacyServiceOrderId ?? '').trim()
|
||||
if (legacyServiceOrderId != '') return 'legacyServiceOrderId:' + legacyServiceOrderId
|
||||
return 'id:' + String(item.id ?? '')
|
||||
}
|
||||
|
||||
function getOrderUpdateTime(item: DeliveryOrderType): number {
|
||||
if (item.updatedAt != '') return parseTime(item.updatedAt)
|
||||
if (item.createdAt != '') return parseTime(item.createdAt)
|
||||
return 0
|
||||
}
|
||||
|
||||
function dedupeOrders(list: Array<DeliveryOrderType>): Array<DeliveryOrderType> {
|
||||
const map = new Map<string, DeliveryOrderType>()
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i]
|
||||
const key = getOrderCanonicalKey(item)
|
||||
const old = map.get(key)
|
||||
if (old == null) {
|
||||
map.set(key, item)
|
||||
continue
|
||||
}
|
||||
if (isPendingStatus(old.status) && isOngoingStatus(item.status)) {
|
||||
map.set(key, item)
|
||||
continue
|
||||
}
|
||||
if (isOngoingStatus(old.status) && isPendingStatus(item.status)) {
|
||||
continue
|
||||
}
|
||||
if (getOrderUpdateTime(item) > getOrderUpdateTime(old)) {
|
||||
map.set(key, item)
|
||||
}
|
||||
}
|
||||
return Array.from(map.values())
|
||||
}
|
||||
|
||||
const filteredOrders = computed((): Array<DeliveryOrderType> => {
|
||||
const keyword = searchKeyword.value.trim().toLowerCase()
|
||||
let result: Array<DeliveryOrderType>
|
||||
let result = orders.value.slice()
|
||||
if (keyword == '') {
|
||||
result = orders.value.slice()
|
||||
result = result.slice()
|
||||
} else {
|
||||
result = orders.value.filter((item) => item.orderNo.toLowerCase().includes(keyword))
|
||||
result = result.filter((item) => item.orderNo.toLowerCase().includes(keyword))
|
||||
}
|
||||
if (currentTab.value == 'pending') {
|
||||
result = result.filter((item) => isPendingStatus(item.status))
|
||||
}
|
||||
if (currentTab.value == 'today' || currentTab.value == 'ongoing') {
|
||||
result = result.filter((item) => isOngoingStatus(item.status))
|
||||
}
|
||||
if (currentTab.value == 'history') {
|
||||
result = result.filter((item) => isHistoryStatus(item.status))
|
||||
}
|
||||
result = dedupeOrders(result)
|
||||
return sortOrderList(result)
|
||||
})
|
||||
|
||||
@@ -233,7 +302,8 @@ function formatTags(tags: Array<string>): string {
|
||||
}
|
||||
|
||||
function showReject(status: DeliveryOrderStatus): boolean {
|
||||
return status == 'pending_assignment' || status == 'pending_accept'
|
||||
// 仅待接单状态可拒单;assigned(已派单)不可拒单,只能查看详情/出发
|
||||
return isPendingStatus(String(status))
|
||||
}
|
||||
|
||||
function getActionText(status: DeliveryOrderStatus): string {
|
||||
@@ -262,26 +332,38 @@ function rejectOrder(orderId: string) {
|
||||
}
|
||||
|
||||
async function handleAction(orderId: string, status: DeliveryOrderStatus) {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') {
|
||||
await acceptServiceOrder(orderId)
|
||||
const s = normalizeStatus(String(status))
|
||||
// 待接单:可以接单
|
||||
if (isPendingStatus(s)) {
|
||||
const result = await acceptServiceOrder(orderId)
|
||||
if (!result.ok) {
|
||||
uni.showToast({ title: result.message != '' ? result.message : '接单失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: '接单成功', icon: 'success' })
|
||||
loadData()
|
||||
await loadData()
|
||||
return
|
||||
}
|
||||
// 已派单:不显示接单按钮,显示查看详情;如果需要出发则显示出发
|
||||
if (s == 'assigned' || s == 'accepted' || s == 'waiting_departure' || s == 'order_accepted') {
|
||||
// 已派单状态:当前流程需要出发时,跳转到出发页;否则显示查看详情
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId })
|
||||
return
|
||||
}
|
||||
if (status == 'accepted' || status == 'waiting_departure') {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId })
|
||||
return
|
||||
}
|
||||
if (status == 'departed' || status == 'on_the_way') {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId })
|
||||
return
|
||||
}
|
||||
if (status == 'arrived') {
|
||||
if (s == 'departed' || s == 'on_the_way' || s == 'order_departed') {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/checkin?id=' + orderId })
|
||||
return
|
||||
}
|
||||
if (status == 'in_service' || status == 'serving' || status == 'completed') {
|
||||
goRecord(orderId)
|
||||
if (s == 'arrival_pending') {
|
||||
uni.showToast({ title: '等待消费者确认到达', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (status == 'in_service' || status == 'serving' || status == 'ORDER_IN_SERVICE' || status == 'completed' || status == 'ORDER_COMPLETED') {
|
||||
goDetail(orderId)
|
||||
return
|
||||
}
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') {
|
||||
|
||||
Reference in New Issue
Block a user