65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import type { CertRead, VehicleDetail } from '@/api/pl'
|
|
import type { VehiclePersonnelViewRow } from '@/components/business/pl-vehicle-personnel-view-list/index.vue'
|
|
import type { VehicleViewBundle } from '@/composables/usePlVehicleViewDetail'
|
|
|
|
export interface TransportResourceSnapshotCert extends CertRead {}
|
|
|
|
export interface TransportResourceSnapshotPersonnel {
|
|
personnelId?: string
|
|
personnelName: string
|
|
phoneNo?: string
|
|
age?: number | null
|
|
idCardNo?: string
|
|
role: string
|
|
isDefault?: number
|
|
remark?: string
|
|
certList?: TransportResourceSnapshotCert[]
|
|
}
|
|
|
|
export interface TransportResourceSnapshot {
|
|
snapshottedAt?: string
|
|
vehicleId: string
|
|
vehicleType: string
|
|
carrierId?: string
|
|
carrierName?: string
|
|
licensePlate: string
|
|
trailerNo?: string
|
|
loadCapacity?: number | string | null
|
|
vehicleStatus: string
|
|
certList?: TransportResourceSnapshotCert[]
|
|
personnelList?: TransportResourceSnapshotPersonnel[]
|
|
personnelSummary?: string
|
|
selectedDriverId?: string
|
|
}
|
|
|
|
/** 将计划/运输单上的资源快照转为车辆查看组件可消费的 bundle */
|
|
export function snapshotToVehicleViewBundle(
|
|
snapshot: TransportResourceSnapshot
|
|
): VehicleViewBundle {
|
|
const detail: VehicleDetail = {
|
|
id: snapshot.vehicleId,
|
|
vehicleType: snapshot.vehicleType,
|
|
carrierId: snapshot.carrierId,
|
|
carrierName: snapshot.carrierName,
|
|
licensePlate: snapshot.licensePlate,
|
|
trailerNo: snapshot.trailerNo,
|
|
loadCapacity: snapshot.loadCapacity != null ? Number(snapshot.loadCapacity) : undefined,
|
|
vehicleStatus: snapshot.vehicleStatus,
|
|
certList: (snapshot.certList || []) as CertRead[],
|
|
createTime: snapshot.snapshottedAt || ''
|
|
}
|
|
|
|
const personnelList: VehiclePersonnelViewRow[] = (snapshot.personnelList || []).map(person => ({
|
|
personnelId: person.personnelId,
|
|
personnelName: person.personnelName,
|
|
phoneNo: person.phoneNo,
|
|
age: person.age,
|
|
role: person.role,
|
|
isDefault: person.isDefault,
|
|
remark: person.remark,
|
|
certList: person.certList || []
|
|
}))
|
|
|
|
return { detail, personnelList }
|
|
}
|