🔀 合并 websoft/dev,统一待回单确认与公路配载校验
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -26,6 +26,35 @@ const uniqueOrgNames = (values = []) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
// 候选司机取数上限:超出后只能靠关键字缩小范围
|
||||
const DRIVER_CANDIDATE_MAX_SIZE = 200;
|
||||
|
||||
/**
|
||||
* 派单候选司机:租户内的司机档案,按岗位等条件过滤。
|
||||
*
|
||||
* 与组织、承运商都无关——司机档案与组织树、承运商之间没有外键,`organization_name`
|
||||
* 只是自由文本,用它做匹配会让小程序自动建档的司机永远进不了候选。
|
||||
*/
|
||||
export const fetchDriverCandidates = async (query = {}) => {
|
||||
const params = { ...query };
|
||||
const size = Math.min(Math.max(Number(params.size) || 50, 50), DRIVER_CANDIDATE_MAX_SIZE);
|
||||
delete params.size;
|
||||
const res = await getDriverList(1, size, params);
|
||||
return extractRecords(res).slice(0, size);
|
||||
};
|
||||
|
||||
/**
|
||||
* 司机候选项的展示文本:姓名(手机尾号后 4 位)。
|
||||
*
|
||||
* 只用于下拉渲染。写回表单的仍是姓名本身,别把带尾号的文本当值用。
|
||||
*/
|
||||
export const driverOptionText = (item = {}) => {
|
||||
const name = normalizeOrgName(item.driverName || item.name);
|
||||
const mobile = String(item.mobile || item.phone || item.driverPhone || '').trim();
|
||||
if (!name) return '';
|
||||
return mobile.length >= 4 ? `${name}(${mobile.slice(-4)})` : name;
|
||||
};
|
||||
|
||||
/**
|
||||
* 解析承运商客商档案上联系人的所属组织(branchName),无联系人时回退客商所属组织。
|
||||
*/
|
||||
@@ -72,13 +101,6 @@ export const resolveCarrierOrganizationNames = async ({ carrierId, carrierName }
|
||||
return orgNames;
|
||||
};
|
||||
|
||||
export const clearCarrierOrganizationCache = (carrier = {}) => {
|
||||
const id = String(carrier.carrierId || '').trim();
|
||||
const name = normalizeOrgName(carrier.carrierName);
|
||||
if (id) orgNameCache.delete(id);
|
||||
if (name) orgNameCache.delete(name);
|
||||
};
|
||||
|
||||
export const matchOrganizationName = (value, orgNames = []) => {
|
||||
const text = normalizeOrgName(value);
|
||||
if (!text || !orgNames.length) return false;
|
||||
@@ -90,34 +112,9 @@ const filterByOrganizations = (records = [], orgNames = []) => {
|
||||
return records.filter(item => matchOrganizationName(item.organizationName, orgNames));
|
||||
};
|
||||
|
||||
/**
|
||||
* 按承运商联系人所属组织筛选司机。
|
||||
* 未选择承运商时返回空列表(需先选承运商)。
|
||||
*/
|
||||
export const fetchDriversByCarrierOrganizations = async (
|
||||
query = {},
|
||||
{ carrierId, carrierName } = {}
|
||||
) => {
|
||||
if (!String(carrierId || '').trim() && !normalizeOrgName(carrierName)) {
|
||||
return [];
|
||||
}
|
||||
const orgNames = await resolveCarrierOrganizationNames({ carrierId, carrierName });
|
||||
if (!orgNames.length) return [];
|
||||
|
||||
const size = Math.max(Number(query.size) || 50, 50);
|
||||
const params = { ...query };
|
||||
delete params.size;
|
||||
// 单组织时用后端模糊条件缩小范围;多组织再前端精确过滤
|
||||
if (orgNames.length === 1) {
|
||||
params.organizationName = orgNames[0];
|
||||
}
|
||||
const res = await getDriverList(1, Math.min(size * 5, 200), params);
|
||||
return filterByOrganizations(extractRecords(res), orgNames).slice(0, size);
|
||||
};
|
||||
|
||||
/**
|
||||
* 按承运商联系人所属组织筛选车辆。
|
||||
* 未选择承运商时返回空列表。
|
||||
* 未选择承运商时返回空列表(需先选承运商)。
|
||||
*/
|
||||
export const fetchVehiclesByCarrierOrganizations = async (
|
||||
query = {},
|
||||
|
||||
@@ -106,6 +106,9 @@ const CERT_SNAPSHOT_GROUPS = {
|
||||
fields: [
|
||||
{ key: 'realName', label: '真实姓名' },
|
||||
{ key: 'idCardNo', label: '身份证号' },
|
||||
{ key: 'birthday', label: '出生年月', type: TYPE_DATE },
|
||||
{ key: 'addressRegion', label: '住址' },
|
||||
{ key: 'address', label: '详细地址' },
|
||||
{ key: 'idCardFrontUrl', label: '身份证正面照', type: TYPE_IMAGE },
|
||||
{ key: 'idCardBackUrl', label: '身份证反面照', type: TYPE_IMAGE },
|
||||
{ key: 'idCardValidStart', label: '身份证有效期起', type: TYPE_DATE },
|
||||
|
||||
Reference in New Issue
Block a user