解决登录显示、首页显示bug
This commit is contained in:
@@ -6,11 +6,19 @@ import { rpcOrNull, rpcOrValue } from '@/services/analytics/rpc.uts'
|
||||
export type DeliveryStaff = {
|
||||
id: string
|
||||
uid: string | null
|
||||
station_id: string | null
|
||||
station_name: string | null
|
||||
staff_no: string | null
|
||||
nickname: string
|
||||
avatar: string | null
|
||||
phone: string
|
||||
status: number
|
||||
is_active: boolean
|
||||
online_status: string
|
||||
certificate_status: string
|
||||
certificate_expire_at: string | null
|
||||
service_area: string | null
|
||||
skills: Array<string> | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
@@ -60,12 +68,29 @@ export async function fetchDeliveryStaffPage(
|
||||
* 保存配送员
|
||||
*/
|
||||
export async function saveDeliveryStaff(staff: any): Promise<string | null> {
|
||||
const rawSkills = typeof staff.skillsText === 'string' ? staff.skillsText : ''
|
||||
const parts = rawSkills.split(',')
|
||||
const skills = [] as Array<string>
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const item = parts[i].trim()
|
||||
if (item != '') {
|
||||
skills.push(item)
|
||||
}
|
||||
}
|
||||
const res = await rpcOrValue('rpc_admin_save_delivery_staff', {
|
||||
p_id: staff.id,
|
||||
p_uid: staff.uid,
|
||||
p_station_id: staff.station_id,
|
||||
p_staff_no: staff.staff_no,
|
||||
p_nickname: staff.nickname,
|
||||
p_avatar: staff.avatar,
|
||||
p_phone: staff.phone,
|
||||
p_status: staff.status
|
||||
p_status: staff.status,
|
||||
p_online_status: staff.online_status,
|
||||
p_certificate_status: staff.certificate_status,
|
||||
p_certificate_expire_at: staff.certificate_expire_at,
|
||||
p_service_area: staff.service_area,
|
||||
p_skills: skills
|
||||
} as any)
|
||||
return res != null ? String(res) : null
|
||||
}
|
||||
|
||||
143
services/deliveryService.uts
Normal file
143
services/deliveryService.uts
Normal file
@@ -0,0 +1,143 @@
|
||||
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'
|
||||
import type {
|
||||
DeliveryCheckinPayloadType,
|
||||
DeliveryDashboardType,
|
||||
DeliveryExceptionPayloadType,
|
||||
DeliveryFinishPayloadType,
|
||||
DeliveryInfoType,
|
||||
DeliveryLocationType,
|
||||
DeliveryLoginPayloadType,
|
||||
DeliveryLoginResultType,
|
||||
DeliveryMessageType,
|
||||
DeliveryOrderQueryType,
|
||||
DeliveryOrderType,
|
||||
DeliveryProgressPayloadType,
|
||||
DeliveryRecordType,
|
||||
DeliveryEvidenceRecordType
|
||||
} 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 == '') {
|
||||
return null
|
||||
}
|
||||
return await getDeliveryProfileByUserId(userInfo.id)
|
||||
}
|
||||
|
||||
export async function getDeliveryByUserId(userId: string): Promise<DeliveryInfoType | null> {
|
||||
return await getDeliveryProfileByUserId(userId)
|
||||
}
|
||||
|
||||
export async function getCurrentDeliverer(): Promise<DeliveryInfoType | null> {
|
||||
return await getDeliveryProfile()
|
||||
}
|
||||
|
||||
export async function checkDeliveryAccountByUserId(userId: string): Promise<DeliveryInfoType | null> {
|
||||
return await getDeliveryProfileByUserId(userId)
|
||||
}
|
||||
|
||||
export async function checkDeliveryAuth(): Promise<boolean> {
|
||||
const result = await requireDeliveryAuth({ redirectOnFail: false, toastOnFail: false })
|
||||
return result.ok
|
||||
}
|
||||
|
||||
export async function getDeliveryDashboard(): Promise<DeliveryDashboardType> {
|
||||
return await getDeliveryDashboardByStaffId(getCurrentStaffId())
|
||||
}
|
||||
|
||||
export async function getDeliveryOrders(params: DeliveryOrderQueryType): Promise<Array<DeliveryOrderType>> {
|
||||
return await getDeliveryOrdersByStaffId(getCurrentStaffId(), params)
|
||||
}
|
||||
|
||||
export async function getDeliveryOrderDetail(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await getDeliveryOrderDetailById(id)
|
||||
}
|
||||
|
||||
export async function acceptDeliveryOrder(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await acceptDeliveryOrderById(id)
|
||||
}
|
||||
|
||||
export async function rejectDeliveryOrder(id: string, reason: string): Promise<DeliveryOrderType | null> {
|
||||
return await rejectDeliveryOrderById(id, reason)
|
||||
}
|
||||
|
||||
export async function startDepart(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
|
||||
return await startDepartById(id, location)
|
||||
}
|
||||
|
||||
export async function arriveOrder(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
|
||||
return await arriveOrderById(id, location)
|
||||
}
|
||||
|
||||
export async function checkinOrder(id: string, payload: DeliveryCheckinPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await checkinOrderById(id, payload)
|
||||
}
|
||||
|
||||
export async function startService(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await startServiceById(id)
|
||||
}
|
||||
|
||||
export async function saveServiceProgress(id: string, payload: DeliveryProgressPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await saveServiceProgressById(id, payload)
|
||||
}
|
||||
|
||||
export async function uploadEvidence(id: string, phase: string, files: Array<string>): Promise<Array<DeliveryEvidenceRecordType>> {
|
||||
return await uploadEvidenceById(id, phase, files)
|
||||
}
|
||||
|
||||
export async function retryUploadEvidence(id: string, evidenceId: string): Promise<DeliveryEvidenceRecordType | null> {
|
||||
return await retryEvidenceById(id, evidenceId)
|
||||
}
|
||||
|
||||
export async function submitException(id: string, payload: DeliveryExceptionPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await submitExceptionById(id, payload)
|
||||
}
|
||||
|
||||
export async function finishService(id: string, payload: DeliveryFinishPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await finishServiceById(id, payload)
|
||||
}
|
||||
|
||||
export async function getDeliveryRecords(): Promise<Array<DeliveryRecordType>> {
|
||||
return await getDeliveryRecordsByStaffId(getCurrentStaffId())
|
||||
}
|
||||
|
||||
export async function getDeliveryMessages(): Promise<Array<DeliveryMessageType>> {
|
||||
return await getDeliveryMessagesList()
|
||||
}
|
||||
|
||||
export async function updateDeliveryOnlineStatus(status: string): Promise<DeliveryInfoType | null> {
|
||||
return await updateDeliveryOnlineStatusByStaffId(getCurrentStaffId(), status)
|
||||
}
|
||||
Reference in New Issue
Block a user