补充数据库数据,修改分类栏内容

This commit is contained in:
2026-05-21 11:50:32 +08:00
parent b8b0b453e0
commit 7ba3d313be
32 changed files with 6657 additions and 1684 deletions

View File

@@ -1,60 +1,53 @@
import { getDeliveryProfileByUserId, loginDelivery as loginDeliveryApi } from '@/api/delivery.uts'
import {
acceptDeliveryOrderById,
arriveOrderById,
checkinOrderById,
finishServiceById,
getDeliveryDashboardByStaffId,
getDeliveryMessagesList,
getDeliveryOrderDetailById,
getDeliveryOrdersByStaffId,
getDeliveryProfileByUserId,
getDeliveryRecordsByStaffId,
loginDelivery as loginDeliveryApi,
rejectDeliveryOrderById,
retryEvidenceById,
saveServiceProgressById,
startDepartById,
startServiceById,
submitExceptionById,
updateDeliveryOnlineStatusByStaffId,
uploadEvidenceById
} from '@/api/delivery.uts'
import { getDeliveryInfo, getUserInfo, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
acceptCareOrder,
checkInCareOrder,
completeCareOrder,
getCareOrderDetail,
getCareRecords,
getDeliveryCareDashboard,
getDeliveryCareProfile,
getHistoryCareOrders,
getPendingCareOrders,
getTodayCareOrders,
markCareOrderArrived,
markCareOrderDeparted,
rejectCareOrder,
startCareService,
submitCareAbnormalReport,
submitCareServiceRecord,
updateCareOrderStatus,
updateDeliveryCareOnlineStatus
} from '@/mock/delivery-care.mock.uts'
import { getUserInfo, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
import type {
DeliveryAbnormalReportType,
DeliveryCheckinPayloadType,
DeliveryDashboardType,
DeliveryExceptionPayloadType,
DeliveryFinishPayloadType,
DeliveryInfoType,
DeliveryLocationType,
DeliveryLoginPayloadType,
DeliveryLoginResultType,
DeliveryMessageType,
DeliveryOrderQueryType,
DeliveryOrderStatus,
DeliveryOrderType,
DeliveryProgressPayloadType,
DeliveryRecordType,
DeliveryEvidenceRecordType
DeliveryServiceRecordType
} from '@/types/delivery.uts'
function getCurrentStaffId(): string {
const info = getDeliveryInfo()
if (info != null) {
return info.id
}
return ''
}
export async function loginDelivery(payload: DeliveryLoginPayloadType): Promise<DeliveryLoginResultType> {
return await loginDeliveryApi(payload)
}
export async function getDeliveryProfile(): Promise<DeliveryInfoType | null> {
const userInfo = getUserInfo()
if (userInfo == null || userInfo.id == null || userInfo.id == '') {
const authResult = await requireDeliveryAuth({ redirectOnFail: false, toastOnFail: false })
if (!authResult.ok) {
return null
}
return await getDeliveryProfileByUserId(userInfo.id)
return getDeliveryCareProfile()
}
export async function getDeliveryByUserId(userId: string): Promise<DeliveryInfoType | null> {
@@ -75,69 +68,192 @@ export async function checkDeliveryAuth(): Promise<boolean> {
}
export async function getDeliveryDashboard(): Promise<DeliveryDashboardType> {
return await getDeliveryDashboardByStaffId(getCurrentStaffId())
return getDeliveryCareDashboard()
}
export async function getDeliveryOrders(params: DeliveryOrderQueryType): Promise<Array<DeliveryOrderType>> {
return await getDeliveryOrdersByStaffId(getCurrentStaffId(), params)
if (params.tab == 'pending' || params.tab == 'pending_assignment' || params.tab == 'pending_accept') {
return getPendingCareOrders()
}
if (params.tab == 'history' || params.tab == 'completed' || params.tab == 'archive') {
return getHistoryCareOrders()
}
return getTodayCareOrders()
}
export async function getDeliveryOrderDetail(id: string): Promise<DeliveryOrderType | null> {
return await getDeliveryOrderDetailById(id)
return getCareOrderDetail(id)
}
export async function acceptDeliveryOrder(id: string): Promise<DeliveryOrderType | null> {
return await acceptDeliveryOrderById(id)
return acceptCareOrder(id)
}
export async function rejectDeliveryOrder(id: string, reason: string): Promise<DeliveryOrderType | null> {
return await rejectDeliveryOrderById(id, reason)
return rejectCareOrder(id, reason)
}
export async function startDepart(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
return await startDepartById(id, location)
const order = markCareOrderDeparted(id)
if (order != null) {
order.lastLocation = location
}
return order
}
export async function arriveOrder(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
return await arriveOrderById(id, location)
const order = markCareOrderArrived(id)
if (order != null) {
order.lastLocation = location
}
return order
}
export async function checkinOrder(id: string, payload: DeliveryCheckinPayloadType): Promise<DeliveryOrderType | null> {
return await checkinOrderById(id, payload)
return checkInCareOrder(id, payload.location, payload.note)
}
export async function startService(id: string): Promise<DeliveryOrderType | null> {
return await startServiceById(id)
return startCareService(id)
}
export async function saveServiceProgress(id: string, payload: DeliveryProgressPayloadType): Promise<DeliveryOrderType | null> {
return await saveServiceProgressById(id, payload)
const current = getCareOrderDetail(id)
if (current == null) {
return null
}
current.serviceItems = payload.items
current.progressNote = payload.progressNote
current.serviceSummary = payload.serviceSummary
return current
}
export async function uploadEvidence(id: string, phase: string, files: Array<string>): Promise<Array<DeliveryEvidenceRecordType>> {
return await uploadEvidenceById(id, phase, files)
export async function uploadEvidence(id: string, phase: string, files: Array<string>): Promise<Array<any>> {
return files.map((item, index) => ({
id: id + '-evidence-' + String(index + 1),
orderId: id,
phase,
fileType: 'image',
name: 'mock-image-' + String(index + 1),
url: '',
localPath: item,
status: 'success',
progress: 100,
retryable: false,
createdAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
})) as Array<any>
}
export async function retryUploadEvidence(id: string, evidenceId: string): Promise<DeliveryEvidenceRecordType | null> {
return await retryEvidenceById(id, evidenceId)
export async function retryUploadEvidence(id: string, evidenceId: string): Promise<any | null> {
return {
id: evidenceId,
orderId: id,
phase: 'service',
fileType: 'image',
name: 'mock-retry',
url: '',
localPath: '',
status: 'success',
progress: 100,
retryable: false,
createdAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
} as any
}
export async function submitException(id: string, payload: DeliveryExceptionPayloadType): Promise<DeliveryOrderType | null> {
return await submitExceptionById(id, payload)
return submitCareAbnormalReport(id, payload)
}
export async function finishService(id: string, payload: DeliveryFinishPayloadType): Promise<DeliveryOrderType | null> {
return await finishServiceById(id, payload)
export async function finishService(id: string): Promise<DeliveryOrderType | null> {
return completeCareOrder(id)
}
export async function getDeliveryRecords(): Promise<Array<DeliveryRecordType>> {
return await getDeliveryRecordsByStaffId(getCurrentStaffId())
return getCareRecords()
}
export async function getDeliveryMessages(): Promise<Array<DeliveryMessageType>> {
return await getDeliveryMessagesList()
return [
{
id: 'delivery-msg-01',
title: '今日待服务提醒',
content: '请优先处理上午 9:00 的上门助浴订单。',
type: 'workbench',
createdAt: new Date().toISOString().replace('T', ' ').substring(0, 19),
read: false,
orderId: 'mock-care-001'
} as DeliveryMessageType
]
}
export async function updateDeliveryOnlineStatus(status: string): Promise<DeliveryInfoType | null> {
return await updateDeliveryOnlineStatusByStaffId(getCurrentStaffId(), status)
if (status == 'online' || status == 'resting' || status == 'busy') {
return updateDeliveryCareOnlineStatus(status)
}
return getDeliveryCareProfile()
}
export async function getDeliveryDashboardStats(): Promise<DeliveryDashboardType> {
return getDeliveryCareDashboard()
}
export async function getPendingServiceOrders(): Promise<Array<DeliveryOrderType>> {
return getPendingCareOrders()
}
export async function getTodayServiceOrders(): Promise<Array<DeliveryOrderType>> {
return getTodayCareOrders()
}
export async function getHistoryServiceOrders(): Promise<Array<DeliveryOrderType>> {
return getHistoryCareOrders()
}
export async function getServiceOrderDetail(orderId: string): Promise<DeliveryOrderType | null> {
return getCareOrderDetail(orderId)
}
export async function acceptServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
return acceptCareOrder(orderId)
}
export async function rejectServiceOrder(orderId: string, reason: string): Promise<DeliveryOrderType | null> {
return rejectCareOrder(orderId, reason)
}
export async function markDeparted(orderId: string): Promise<DeliveryOrderType | null> {
return markCareOrderDeparted(orderId)
}
export async function markArrived(orderId: string): Promise<DeliveryOrderType | null> {
return markCareOrderArrived(orderId)
}
export async function checkInServiceOrder(orderId: string, note: string, location: DeliveryLocationType | null = null): Promise<DeliveryOrderType | null> {
return checkInCareOrder(orderId, location, note)
}
export async function startServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
return startCareService(orderId)
}
export async function submitServiceRecord(orderId: string, record: DeliveryServiceRecordType): Promise<DeliveryOrderType | null> {
return submitCareServiceRecord(orderId, record)
}
export async function completeServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
return completeCareOrder(orderId)
}
export async function submitAbnormalReport(orderId: string, report: DeliveryExceptionPayloadType): Promise<DeliveryOrderType | null> {
return submitCareAbnormalReport(orderId, report)
}
export async function updateOrderStatus(orderId: string, nextStatus: DeliveryOrderStatus, extraRemark: string = ''): Promise<DeliveryOrderType | null> {
return updateCareOrderStatus(orderId, nextStatus, extraRemark)
}
export async function getAbnormalReport(orderId: string): Promise<DeliveryAbnormalReportType | null> {
const order = getCareOrderDetail(orderId)
return order != null ? order.abnormalReport : null
}