提交
This commit is contained in:
1 parent
0e60b88cba
commit
87f7f6bf38
34 files changed
+18326
-6165
No files matched your search
@@ -21,7 +21,6 @@ export function isRequiredCertSlotComplete(
|
||||
): boolean {
|
||||
if (!cert) return false
|
||||
if (!matchRequiredCertName(cert.certName, requiredName)) return false
|
||||
if (!cert.certNo?.trim()) return false
|
||||
if (!cert.expireDate) return false
|
||||
if (!cert.attachmentUrls?.trim()) return false
|
||||
return true
|
||||
@@ -32,10 +31,9 @@ export function getMissingRequiredCertFieldLabels(
|
||||
requiredName: string
|
||||
): string[] {
|
||||
if (!cert || !matchRequiredCertName(cert.certName, requiredName)) {
|
||||
return ['证号', '有效期', '附件']
|
||||
return ['有效期', '附件']
|
||||
}
|
||||
const missing: string[] = []
|
||||
if (!cert.certNo?.trim()) missing.push('证号')
|
||||
if (!cert.expireDate) missing.push('有效期')
|
||||
if (!cert.attachmentUrls?.trim()) missing.push('附件')
|
||||
return missing
|
||||
@@ -133,12 +131,28 @@ function findCertIndexForRequired(
|
||||
export function mergeCertListWithRequiredSlots(
|
||||
existing: CertRowWithMeta[],
|
||||
requiredNames: readonly string[],
|
||||
options?: { vehiclePart?: string }
|
||||
options?: { vehiclePart?: string; stripManagedNames?: readonly string[] }
|
||||
): CertRowWithMeta[] {
|
||||
const vehiclePart = options?.vehiclePart
|
||||
const next = existing.map(cert => ({ ...cert }))
|
||||
const stripManagedNames = options?.stripManagedNames
|
||||
const normalizedPart = vehiclePart ? normalizeVehicleCertPart(vehiclePart) : null
|
||||
|
||||
let source = existing
|
||||
if (stripManagedNames?.length) {
|
||||
source = existing.filter(cert => {
|
||||
if (normalizedPart && normalizeVehicleCertPart(cert.vehiclePart) !== normalizedPart) {
|
||||
return true
|
||||
}
|
||||
if (requiredNames.some(name => matchRequiredCertName(cert.certName, name))) {
|
||||
return true
|
||||
}
|
||||
const isManaged = stripManagedNames.some(name => matchRequiredCertName(cert.certName, name))
|
||||
return !isManaged
|
||||
})
|
||||
}
|
||||
|
||||
const next = source.map(cert => ({ ...cert }))
|
||||
|
||||
const extras = next.filter(cert => {
|
||||
if (normalizedPart && normalizeVehicleCertPart(cert.vehiclePart) !== normalizedPart) {
|
||||
return false
|
||||
|
||||
@@ -5,10 +5,20 @@ export const PL_PERSONNEL_CERT_MISSING_SUFFIX = '(证书缺失)'
|
||||
export const PL_PERSONNEL_DRIVER_REQUIRED_CERT_NAMES = [
|
||||
'身份证',
|
||||
'驾驶证',
|
||||
'从业资格证'
|
||||
'驾驶员从业资格证'
|
||||
] as const
|
||||
|
||||
export const PL_PERSONNEL_ESCORT_REQUIRED_CERT_NAMES = ['身份证', '从业资格证'] as const
|
||||
export const PL_PERSONNEL_ESCORT_REQUIRED_CERT_NAMES = [
|
||||
'身份证',
|
||||
'押运员从业资格证'
|
||||
] as const
|
||||
|
||||
export const PL_PERSONNEL_BOTH_REQUIRED_CERT_NAMES = [
|
||||
'身份证',
|
||||
'驾驶证',
|
||||
'驾驶员从业资格证',
|
||||
'押运员从业资格证'
|
||||
] as const
|
||||
|
||||
export type PersonnelCertRole = 'driver' | 'escort'
|
||||
export type PersonnelType = 'driver' | 'escort' | 'both'
|
||||
@@ -69,7 +79,10 @@ export function getRequiredPersonnelCertNamesByType(
|
||||
if (personnelType === 'escort') {
|
||||
return PL_PERSONNEL_ESCORT_REQUIRED_CERT_NAMES
|
||||
}
|
||||
return PL_PERSONNEL_DRIVER_REQUIRED_CERT_NAMES
|
||||
if (personnelType === 'driver') {
|
||||
return PL_PERSONNEL_DRIVER_REQUIRED_CERT_NAMES
|
||||
}
|
||||
return PL_PERSONNEL_BOTH_REQUIRED_CERT_NAMES
|
||||
}
|
||||
|
||||
/** 车辆关联人员:从人员主数据类型映射为关联角色(司机/押运员) */
|
||||
@@ -105,7 +118,6 @@ export function isPersonnelCertStrictComplete(
|
||||
): boolean {
|
||||
if (!cert?.certName?.trim()) return false
|
||||
if (!matchRequiredCertName(cert.certName, requiredName)) return false
|
||||
if (!cert.certNo?.trim()) return false
|
||||
if (!cert.expireDate) return false
|
||||
if (!cert.attachmentUrls?.trim()) return false
|
||||
return true
|
||||
@@ -117,12 +129,8 @@ export function matchRequiredCertName(
|
||||
): boolean {
|
||||
const name = actualName?.trim() || ''
|
||||
if (!name) return false
|
||||
if (requiredName === '从业资格证') {
|
||||
return (
|
||||
name === '从业资格证' ||
|
||||
name === '危化品从业资格证' ||
|
||||
name.includes('从业资格证')
|
||||
)
|
||||
if (requiredName === '押运员从业资格证') {
|
||||
return name === '押运员从业资格证' || name === '押运员证'
|
||||
}
|
||||
return name === requiredName
|
||||
}
|
||||
@@ -130,7 +138,6 @@ export function matchRequiredCertName(
|
||||
export function isPersonnelCertUploaded(cert?: Pick<CertRow, 'certName' | 'certNo' | 'expireDate' | 'attachmentUrls'>) {
|
||||
return Boolean(
|
||||
cert?.certName?.trim() &&
|
||||
cert?.certNo?.trim() &&
|
||||
cert?.expireDate &&
|
||||
cert?.attachmentUrls?.trim()
|
||||
)
|
||||
@@ -190,7 +197,8 @@ export function getPersonnelCertMissingSuffix(
|
||||
export const PL_PERSONNEL_CERT_SHORT_LABELS: Record<string, string> = {
|
||||
身份证: '身',
|
||||
驾驶证: '驾',
|
||||
从业资格证: '业'
|
||||
驾驶员从业资格证: '业',
|
||||
押运员从业资格证: '押'
|
||||
}
|
||||
|
||||
export type PersonnelCertBadgeStatus = 'missing' | 'valid' | 'expiring' | 'expired'
|
||||
@@ -207,10 +215,9 @@ function getPersonnelCertMissingFieldLabels(
|
||||
requiredName: string
|
||||
): string[] {
|
||||
if (!cert || !matchRequiredCertName(cert.certName, requiredName)) {
|
||||
return ['证号', '有效期', '附件']
|
||||
return ['有效期', '附件']
|
||||
}
|
||||
const missing: string[] = []
|
||||
if (!cert.certNo?.trim()) missing.push('证号')
|
||||
if (!cert.expireDate) missing.push('有效期')
|
||||
if (!cert.attachmentUrls?.trim()) missing.push('附件')
|
||||
return missing
|
||||
|
||||
@@ -79,7 +79,6 @@ export function mergeVehicleCertsByPart<T extends CertRow>(
|
||||
export function isVehicleCertUploaded(cert?: Pick<CertRow, 'certName' | 'certNo' | 'expireDate' | 'attachmentUrls'>) {
|
||||
return Boolean(
|
||||
cert?.certName?.trim() &&
|
||||
cert?.certNo?.trim() &&
|
||||
cert?.expireDate &&
|
||||
cert?.attachmentUrls?.trim()
|
||||
)
|
||||
@@ -264,10 +263,9 @@ function getVehicleCertMissingFieldLabels(
|
||||
requiredName: string
|
||||
): string[] {
|
||||
if (!cert || !matchVehicleRequiredCertName(cert.certName, requiredName)) {
|
||||
return ['证号', '有效期', '附件']
|
||||
return ['有效期', '附件']
|
||||
}
|
||||
const missing: string[] = []
|
||||
if (!cert.certNo?.trim()) missing.push('证号')
|
||||
if (!cert.expireDate) missing.push('有效期')
|
||||
if (!cert.attachmentUrls?.trim()) missing.push('附件')
|
||||
return missing
|
||||
|
||||
Reference in new issue
Block a user